peaks

Peaks class definition.

class Peaks(frequency, velocity, identifier='0', **kwargs)

Bases: object

Class for handling dispersion peaks.

Variables:
  • frequency (ndarray) – Frequency associate with each peak.

  • velocity (ndarray) – Velocity associate with each peak.

  • identifier (str) – Used to uniquely identify the Peaks object.

  • attrs (list) – List of strings describing Peak attributes.

__init__(frequency, velocity, identifier='0', **kwargs)

Create Peaks from a iterable of frequencies and velocities.

Parameters:
  • frequency, velocity (iterable of floats) – Frequency and velocity (one per peak), respectively.

  • identifier (str, optional) – String to uniquely identify the provided Peaks, default is “0”.

  • **kwargs (kwargs) – Optional keyword argument(s) these may include additional information about the dispersion peaks such as: azimuth, ellipticity, power, and noise. Will generally not be entered directly.

Returns:

Peaks – Instantiated Peaks object.

axes_defaults = {'azimuth': {'label': 'Azimuth (deg)', 'scale': 'linear'}, 'frequency': {'label': 'Frequency (Hz)', 'scale': 'log'}, 'slowness': {'label': 'Slowness (s/m)', 'scale': 'log'}, 'velocity': {'label': 'Velocity (m/s)', 'scale': 'linear'}, 'wavelength': {'label': 'Wavelength (m)', 'scale': 'log'}}
property azimuth
property ellipticity
property extended_attrs

List of available Peaks attributes, including calculated.

property frequency
classmethod from_dict(data_dict, identifier='0')

Initialize Peaks from dict.

Parameters:
  • data_dict (dict) – Of the form {“frequency”:freq, “velocity”:vel, “kwarg1”: kwarg1} where freq is a list of floats denoting frequency values. vel is a list of floats denoting velocity values. kwarg1 is an optional keyword argument denoting some additional parameter (may include more than one).

  • identifiers (str) – String to uniquely identify the provided Peaks object.

Returns:

Peaks – Initialized Peaks instance.

classmethod from_json(fname)

Read Peaks from json file.

Parameters:

fnames (str) – Name of the input file, may contain a relative or the full path.

Returns:

Peaks – Initialized Peaks object.

classmethod from_max(fname, wavetype='rayleigh')

Initialize a Peaks object from a .max file.

Parameters:
  • fname (str) – Denotes the filename for the .max file, may include a relative or the full path.

  • wavetype ({‘rayleigh’, ‘love’}, optional) – Wavetype to extract from file, default is ‘rayleigh’.

Returns:

Peaks – Initialized Peaks object.

Notes

If the results from multiple time windows are in the same .max file, as is most often the case, this method ignores all but the first instance found.

property noise
plot(xtype='frequency', ytype='velocity', plot_kwargs=None, mask=None)

Plot dispersion data in Peaks object.

Parameters:
  • xtype ({‘frequency’, ‘wavelength’}, optional) – Denote whether the x-axis should be either frequency or wavelength, default is frequency.

  • ytype ({‘velocity’, ‘slowness’}, optional) – Denote whether the y-axis should be either velocity or slowness, default is velocity.

  • plot_kwargs (dict, optional) – Keyword arguments to pass along to ax.plot, default is None indicating the predefined settings should be used.

  • mask (ndarray, optional) – Boolean array mask to determine which points are to be plotted, default is None so all valid points will be plotted.

Returns:

tuple – Of the form (fig, ax) where fig and ax are the Figure and Axes objects which were generated on-the-fly.

property power
reject_box_inside(xtype, xlims, ytype, ylims)

Reject peaks inside the stated limits.

Parameters:
  • xtype, ytype ({“frequency”, “velocity”, “slowness”, “wavelength”}) – Parameter domain in which the limits are defined.

  • xlims, ylims (tuple) – Tuple with the lower and upper limits for each of the boundaries.

Returns:

None – Updates the Peaks object’s state.

reject_limits_outside(attr, limits)

Reject peaks outside the stated bounds.

Parameters:
  • attr ({“frequency”, “velocity”, “slowness”, “wavelength”}) – Parameter domain in which the limits are defined.

  • limits (tuple) – Tuple with the lower and upper limits. None may be used to perform one-sided rejections. For example limits=(None, 5) will reject all values above 5 and limits=(5, None) will reject all values below 5.

Returns:

None – Updates the Peaks object’s state.

Notes

This method is somewhat similar to swprocess.Peaks.reject_inside(), but is more computationally expensive.

simplify_mpeaks(attr)

Produce desired attribute with multiple peaks removed.

Parameters:

attr ({“frequency”, “velocity”, “azimuth”, “power”, “ellipticity”, “noise”}) – Attribute of interest.

Returns:

ndarray – With the attribute of interest simplified to remove duplicate peaks.

property slowness
to_json(fname, append=False)

Write Peaks to json file.

Parameters:
  • fname (str) – Output file name, can include a relative or the full path.

  • append (bool, optional) – Controls whether fname (if it exists) should be appended to or overwritten, default is False indicating fname will be overwritten.

Returns:

None – Instead writes file to disk.

property velocity
property wavelength
property wavenumber