5.2.10.11. eqcorrscan.utils.plotting.pretty_template_plot

eqcorrscan.utils.plotting.pretty_template_plot(template, background=False, event=False, sort_by='distance', **kwargs)[source]

Plot of a single template, possibly within background data.

Parameters:
  • template (obspy.core.stream.Stream) – Template stream to plot

  • background (obspy.core.stream.stream) – Stream to plot the template within.

  • event (obspy.core.event.event.Event) – Event object containing picks, and optionally information on the origin and arrivals. When supplied, function tries to extract hypocentral distance from origin/arrivals, to sort the template traces by hypocentral distance.

  • sort_by (string) – “distance” (default) or “pick_time” (not relevant if no event supplied)

  • title (str) – Title of figure

  • show (bool) – Whether to show the figure or not (defaults to True)

  • save (bool) – Whether to save the figure or not (defaults to False)

  • savefile (str) – Filename to save figure to, if save==True (defaults to “EQcorrscan_figure.png”)

  • return_figure (bool) – Whether to return the figure or not (defaults to True), if False then the figure will be cleared and closed.

  • size (tuple of float) – Figure size as (width, height) in inches. Defaults to (10.5, 7.5)

Returns:

matplotlib.figure.Figure

Example

>>> from obspy import read, read_events
>>> import os
>>> from eqcorrscan.core import template_gen
>>> from eqcorrscan.utils.plotting import pretty_template_plot
>>> # Get the path to the test data
>>> import eqcorrscan
>>> import os
>>> TEST_PATH = os.path.dirname(eqcorrscan.__file__) + '/tests/test_data'
>>>
>>> test_file = os.path.join(TEST_PATH, 'REA', 'TEST_',
...                          '01-0411-15L.S201309')
>>> test_wavefile = os.path.join(
...     TEST_PATH, 'WAV', 'TEST_', '2013-09-01-0410-35.DFDPC_024_00')
>>> event = read_events(test_file)[0]
>>> st = read(test_wavefile)
>>> st = st.filter('bandpass', freqmin=2.0, freqmax=15.0)
>>> for tr in st:
...     tr = tr.trim(tr.stats.starttime + 30, tr.stats.endtime - 30)
...     # Hack around seisan 2-letter channel naming
...     tr.stats.channel = tr.stats.channel[0] + tr.stats.channel[-1]
>>> template = template_gen._template_gen(event.picks, st, 2)
>>> pretty_template_plot(template, background=st, # doctest +SKIP
...                      event=event) 

(Source code)