saul.spectral.helpers
Contains helper functions and constants for tasks related to spectral estimation and filtering.
- saul.spectral.helpers.get_ak_infra_noise()[source]
Returns the Alaska ambient infrasound noise models from Macpherson et al. (2022).
Macpherson, K. A., Coffey, J. R., Witsil, A. J., Fee, D., Holtkamp, S., Dalton, S., McFarlin, H., & West, M. (2022). Ambient infrasound noise, station performance, and their relation to land cover across Alaska. Seismological Research Letters, 93(4), 2239–2258. https://doi.org/10.1785/0220210365
Usage example:
from saul import get_ak_infra_noise p, hnm, mnm, lnm = get_ak_infra_noise()
- Returns:
Period [s], high noise model [dB rel. 1 Pa2 Hz–1], median noise model [dB rel. 1 Pa2 Hz–1], low noise model [dB rel. 1 Pa2 Hz–1]
- Return type:
- saul.spectral.helpers.obspy_filter_response(filter_type, sampling_rate, freqs=4096, plot=False, **options)[source]
Calculate the frequency response of an ObsPy filter.
Based on ObsPy 1.4.1.
- Parameters:
filter_type (str) – Type of filter to use. Note that not all of ObsPy’s filter types are supported; see the match statement in the code
freqs (int or array_like) – Passed on as
worNargument toscipy.signal.freqz_zpk()— if an array, the response will be computed at these frequenciesplot (bool) – Whether to plot the frequency response
**options – Necessary keyword arguments that will be passed on to the respective filter function (e.g.,
freqmin=1,freqmax=5forfilter_type='bandpass')
- Returns:
Array of frequencies at which the response was computed [Hz], frequency response [dB]
- Return type:
- saul.spectral.helpers.extract_trace_filter_params(tr)[source]
Extract filter parameters from an ObsPy
Traceobject.Expects to find a filter operation in the string stored in
tr.stats.processing[-1]. Can be combined withobspy_filter_response()to conveniently plot the filter response of the previous filtering operation like so:tr.filter(...) _ = obspy_filter_response(plot=True, **extract_trace_filter_params(tr))
Warning
The uses sketchy string processing and
eval()to extract the filter parameters! It fails to extract*argsintr.filter(type, *args, **options)— onlytypeand**optionsare extracted.