Package structure
All the modules and functions are documented in the following sections.
pynewmarkdisp.newmark
Functions to calculate permanent displacements using empirical correlations.
Permanent displacements are calculated based on the Newmark (1965) sliding block method.
direct_newmark
Calculate the permanent displacements using the direct Newmark method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
time |
(n,) ndarray
|
1D array with the time series of the earthquake record, in [s]. |
required |
accel |
(n,) ndarray
|
1D array with the acceleration series of the earthquake record. |
required |
ky |
float
|
Critical seismic coefficient (yield coefficient). |
required |
g |
float
|
Acceleration of gravity, in the same units as |
required |
Returns:
Name | Type | Description |
---|---|---|
newmark_str |
dict
|
Dictionary with the structure from the Newmark's method. The structure includes time, acceleration, velocity, and displacements series, as well as the critical seismic coefficient and accelerarion, and the permanent displacement calculated (in meters). |
Source code in pynewmarkdisp/newmark.py
empirical_correlations
Run a function of an empirical correlation for uₚ calculation.
It is possible to call a function from the empir_corr.py
module by
passing the ID of the function to the opt
keyword argument, or by
passing the function itself to the correlation_funct
keyword argument.
The opt
keyword argument follows the numbering of the functions in the
Table 1 of Meehan & Vahedifard (2013)
(see the empir_corr.py
module for more details).
After choosing either opt
or correlation_funct
, the remaining
keyword arguments are passed to the chosen function.
Returns:
Name | Type | Description |
---|---|---|
perm_disp |
float
|
Permanent displacement calculated by the chosen function using an empirical correlation. |
Source code in pynewmarkdisp/newmark.py
first_newmark_integration
Perform the first integration of the Newmark method.
The integration is performed using the trapezoidal rule. It accounts for energy dissipation at each peak above the critical acceleration by subtracting the area between $y=a_y$ and $y=a(t)$ after the peak until the velocity is zero.
This funtion is optimized for speed using Numba.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
time |
(n, ) ndarray
|
1D array with the time series of the earthquake record, in units
consistent with |
required |
accel |
(n, ) ndarray
|
1D array with the acceleration series of the earthquake record, in the
same units as |
required |
ay |
int or float
|
Critical acceleration, in the same units as |
required |
Returns:
Name | Type | Description |
---|---|---|
vel |
(n, ) ndarray
|
1D array with the velocity series obtained by the first integration of
the Newmark method. Units are consistent with |
Source code in pynewmarkdisp/newmark.py
plot_newmark_integration
Plot the double-integration procedure of the direct Newmark method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
newmark_str |
dict
|
Dictionary with the structure from the Newmark's method. The structure
includes time, acceleration, velocity, and displacements series, as
well as the critical seismic coefficient and accelerarion, and the
permanent displacement calculated (in meters). This dictionary is
returned by the |
required |
compressed |
bool
|
If |
False
|
Returns:
Name | Type | Description |
---|---|---|
fig |
matplotlib.figure.Figure
|
Matplotlib object which might be used to save the figure as a file. |
Source code in pynewmarkdisp/newmark.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
|
trapz
Calculate the area under de curve y=f(x) by the trapezoidal rule method.
This funtion is optimized for speed using Numba.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y |
(n, ) ndarray
|
1D array with the values of the function y=f(x). |
required |
x |
(n, ) ndarray
|
1D array with the values of the independent variable x. |
required |
Returns:
Name | Type | Description |
---|---|---|
area |
float
|
Area under the curve y=f(x) calculated by the trapezoidal rule method. |
Source code in pynewmarkdisp/newmark.py
pynewmarkdisp.spatial
Functions to calculate permanent displacements in a spatial domain.
get_dip_azimuth
Calculate the azimuth of the slope dip direction from the North.
Positive values are clockwise from the North. The azimuth is returned in [°], ranging from 0 to 360.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dem |
(m, n) array
|
2D array with the digital elevation model (DEM) of the area. |
required |
cellsize |
int
|
Cell size of the raster representing the DEM. Its default value is 1. |
1
|
Returns:
Name | Type | Description |
---|---|---|
azimuth |
(m, n) array
|
Spatial distribution of the azimuth of the slope dip direction. |
Source code in pynewmarkdisp/spatial.py
get_hillshade
Generate a hillshade image from the DEM.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dem |
(m, n) array
|
2D array with the digital elevation model (DEM) of the area |
required |
sun_azimuth |
int or float
|
Azimuth of the sun, in [°]. Its default value is 315. |
315
|
sun_altitude |
int or float
|
Angle from the horizontal plane to the sun, in degrees, indicating the altitude of the sun. Its default value is 30. |
30
|
cellsize |
int
|
Cell size of the raster representing the DEM. Units must be consistent
with the units of |
1
|
Returns:
Name | Type | Description |
---|---|---|
hillshade |
(m, n) array
|
2D array with the hillshade raster. |
Source code in pynewmarkdisp/spatial.py
get_idx_at_coords
Convert coordinates to array indexes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
int or float
|
Coordinate in the x-direction. |
required |
y |
int or float
|
Coordinate in the y-direction. |
required |
spat_ref |
dict
|
Dictionary with the spatial reference of the raster. It contains the
same information of the ASCII file header. See the documentation of
the |
required |
Returns:
Name | Type | Description |
---|---|---|
indexes |
tuple
|
Tuple with the indexes of the array corresponding to the given coordinates. |
Source code in pynewmarkdisp/spatial.py
get_slope
Calculate the slope (or inclination) of the terrain.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dem |
(m, n) array
|
2D array with the digital elevation model (DEM) of the area. |
required |
cellsize |
int
|
Cell size of the raster representing the DEM. Units must be consistent
with the units of |
1
|
Returns:
Name | Type | Description |
---|---|---|
slope |
(m, n) array
|
Spatial distribution of the slope, in degrees. |
Source code in pynewmarkdisp/spatial.py
hzt_accel_from_2_dir
Calculate the resultant acceleration from two horizontal components.
This funtion is optimized for speed using Numba.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
accel_ew |
(n,) ndarray
|
1D array with the acceleration series in the East-West direction. |
required |
accel_ns |
(n,) ndarray
|
1D array with the acceleration series in the North-South direction. |
required |
azimuth |
float or int
|
Azimuth of the slope dip direction, in [°] and measured clockwise from North. |
required |
Returns:
Name | Type | Description |
---|---|---|
accel_hzt |
(n, ) ndarray
|
1D array with the resultant horizontal acceleration series. |
Source code in pynewmarkdisp/spatial.py
load_ascii_raster
Load a raster file in ASCII format (.ASC
extension).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
File to be loaded. It must be in Esri ASCII raster format. Its header must be 6 lines long, and the spatial location of the raster is specified by the location of the lower left corner of the lower left cell, as shown below:
|
required |
dtype |
data-type
|
Data type of the returned array. If not given (i.e., |
None
|
Returns:
Name | Type | Description |
---|---|---|
raster |
(m, n) ndarray
|
Raster data given as a 2D array. |
header |
dict
|
Header of the raster file. |
Source code in pynewmarkdisp/spatial.py
map_zones
Associate geotechnical parameters to zones.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameters |
dict
|
Dictionary with the geotechnical parameters of each zone. The keys are the zone numbers, and the values are tuples with the zone's friction angle in [°], cohesion in [kPa], and unit weight in [kN/m³], respectively. |
required |
zones |
(m, n) ndarray
|
2D array with the zone number assigned to each cell. There has to be as many zone numbers as keys in the parameters dictionary. |
required |
Returns:
Type | Description |
---|---|
phi, c, gamma : (m, n) ndarray, (m, n) ndarray, (m, n) ndarray
|
Three 2D arrays with the spatial distribution of the friction angle,
cohesion, and unit weight, respectively. Each array has the same shape
as |
Source code in pynewmarkdisp/spatial.py
plot_spatial_field
Plot a spatial field.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field |
(m, n) ndarray
|
2D array with the spatial field to be plotted. |
required |
dem |
(m, n) ndarray or None
|
2D array with the digital elevation model (DEM) of the area. It is used
to plot the hillshade below the spatial field to enhance the
visualization. By default its value is |
None
|
discrete |
bool
|
If |
False
|
**kwargs |
dict
|
Additional keyword arguments. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
fig |
matplotlib.figure.Figure
|
Matplotlib object which might be used to save the figure as a file. |
Source code in pynewmarkdisp/spatial.py
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 |
|
reclass_raster
Reclassify a raster based on a list of limits.
Convert a continuous raster into a categorical one. The limits are used to define the categories.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field |
(m, n) ndarray
|
2D array with the spatial field to be reclassified. |
required |
limits |
array_like
|
Limits to be used in the reclassification. The minimum and maximum values of the field should not be included as the first and last elements of the list, as they are automatically included in the limits. |
required |
Returns:
Name | Type | Description |
---|---|---|
field_reclass |
(m, n) ndarray
|
2D array with the reclassified field. |
Source code in pynewmarkdisp/spatial.py
spatial_hzt_accel_from_2_dir
Calculate spatially the resultant acceleration from two hztl components.
The azimuth is spatially distributed (e.g., obtained using the
get_dip_azimuth
function), but accel_ew
, accel_ns
, and
time_vect
are constant over all the spatial domain.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
accel_ew |
(p,) ndarray
|
1D array with the acceleration series in the East-West direction. |
required |
accel_ns |
(p,) ndarray
|
1D array with the acceleration series in the North-South direction. |
required |
azimuth |
(m, n) ndarray
|
2D array with the spatial distribution of the azimuth of the slope dip direction, in [°] and measured clockwise from North. |
required |
Returns:
Name | Type | Description |
---|---|---|
accel_hzt |
(m, n) ndarray
|
2D array with the resultant horizontal acceleration series calculated at each cell. There is a 1D array with the resultant horizontal acceleration series at each cell (i, j). |
Source code in pynewmarkdisp/spatial.py
spatial_newmark
Calculate the spatial distribution of permanent displacements.
Perform the direct Newmarkl method for each cell of the spatial domain and return the spatial distribution of the permanent displacements.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
time |
ndarray
|
1D or 2D array with the time data, in [s]. |
required |
accel |
tuple, list or ndarray
|
Object with the acceleration data. If it |
required |
ky |
ndarray
|
2D array with the spatial distribution of the critical seismic coefficient. |
required |
g |
float
|
Acceleration of gravity, in the same units as |
required |
azimuth |
(m, n) ndarray or None
|
2D array with the spatial distribution of the azimuth of the slope dip
direction, in [°] and measured clockwise from North. By default its
value is |
None
|
Returns:
Name | Type | Description |
---|---|---|
permanent_disp |
(m, n) ndarray
|
2D array with the spatial distribution of permanent displacements. |
Source code in pynewmarkdisp/spatial.py
verify_newmark_at_cell
Verify the direct Newmark method at a specific cell.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell |
tuple
|
Tuple with the index of the cell to be verified. |
required |
time |
ndarray
|
1D or 2D array with the time data, in [s]. |
required |
accel |
tuple or list or ndarray
|
Object with the acceleration data. If it |
required |
g |
float
|
Acceleration of gravity, in the same units as |
required |
depth |
(m, n) ndarray
|
2D array with the spatial distribution of the potential sliding surface depth, in [m]. |
required |
depth_w |
ndarray
|
2D array with the spatial distribution of the water table depth, in [m]. |
required |
slope |
(m, n) ndarray
|
2D array with the spatial distribution of the slope inclination, in [°]. |
required |
phi |
(m, n) ndarray
|
2D array with the spatial distribution of the internal friction angle, in [°]. |
required |
c |
(m, n) ndarray
|
2D array with the spatial distribution of the cohesion, in [kPa]. |
required |
gamma |
ndarray
|
2D array with the spatial distribution of the soil unit weight, in [kN/m³]. |
required |
azimuth |
(m, n) ndarray or None
|
2D array with the spatial distribution of the azimuth of the slope dip
direction, in [°] and measured clockwise from North. By default its
value is |
None
|
Returns:
Name | Type | Description |
---|---|---|
newmark_str |
dict
|
Dictionary with the results of the direct Newmark method at the cell. |
Source code in pynewmarkdisp/spatial.py
pynewmarkdisp.infslope
Functions to calculate the factor of safety of an infinite slope mechanism.
factor_of_safety
Calculate the factor of safety for an infinite slope mechanism.
Inputs can be either constant or spatially distributed variables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
depth |
float or (m, n) ndarray
|
Depth of the planar suface, in [m]. |
required |
depth_w |
float or ndarray
|
Depth of the watertable, in [m]. |
required |
slope |
float or ndarray
|
Slope inclination, in [°]. |
required |
phi |
float or ndarray
|
Slope inclination, in [°]. |
required |
c |
float or ndarray
|
Cohesion, in [kPa]. |
required |
gamma |
float or ndarray
|
Average unit weigth of the soil, in [kN/m³]. |
required |
ks |
float or ndarray
|
Seismic coefficient for pseudostatic analysis. Its default value is
|
0
|
Returns:
Name | Type | Description |
---|---|---|
fs |
float or ndarray
|
Factor of safety |
Source code in pynewmarkdisp/infslope.py
get_ky
Compute the critical seismic coefficient of an infinite slope mechanism.
Inputs can be either constant or spatially distributed variables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
depth |
float or (m, n) ndarray
|
Depth of the planar suface, in [m]. |
required |
depth_w |
float or ndarray
|
Depth of the watertable, in [m]. |
required |
slope |
float or ndarray
|
Slope inclination, in [°]. |
required |
phi |
float or ndarray
|
Slope inclination, in [°]. |
required |
c |
float or ndarray
|
Cohesion, in [kPa]. |
required |
gamma |
float or ndarray
|
Average unit weigth of the soil, in [kN/m³]. |
required |
Returns:
Name | Type | Description |
---|---|---|
ky |
float or ndarray
|
Critical seismic coefficient. |
Source code in pynewmarkdisp/infslope.py
min_fs_and_depth
Calculate the minimum factor of safety and the depth at which it occurs.
As for the factor_of_safety
function, inputs can be either constant or
spatially distributed variables.
It evaluates the factor of safety for a range of nd
depths between the
terrain surface and the slip surface and return the minimum factor of
safety and the depth at which it occurs. This is useful to find the
critical slip surface, which will be located at the first depth where the
factor of safety drops below 1 or where it reaches its minimum value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
depth |
float or (m, n) ndarray
|
Depth of the planar suface, in [m]. |
required |
depth_w |
float or ndarray
|
Depth of the watertable, in [m]. |
required |
slope |
float or ndarray
|
Slope inclination, in [°]. |
required |
phi |
float or ndarray
|
Slope inclination, in [°]. |
required |
c |
float or ndarray
|
Cohesion, in [kPa]. |
required |
gamma |
float or ndarray
|
Average unit weigth of the soil, in [kN/m³]. |
required |
ks |
float or ndarray
|
Seismic coefficient for pseudostatic analysis. Its default value is
|
0
|
nd |
int
|
Number of depths to evaluate between the terrain surface and the slip
surface. The default is |
10
|
Returns:
Name | Type | Description |
---|---|---|
min_fs |
float or ndarray
|
Minimum factor of safety |
depth_at_min_fs |
float or ndarray
|
Depth at which the minimum factor of safety occurs, in [m]. |
Source code in pynewmarkdisp/infslope.py
num_to_2darray
Turn an int or float input into a 2D array with shape (1, 1).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
num |
int or float
|
Variable to be converted to a 2D array |
required |
Returns:
Name | Type | Description |
---|---|---|
num_array |
ndarray
|
2D array with shape (1, 1) whose only element is the input variable. |
Source code in pynewmarkdisp/infslope.py
pynewmarkdisp.empir_corr
Functions to calculate permanent displacements from empirical correlations.
Most of the functions in this module are taken from Table 1 in
Meehan & Vahedifard (2013),
who compiled a several empirical correlations or simplified methods for
calculating the permanent displacement of a slope. The keys of the
correlations
dictionary are the same as the numbering of the cited table.
However, additional functions were added to the dictionary after consulting
the original references.
ambraseys_and_menu_88
Ambraseys and Menu (1988) empirical correlation for uₚ.
Eq. 10 in Meehan & Vahedifard (2013).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ay |
float
|
Critical acceleration, in fraction of g. |
required |
a_max |
float
|
Peak horizontal ground acceleration, in fraction of g. |
required |
Returns:
Name | Type | Description |
---|---|---|
perm_disp |
float
|
Permanent displacement, in [m]. |
Source code in pynewmarkdisp/empir_corr.py
bray_and_travasarou_07_eq6
Bray and Travasarou (2007) empirical correlation for uₚ.
Eq. 10 in Meehan & Vahedifard (2013). Eq. 6 in Bray and Travasarou (2007).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ay |
float
|
Critical acceleration, in fraction of g. |
required |
a_max |
float
|
Peak horizontal ground acceleration, in fraction of g. |
required |
magnitude |
float
|
Earthquake magnitude. |
required |
Returns:
Name | Type | Description |
---|---|---|
perm_disp |
float
|
Permanent displacement, in [m]. |
Source code in pynewmarkdisp/empir_corr.py
hynesgriffin_and_Franklin_1984_mean
Hynes-Griffin and Franklin (1984) empirical correlation for uₚ (mean).
Eq. 8 in Meehan & Vahedifard (2013). It is a functional form of the mean resulting from regression analysis of chart-based solution from the original paper.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ay |
float
|
Critical acceleration, in fraction of g. |
required |
a_max |
float
|
Peak horizontal ground acceleration, in fraction of g. |
required |
Returns:
Name | Type | Description |
---|---|---|
perm_disp |
float
|
Permanent displacement, in [m]. |
Source code in pynewmarkdisp/empir_corr.py
hynesgriffin_and_Franklin_1984_ub
Hynes-Griffin and Franklin (1984) empirical corr. for uₚ (upper bound).
Eq. 7 in Meehan & Vahedifard (2013). It is a functional form of the upper bound resulting from regression analysis of chart-based solution from the original paper.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ay |
float
|
Critical acceleration, in fraction of g. |
required |
a_max |
float
|
Peak horizontal ground acceleration, in fraction of g. |
required |
Returns:
Name | Type | Description |
---|---|---|
perm_disp |
float
|
Permanent displacement, in [m]. |
Source code in pynewmarkdisp/empir_corr.py
jibson_07_eq10
Jibson (2007) empirical correlation for uₚ.
Eq. 19 in Meehan & Vahedifard (2013). Eq. 10 in Jibson (2007).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ay |
float
|
Critical acceleration, in fraction of g. |
required |
a_max |
float
|
Peak horizontal ground acceleration, in fraction of g. |
required |
arias_int |
float
|
Arias intensity, in [m/s]. |
required |
Returns:
Name | Type | Description |
---|---|---|
perm_disp |
float
|
Permanent displacement, in [m]. |
Source code in pynewmarkdisp/empir_corr.py
jibson_07_eq6
Jibson (2007) empirical correlation for uₚ.
Eq. 16 in Meehan & Vahedifard (2013). Eq. 6 in Jibson (2007).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ay |
float
|
Critical acceleration, in fraction of g. |
required |
a_max |
float
|
Peak horizontal ground acceleration, in fraction of g. |
required |
Returns:
Name | Type | Description |
---|---|---|
perm_disp |
float
|
Permanent displacement, in [m]. |
Source code in pynewmarkdisp/empir_corr.py
jibson_07_eq9
Jibson (2007) empirical correlation for uₚ.
Eq. 18 in Meehan & Vahedifard (2013). Eq. 9 in Jibson (2007).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ay |
float
|
Critical acceleration, in fraction of g. |
required |
arias_int |
float
|
Arias intensity, in [m/s]. |
required |
Returns:
Name | Type | Description |
---|---|---|
perm_disp |
float
|
Permanent displacement, in [m]. |
Source code in pynewmarkdisp/empir_corr.py
saygili_and_rathje_08_eq5
Saygili and Rathje (2008) empirical correlation for uₚ.
Eq. 20 in Meehan & Vahedifard (2013). Eq. 5 in Saygili and Rathje (2008).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ay |
float
|
Critical acceleration, in fraction of g. |
required |
a_max |
float
|
Peak horizontal ground acceleration, in fraction of g. |
required |
Returns:
Name | Type | Description |
---|---|---|
perm_disp |
float
|
Permanent displacement, in [m]. |
Source code in pynewmarkdisp/empir_corr.py
saygili_and_rathje_08_eq6col2
Saygili and Rathje (2008) empirical correlation for uₚ.
Eq. 21 in Meehan & Vahedifard (2013). Eq. 6 in Saygili and Rathje (2008) with parameters from Table 1, column 2.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ay |
float
|
Critical acceleration, in fraction of g. |
required |
a_max |
float
|
Peak horizontal ground acceleration, in fraction of g. |
required |
v_max |
float
|
Peak horizontal ground velocity, in [cm/s]. |
required |
Returns:
Name | Type | Description |
---|---|---|
perm_disp |
float
|
Permanent displacement, in [m]. |
Source code in pynewmarkdisp/empir_corr.py
saygili_and_rathje_08_eq6col4
Saygili and Rathje (2008) empirical correlation for uₚ.
Not in Meehan & Vahedifard (2013), but it is equivalent to Eq. 21. Eq. 6 in Saygili and Rathje (2008) with parameters from Table 1, column 4.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ay |
float
|
Critical acceleration, in fraction of g. |
required |
a_max |
float
|
Peak horizontal ground acceleration, in fraction of g. |
required |
arias_int |
float
|
Arias intensity, in [m/s]. |
required |
Returns:
Name | Type | Description |
---|---|---|
perm_disp |
float
|
Permanent displacement, in [m]. |