pySW4.plotting.waveforms module

Plotting routines for observed and synthetic waveforms.

author:

Shahar Shani-Kadmiel (s.shanikadmiel@tudelft.nl)

Omry Volk (omryv@post.bgu.ac.il)

Tobias Megies (megies@geophysik.uni-muenchen.de)

copyright:

Shahar Shani-Kadmiel (s.shanikadmiel@tudelft.nl)

Omry Volk (omryv@post.bgu.ac.il)

Tobias Megies (megies@geophysik.uni-muenchen.de)

license:

This code is distributed under the terms of the GNU Lesser General Public License, Version 3 (https://www.gnu.org/copyleft/lesser.html)

SW4 uses a right handed coordinate system

     X
   ⋰
 ⋰
o------->Y
|
|
V
Z

If the azimuth of the SW4 grid is 0 this translates to:

  • X == Northing
  • Y == Easting
  • Z == Vertical (inverted!)
_plot_seismograms(st_synth_, st_real_, channel_map, unit_label, outfile, figsize=None, info_text=None)[source]

Helper function that plots synthetic vs. real data to an image file.

Parameters:

st_synth : obspy.core.stream.Stream

Synthetic waveform data.

st_real : obspy.core.stream.Stream

Observed waveform data.

channel_map : dict

Mapping dictionary to match synthetic channel to component in observed data.

unit_label : str

Label string for y-axis of waveforms.

outfile : str

Output filename (absolute or relative path) for image including suffix (e.g. png).

figsize : 2-tuple of floats

Matplotlib figure size (inches x/y).

create_seismogram_plots(input_file, folder=None, stream_observed=None, inventory=None, water_level=None, pre_filt=None, filter_kwargs=None, channel_map=None, used_stations=None, synthetic_starttime=None, synthetic_data_glob='*.?v', t0_correction_fraction=0.0, synthetic_scaling=False, verbose=False)[source]

Create all waveform plots, comparing synthetic and observed data.

Ideally works on a SW4 input file, or explicitely on an folder with SW4 output files. Assumes output in SAC format. Observed/real data and station metadata can be specified, along with deconvolution parameters to get to physical units.

Parameters:

input_file : str

Filename (potentially with absolute/relative path) of SW4 input file used to control the simulation. Use None to work on folder with SW4 output without using metadata from input file.

folder : str

Folder with SW4 output files or None if output folder location can be used from input file. Only needed when no input file is specified or if output folder was moved to a different location after the simulation.

stream_observed : obspy.core.stream.Stream

Observed/real data to compare with synthetics.

inventory : obspy.core.inventory.inventory.Inventory

Station metadata for observed/real data.

water_level : float

Water level for instrument response removal (see obspy.core.trace.remove_response()).

pre_filt : 4-tuple of float

Frequency domain pre-filtering in response removal (see obspy.core.trace.Trace.remove_response()).

filter_kwargs : dict

Filter parameters for filtering applied to observed data after response removal before comparison to synthetic data. kwargs are passed on to obspy.core.stream.Stream.filter().

channel_map : dict

Mapping dictionary to match synthetic channel to component in observed data.

used_stations : list

Station codes to consider in plot output. Use all stations if left None.

synthetic_starttime : obspy.core.utcdatetime.UTCDateTime

Start time of synthetic data, only needed if no input file is specified or if input file did not set the correct origin time of the event.

synthetic_data_glob : str

Glob pattern to lookup synthetic data. Use e.g. ‘*.[xyz]’ or ‘*.?’ for synthetic data saved as “displacement” (the solution of the forward solver), or ‘*.?v’ for synthetic data saved as “velocity” (the differentiated solution of the forward solver).

t0_correction_fraction : float

Fraction of t0 used in SW4 simulation (offset of source time function to prevent solver artifacts) to account for (i.e. shift synthetics left to earlier absolute time). ‘0.0’ means no correction of synthetics time is done, ‘1.0’ means that synthetic trace is shifted left in time by t0 of SW4 run.

synthetic_scaling : bool or float

Scaling to apply to synthetic seismograms. If False, no scaling is applied. If a float is provided, all synthetics’ will be scaled with the given factor (e.g. using 2.0 will scale up synthetics by a factor of 2).

plot_traces(traces, mode='', yscale='auto', hspace=0.2, wspace=0.05, figsize=None, fig=None, **kwargs)[source]

Plot all traces and their Fourier specra side-by-side.

Parameters:

traces : Stream

Traces to be plotted in an Stream object.

mode : {‘displacement’, ‘velocity’, ‘div’, ‘curl’, ‘strains’}

Mode describes the type of data in traces.

Optionaly, an alternative string can be given that will be used as the y-label of the time-histories.

yscale : {‘auto’, ‘all’, ‘normalize’}

Set the scale of the vertical y-axis:

  • auto - Vertical scale of each axes is automatically set to the -|max| and |max| of each trace.
  • all - Vertical scale of all axes is set to the same limits which are the -|max| and |max| of all traces.
  • normalize - Each trace is normalized and plotted (ylim=(-1, 1)).

hspace : float

The hight space between axes. See GridSpec documentation.

wspace : float

The width space between axes. See GridSpec documentation.

figsize : 2-tuple

Size of the Figure.

fig : Figure

A Figure instance.

Other Parameters:
 

kwargs : plot() propeties.