peakssuite

PeaksSuite class definition.

class PeaksSuite(peaks)

Bases: object

__init__(peaks)

Instantiate a PeaksSuite object from a Peaks object.

Parameters:

peaks (Peaks) – A Peaks object to include in the suite.

Returns:

PeaksSuite – Instantiated PeaksSuite object.

append(peaks)

Append a Peaks object to PeaksSuite.

Parameters:

peaks (Peaks) – A Peaks object to include in the suite.

Returns:

None – Appends Peaks to PeaksSuite.

static calc_resolution_limits(xtype, attribute, ytype, limits, xs, ys)

Calculate resolution limits for a variety of domains.

classmethod from_dict(dicts)

Instantiate PeaksSuite from list of dict.

Parameters:

dicts (list of dict or dict) – List of dict or a single dict containing dispersion data.

Returns:

PeaksSuite – Instantiated PeaksSuite object.

classmethod from_json(fnames)

Instantiate PeaksSuite from json file(s).

Parameters:

fnames (list of str or str) – File name or list of file names containing dispersion data. Names may contain a relative or the full path.

Returns:

PeaksSuite – Instantiated PeaksSuite object.

classmethod from_max(fnames, wavetype='rayleigh')

Instantiate PeaksSuite from .max file(s).

Parameters:
  • fnames (list of str or str) – File name or list of file names containing dispersion data. Names may contain a relative or the full path.

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

Returns:

Peaks – Initialized PeaksSuite object.

classmethod from_peaks(peaks)

Instantiate PeaksSuite from iterable of Peaks.

Parameters:

peaks (iterable) – Iterable containing Peaks objects.

Returns:

PeaksSuite – Instantiated PeaksSuite object.

classmethod from_peakssuite(peakssuites)

Instantiate PeaksSuite from iterable of PeaksSuite.

Parameters:

peakssuites (iterable) – Iterable containing PeaksSuite objects.

Returns:

PeaksSuite – Instantiated PeaksSuite object.

interactive_trimming(xtype='wavelength', ytype='velocity', plot_kwargs=None, resolution_limits=None, resolution_limits_plot_kwargs=None, margins=0.1)

Interactively trim experimental dispersion data.

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 can be in the form plot_kwargs = {“key”:value_allpeaks} or plot_kwargs = {“key”:[value_peaks0, value_peaks1, … ]}, default is None indicating the predefined settings should be used.

  • resolution_limits (iterable, optional) – Of form (“domain”, (min, max)) where “domain” is a str denoting the domain of the limits and min and max are floats denoting their value, default is None so no resolution limits are plotted for reference.

  • resolution_limits_plot_kwargs (dict, optional) – Formatting of resolution limits passed to ax.plot, default is None so default settings will be used.

Returns:

None – Updates the PeaksSuite state.

plot(xtype='frequency', ytype='velocity', ax=None, 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.

  • ax (Axes, optional) – Axes object on which to plot the disperison peaks, default is None so Axes will be generated on-the-fly.

  • plot_kwargs (dict, optional) – Keyword arguments to pass along to ax.plot can be in the form plot_kwargs = {“key”:value_allpeaks} or plot_kwargs = {“key”:[value_peaks0, value_peaks1, … ]}, default is None indicating the predefined settings should be used.

  • mask (list of ndarray, optional) – Boolean array mask for each Peaks object in the PeaksSuite to control which points will be plotted, default is None so no mask is applied.

Returns:

None or tupleNone if ax is provided, otherwise tuple of the form (fig, ax) where fig is the figure handle and ax is the axes handle.

static plot_resolution_limits(ax, xtype, ytype, attribute, limits, plot_kwargs=None)

Plot resolution limits on provided Axes.

Parameters:
  • ax (Axes) – Axes on which resolution limit is to be plotted.

  • xtype ({“frequency”, “wavelength”}) – Attribute on x-axis.

  • ytype ({“velocity”, “slowness”, “wavenumber”}) – Attribute on y-axis.

  • limits (tuple) – Of the form (lower limit, upper limit).

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

Returns:

None – Updates Axes with resolution limit (if possible).

static plot_statistics(ax, xx, mean, stddev, errorbar_kwargs=None)
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 PeaksSuite internal state.

reject_limits_outside(attribute, limits)

Reject peaks outside the stated limits.

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 PeaksSuite internal state.

statistics(xtype, ytype, xx, ignore_corr=True, drop_sample_if_fewer_count=3, mean_substitution=False)

Determine the statistics of the PeaksSuite.

Parameters:
  • xtype ({“frequency”,”wavelength”}) – Axis along which to calculate statistics.

  • ytype ({“velocity”, “slowness”}) – Axis along which to define uncertainty.

  • xx (iterable) – Values in xtype units where statistics are to be calculated.

  • ignore_corr (bool, optional) – Ignore calculation of data’s correlation coefficients, default is True.

  • drop_sample_if_fewer_count (int, optional) – Remove statistic sample if the number of valid entries is fewer than the specified number, default is 3.

Returns:

tuple – Of the form (xx, mean, std, corr) where mean and std are the mean and standard deviation at each point and corr are the correlation coefficients between every point and all other points.

to_array(xtype, ytype, xx)

Create an array representation of the PeaksSuite.

Parameters:
  • xtype ({“frequency”,”wavelength”}) – Axis along which to define samples.

  • ytype ({“velocity”, “slowness”}) – Axis along which to define values.

  • xx (iterable) – Values, in the units of xtype, where PeaksSuite is to be discretized.

Returns:

tuple – Of the form (xx, array) where xx is the discretized values and array is a two-dimensional array with one row per Peaks in the PeaksSuite and one column for each entry of xx. Missing values are denoted with np.nan.

to_json(fname)

Write PeaksSuite to json file.

Parameters:

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

Returns:

None – Write json to disk.