mt_metadata.timeseries.filters package
Subpackages
Submodules
mt_metadata.timeseries.filters.channel_response_filter module
mt_metadata.timeseries.filters.coefficient_filter module
- class mt_metadata.timeseries.filters.coefficient_filter.CoefficientFilter(**kwargs)[source]
Bases:
FilterBase
Metadata Key
Description
Example
name
Required: True
Units: None
Type: string
Style: name
Default: None
Name of filter applied or to be applied. If more than one filter input as a comma separated list.
“lowpass_magnet ic”
comments
Required: False
Units: None
Type: string
Style: free form
Default: None
Any comments about the filter.
ambient air temperature
type
Required: True
Units: None
Type: string
Style: controlled vocabulary
Default: None
Type of filter, must be one of the available filters.
fap_table
units_in
Required: True
Units: None
Type: string
Style: alpha numeric
Default: None
Name of the input units to the filter. Should be all lowercase and separated with an underscore, use ‘per’ if units are divided and ‘-’ if units are multiplied.
count
units_out
Required: True
Units: None
Type: string
Style: alpha numeric
Default: None
Name of the output units. Should be all lowercase and separated with an underscore, use ‘per’ if units are divided and ‘-’ if units are multiplied.
millivolt
calibration_date
Required: False
Units: None
Type: string
Style: date
Default: 1980-01-01T00:00:00+00:00
Most recent date of filter calibration in ISO format of YYY-MM-DD.
2020-01-01
gain
Required: True
Units: None
Type: float
Style: number
Default: 1.0
Scale factor for a simple coefficient filter.
100
- complex_response(frequencies, **kwargs)[source]
- Parameters:
frequencies (numpy array of frequencies, expected in Hz) –
- Returns:
h
- Return type:
numpy array of (possibly complex-valued) frequency response at the input frequencies
- to_obspy(stage_number=1, cf_type='DIGITAL', sample_rate=1, normalization_frequency=0)[source]
stage_sequence_number, stage_gain, stage_gain_frequency, input_units, output_units, cf_transfer_function_type, resource_id=None, resource_id2=None, name=None, numerator=None, denominator=None, input_units_description=None, output_units_description=None, description=None, decimation_input_sample_rate=None, decimation_factor=None, decimation_offset=None, decimation_delay=None, decimation_correction=None
- Parameters:
stage_number (TYPE, optional) – DESCRIPTION, defaults to 1
cf_type (TYPE, optional) – DESCRIPTION, defaults to “DIGITAL”
sample_rate (TYPE, optional) – DESCRIPTION, defaults to 1
- Returns:
DESCRIPTION
- Return type:
TYPE
mt_metadata.timeseries.filters.filter_base module
Created on Wed Dec 23 21:30:36 2020
- copyright:
Jared Peacock (jpeacock@usgs.gov) Karl Kappler
- license:
MIT
This is a base class for filters associated with calibration and instrument and acquistion system responses. We will extend this class for each specific type of filter we need to implement. Typical filters we will want to support:
PoleZero (or ‘zpk’) responses like those provided by IRIS
Frequency-Amplitude-Phase (FAP) tables: look up tables from laboratory calibrations via frequency sweep on a spectrum analyser.
Time Delay Filters: can come about in decimation, or from general timing errors that have been characterized
Coefficient multipliers, i.e. frequency independent gains
FIR filters
IIR filters
Many filters can be represented in more than one of these forms. For example a Coefficient Multiplier can be seen as an FIR with a single coefficient. Similarly, an FIR can be represented as a ‘zpk’ filter with no poles. An IIR filter can also be associated with a zpk representation. However, solving for the ‘zpk’ representation can be tedious and approximate and if we have for example, the known FIR coefficients, or FAP lookup table, then there is little to be gained by changing the representation.
The ‘stages’ that are described in the IRIS StationXML documentation appear to cover all possible linear time invariant filter types we are likely to encounter.
A FilterBase object has a direction, defined by has units_in and units_out attrs. These are the units before and after multiplication by the complex_response of the filter in frequency domain. It is very similar to an “obspy filter stage”
- class mt_metadata.timeseries.filters.filter_base.FilterBase(**kwargs)[source]
Bases:
Base
Metadata Key
Description
Example
name
Required: True
Units: None
Type: string
Style: name
Default: None
Name of filter applied or to be applied. If more than one filter input as a comma separated list.
“lowpass_magnet ic”
comments
Required: False
Units: None
Type: string
Style: free form
Default: None
Any comments about the filter.
ambient air temperature
type
Required: True
Units: None
Type: string
Style: controlled vocabulary
Default: None
Type of filter, must be one of the available filters.
fap_table
units_in
Required: True
Units: None
Type: string
Style: alpha numeric
Default: None
Name of the input units to the filter. Should be all lowercase and separated with an underscore, use ‘per’ if units are divided and ‘-’ if units are multiplied.
count
units_out
Required: True
Units: None
Type: string
Style: alpha numeric
Default: None
Name of the output units. Should be all lowercase and separated with an underscore, use ‘per’ if units are divided and ‘-’ if units are multiplied.
millivolt
calibration_date
Required: False
Units: None
Type: string
Style: date
Default: 1980-01-01T00:00:00+00:00
Most recent date of filter calibration in ISO format of YYY-MM-DD.
2020-01-01
gain
Required: True
Units: None
Type: float
Style: number
Default: 1.0
scalar gain of the filter across all frequencies, producted with any frequency depenendent terms
1.0
- property calibration_date
calibration date (YYYY-MM-DD) :rtype: string
- Type:
return
- property decimation_active
if decimation is prescribed :rtype: bool
- Type:
return
- classmethod from_obspy_stage(stage, mapping=None)[source]
Expected to return a multiply operation function
- Parameters:
cls (filter object) – a filter object
stage (
obspy.inventory.response.ResponseStage
) – Obspy stage filtermapping (dict, optional) – dictionary for mapping from an obspy stage, defaults to None
- Raises:
TypeError – If stage is not a
obspy.inventory.response.ResponseStage
- Returns:
the appropriate mt_metadata.timeseries.filter object
- Return type:
mt_metadata.timeseries.filter object
- get_filter_description()[source]
- Returns:
predetermined filter description based on the type of filter
- Return type:
string
- property name
name of the filter :rtype: str
- Type:
return
- property obspy_mapping
mapping to an obspy filter :rtype: dict
- Type:
return
- pass_band(frequencies, window_len=5, tol=0.5, **kwargs)[source]
Caveat: This should work for most Fluxgate and feedback coil magnetometers, and basically most filters having a “low” number of poles and zeros. This method is not 100% robust to filters with a notch in them.
Try to estimate pass band of the filter from the flattest spots in the amplitude.
The flattest spot is determined by calculating a sliding window with length window_len and estimating normalized std.
- ..note:: This only works for simple filters with
on flat pass band.
- Parameters:
window_len (integer) – length of sliding window in points
tol (float) – the ratio of the mean/std should be around 1 tol is the range around 1 to find the flat part of the curve.
- Returns:
pass band frequencies
- Return type:
np.ndarray
- plot_response(frequencies, x_units='period', unwrap=True, pb_tol=0.1, interpolation_method='slinear')[source]
- property total_gain
Total gain of the filter :rtype: float
- Type:
return
- property units_in
Input units of the filter :rtype: string
- Type:
return
- property units_out
Output units of the filter :rtype: string
- Type:
return
- mt_metadata.timeseries.filters.filter_base.get_base_obspy_mapping()[source]
Different filters have different mappings, but the attributes mapped here are common to all of them. Hence the name “base obspy mapping” Note: If we wanted to support inverse forms of these filters, and argument specifying filter direction could be added.
- Returns:
mapping to an obspy filter, mapping[‘obspy_label’] = ‘mt_metadata_label’
- Return type:
dict
mt_metadata.timeseries.filters.filtered module
Created on Wed Dec 23 21:30:36 2020
- copyright:
Jared Peacock (jpeacock@usgs.gov)
- license:
MIT
- class mt_metadata.timeseries.filters.filtered.Filtered(**kwargs)[source]
Bases:
Base
Metadata Key
Description
Example
name
Required: True
Units: None
Type: string
Style: name list
Default: []
Name of filter applied or to be applied. If more than one filter input as a comma separated list.
“[counts2mv, lo wpass_magnetic] “
applied
Required: True
Units: None
Type: boolean
Style: name list
Default: []
Boolean if filter has been applied or not. If more than one filter input as a comma separated list. Needs to be the same length as name or if only one entry is given it is assumed to apply to all filters listed.
“[True, False]”
comments
Required: False
Units: None
Type: string
Style: name
Default: None
Any comments on filters.
low pass is not calibrated
- property applied
- property name
mt_metadata.timeseries.filters.fir_filter module
- class mt_metadata.timeseries.filters.fir_filter.FIRFilter(**kwargs)[source]
Bases:
FilterBase
Note: Regarding the symmetery property the json standard indicates that we expect the values “NONE”, “ODD”, “EVEN”. These are obspy standards. StationXML gives options: “A”, “B”, “C”. A:NONE, B:ODD, C:EVEN
- property coefficient_gain
The gain at the reference frequency due only to the coefficients Sometimes this is different from the gain in the stationxml and a corrective scalar must be applied
- property coefficients
- complex_response(frequencies, **kwargs)[source]
- Parameters:
frequencies (numpy array of frequencies, expected in Hz) –
- Returns:
h
- Return type:
numpy array of (possibly complex-valued) frequency response at the input frequencies
- property corrective_scalar
- property n_coefficients
- property output_sampling_rate
- property symmetry_corrected_coefficients
- to_obspy(stage_number=1, normalization_frequency=1, sample_rate=1)[source]
create an obspy stage
- Returns:
DESCRIPTION
- Return type:
TYPE
- unscaled_complex_response(frequencies)[source]
need this to avoid RecursionError. The problem is that some FIRs need a scale factor to make their gains be the same as those reported in the stationXML. The pure coefficients themselves sometimes result in pass-band gains that differ from the gain in the XML. For example filter fs2d5 has a passband gain of 0.5 based on the coefficients alone, but the cited gain in the xml is almost 1.
I wanted to scale the coefficients so they equal the gain… but maybe we can add the gain in complex response :param frequencies: :return:
mt_metadata.timeseries.filters.frequency_response_table_filter module
- class mt_metadata.timeseries.filters.frequency_response_table_filter.FrequencyResponseTableFilter(**kwargs)[source]
Bases:
FilterBase
Phases should be in radians.
- property amplitudes
calibrated amplitudes :rtype: np.ndarray
- Type:
return
- complex_response(frequencies, interpolation_method='slinear')[source]
Computes complex response for given frequency range :param frequencies: array of frequencies to estimate the response :type frequencies: np.ndarray :return: complex response :rtype: np.ndarray
- property frequencies
calibration frequencies :rtype: np.ndarray
- Type:
return
- property max_frequency
maximum frequency :rtype: float
- Type:
return
- property min_frequency
minimum frequency :rtype: float
- Type:
return
- property phases
Should be in units of radians
- Returns:
calibrated phases
- Return type:
np.ndarray
- to_obspy(stage_number=1, normalization_frequency=1, sample_rate=1)[source]
Convert to an obspy stage
- Parameters:
stage_number (integer, optional) – sequential stage number, defaults to 1
normalization_frequency (float, optional) – Normalization frequency, defaults to 1
sample_rate (float, optional) – sample rate, defaults to 1
- Returns:
Obspy stage filter
- Return type:
obspy.core.inventory.ResponseListResponseStage
mt_metadata.timeseries.filters.helper_functions module
- mt_metadata.timeseries.filters.helper_functions.decimation_info_is_degenerate(obspy_stage)[source]
Check a few condtions that may apply to an obspy stage which if true imply that the decimation information can be stripped out as it bears no information about aany data transformation; Case 1: All these attrs are None decimation has no information: {‘decimation_input_sample_rate’, ‘decimation_factor’, ‘decimation_offset’, ‘decimation_delay’, ‘decimation_correction’} Case 2:
- mt_metadata.timeseries.filters.helper_functions.make_coefficient_filter(gain=1.0, name='generic coefficient filter', **kwargs)[source]
- Parameters:
gain (float) –
name (string) –
units_in (string) – A supported unit or “unknown” one of “digital counts”, “millivolts”, etc. A complete list of units can be found in mt_metadata/mt_metadata/util/units.py and is accessible as a table via: from mt_metadata.utils.units import UNITS_DF
- mt_metadata.timeseries.filters.helper_functions.make_frequency_response_table_filter(file_path, case='bf4')[source]
- Parameters:
filepath (pathlib.Path or string) –
case (string, placeholder for handling different fap table formats.) –
- Returns:
fap_filter
- Return type:
mt_metadata.timeseries.filters.obspy_stages module
Idea here is to add logic to interrogate stage filters received from StationXML
- mt_metadata.timeseries.filters.obspy_stages.check_if_coefficient_filter_is_delay_only(stage)[source]
stage: obspy_stage type in obspy.core.inventory.response This function may wind up being a method of the CoefficientFilter class, but leaving it separate for now. Conditions to check: 1. Gain is unity 2. Decimation Factor is 1 3. delay is non-zero 4. delay has not been corrected on the data-center side. If all four of these are true we assume this is a pathological CoefficienFilter and would actually be a TimeDelay() filter instance if one existed in StationXML.
- mt_metadata.timeseries.filters.obspy_stages.create_filter_from_stage(stage)[source]
This works on a single stage, we need a catalog of stage classes obspy.core.inventory.response.CoefficientsTypeResponseStage obspy.core.inventory.response.FIRResponseStage obspy.core.inventory.response.PolesZerosResponseStage
CoefficientsTypeResponseStage: cases include -numerator=[],denominator=[]
- Sometimes filter stages in obspy are used to kluge-represent filters of other types
# Encountered Cases This Far: # CoefficientTypeResponseStage Used to package a time-delay filter
- Parameters:
stage –
- mt_metadata.timeseries.filters.obspy_stages.create_frequency_response_table_filter_from_stage(stage)[source]
Notes: Issue here is that the stage has a list of response_list_elements, it does not actually have attrs frequencies, amplitudes, phases… will try assigning them on the fly here
- Parameters:
stage –
mt_metadata.timeseries.filters.plotting_helpers module
- mt_metadata.timeseries.filters.plotting_helpers.cast_angular_frequency_to_period_or_hertz(w, units)[source]
- mt_metadata.timeseries.filters.plotting_helpers.is_flat_amplitude(array)[source]
Check of an amplitude response is basically flat. If so, it is best to tune the y-axis lims to make numeric noise invisible
- Parameters:
array –
- mt_metadata.timeseries.filters.plotting_helpers.plot_response(frequencies, complex_response, poles=None, zeros=None, xlim=None, title=None, x_units='Period', unwrap=True, pass_band=None, label=None, normalization_frequency=None)[source]
This function was contributed by Ben Murphy at USGS 2021-03-17: there are some issues encountered when using this function to plot generic resposnes, looks like the x-axis gets out of order when using frequency as the axis …
Edited 2021-11-18 JP to be more instructive and general.
- Parameters:
w_obs –
resp_obs –
zpk_obs –
zpk_pred –
w_values –
xlim –
title –
mt_metadata.timeseries.filters.pole_zero_filter module
- class mt_metadata.timeseries.filters.pole_zero_filter.PoleZeroFilter(**kwargs)[source]
Bases:
FilterBase
- complex_response(frequencies, **kwargs)[source]
Computes complex response for given frequency range :param frequencies: array of frequencies to estimate the response :type frequencies: np.ndarray
- Returns:
complex response
- Return type:
np.ndarray
- property n_poles
number of poles :rtype: integer
- Type:
return
- property n_zeros
number of zeros :rtype: integer
- Type:
return
- normalization_frequency(estimate='mean', window_len=5, tol=0.0001)[source]
Try to estimate the normalization frequency in the pass band by finding the flattest spot in the amplitude.
The flattest spot is determined by calculating a sliding window with length window_len and estimating normalized std.
..note:: This only works for simple filters with on flat pass band.
- Parameters:
window_len (integer) – length of sliding window in points
tol (float) – the ratio of the mean/std should be around 1 tol is the range around 1 to find the flat part of the curve.
- Returns:
estimated normalization frequency Hz
- Return type:
float
- property poles
array of poles :rtype: np.ndarray
- Type:
return
- to_obspy(stage_number=1, pz_type='LAPLACE (RADIANS/SECOND)', normalization_frequency=1, sample_rate=1)[source]
Convert the filter to an obspy filter
- Parameters:
stage_number (integer, optional) – sequential stage number, defaults to 1
pz_type (string, optional) – Pole Zero type, defaults to “LAPLACE (RADIANS/SECOND)”
normalization_frequency (float, optional) – Normalization frequency, defaults to 1
sample_rate (float, optional) – sample rate, defaults to 1
- Returns:
Obspy stage filter
- Return type:
obspy.core.inventory.PolesZerosResponseStage
- property total_gain
total gain of the filter :rtype: float
- Type:
return
- zero_pole_gain_representation()[source]
- Returns:
scipy.signal.ZPG object
- Return type:
scipy.signal.ZerosPolesGain
- property zeros
array of zeros :rtype: np.ndarray
- Type:
return
mt_metadata.timeseries.filters.time_delay_filter module
- class mt_metadata.timeseries.filters.time_delay_filter.TimeDelayFilter(**kwargs)[source]
Bases:
FilterBase
- complex_response(frequencies, **kwargs)[source]
Computes complex response for given frequency range :param frequencies: array of frequencies to estimate the response :type frequencies: np.ndarray
- Returns:
complex response
- Return type:
np.ndarray
- to_obspy(stage_number=1, sample_rate=1, normalization_frequency=0)[source]
Convert to an obspy stage
- Parameters:
stage_number (integer, optional) – sequential stage number, defaults to 1
normalization_frequency (float, optional) – Normalization frequency, defaults to 1
sample_rate (float, optional) – sample rate, defaults to 1
- Returns:
Obspy stage filter
- Return type:
obspy.core.inventory.CoefficientsTypeResponseStage
Module contents
- class mt_metadata.timeseries.filters.ChannelResponse(**kwargs)[source]
Bases:
Base
This class holds a list of all the filters associated with a channel. The list should be ordered to match the order in which the filters are applied to the signal.
It has methods for combining the responses of all the filters into a total response that we will apply to a data segment.
- complex_response(frequencies=None, filters_list=None, include_decimation=False, include_delay=False, normalize=False, **kwargs)[source]
Computes the complex response of self. Allows the user to optionally supply a subset of filters
- Parameters:
frequencies (np.ndarray, optional) – frequencies to compute complex response, defaults to None
include_delay (bool, optional) – include delay in complex response, defaults to False
include_decimation (bool, optional) – Include decimation in response, defaults to True
normalize (bool, optional) – normalize the response to 1, defaults to False
- Returns:
complex response along give frequency array
- Return type:
np.ndarray
- compute_instrument_sensitivity(normalization_frequency=None, sig_figs=6)[source]
Compute the StationXML instrument sensitivity for the given normalization frequency
- Parameters:
normalization_frequency (TYPE) – DESCRIPTION
- Returns:
DESCRIPTION
- Return type:
TYPE
- property delay_filters
all the time delay filters as a list
- Type:
return
- property filters_list
filters list
- property frequencies
frequencies to estimate filters
- get_list_of_filters_to_remove(include_decimation=False, include_delay=False)[source]
- Parameters:
include_decimation – bool
include_delay – bool
- Returns:
# Experimental snippet if we want to allow filters with the opposite convention # into channel response – I don’t think we do. # if self.correction_operation == “multiply”: # inverse_filters = [x.inverse() for x in self.filters_list] # self.filters_list = inverse_filters
- property names
names of the filters
- property non_delay_filters
all the non-time_delay filters as a list
- Type:
return
- property normalization_frequency
get normalization frequency from ZPK or FAP filter
- property pass_band
estimate pass band for all filters in frequency
- plot_response(frequencies=None, x_units='period', unwrap=True, pb_tol=0.1, interpolation_method='slinear', include_delay=False, include_decimation=False)[source]
Plot the response
- Parameters:
frequencies (np.ndarray, optional) – frequencies to compute response, defaults to None
x_units (string, optional) – [ period | frequency ], defaults to “period”
unwrap (bool, optional) – Unwrap phase, defaults to True
pb_tol (float, optional) – pass band tolerance, defaults to 1e-1
interpolation_method (string, optional) – Interpolation method see scipy.signal.interpolate [ slinear | nearest | cubic | quadratic | ], defaults to “slinear”
include_delay (bool, optional) – include delays in response, defaults to False
include_decimation (bool, optional) – Include decimation in response, defaults to True
- to_obspy(sample_rate=1)[source]
Output
obspy.core.inventory.InstrumentSensitivity
object that can be used in a stationxml file.- Parameters:
normalization_frequency (TYPE) – DESCRIPTION
- Returns:
DESCRIPTION
- Return type:
TYPE
- property total_delay
the total delay of all filters
- Type:
return
- property units_in
the units of the channel
- Type:
return
- property units_out
the units of the channel
- Type:
return
- class mt_metadata.timeseries.filters.CoefficientFilter(**kwargs)[source]
Bases:
FilterBase
Metadata Key
Description
Example
name
Required: True
Units: None
Type: string
Style: name
Default: None
Name of filter applied or to be applied. If more than one filter input as a comma separated list.
“lowpass_magnet ic”
comments
Required: False
Units: None
Type: string
Style: free form
Default: None
Any comments about the filter.
ambient air temperature
type
Required: True
Units: None
Type: string
Style: controlled vocabulary
Default: None
Type of filter, must be one of the available filters.
fap_table
units_in
Required: True
Units: None
Type: string
Style: alpha numeric
Default: None
Name of the input units to the filter. Should be all lowercase and separated with an underscore, use ‘per’ if units are divided and ‘-’ if units are multiplied.
count
units_out
Required: True
Units: None
Type: string
Style: alpha numeric
Default: None
Name of the output units. Should be all lowercase and separated with an underscore, use ‘per’ if units are divided and ‘-’ if units are multiplied.
millivolt
calibration_date
Required: False
Units: None
Type: string
Style: date
Default: 1980-01-01T00:00:00+00:00
Most recent date of filter calibration in ISO format of YYY-MM-DD.
2020-01-01
gain
Required: True
Units: None
Type: float
Style: number
Default: 1.0
Scale factor for a simple coefficient filter.
100
- complex_response(frequencies, **kwargs)[source]
- Parameters:
frequencies (numpy array of frequencies, expected in Hz) –
- Returns:
h
- Return type:
numpy array of (possibly complex-valued) frequency response at the input frequencies
- to_obspy(stage_number=1, cf_type='DIGITAL', sample_rate=1, normalization_frequency=0)[source]
stage_sequence_number, stage_gain, stage_gain_frequency, input_units, output_units, cf_transfer_function_type, resource_id=None, resource_id2=None, name=None, numerator=None, denominator=None, input_units_description=None, output_units_description=None, description=None, decimation_input_sample_rate=None, decimation_factor=None, decimation_offset=None, decimation_delay=None, decimation_correction=None
- Parameters:
stage_number (TYPE, optional) – DESCRIPTION, defaults to 1
cf_type (TYPE, optional) – DESCRIPTION, defaults to “DIGITAL”
sample_rate (TYPE, optional) – DESCRIPTION, defaults to 1
- Returns:
DESCRIPTION
- Return type:
TYPE
- class mt_metadata.timeseries.filters.FIRFilter(**kwargs)[source]
Bases:
FilterBase
Note: Regarding the symmetery property the json standard indicates that we expect the values “NONE”, “ODD”, “EVEN”. These are obspy standards. StationXML gives options: “A”, “B”, “C”. A:NONE, B:ODD, C:EVEN
- property coefficient_gain
The gain at the reference frequency due only to the coefficients Sometimes this is different from the gain in the stationxml and a corrective scalar must be applied
- property coefficients
- complex_response(frequencies, **kwargs)[source]
- Parameters:
frequencies (numpy array of frequencies, expected in Hz) –
- Returns:
h
- Return type:
numpy array of (possibly complex-valued) frequency response at the input frequencies
- property corrective_scalar
- property n_coefficients
- property output_sampling_rate
- property symmetry_corrected_coefficients
- to_obspy(stage_number=1, normalization_frequency=1, sample_rate=1)[source]
create an obspy stage
- Returns:
DESCRIPTION
- Return type:
TYPE
- unscaled_complex_response(frequencies)[source]
need this to avoid RecursionError. The problem is that some FIRs need a scale factor to make their gains be the same as those reported in the stationXML. The pure coefficients themselves sometimes result in pass-band gains that differ from the gain in the XML. For example filter fs2d5 has a passband gain of 0.5 based on the coefficients alone, but the cited gain in the xml is almost 1.
I wanted to scale the coefficients so they equal the gain… but maybe we can add the gain in complex response :param frequencies: :return:
- class mt_metadata.timeseries.filters.FrequencyResponseTableFilter(**kwargs)[source]
Bases:
FilterBase
Phases should be in radians.
- property amplitudes
calibrated amplitudes :rtype: np.ndarray
- Type:
return
- complex_response(frequencies, interpolation_method='slinear')[source]
Computes complex response for given frequency range :param frequencies: array of frequencies to estimate the response :type frequencies: np.ndarray :return: complex response :rtype: np.ndarray
- property frequencies
calibration frequencies :rtype: np.ndarray
- Type:
return
- property max_frequency
maximum frequency :rtype: float
- Type:
return
- property min_frequency
minimum frequency :rtype: float
- Type:
return
- property phases
Should be in units of radians
- Returns:
calibrated phases
- Return type:
np.ndarray
- to_obspy(stage_number=1, normalization_frequency=1, sample_rate=1)[source]
Convert to an obspy stage
- Parameters:
stage_number (integer, optional) – sequential stage number, defaults to 1
normalization_frequency (float, optional) – Normalization frequency, defaults to 1
sample_rate (float, optional) – sample rate, defaults to 1
- Returns:
Obspy stage filter
- Return type:
obspy.core.inventory.ResponseListResponseStage
- class mt_metadata.timeseries.filters.PoleZeroFilter(**kwargs)[source]
Bases:
FilterBase
- complex_response(frequencies, **kwargs)[source]
Computes complex response for given frequency range :param frequencies: array of frequencies to estimate the response :type frequencies: np.ndarray
- Returns:
complex response
- Return type:
np.ndarray
- property n_poles
number of poles :rtype: integer
- Type:
return
- property n_zeros
number of zeros :rtype: integer
- Type:
return
- normalization_frequency(estimate='mean', window_len=5, tol=0.0001)[source]
Try to estimate the normalization frequency in the pass band by finding the flattest spot in the amplitude.
The flattest spot is determined by calculating a sliding window with length window_len and estimating normalized std.
..note:: This only works for simple filters with on flat pass band.
- Parameters:
window_len (integer) – length of sliding window in points
tol (float) – the ratio of the mean/std should be around 1 tol is the range around 1 to find the flat part of the curve.
- Returns:
estimated normalization frequency Hz
- Return type:
float
- property poles
array of poles :rtype: np.ndarray
- Type:
return
- to_obspy(stage_number=1, pz_type='LAPLACE (RADIANS/SECOND)', normalization_frequency=1, sample_rate=1)[source]
Convert the filter to an obspy filter
- Parameters:
stage_number (integer, optional) – sequential stage number, defaults to 1
pz_type (string, optional) – Pole Zero type, defaults to “LAPLACE (RADIANS/SECOND)”
normalization_frequency (float, optional) – Normalization frequency, defaults to 1
sample_rate (float, optional) – sample rate, defaults to 1
- Returns:
Obspy stage filter
- Return type:
obspy.core.inventory.PolesZerosResponseStage
- property total_gain
total gain of the filter :rtype: float
- Type:
return
- zero_pole_gain_representation()[source]
- Returns:
scipy.signal.ZPG object
- Return type:
scipy.signal.ZerosPolesGain
- property zeros
array of zeros :rtype: np.ndarray
- Type:
return
- class mt_metadata.timeseries.filters.TimeDelayFilter(**kwargs)[source]
Bases:
FilterBase
- complex_response(frequencies, **kwargs)[source]
Computes complex response for given frequency range :param frequencies: array of frequencies to estimate the response :type frequencies: np.ndarray
- Returns:
complex response
- Return type:
np.ndarray
- to_obspy(stage_number=1, sample_rate=1, normalization_frequency=0)[source]
Convert to an obspy stage
- Parameters:
stage_number (integer, optional) – sequential stage number, defaults to 1
normalization_frequency (float, optional) – Normalization frequency, defaults to 1
sample_rate (float, optional) – sample rate, defaults to 1
- Returns:
Obspy stage filter
- Return type:
obspy.core.inventory.CoefficientsTypeResponseStage