Hvsr

Class definition for Hvsr object.

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

Bases: object

Class for creating and manipulating HVSR objects.

Variables
  • amp (ndarray) – Array of HVSR amplitudes. Each row represents an individual curve/time window and each column a frequency.

  • frq (ndarray) – Vector of frequencies corresponds to each column.

  • nseries (int) – Number of windows in Hvsr object.

  • valid_window_indices (ndarray) – Boolean array indicating valid windows.

__init__(amplitude, frequency, find_peaks=True, f_low=None, f_high=None, meta=None)

Create Hvsr from iterable of amplitude and frequency.

Parameters
  • amplitude (ndarray) – Array of HVSR amplitudes. Each row represents an individual curve/time window 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.

  • f_low, f_high (float, optional) – Upper and lower frequency limits to restrict peak selection, default is None meaning search range will not be restricted.

  • meta (dict, optional) – Meta information about the object, default is None.

Returns

Hvsr – Initialized with amplitude and frequency.

static correct_distribution(distribution)
static find_peaks(amp, starting_index=0, **kwargs)

Indices of all peaks in amp.

Wrapper method for scipy.signal.find_peaks function.

Parameters
  • amp (ndarray) – 2D 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 a list of lists (one per window) of peak indices, and settings is a dict, refer to scipy.signal.find_peaks documentation for details.

mc_peak_amp(distribution='lognormal')

Amplitude of the peak of the mean HVSR curve.

Parameters

distribution ({‘normal’, ‘lognormal’}, optional) – Refer to mean_curve for details.

Returns

float – Amplitude associated with the peak of the mean HVSR curve.

mc_peak_frq(distribution='lognormal')

Frequency of the peak of the mean HVSR curve.

Parameters

distribution ({‘normal’, ‘lognormal’}, optional) – Refer to mean_curve for details.

Returns

float – Frequency associated with the peak of the mean HVSR curve.

mean_curve(distribution='lognormal')

Mean HVSR curve.

Parameters

distribution ({‘normal’, ‘lognormal’}, optional) – Assumed distribution of mean curve, default is ‘lognormal’.

Returns

ndarray – Mean HVSR curve according to the distribution specified.

Raises

NotImplementedError – If distribution does not match the available options.

mean_f0_amp(distribution='lognormal')

Mean amplitude of f0 of valid time windows.

Parameters

distribution ({‘normal’, ‘lognormal’}) – Assumed distribution of f0, default is ‘lognormal’.

Returns

float – Mean amplitude of f0 according to the distribution specified.

Raises

NotImplementedError – If distribution does not match the available options.

mean_f0_frq(distribution='lognormal')

Mean f0 of valid time windows.

Parameters

distribution ({‘normal’, ‘lognormal’}) – Assumed distribution of f0, default is ‘lognormal’.

Returns

float – Mean value of f0 according to the distribution specified.

Raises

NotImplementedError – If distribution does not match the available options.

nstd_curve(n, distribution='lognormal')

nth standard deviation curve.

Parameters
  • n (float) – Number of standard deviations away from the mean curve.

  • distribution ({‘lognormal’, ‘normal’}, optional) – Assumed distribution of mean curve, the default is ‘lognormal’.

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 ({‘lognormal’, ‘normal’}, optional) – Assumed distribution of f0, the default is ‘lognormal’.

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 for the valid time windows.

  • distribution ({‘lognormal’, ‘normal’}, optional) – Assumed distribution of f0, the default is ‘lognormal’.

Returns

float – Value n standard deviations from mean f0.

property peak_amp

Valid peak amplitude vector.

property 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='lognormal', distribution_mc='lognormal')

Perform rejection of spurious HVSR 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 ({‘lognormal’, ‘normal’}, optional) – Assumed distribution of f0 from time windows, the default is ‘lognormal’.

  • distribution_mc ({‘lognormal’, ‘normal’}, optional) – Assumed distribution of mean curve, the default is ‘lognormal’.

Returns

int – Number of iterations required for convergence.

property rejected_window_indices

Rejected window indices.

std_curve(distribution='lognormal')

Sample standard deviation of the mean HVSR curve.

Parameters

distribution ({‘normal’, ‘lognormal’}, optional) – Assumed distribution of HVSR curve, default is ‘lognormal’.

Returns

ndarray – Sample standard deviation of HVSR curve according to the distribution specified.

Raises
  • ValueError – If only single time window is defined.

  • NotImplementedError – If distribution does not match the available options.

std_f0_amp(distribution='lognormal')

Sample standard deviation of the amplitude of f0.

Parameters

distribution ({‘normal’, ‘lognormal’}, optional) – Assumed distribution of f0, default is ‘lognormal’.

Returns

float – Sample standard deviation of the amplitude of f0 considering only the valid time windows.

Raises

NotImplementedError – If distribution does not match the available options.

std_f0_frq(distribution='lognormal')

Sample standard deviation of f0 of valid time windows.

Parameters

distribution ({‘normal’, ‘lognormal’}, optional) – Assumed distribution of f0, default is ‘lognormal’.

Returns

float – Sample standard deviation of f0.

Raises

NotImplementedError – If distribution does not match the available options.

to_file(fname, distribution_f0, distribution_mc, data_format='hvsrpy')

Save HVSR data to summary file.

Parameters
  • fname (str) – Name of file to save the results, may be a full or relative path.

  • distribution_f0 ({‘lognormal’, ‘normal’}, optional) – Assumed distribution of f0 from the time windows, the default is ‘lognormal’.

  • distribution_mc ({‘lognormal’, ‘normal’}, optional) – Assumed distribution of mean curve, the default is ‘lognormal’.

  • data_format ({‘hvsrpy’, ‘geopsy’}, optional) – Format of output data file, default is ‘hvsrpy’.

Returns

None – Writes file to disk.

update_peaks(**kwargs)

Update with the lowest frequency, highest amplitude peaks.

Parameters

**kwargs (dict) – Refer to find_peaks documentation.

Returns

None – Updates peaks attribute.