earthscopestraintools.strain_visualization module

earthscopestraintools.strain_visualization.map_strain(areal: array, differential: array, shear: array, lats: array | None = None, lons: array | None = None, station_list: list | None = None, colors: list | None = None, units: str | None = None, scale_length: float | None = None, title: str | None = None, savefig: str | None = None)
Creates a map of the principal strain axes (x-axis = East, y-axis = North). Supply area, differential, and shear strains with optional location information and plot parameters.

If a plot with strain units on the x- and y- axes is desired, omit station location information and the strain axes will be centered on zero.

Parameters:
  • areal (np.array) – Array of areal (Eee+Enn) strains

  • differential (np.array) – Array of differential (Eee-Enn) strains

  • shear (np.array) – Array of engineering shear (2Een) strains

  • lats (np.array) – (Optional) Array of latitudes or y-axis locations

  • lons (np.array) – (Optional) Array of longitudes or y-axis locations

  • station_list (list) – (Optional) List of station names to label.

  • colors (list) – (Optional) List of colors for the strain axes

  • units (str) – (Optional) Units to label strain

  • scale_length (float) – (Optional) Length to make the scale bar. Will plot a default scale based on magnitude of the data none is provided.

  • title (str) – Plot title

  • savefig (str) – Save figure with the input string as the filename. Extension will determine format (png, svg, pdf, eps, ps).

Returns:

Map/Figure of strain axes

Return type:

matplotlib.pyplot.figure

Example

>>> from earthscopestraintools.strain_visualization import map_strain
>>> import numpy as np
>>> # Array of offsets to plot in areal, differential, and shear strains
>>> ea = np.array([1,0.5,0.25])*10
>>> ed = np.array([1,0.5,0])*10
>>> es = np.array([0.5,-0.5,0])*10
>>> # Colors for each set of axes
>>> colors = ['lightblue','orange','maroon']
>>> # labeels for each set of arrows
>>> station_list = ['lightblue','orange','maroon']
>>> # location informtion
>>> lats, lons = np.array([13,12.5,12.0]), np.array([40,40.5,41])
>>> # call the function
>>> map_strain(areal=ea,differential=ed,shear=es,
...            lats=lats, lons=lons,station_list=station_list,
...            colors=colors,units='ms',title='Principal Strain Axes')
>>>
earthscopestraintools.strain_visualization.strain_video(df, start: str | None = None, end: str | None = None, skip: int = 1, interval: float | None = None, azimuth_arrow: float | None = None, title: str | None = None, units: str | None = None, repeat: bool = False, savegif: str | None = None)

Displays a gif of the strain time series provided, with time series and strain axes displayed. Strain is shown relative to the first data point.

Parameters:
  • df (pd.DataFrame) – Dataframe with datetime (in seconds) index and regional strain columns (‘Eee+Enn’, ‘Eee-Enn’, ‘2Ene’)

  • start (str) – (Optional) Start of the video as a datetime string.

  • end (str) – (Optional) End of the video as a datetime string.

  • skip (int) – (optional) number of data points to skip per frame (eg. if using 5 minute Timeseries, skip=2 will decimate the dataset to a 10 minute period)

  • interval (float) – (Optional) Time between frames (in microseconds).

  • azimuth_arrow ((Optional) Directional arrow to plot behind the strain axes, in degrees (default is None)) – float

  • title (str) – (Optional) Plot title

  • repeat (bool) – (Optional) Choose if the animation repeats. Defaults to false.

  • units (str) – (Optional) Units to label strain

Returns:

Gif of the strain time series

Return type:

matplotlib.animation