pyrocko.plot.dynamic_rupture¶
Functions
|
Clear all temporary needed grid and colormap cpt files. |
|
Create gmt-readable colormap cpt file called my_<cmap>.cpt. |
|
Generate a gif based on a given mp4 using ffmpeg. |
|
Generate a mp4 movie based on given png files using ffmpeg. |
|
Generate a movie based on a given source for dynamic parameter. |
|
Convert x and y relative coordinates on extended ruptures into latlon. |
|
Convert relative coordinates on extended ruptures into length and width. |
Classes
|
Map plotting of attributes and results of the |
|
Plot of attributes and results of the |
- make_colormap(gmt, vmin, vmax, C=None, cmap=None, space=False)[source]¶
Create gmt-readable colormap cpt file called my_<cmap>.cpt.
- Parameters:
vmin (float) – Minimum value covered by the colormap.
vmax (float) – Maximum value covered by the colormap.
C (str) – Comma seperated R/G/B values for cmap definition.
cmap (str) – Name of the colormap. Colormap is stored as “my_<cmap>.cpt”. If name is equivalent to a matplotlib colormap, R/G/B strings are extracted from this colormap.
space (bool) – If
True
, the range of the colormap is broadened below vmin and above vmax.
- xy_to_latlon(source, x, y)[source]¶
Convert x and y relative coordinates on extended ruptures into latlon.
- Parameters:
source (
RectangularSource
orPseudoDynamicRupture
) – Extended source class, on which the given point is located.x (
float
orndarray
) – Relative point coordinate along strike (range: -1:1).y (
float
orndarray
) – Relative downdip point coordinate (range: -1:1).
- Returns:
Latitude and Longitude of the given point in [deg].
- Return type:
- xy_to_lw(source, x, y)[source]¶
Convert relative coordinates on extended ruptures into length and width.
- Parameters:
source (
RectangularSource
orPseudoDynamicRupture
) – Extended source, on which the given points are located.x (float or
ndarray
) – Relative point coordinates along strike (range: -1:1).y (float or
ndarray
) – Relative downdip point coordinates (range: -1:1).
- Returns:
Length and downdip width of the given points from the anchor in [m].
- Return type:
- class RuptureMap(source=None, fontcolor='darkslategrey', width=20.0, height=14.0, margins=None, color_wet=(216, 242, 254), color_dry=(238, 236, 230), topo_cpt_wet='light_sea_uniform', topo_cpt_dry='light_land_uniform', show_cities=False, *args, **kwargs)[source]¶
Bases:
Map
Map plotting of attributes and results of the
PseudoDynamicRupture
.- property size¶
Figure size in [cm].
- property font¶
Font style (size and type).
- property source¶
PseudoDynamicRupture whose attributes are plotted.
Note, that source.patches attribute needs to be calculated in advance.
- patch_data_to_grid(data, *args, **kwargs)[source]¶
Generate a grid file based on regular patch wise data.
- Parameters:
data (
ndarray
) – Patchwise grid data.
- xy_data_to_grid(x, y, data, *args, **kwargs)[source]¶
Generate a grid file based on gridded data using xy coordinates.
Convert a grid based on relative fault coordinates (range -1:1) along strike (x) and downdip (y) into a .grd file.
- draw_image(gridfile, cmap, cbar=True, **kwargs)[source]¶
Draw grid data as image and include, if whished, a colorbar.
- draw_contour(gridfile, contour_int, anot_int, angle=None, unit='', color='', style='', **kwargs)[source]¶
Draw grid data as contour lines.
- Parameters:
gridfile (str) – File of the grid which shall be plotted.
contour_int (float) – Interval of contour lines in units of the gridfile.
anot_int (float) – Interval of labelled contour lines in units of the gridfile. Must be a integer multiple of contour_int.
angle (float) – Rotation angle of the labels in [deg].
unit (str) – Name of the unit in the grid file. It will be displayed behind the label on labelled contour lines.
color (str) – GMT readable color code or string of the contour lines.
style (str) – Line style of the contour lines. If not given, solid lines are plotted.
- draw_colorbar(cmap, label='', anchor='top_right', **kwargs)[source]¶
Draw a colorbar based on a existing colormap.
- draw_vector(x_gridfile, y_gridfile, vcolor='', **kwargs)[source]¶
Draw vectors based on two grid files.
Two grid files for vector lengths in x and y need to be given. The function calls gmt.grdvector. All arguments defined for this function in gmt can be passed as keyword arguments. Different standard settings are applied if not defined differently.
- draw_dynamic_data(data, **kwargs)[source]¶
Draw an image of any data gridded on the patches e.g dislocation.
- Parameters:
data (
ndarray
) – Patchwise grid data.
- draw_patch_parameter(attribute, **kwargs)[source]¶
Draw an image of a chosen patch attribute e.g traction.
- Parameters:
attribute (str) – Patch attribute, which is plotted. All patch attributes can be taken (see doc of
OkadaSource
) and alsotraction
,tx
,ty
ortz
to display the length or the single components of the traction vector.
- draw_time_contour(store, clevel=[], **kwargs)[source]¶
Draw high contour lines of the rupture front propgation time.
- draw_points(lats, lons, symbol='point', size=None, **kwargs)[source]¶
Draw points at given locations.
- draw_dislocation(time=None, component='', **kwargs)[source]¶
Draw dislocation onto map at any time.
For a given time (if
time
isNone
,tmax
is used) and given component the patchwise dislocation is plotted onto the map.
- draw_dislocation_contour(time=None, component=None, clevel=[], **kwargs)[source]¶
Draw dislocation contour onto map at any time.
For a given time (if
time
isNone
,tmax
is used) and given component the patchwise dislocation is plotted as contour onto the map.- Parameters:
time (float) – Time after origin, for which dislocation is computed. If
None
,tmax
is taken.component (str) – Dislocation component, which shall be plotted:
x
along strike,y
along updip,z
normal``. IfNone
, the length of the dislocation vector is plotted.clevel (
list
offloat
) – Times, for which contour lines are drawn.
- draw_dislocation_vector(time=None, **kwargs)[source]¶
Draw vector arrows onto map indicating direction of dislocation.
For a given time (if
time
isNone
,tmax
is used) and given component the dislocation is plotted as vectors onto the map.- Parameters:
time (float) – Time after origin [s], for which dislocation is computed. If
None
,tmax
is used.
- class RuptureView(source=None, figsize=None, fontsize=None)[source]¶
Bases:
Object
Plot of attributes and results of the
PseudoDynamicRupture
.- property source¶
PseudoDynamicRupture whose attributes are plotted.
Note, that source.patches attribute needs to be calculated for :type source:
PseudoDynamicRupture
.
- draw_points(length, width, *args, **kwargs)[source]¶
Draw a point onto the figure.
Args and kwargs can be defined according to
matplotlib.pyplot.scatter()
.
- draw_dynamic_data(data, **kwargs)[source]¶
Draw an image of any data gridded on the patches e.g dislocation.
- Parameters:
data (
ndarray
) – Patchwise grid data.
- draw_patch_parameter(attribute, **kwargs)[source]¶
Draw an image of a chosen patch attribute e.g traction.
- Parameters:
attribute (str) – Patch attribute, which is plotted. All patch attributes can be taken (see doc of
OkadaSource
) and also'traction', 'tx', 'ty', 'tz'
to display the length or the single components of the traction vector.
- draw_time_contour(store, clevel=[], **kwargs)[source]¶
Draw high resolution contours of the rupture front propgation time
- draw_dislocation(time=None, component='', **kwargs)[source]¶
Draw dislocation onto map at any time.
For a given time (if
time
isNone
,tmax
is used) and given component the patchwise dislocation is plotted onto the map.
- draw_dislocation_contour(time=None, component=None, clevel=[], **kwargs)[source]¶
Draw dislocation contour onto map at any time.
For a given time (if time is
None
,tmax
is used) and given component the patchwise dislocation is plotted as contour onto the map.
- draw_source_dynamics(variable, store, deltat=None, *args, **kwargs)[source]¶
Display dynamic source parameter.
Fast inspection possibility for the cumulative moment and the source time function approximation (assuming equal paths between different patches and observation point - valid for an observation point in the far field perpendicular to the source strike), so the cumulative moment rate function.
- Parameters:
variable (str) – Dynamic parameter, which shall be plotted. Choose between ‘moment_rate’ (‘stf’) or ‘cumulative_moment’ (‘moment’)
store (
Store
) – Greens function store, whose store.config.deltat defines the time increment between two parameter snapshots. Ifstore
is not given, the time increment is defined is taken fromdeltat
.deltat (float) – Time increment between two parameter snapshots. If not given, store.config.deltat is used to define
deltat
.
- draw_patch_dynamics(variable, nx, ny, store=None, deltat=None, *args, **kwargs)[source]¶
Display dynamic boundary element / patch parameter.
Fast inspection possibility for different dynamic parameter for a single patch / boundary element. The chosen parameter is plotted for the chosen patch.
- Parameters:
variable (str) – Dynamic parameter, which shall be plotted. Choose between ‘moment_rate’ (‘stf’) or ‘cumulative_moment’ (‘moment’).
nx (int) – Patch index along strike (range: 0:source.nx - 1).
nx – Patch index downdip (range: 0:source.ny - 1).
store (
Store
) – Greens function store, whose store.config.deltat defines the time increment between two parameter snapshots. Ifstore
is not given, the time increment is defined is taken fromdeltat
.deltat (float) – Time increment between two parameter snapshots. If not given, store.config.deltat is used to define
deltat
.
- render_movie(fn_path, output_path, framerate=20)[source]¶
Generate a mp4 movie based on given png files using ffmpeg.
Render a movie based on a set of given .png files in fn_path. All files must have a filename specified by
fn_path
(e.g. givingfn_path
with/temp/f%04.png
a valid png filename would be/temp/f0001.png
). The files must have a numbering, indicating their order in the movie.
- render_gif(fn, output_path, loops=-1)[source]¶
Generate a gif based on a given mp4 using ffmpeg.
Render a gif based on a given .mp4 movie file in
fn
path.
- rupture_movie(source, store, variable='dislocation', draw_time_contours=False, fn_path='.', prefix='', plot_type='map', deltat=None, framerate=None, store_images=False, render_as_gif=False, gif_loops=-1, **kwargs)[source]¶
Generate a movie based on a given source for dynamic parameter.
Create a MPEG-4 movie or gif of one of the following dynamic parameters (
dislocation
,dislocation_x
(along strike),dislocation_y
(along updip),dislocation_z
(normal),slip_rate
,moment_rate
). If desired, the single snap shots can be stored as images as well.kwargs
have to be given according to the chosenplot_type
.- Parameters:
source (
PseudoDynamicRupture
) – Pseudo dynamic rupture, for which the movie is produced.store (
Store
) – Greens function store, which is used for time calculation. Ifdeltat
is not given, it is taken from the store.config.deltatvariable (str) – Dynamic parameter, which shall be plotted. Choose between
dislocation
,dislocation_x
(along strike),dislocation_y
(along updip),dislocation_z
(normal),slip_rate
andmoment_rate
, defaultdislocation
.draw_time_contours (bool) – If
True
, corresponding isochrones are drawn on the each plots.fn_path (str) – Absolut or relative path, where movie (and optional images) are stored.
prefix (str) – File prefix used for the movie (and optional image) files.
plot_type (str) – Choice of plot type:
map
,view
(map plot usingRuptureMap
or plane view usingRuptureView
).deltat (float) – Time between parameter snapshots. If not given, store.config.deltat is used to define
deltat
.store_images (bool) – Choice to store the single .png parameter snapshots in
fn_path
or not.render_as_gif (bool) – If
True
, the movie is converted into a gif. IfFalse
, the movie is returned as mp4.gif_loops (int) – If
render_as_gif
isTrue
, a gif withgif_loops
number of loops (repetitions) is returned.-1
is no repetition,0
infinite.