pysep.utils.plot#

Pysep plotting utilities

Module Contents#

Functions#

plot_geometric_spreading(distances, max_amplitudes, ...)

Plot a scatter plot of peak amplitudes vs distance and a corresponding line

plot_source_receiver_map(inv, event[, subset, save, ...])

Simple utility to plot station and event on a single map with Cartopy

set_plot_aesthetic(ax[, ytick_fontsize, ...])

Give a nice look to the output figure by creating thick borders on the

pysep.utils.plot.plot_geometric_spreading(distances, max_amplitudes, geometric_spreading_factor, geometric_k_value, units='km', station_ids=None, include=None, show=False, save='geometric_spreading.png', ymax=None, **kwargs)[source]#

Plot a scatter plot of peak amplitudes vs distance and a corresponding line representing geometric scatter. Allow ignoring stations by index.

Note

see recsec.RecordSection._calculate_geometric_spreading() for more information on this function

Parameters:
  • distances (list or np.array) – source-receiver distance in units units

  • max_amplitudes (list or np.array) – peak amplitudes, units irrelevant

  • units (st) – ‘km’ or ‘deg’ for kilometers or degrees, respectively. used for the x-axis label only

  • geometric_spreading_factor (float) – exponent for spreading eq

  • geometric_k_value (float) – constant scale factor for spreading eq

  • station_ids (list or np.array) – station ids for optional text labels

  • include (list or np.array) – indices of stations included in equation, used for colors

  • show (bool) – show the figure after generation

  • save (str) – file name to save figure

  • ymax (float) – set the ceiling y limit manually (incase some stations are scaled improperly which would throw off all the scaling). Also cuts off any stations above this limit and plots them differently

pysep.utils.plot.plot_source_receiver_map(inv, event, subset=None, save='./station_map.png', projection=None, show=False)[source]#

Simple utility to plot station and event on a single map with Cartopy

Parameters:
  • event (obspy.core.event.Event) – event to get location from

  • inv (obspy.core.inventory.Inventory) – inventory to get locatiosn from

  • subset (list of str) – allow subsetting stations in the Inventory. Station IDs should match the format output by function obspy.trace.Trace.get_id(), that is, NN.SSS.LL.CCC (Network, Station, Location, Channel). Location and channel information are not used during subsetting.

  • save (str) – filename to save station map, defaults: ./station_map.png

  • projection (str) – map projection, ‘local, ‘ortho’, ‘global’ or None. If None, will be determined based on largest src-rcv distance

  • show (bool) – show the figure in the GUI

pysep.utils.plot.set_plot_aesthetic(ax, ytick_fontsize=8.0, xtick_fontsize=12.0, tick_linewidth=1.5, tick_length=5.0, tick_direction='in', xlabel_fontsize=10.0, ylabel_fontsize=10.0, axis_linewidth=2.0, spine_zorder=8, spine_top=True, spine_bot=True, spine_left=True, spine_right=True, title_fontsize=10.0, xtick_minor=None, xtick_major=None, ytick_minor=None, ytick_major=None, xgrid_major=True, xgrid_minor=True, ygrid_major=True, ygrid_minor=True, **kwargs)[source]#

Give a nice look to the output figure by creating thick borders on the axis, adjusting fontsize etc. All plot aesthetics should be placed here so it’s easiest to find.

Parameters:
  • ax (matplotlib.axes._subplots.AxesSubplot) – matplotlib axis figure to set plot aesthetic for

  • ytick_fontsize (float) – fontsize for labels next to Y-axis ticks

  • xtick_fontsize (float) – fontsize for labels next to X-axis ticks

  • tick_linewidth (float) – thickness of tick marks for both X and Y axes

  • tick_length (float) – length of tick marks for both X and Y axes

  • tick_direction (str) – ‘in’ for ticks pointing inwards, ‘out’ for ticks pointing outwards

  • xlabel_fontsize (float) – font size for the X-axis main label (e.g., Time)

  • ylabel_fontsize (float) – font size for the Y-axis main label (e.g., Ampli)

  • axis_linewidth (float) – line thickness for the borders of the figure

  • spine_zorder (int) – Z order (visibility) of the axis borders (spines)

  • spine_top (bool) – toggle on/off the top axis border

  • spine_bot (bool) – toggle on/off the bottom axis border

  • spine_left (bool) – toggle on/off the left axis border

  • spine_right (bool) – toggle on/off the right axis border

  • title_fontsize (float) – font size of the main title at the top of the figure

  • xtick_minor (float) – how often minor tick marks are drawn on X axis

  • xtick_major (float) – how often major tick marks are drawn on X axis

  • xtick_minor – how often minor tick marks are drawn on Y axis

  • ytick_major (float) – how often major tick marks are drawn on Y axis

  • xgrid_minor (bool) – turn on grid lines for each minor X tick

  • xgrid_major (bool) – turn on grid lines for each major X tick

  • ygrid_minor (bool) – turn on grid lines for each minor Y tick

  • ygrid_major (bool) – turn on grid lines for each minor Y tick

Return type:

matplotlib.axes._subplots.AxesSubplot

Returns:

input axis with aesthetic changed