4.2. EQcorrscan_plotting — EQcorrscan 0.1.0 documentation

# 4.2. EQcorrscan_plotting

Utility code for most of the plots used as part of the EQcorrscan package.

Copyright 2015 Calum Chamberlain

This file is part of EQcorrscan.

> EQcorrscan is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

> EQcorrscan is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

> You should have received a copy of the GNU General Public License along with EQcorrscan. If not, see <http://www.gnu.org/licenses/>.

`EQcorrscan_plotting.` `NR_plot`(stream, NR_stream, detections, false_detections=False, size=(18.5, 10), save=False, title=False)

  Function to plot the Network response alongside the streams used -highlights detection times in the network response.

  Parameters: | stream – Stream to plot NR_stream – Stream for the network response detections (list of datetime objects) – List of the detections false_detections (list of datetime) – Either False (default) or list of false detectiontimes size (tuple) – Size of figure, default is (18.5,10) save (bool) – Save figure or plot to screen, if not False, must be stringof save path. title (str) – String for the title of the plot, set to False

`EQcorrscan_plotting.` `SVD_plot`(SVStreams, SValues, stachans, title=False)

  Function to plot the singular vectors from the clustering routines, oneplot for each stachan

  Parameters: | SVStreams (list of :class:Obspy.Stream) – See clustering.SVD_2_Stream - will assume these areordered by power, e.g. first singular vector in the first stream SValues (list of float) – List of the singular values corresponding to the SVStreams stachans (list) – List of station.channel

`EQcorrscan_plotting.` `_spec_trace`(trace, cmap=None, wlen=0.4, log=False, trc=u'k', tralpha=0.9, size=(10, 2.5), axes=None, title=None)

  Function to plot a trace over that traces spectrogram. Uses obspys spectrogram routine.

  Parameters: | trace (obspy.Trace) – trace to plot cmap (str) – [Matplotlib colormap](http://matplotlib.org/examples/color/ colormaps_reference.html) wlen (float) – Window length for fft in seconds log (bool) – Use a log frequency scale trc (str) – Color for the trace. tralpha (float) – Opacity level for the seismogram, from transparent (0.0) to opaque (1.0). size (tuple) – Plot size, tuple of floats, inches axes (matplotlib axes) – Axes to plot onto, defaults to self generating. title (str) – Title for the plot.

`EQcorrscan_plotting.` `chunk_data`(tr, samp_rate, state=u'mean')

  Function to downsample data for plotting by computing the maximum of data within chunks, useful for plotting waveforms or cccsums, large datasets that would otherwise exceed the complexity allowed, and overflow.

  Parameters: | tr (obspy.Trace) – Trace to be chunked samp_rate (float) – Desired sampling rate in Hz state (str) – Either ‘Min’, ‘Max’, ‘Mean’ or ‘Maxabs’ to return one of these for the chunks. Maxabs will return the largest (positive or negative) for that chunk.
  Returns: |
  class: | obspy.Trace

`EQcorrscan_plotting.` `cumulative_detections`(dates, template_names, save=False, savefile=u'')

  Simple plotting function to take a list of datetime objects and plot a cumulative detections list. Can take dates as a list of lists and will plot each list seperately, e.g. if you have dates from more than one template it will overlay them in different colours.

  Parameters: | dates (list of lists of datetime.datetime) – Must be a list of lists of datetime.datetime objects template_names (list of strings) – List of the template names in order of the dates save (bool) – Save figure or show to screen, optional savefile (str) – String to save to, optional

`EQcorrscan_plotting.` `detection_multiplot`(stream, template, times, streamcolour=u'k', templatecolour=u'r')

  Function to plot the stream of data that has been detected in, withthe template on top of it timed according to a list of given times, justa pretty way to show a detection!

  Parameters: | stream (obspy.Stream) – Stream of data to be plotted as the base (black) template (obspy.Stream) – Template to be plotted on top of the base stream (red) times (list of datetime.datetime) – list of times of detections in the order of the channels in template. streamcolour (str) – String of matplotlib colour types for the stream templatecolour (str) – Colour to plot the template in.

`EQcorrscan_plotting.` `freq_mag`(magnitudes, completeness, max_mag, binsize=0.2)

  Function to make a frequency-magnitude histogram and cumulative density plot. This can compute a b-value, but not a completeness at the moment. B-value is computed by linear fitting to section of curve between completeness and max_mag.

  Parameters: | magnitudes (list) – list of float of magnitudes completeness (float) – Level to compute the b-value above max_mag (float) – Maximum magnitude to try and fit a b-value to binsize (float) – Width of histogram bins, defaults to 0.2

`EQcorrscan_plotting.` `interev_mag`(times, mags)

  Function to plot interevent times against magnitude for given times and magnitudes.

  Parameters: | times (list of datetime) – list of the detection times, must be sorted the same as mags mags (list of float) – list of magnitudes

`EQcorrscan_plotting.` `interev_mag_sfiles`(sfiles)

  Function to plot interevent-time versus magnitude for series of events. thin Wrapper for interev_mag.

  Parameters: | sfiles (list) – List of sfiles to read from

`EQcorrscan_plotting.` `multi_event_singlechan`(streams, catalog, clip=10.0, pre_pick=2.0, freqmin=False, freqmax=False, realign=False, cut=(-3.0, 5.0), PWS=False, title=False)

  Function to plot data from a single channel at a single station for multiple events - data will be alligned by their pick-time given in the picks.

  Parameters: | streams (list of :class:obspy.stream) – List of the streams to use, can contain more traces than you plan on plotting catalog (obspy.core.event.Catalog) – Catalog of events, one for each trace, with a single pick clip (float) – Length in seconds to plot, defaults to 10.0 pre_pick (float) – Length in seconds to extract and plot before the pick, defaults to 2.0 freqmin (float) – Low cut for bandpass in Hz freqmax (float) – High cut for bandpass in Hz realign (bool) – To compute best alignement based on correlation or not. cut (tuple) – tuple of start and end times for cut in seconds from the pick PWS (bool) – compute Phase Weighted Stack, if False, will compute linear stack. title (str) – Plot title.
  Returns: | Alligned and cut traces, and new picks

`EQcorrscan_plotting.` `peaks_plot`(data, starttime, samp_rate, save=False, peaks=[(0, 0)], savefile=u'')

  Simple utility code to plot the correlation peaks to check that the peak finding routine is running correctly, used in debugging for the EQcorrscan module.

  Parameters: | data (numpy.array) – Numpy array of the data within which peaks have been found starttime (obspy.UTCDateTime) – Start time for the data samp_rate (float) – Sampling rate of data in Hz save (Boolean, optional) – Save figure or plot to screen (False) peaks (list of Tuple, optional) – List of peak locations and amplitudes (loc, amp) savefile (String, optional) – Path to save to, only used if save=True

`EQcorrscan_plotting.` `plot_synth_real`(real_template, synthetic, channels=False)

  Plot multiple channels of data for real data and synthetic.

  Parameters: | real_template (obspy.Stream) – Stream of the real template synthetic (obspy.Stream) – Stream of synthetic template channels (list of str) – List of tuples of (station, channel) to plot, default isFalse, which plots all.

`EQcorrscan_plotting.` `pretty_template_plot`(template, size=(18.5, 10.5), save=False, title=False, background=False, picks=False)

  Function to make a pretty plot of a single template, designed to work better than the default obspy plotting routine for short data lengths.

  Parameters: | template – Template stream to plot size (tuple) – tuple of plot size save (bool) – if False will plot to screen, if True will save title (bool) – String if set will be the plot title background – Stream to plot the template within. picks (list of :class: eqcorrscan.utils.Sfile_util.PICK) – List of eqcorrscan type picks.

`EQcorrscan_plotting.` `spec_trace`(traces, cmap=None, wlen=0.4, log=False, trc=u'k', tralpha=0.9, size=(10, 13), Fig=None, title=None, show=True)

  Wrapper for _spec_trace, take a stream or list of traces and plots the trace with the spectra beneath it - this just does the overseeing to work out if it needs to add subplots or not.

  Parameters: | traces (either stream or list of traces) – Traces to be plotted, can be a single obspy.Stream, or a list of obspy.Trace cmap (str) – [Matplotlib colormap](http://matplotlib.org/examples/color/ colormaps_reference.html) wlen (float) – Window length for fft in seconds log (bool) – Use a log frequency scale trc (str) – Color for the trace. tralpha (float) – Opacity level for the seismogram, from transparent (0.0) to opaque (1.0). size (tuple) – Plot size, tuple of floats, inches axes – Figure to plot onto, defaults to self generating. show (bool) – To show plot or not, if false, will return Fig.

`EQcorrscan_plotting.` `threeD_gridplot`(nodes, save=False, savefile=u'')

  Function to plot in 3D a series of grid points.

  Parameters: | nodes (list of tuples) – List of tuples of the form (lat, long, depth) save (bool) – if True will save without plotting to screen, if False (default) will plot to screen but not save savefile (str) – required if save=True, path to save figure to.

`EQcorrscan_plotting.` `threeD_seismplot`(stations, nodes)

  Function to plot seismicity and stations in a 3D, movable, zoomable space using matplotlibs Axes3D package.

  Parameters: | stations (list of tuple) – list of one tuple per station of (lat, long, elevation), with up positive. nodes (list of tuple) – list of one tuple per event of (lat, long, depth) with down positive.

`EQcorrscan_plotting.` `triple_plot`(cccsum, cccsum_hist, trace, threshold, save=False, savefile=u'')

  Main function to make a triple plot with a day-long seismogram, day-long correlation sum trace and histogram of the correlation sum to show normality.

  Parameters: | cccsum (numpy.ndarray) – Array of the cross-channel cross-correlation sum cccsum_hist (numpy.ndarray) – cccsum for histogram plotting, can be the same as cccsum but included if cccsum is just an envelope. trace (obspy.Trace) – A sample trace from the same time as cccsum threshold (float) – Detection threshold within cccsum save (bool, optional) – If True will svae and not plot to screen, vice-versa if False savefile (str, optional) – Path to save figure to, only required if save=True