relmt.plot module#

Plotting utilities for relMT

relmt.plot.alignment(arr, hdr, dt_mccc=None, dt_rms=None, dt_pca=None, ccij=None, event_list=None, event_dict={}, station_dict={}, sort='pci', highlight_events=[])[source]#

Plot waveform array with alignment diagnostics

Parameters:
  • arr (ndarray) – (events, components, samples) Waveform array

  • hdr (Header) – Header of the waveform array

  • event_list (list[int]) – List of event IDs to show

  • event_dict (dict[int, Event]) – The seismic event catalog

  • dt_mccc (ndarray | None) – Time shifts from MCCC alignment

  • dt_rms (ndarray | None) – RMS of time shifts from MCCC alignment

  • dt_pca (ndarray | None) – Time shifts from PCA alignment

  • ccij (ndarray | None) – 2D Cross-correlation matrix between all event pairs

  • sort (str) – Sort by “magnitude”, “pci” (principal component index), or “none” (input order)

  • refevs – Highlight these reference events in red

  • station_dict (dict[int, Event])

  • highlight_events (list[int])

Returns:

  • fig – The matplotlib.figure.Figure containing the plot

  • axs – Dictionary of matplotlib.axes.Axes in the plot with keys: - “dt”: Time shifts - “snr”: Signal to noise ratios - “pv”: Principal seismograms - “wv”: Waveform section - “cci”: Average correlation of each event - “ccij”: Cross-correlation matrix - “ec”: Expansion coefficients

relmt.plot.amplitude_connections(amplitudes, s_amplitudes=None, highlight=None, ax=None, node_size=250.0, node_linewidth=1.0)[source]#

Plot a graph representation of event connections.

Events are connected as pairs or triplets through relative amplitude measurements. Represent these connections as a graph and colour by number of connections

..note:

Requires networkx to be installed.

Parameters:
  • amplitudes (list[P_Amplitude_Ratio] | list[S_Amplitude_Ratios]) – Event pair- or tripletwise P- or S-amplitude mesuremetns.

  • s_samplitudes – Second set of S-amplitude measurements. Observations will be combined

  • highlight (list[int] | None) – Highlight these events with a larger node and thicker outline

  • ax (Axes | None) – Plot into this axis. If None, create one

  • node_size (float) – Size of a node. Increase if you have big numbers

  • node_linewidth (float) – Width of the node edge

  • s_amplitudes (list[S_Amplitude_Ratios] | None)

Returns:

AxesThe axis of the plot

relmt.plot.amplitudes(amplitudes, highlight=[], title=None, weights=None, norms=None)[source]#

Plot amplitude observations and misfits in the same layout as the script.

Parameters:
  • amplitudes (list[P_Amplitude_Ratio] | list[S_Amplitude_Ratios]) – In-memory amplitude observations, either all P or all S observations.

  • highlight (list[int]) – Events to highlight. If omitted, events from the worst-misfit observation are highlighted.

  • title (str | None) – Optional figure title.

  • weights (ndarray | None) – Optional arrays of shape (observations, n) with 1 <= n <= 3. When provided, each is plotted into an additional row.

  • norms (ndarray | None) – Optional arrays of shape (observations, n) with 1 <= n <= 3. When provided, each is plotted into an additional row.

Returns:

tuple[Figure, ndarray]Figure and axes array containing the plot

relmt.plot.bootstrap_matrix(moment_tensors, plot_beachball=False, best_mt=None, takeoff=None, subplot_kwargs={'figsize': (8, 9)})[source]#

Plot bootstrapped moment tensor components

Parameters:
  • moment_tensors (list[MT]) – List of bootstrap results

  • plot_beachball (bool) – Plot bootstrap results as beacball plot. Requires pyrocko

  • best_mt (MT | None) – Also show the best moment tensor, when plot_beachball=True Requires pyrocko.

  • takeoff (ndarray | None) – (2, N) array of takeoff azimuth and plunge angles (degree).

  • subplot_kwargs (dict) – Keyword arguments passed on to matplotlib.pyplot.subplots()

Returns:

  • fig – The class matplotlib..figure.Figure that holds the plot

  • axs(6, 6) array of class matplotlib.axes.Axes

relmt.plot.mt_matrix(mtd, highlight=[], names={}, values={}, valuename='Value', cmap=<matplotlib.colors.ListedColormap object>, overlay_dc_at=1.0, ax=None)[source]#

Plot moment tensors into a square matrix

Parameters:
  • mtd (dict[int, MT]) – Dictionary holding the moment tensors

  • ax (Axes | None) – Plot into existing axes

  • highlight (list[int]) – Highlight these moment tensors

  • overlay_dc_at (float) – Overlay a double couple beachball if DC fraction is at least this large

  • names (dict[int, str])

  • values (dict[int, float])

  • valuename (str)

Returns:

tuple[Figure, Axes] – * Axes of the plot * .. note – Requires pyrocko

relmt.plot.p_reconstruction(wvfA, wvfB, Aab, sampling_rate=None, events_ab=None, axs=None)[source]#

Plot reconstruction of P wave train of event B from event A

Top panel shows reconstucted data over waveform A. Bottom two panels show waveform A and B, respectively.

Parameters:
  • wvfA (ndarray) – (samles,) waveforms of event A and B

  • wvfB (ndarray) – (samles,) waveforms of event A and B

  • Aab (float) – Relative amplitude between A and B

  • sampling_rate (float | None) – Sampling rate (seconds)

  • events_ab (tuple[int, int] | None) – Show event numbers in axis titles

  • axs (tuple[Axes, Axes, Axes] | None) – A tuple of axes to plot into. If None, create new axes.

Returns:

tuple[Axes, Axes, Axes]Axes of the resulting subplots

relmt.plot.s_reconstruction(wvfA, wvfB, wvfC, Babc, Bacb, sampling_rate=None, events_abc=None, axs=None)[source]#

Plot reconstruction of S wave train of event A from events B and C

Top panel shows reconstucted data over waveform A. Bottom two panels show waveform A, B, and C, respectively.

Parameters:
  • wvfA (ndarray) – Waveform of events A, B, and C

  • wvfB (ndarray) – Waveform of events A, B, and C

  • wvfC (ndarray) – Waveform of events A, B, and C

  • Babc (float) – Relative contribution of B to A

  • Bacb (float) – Relative contribution of C to A

  • samling_rate – Supply to show a time axis

  • events_abc (tuple[int, int, int] | None) – Show event numbers in axis titles.

  • axs (tuple[Axes, Axes, Axes, Axes] | None) – Tuple of axes to plot into. If None, create new axes.

  • sampling_rate (float | None)

Returns:

tuple[Axes, Axes, Axes, Axes]Axes of the resulting subplots

relmt.plot.section_2d(mat, scaling=None, time_shift=0.0, sampling_rate=1.0, components=None, ax=None, wiggle=True, image=False, plot_kwargs={}, image_kwargs={})[source]#

Plot a section of seismograms in 2D array.

Parameters:
  • mat (ndarray) – (events, samples) Waveform matrix

  • scaling (float | None) – If None, scale each trace to its absolute maximum value. If 0, scale by absolute value of the section. If non-zero float, scale each trace by this factor.

  • time_shift (float) – Add time shift to tick labels (seconds)

  • sampling_rate (float) – Sampling rate of the seismograms (Hertz)

  • components (str | None) – String of channel names in order

  • ax (Axes | None) – Place plot in existing axis. If None, create an axis

  • wiggle (bool) – Produce a wiggle plot

  • image (bool) – Produce a colored image plot

  • plot_kwargs (dict) – Additional keyword arguments passed to matplotlib.pyplot.plot() (wiggle plot)

  • image_kwargs (dict) – Additional keyword arguments passed to matplotlib.pyplot.imshow() (image plot)

Returns:

AxesAxis containing the plot

relmt.plot.section_3d(arr, scale=-1.0, ax=None, sampling_rate=None, components=None, station=None, events_=None, phase=None, plot_kwargs={})[source]#

Plot seismograms in waveform matrix containing N events, C components and S samples

Parameters:
  • arr (ndarray) – (events, components, samples) Waveform matrix

  • scale (float) –

    • < 0 each trace is scaled to its maximum amplitude (default)

    • = 0 each trace is scaled to the maximum amplitude of the section

    • > 0 then each trace is scaled to that amplitude

  • ax (Axes | None) – When supplied, plot into this axis instead of creating a new figure

  • sampling_rate (float | None) – Sampling rate of the seismic waveform (Hertz)

  • station (str | None) – Station code

  • events – Event names corresponding to the first dimension of the waveform array.

  • phase (str | None) – Seismic phase type to consider (‘P’ or ‘S’)

  • plot_kwargs (dict) – Additional keyword arguments passed to matplotlib.pyplot.plot()

  • components (str | None)

  • events_ (list | None)

Returns:

AxesAxis containing the plot

relmt.plot.spectra(arr, hdr, bandpassd={}, highlight=[], integrate=False, ax=None)[source]#

Plot spectra of waveform array

Parameters:
  • arr (ndarray) – (events, components, samples) Waveform array

  • hdr (Header) – Header of the waveform array

  • evd – Event dictionary

  • bandpasd – Dictionary of wavelet bandpasses per waveform id and event id

  • highlight (list[int]) – Highlight these event IDs with discrete colors

  • ax – Plot into this axis. If None, create one.

  • bandpassd (dict[str, dict[str, tuple]])

  • integrate (bool)

Return type:

Axes