Hvsr

Class definition for Hvsr object.

class Hvsr(amplitude, frequency, find_peaks=True, meta=None)

Bases: object

Class for creating and manipulating horizontal-to-vertical spectral ratio objects.

Variables:
  • amp (ndarray) – Array of H/V amplitudes. Each row represents an individual curve and each column a frequency.
  • frq (ndarray) – Vector of frequencies corresponds to each column.
  • n_windows (int) – Number of windows in Hvsr object.
  • valid_window_indices (ndarray) – Array of indices indicating valid windows.
__init__(amplitude, frequency, find_peaks=True, meta=None)

Initialize a Hvsr object from an amplitude and frequency vector.

Parameters:
  • amplitude (ndarray) – Array of H/V amplitudes. Each row represents an individual curve and each column a frequency.
  • frequency (ndarray) – Vector of frequencies, corresponding to each column.
  • find_peaks (bool, optional) – Indicates whether peaks of Hvsr will be found when created, default is True.
  • meta (dict, optional) – Meta information about the object, default is None.
Returns:

Hvsr – Initialized with amplitude and frequency.

static find_peaks(amp, **kwargs)

Indices of all peaks in amp.

Wrapper method for scipy.signal.find_peaks function.

Parameters:
  • amp (ndarray) – Vector or array of amplitudes. See amp attribute for details.
  • **kwargs (dict) – Refer to scipy.signal.find_peaks documentation.
Returns:

Tuple – Of the form (peaks, settings). Where peaks is an ndarray or list of ndarray (one per window) of peak indices, and settings is dict, refer to scipy.signal.find_peaks documentation for details.

mc_peak_amp(distribution='log-normal')

Amplitude of the peak of the mean H/V curve.

Parameters:distribution ({‘normal’, ‘log-normal’}, optional) – Refer to mean_curve for details.
Returns:float – Amplitude associated with the peak of the mean H/V curve.
mc_peak_frq(distribution='log-normal')

Frequency of the peak of the mean H/V curve.

Parameters:distribution ({‘normal’, ‘log-normal’}, optional) – Refer to mean_curve for details.
Returns:float – Frequency associated with the peak of the mean H/V curve.
mean_curve(distribution='log-normal')

Return mean H/V curve.

Parameters:distribution ({‘normal’, ‘log-normal’}, optional) – Assumed distribution of mean curve, default is ‘log-normal’.
Returns:ndarray – Mean H/V curve according to the distribution specified.
Raises:KeyError – If distribution does not match the available options.
mean_f0_amp(distribution='log-normal')

Mean amplitude of f0 of valid time windows.

Parameters:distribution ({‘normal’, ‘log-normal’}) – Assumed distribution of f0, default is ‘log-normal’.
Returns:float – Mean amplitude of f0 according to the distribution specified.
Raises:KeyError – If distribution does not match the available options.
mean_f0_frq(distribution='log-normal')

Mean f0 of valid time windows.

Parameters:distribution ({‘normal’, ‘log-normal’}) – Assumed distribution of f0, default is ‘log-normal’.
Returns:float – Mean value of f0 according to the distribution specified.
Raises:KeyError – If distribution does not match the available options.
nstd_curve(n, distribution='log-normal')

nth standard deviation curve.

Parameters:
  • n (float) – Number of standard deviations away from the mean curve.
  • distribution ({‘log-normal’, ‘normal’}, optional) – Assumed distribution of mean curve, the default is ‘log-normal’.
Returns:

ndarray – nth standard deviation curve.

nstd_f0_amp(n, distribution)

Value n standard deviations from mean f0 amplitude.

Parameters:
  • n (float) – Number of standard deviations away from the mean amplitude of f0 from valid time windows.
  • distribution ({‘log-normal’, ‘normal’}, optional) – Assumed distribution of f0, the default is ‘log-normal’.
Returns:

float – Value n standard deviations from mean f0 amplitude.

nstd_f0_frq(n, distribution)

Value n standard deviations from mean f0.

Parameters:
  • n (float) – Number of standard deviations away from the mean f0 from the valid time windows.
  • distribution ({‘log-normal’, ‘normal’}, optional) – Assumed distribution of f0, the default is ‘log-normal’.
Returns:

float – Value n standard deviations from mean f0.

peak_amp

Valid peak amplitude vector.

peak_frq

Valid peak frequency vector.

print_stats(distribution_f0, places=2)

Print basic statistics of Hvsr instance.

reject_windows(n=2, max_iterations=50, distribution_f0='log-normal', distribution_mc='log-normal')

Perform rejection of spurious H/V windows.

Parameters:
  • n (float, optional) – Number of standard deviations from the mean, default value is 2.
  • max_iterations (int, optional) – Maximum number of rejection iterations, default value is 50.
  • distribution_f0 ({‘log-normal’, ‘normal’}, optional) – Assumed distribution of f0 from time windows, the default is ‘log-normal’.
  • distribution_mc ({‘log-normal’, ‘normal’}, optional) – Assumed distribution of mean curve, the default is ‘log-normal’.
Returns:

int – Number of iterations required for convergence.

rejected_window_indices

Rejected window indices.

std_curve(distribution='log-normal')

Sample standard deviation associated with the mean H/V curve.

Parameters:

distribution ({‘normal’, ‘log-normal’}, optional) – Assumed distribution of H/V curve, default is ‘log-normal’.

Returns:

ndarray – Sample standard deviation of H/V curve according to the distribution specified.

Raises:
  • ValueError – If only single time window is defined.
  • KeyError – If distribution does not match the available options.
std_f0_amp(distribution='log-normal')

Sample standard deviation of amplitude of f0 of valid time windows.

Parameters:distribution ({‘normal’, ‘log-normal’}, optional) – Assumed distribution of f0, default is ‘log-normal’.
Returns:float – Sample standard deviation of the amplitude of f0.
Raises:KeyError – If distribution does not match the available options.
std_f0_frq(distribution='log-normal')

Sample standard deviation of f0 of valid time windows.

Parameters:distribution ({‘normal’, ‘log-normal’}, optional) – Assumed distribution of f0, default is ‘log-normal’.
Returns:float – Sample standard deviation of f0.
Raises:KeyError – If distribution does not match the available options.
to_file(fname, distribution_f0, distribution_mc, data_format='hvsrpy')

Save H/V data to summary file.

Parameters:
  • fname (str) – Name of file to save the results, may be a full or relative path.
  • distribution_f0 ({‘log-normal’, ‘normal’}, optional) – Assumed distribution of f0 from the time windows, the default is ‘log-normal’.
  • distribution_mc ({‘log-normal’, ‘normal’}, optional) – Assumed distribution of mean curve, the default is ‘log-normal’.
  • data_format ({‘hvsrpy’, ‘geopsy’}, optional) – Format of output data file, default is ‘hvsrpy’.
Returns:

None – Writes file to disk.

update_peaks(**kwargs)

Update peaks attribute with the lowest frequency, highest amplitude peak.

Parameters:**kwargs (dict) – Refer to find_peaks documentation.
Returns:None – Updates peaks attribute.