cardinal_pythonlib.dsp
Original code copyright (C) 2009-2022 Rudolf Cardinal (rudolf@pobox.com).
This file is part of cardinal_pythonlib.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Digital signal processing functions.
- cardinal_pythonlib.dsp.bandpass_filter(data: List[float] | ndarray, sampling_freq_hz: float, lower_freq_hz: float, upper_freq_hz: float, numtaps: int) List[float] | ndarray [source]
Apply a band-pass filter to the data.
- Parameters:
data¶ – time series of the data
sampling_freq_hz¶ – sampling frequency , in Hz (or other consistent units)
lower_freq_hz¶ – filter cutoff lower frequency in Hz (or other consistent units)
upper_freq_hz¶ – filter cutoff upper frequency in Hz (or other consistent units)
numtaps¶ – number of filter taps
- Returns:
filtered data
Note: number of filter taps = filter order + 1
- cardinal_pythonlib.dsp.highpass_filter(data: List[float] | ndarray, sampling_freq_hz: float, cutoff_freq_hz: float, numtaps: int) List[float] | ndarray [source]
Apply a high-pass filter to the data.
- Parameters:
- Returns:
filtered data
Note: number of filter taps = filter order + 1
- cardinal_pythonlib.dsp.lowpass_filter(data: List[float] | ndarray, sampling_freq_hz: float, cutoff_freq_hz: float, numtaps: int) List[float] | ndarray [source]
Apply a low-pass filter to the data.
- Parameters:
- Returns:
filtered data
Note: number of filter taps = filter order + 1
- cardinal_pythonlib.dsp.normalized_frequency(f: float, sampling_freq: float) float [source]
Returns a normalized frequency:
Principles:
if maximum frequency of interest is , then you should sample at the Nyquist rate of ;
if you sample at , then the maximum frequency is the Nyquist frequency
if you sample at , then the normalized frequency is the range for the frequency range .
e.g. see https://en.wikipedia.org/wiki/Nyquist_frequency, https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.iirnotch.html