netpyne.analysis.filter module
Module for filtering data
Signal filtering functions copied to NetPyNE from ObsPy by Sam Neymotin (NKI)
- Originally:
- Filename: filter.py
- Purpose: Various Seismogram Filtering Functions
- Author: Tobias Megies, Moritz Beyreuther, Yannik Behr
Various Seismogram Filtering Functions
copyright: The ObsPy Development Team (devs@obspy.org) license: GNU Lesser General Public License, Version 3 (https://www.gnu.org/copyleft/lesser.html)
- netpyne.analysis.filter.bandpass(data, freqmin, freqmax, df, corners=4, zerophase=True)[source]
Butterworth-Bandpass Filter.
Filter data from
freqmin
tofreqmax
usingcorners
corners. The filter usesscipy.signal.iirfilter()
(for design) andscipy.signal.sosfilt()
(for applying the filter).- Parameters:
data (array) – Data to filter.
freqmin (float) – Pass band low corner frequency.
freqmax (float) – Pass band high corner frequency.
df (float) – Sampling rate in Hz.
corners (int) – Filter corners / order. Default:
4
zerophase (bool) – If True, apply filter once forwards and once backwards. This results in twice the filter order but zero phase shift in the resulting filtered trace. Default:
True
- Returns:
data – Filtered data.
- Return type:
array
- netpyne.analysis.filter.bandstop(data, freqmin, freqmax, df, corners=4, zerophase=False)[source]
Butterworth-Bandstop Filter.
Filter data removing data between frequencies
freqmin
andfreqmax
usingcorners
corners. The filter usesscipy.signal.iirfilter()
(for design) andscipy.signal.sosfilt()
(for applying the filter).- Parameters:
data (array) – Data to filter.
freqmin (float) – Stop band low corner frequency.
freqmax (float) – Stop band high corner frequency.
df (float) – Sampling rate in Hz.
corners (int) – Filter corners / order. Default:
4
zerophase (bool) – If True, apply filter once forwards and once backwards. This results in twice the filter order but zero phase shift in the resulting filtered trace. Default:
False
- Returns:
data – Filtered data.
- Return type:
array
- netpyne.analysis.filter.lowpass(data, freq, df, corners=4, zerophase=False)[source]
Butterworth-Lowpass Filter.
Filter data removing data over certain frequency
freq
usingcorners
corners. The filter usesscipy.signal.iirfilter()
(for design) andscipy.signal.sosfilt()
(for applying the filter).- Parameters:
data (array) – Data to filter.
freq (float) – Filter corner frequency.
df (float) – Sampling rate in Hz.
corners (int) – Filter corners / order. Default:
4
zerophase (bool) – If True, apply filter once forwards and once backwards. This results in twice the filter order but zero phase shift in the resulting filtered trace. Default:
False
- Returns:
data – Filtered data.
- Return type:
array
- netpyne.analysis.filter.highpass(data, freq, df, corners=4, zerophase=False)[source]
Butterworth-Highpass Filter.
Filter data removing data below certain frequency
freq
usingcorners
corners. The filter usesscipy.signal.iirfilter()
(for design) andscipy.signal.sosfilt()
(for applying the filter).- Parameters:
data (array) – Data to filter.
freq (float) – Filter corner frequency.
df (float) – Sampling rate in Hz.
corners (int) – Filter corners / order. Default:
4
zerophase (bool) – If True, apply filter once forwards and once backwards. This results in twice the filter order but zero phase shift in the resulting filtered trace. Default:
False
- Returns:
data – Filtered data.
- Return type:
array
- netpyne.analysis.filter.envelope(data)[source]
Envelope of a function.
Computes the envelope of the given function. The envelope is determined by adding the squared amplitudes of the function and it’s Hilbert-Transform and then taking the square-root. (See [Kanasewich1981]) The envelope at the start/end should not be taken too seriously.
- Parameters:
data (array) – Data to make envelope of.
- Returns:
data – Envelope of input data.
- Return type:
array
- netpyne.analysis.filter.remez_fir(data, freqmin, freqmax, df)[source]
The minimax optimal bandpass using Remez algorithm. (experimental)
Finite impulse response (FIR) filter whose transfer function minimizes the maximum error between the desired gain and the realized gain in the specified bands using the Remez exchange algorithm.
- Parameters:
data (array) – Data to filter.
freqmin (float) – Low corner frequency.
freqmax (float) – High corner frequency.
df (float) – Sampling rate in Hz.
- Returns:
data – Filtered data.
- Return type:
array
- netpyne.analysis.filter.lowpass_fir(data, freq, df, winlen=2048)[source]
FIR-Lowpass Filter. (experimental)
Filter data by passing data only below a certain frequency.
- Parameters:
data (array) – Data to filter.
freq (float) – Data below this frequency pass.
df (float) – Sampling rate in Hz.
winlen (int) – Window length for filter in samples, must be power of 2. Default:
2048
- Returns:
data – Filtered data.
- Return type:
array
- netpyne.analysis.filter.integer_decimation(data, decimation_factor)[source]
Downsampling by applying a simple integer decimation.
Make sure that no signal is present in frequency bands above the new Nyquist frequency (samp_rate/2/decimation_factor), e.g. by applying a lowpass filter beforehand! New sampling rate is old sampling rate divided by decimation_factor.
- Parameters:
data (array) – Data to filter.
decimation_factor (int) – Integer decimation factor.
- Returns:
data – Downsampled data (array length: old length / decimation_factor)
- Return type:
array
- netpyne.analysis.filter.lowpass_cheby_2(data, freq, df, maxorder=12, ba=False, freq_passband=False)[source]
Cheby2-Lowpass Filter
Filter data by passing data only below a certain frequency. The main purpose of this cheby2 filter is downsampling. This method will iteratively design a filter, whose pass band frequency is determined dynamically, such that the values above the stop band frequency are lower than -96dB.
- Parameters:
data (array) – Data to filter.
freq (float) – The frequency above which signals are attenuated with 95 dB.
df (float) – Sampling rate in Hz.
maxorder (int) – Maximal order of the designed cheby2 filter. Default:
12
ba (bool) – If True return only the filter coefficients (b, a) instead of filtering. Default:
False
freq_passband (bool) – If True return additionally to the filtered data, the iteratively determined pass band frequency. Default:
False
- Returns:
data – Filtered data.
- Return type:
array