xdas.atoms.IIRFilter#
- class xdas.atoms.IIRFilter(order, cutoff, btype='bandpass', ftype='butter', stype='sos', rp=None, rs=None, dim='last')[source]#
Pipeline implementation of an IIR filter.
- Parameters:
order (int) – The order (number of corners) of the IIR filter
cutoff (float or tuple) – The frequency cut-off of the filter. In the case of a low/high-pass filter,
cutoffis a single number. In the case of a bandpass filter,cutoffis a tuple of two number (the upper and lower cut-off frequency, resp.).btype (str) –
- The type of the filter band. Valid options are:
lowpass: removing frequencies abovecutoffhighpass: removing frequencies belowcutoffbandpass(default): removing frequencies belowcutoff[0]and abovecutoff[1]
ftype (str) – The IIR filter type. Default:
butterstype (str) – Form of the output of the filter design. Default:
sosrp – ???. Default:
Noners – ???. Default:
Nonedim (str or int) – The dimension along which the downsampling is applied. This is either an index,
timeordistance, orlast. Default:last
Examples
>>> from xdas.synthetics import wavelet_wavefronts >>> from xdas.atoms import Sequential, IIRFilter >>> da = wavelet_wavefronts()
Using
IIRFilterdirectly:>>> # Highpass > 1.5 Hz >>> da2 = IIRFilter(order=4, cutoff=1.5, btype="highpass", dim="time")(da) >>> da2 <xdas.DataArray (time: 300, distance: 401)> [[ 0.038812 -0.049615 0.061412 ... -0.114737 0.105669 -0.221302] [-0.104748 0.121279 -0.088378 ... 0.171324 -0.086691 0.216594] [ 0.082237 -0.120316 0.004964 ... -0.111284 -0.136088 0.185075] ... [ 0.178379 0.011591 -0.31838 ... -0.228471 -0.314301 0.436016] [-0.194726 -0.004863 0.116678 ... -0.156696 0.397589 -0.130106] [ 0.140117 0.197221 -0.268858 ... 0.322317 -0.414973 -0.055147]] Coordinates: * time (time): 2023-01-01T00:00:00.000 to 2023-01-01T00:00:05.980 * distance (distance): 0.000 to 10000.000
Using
IIRFilteras an atom inSequential:>>> # Bandpass between 1 and 10 Hz >>> sequence = Sequential([ ... IIRFilter(order=6, cutoff=(1.0, 10.0), btype="bandpass", dim="time") ... ]) >>> result = sequence(da) >>> result <xdas.DataArray (time: 300, distance: 401)> [[ 0.00031 -0.000396 0.00049 ... -0.000916 0.000844 -0.001767] [ 0.001484 -0.001998 0.002966 ... -0.005491 0.005625 -0.011501] [ 0.001948 -0.003366 0.006708 ... -0.012976 0.014296 -0.028643] ... [ 0.016432 -0.012658 -0.089414 ... -0.021061 0.168231 -0.118295] [ 0.004816 -0.044008 0.035511 ... -0.040328 0.144616 -0.064695] [-0.014048 -0.079786 0.180202 ... 0.013841 -0.048853 0.062074]] Coordinates: * time (time): 2023-01-01T00:00:00.000 to 2023-01-01T00:00:05.980 * distance (distance): 0.000 to 10000.000
- __init__(order, cutoff, btype='bandpass', ftype='butter', stype='sos', rp=None, rs=None, dim='last')[source]#
Methods
__init__(order, cutoff[, btype, ftype, ...])call(da, **flags)initialize(da, **flags)Determine the sampling rate from da and recompute the IIR coefficients.
initialize_from_state()Recompute and store the IIR coefficients from the current design parameters.
load_state(path)Load the atom state from the NetCDF4 file at path.
reset()Reset all state entries to
...(uninitialised sentinel).save_state(path)Serialise the current state to a NetCDF4 file at path.
set_state(state)Restore the atom state from a previously saved state dict.
Attributes
initializedTrueif every state key has been initialised (no...sentinels remain).stateDict of the current state, including nested atom states.