mspasspy.graphics

class mspasspy.graphics.SectionPlotter(scale=1.0, normalize=False, title=None)[source]

Bases: object

This class was designed to plot data in a seismic reflection style display. That means time is the y axis but runs in a reverse direction and traces are equally spaced along the x axis. The data can be plotted as simple wiggle traces, wiggle trace variable area, an image format, and a wiggletrace variable area plot overlaying an image plot.

The object itself only defines the style of plot to be produced along with other assorted plot parameters. The plot method can be called on any mspass data object to produce a graphic display. TimeSeries data produce a frame with one seismogram plotted. Seismogram data will produce a one frame display with the 3 components arranged in component order from left to right. TimeSeriesEnsembles produce conventional reflection style sections with the data displayed from left to right in whatever order the ensemble is sorted to. SeismogramEnsembles are the only type that create multiple windows. That is, each component is displayed in a different window. The display can be understood as a conversion of a SeismogramEnsemble to a set of 3 TimeSeriesEnsembles that are displayed in 3 windows. The component can be deduced only from the title string with has :0, :1, and :2 appended to it to denote components 0, 1, and 2 respectively.

The plots produced by this object are simple ones for display only. The concept is that fancier tools for gui interaction like a trace editor be created as children of this base class.

change_style(newstyle, fill_color='k', color_map='seismic')[source]

Use this method to change the plot style. Options are described below. Some parameter combinations are illegal and will result in a RuntimeError if used. The illegal combos are listed below for each style.

Parameters:

newstyle

This is the primary switch for this method and is used to define the style of plot that will be produced. The allowed values for this string are listed below along with restrictions (when they exist) on related parameters.

wtva - wiggle trace variable area. That means a wiggle traced with

the positive quadrants colored by the color defined by the fill_color parameter. If fill_color is passed as None a RuntimeError will be thrown.

img - data are displayed as an image with the color_map parameter

defining the matplotlib color map used to map amplitudes into a given color. Note as with wtva the data are presumed to be scaled to be of order 1. color_map must not be None, which it can be if the plot was changed from a previous style like wtva, or a RuntimeError exception will be thrown.

wtvaimg is like wtva but the wtva plot is drawn on top of an

image plot. Since this is the union of wtva and img a RuntimeError exception will be throw if either color_map or fill_color are null.

wt will produce a standard line graph of each input as a

black line (that feature is currently frozen). color_map and fill_color are ignored for this style so no exceptions should occur when the method is called with this value of newstyle.

plot(d)[source]

Call this method to plot any data using the current style setup and any details defined by public attributes.

Parameters:

d – is the data to be plotted. It can be any of the following: TimeSeries, Seismogram, TimeSeriesEnsemble, or SeismogramEnsemble. If d is any other type the method will throw a RuntimeError exception.

Returns:

an array of one or 3 (only for SeismogramEnsemble dat) matplotlib.pylot.gcf() plot handle(s).

Return type:

The plot handle is what matplotlib.pyplot calls a gcf. It is the return of pyplot.gcf() and can be used to alter some properties of the figure. See matplotlib documentation.

class mspasspy.graphics.SeismicPlotter(scale=1.0, normalize=False, title=None)[source]

Bases: object

SeismicPlotter is used to plot mspass data objects in the seismology convention with time as the x axis. Use SectionPlotter to plot data in the seismic reflection convention with time on the y axis and oriented backward (increasing downward).

Four types of plots are supported: wiggle trace, wiggle trace variable area (i.e. filled on positive peaks), image plots, and colored wiggle trace variable area (wtva overlays an image display). Ensembles of Seismogram objects (SeismogramEnsemble object) are plotted in three windows that will appear as Figure 0, Figure 1, and Figure 2. All other object are displayed in a single window. Default display order for ensembles is fill in ensemble order from the bottom up. Use the topdown() method to switch to reverse order.

This is a simple plotter that just generates a basic graphic. The design idea is to use this as a base class for more advanced graphics uses like a trace editor or generic picker. The plot object must be created before any plots can be generated. Any optional changes to the plot behavior, most commonly calls to the change_style method, should be done before calling plot.

bottomup()[source]

Restore (or force) default ensemble plot order of bottup upward.

change_style(newstyle, fill_color='k', color_map='seismic')[source]

Use this method to change the plot style. Options are described below. Some parameter combinations are illegal and will result in a RuntimeError if used. The illegal combos are listed below for each style.

Parameters:

newstyle

This is the primary switch for this method and is used to define the style of plot that will be produced. The allowed values for this string are listed below along with restrictions (when they exist) on related parameters.

wtva - wiggle trace variable area. That means a wiggle traced with

the positive quadrants colored by the color defined by the fill_color parameter. If fill_color is passed as None a RuntimeError will be thrown.

img - data are displayed as an image with the color_map parameter

defining the matplotlib color map used to map amplitudes into a given color. Note as with wtva the data are presumed to be scaled to be of order 1. color_map must not be None, which it can be if the plot was changed from a previous style like wtva, or a RuntimeError exception will be thrown.

wtvaimg is like wtva but the wtva plot is drawn on top of an

image plot. Since this is the union of wtva and img a RuntimeError exception will be throw if either color_map or fill_color are null.

wt will produce a standard line graph of each input as a

black line (that feature is currently frozen). color_map and fill_color are ignored for this style so no exceptions should occur when the method is called with this value of newstyle.

plot(d)[source]
set_topdown()[source]

Call this method to have datat plotted from top down. Default plots ensemble member 0 at the bottom of the plot with successive members plotted in units of 1.0 above the last. When this is called the order is reversed.

topdown()[source]

Switch to mode of plotting ensembles from the top downward from default of bottum upward.

mspasspy.graphics.image_raw(section, t0, dt, ranges=None, cmap=<matplotlib.colors.LinearSegmentedColormap object>, aspect=None, vmin=None, vmax=None)[source]

Plot a numpy 2D array (matrix) in an image format. This type of plot has two uses: (1) large numbers of spatially coherent signals (as in a conventional seismic reflection) are more clearly displayed this way than as wiggles, and (2) this function can be called immediately following a call to wtva_raw to produce an section with variable area wiggle trace data shown on top of the an image representation of the data data (note for dense data it is usually necessary to decimate the data on the column axis to make a clean plot - functions to make such plots need a decimate parameter). This is the low level function to make such plots. It is directly comparable to wtva_raw.

This function was taken directly from the fatiando a terra 0.5 package. The current web site is https://www.fatiando.org/ and apparently the code we use here has been depricated by that group. This function is unaltered from the original found on github for the 0.5 version. Only the documentation was changed to clarify this ancestory. We also changed the name from seismic_image to image_raw to mesh more cleanly with mspass as the name better reflects the functions use.

Parameters:

  • section2D array

    matrix of traces (first dimension time, second dimension traces)

  • t0float

    time of first sample (added for mspass - needed for passive data)

  • dtfloat

    sample rate in seconds

  • ranges(x1, x2)

    min and max horizontal coordinate values (default trace number)

  • cmapcolormap

    color map to be used. (see pyplot.cm module)

  • aspectfloat

    matplotlib imshow aspect parameter, ratio between axes

  • vmin, vmaxfloat

    min and max values for imshow

mspasspy.graphics.imageplot(d, ranges=None, cmap=<matplotlib.colors.LinearSegmentedColormap object>, aspect=None, vmin=None, vmax=None, title=None)[source]

Image plotter for mspass ensemble objects.

mspasspy.graphics.seis2nparray(d)[source]
mspasspy.graphics.ts2nparray(d)[source]
mspasspy.graphics.tse2nparray(ens)[source]
mspasspy.graphics.wtva_raw(section, t0, dt, ranges=None, scale=1.0, color='k', normalize=False)[source]

Plot a numpy 2D array (matrix) in a wiggle trace, variable area format as used in paper seismic section displays. This is the low level function that displays a ensemble of scalar data cast into a matrix with the rows as time and the columns as just trace number. This function is called by the ensemble plotters. For scalar data it is called one but for 3C data 3 windows are created with this function called 3 times.

This function was taken directly from the fatiando a terra 0.5 package. The current web site is https://www.fatiando.org/ and apparently the code we use here has been depricated by that group. This function is unaltered from the original found on github for the 0.5 version. Only the documentation was changed to clarify this ancestory. We also changed the name from seismic_wiggle to wtva_raw to mesh more cleanly with mspass as the name better reflects the functions use.

Additional changes:

Pavlis Aug 27, 2020

Added a test that if color was a None only the wiggles will be drawn (i.e. no shading)

Parameters:

  • section2D array

    matrix of traces (first dimension time, second dimension traces)

  • t0float

    time of first sample (added for mspass - needed for passive data)

  • dtfloat

    sample rate in seconds

  • ranges(x1, x2)

    min and max horizontal values (default trace number)

  • scalefloat

    scale factor multiplied by the section values before plotting

  • colortuple of strings

    Color for filling the wiggle, positive and negative lobes. If None draw only wiggle traces

  • normalize :

    True to normalizes all trace in the section using global max/min data will be in the range (-0.5, 0.5) zero centered

Warning

Slow for more than 200 traces, in this case decimate your data or use image_raw.

mspasspy.graphics.wtvaplot(d, ranges=None, scale=1.0, fill_color='k', normalize=False, cmap=None, title=None)[source]

Wiggle trace variable area plotter for mspass ensemble objects.