notch_filter

function of dascore.proc.filter source

notch_filter(
    patch: Patch ,
    q ,
    **kwargs ,
)-> ‘PatchType’

Apply a second-order IIR notch digital filter on patch’s data.

A notch filter is a band-stop filter with a narrow bandwidth (high quality factor). It rejects a narrow frequency band and leaves the rest of the spectrum little changed.

Parameters

Parameter Description
patch The patch to filter
q Quality factor (float). A higher Q value means a narrower notch,
which targets the specific frequency more precisely.
A lower Q results in a wider notch, meaning a broader range of
frequencies around the specific frequency will be attenuated.
**kwargs Used to specify the dimension(s) and associated frequency and/or wavelength
(or equivalent values) for the filter.
Note

See [scipy.signal.iirnotch] (https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.iirnotch.html) for more information.

Examples

import dascore
pa = dascore.get_example_patch()
 # Apply a notch filter along time axis to remove 60 Hz
filtered = pa.notch_filter(time=60, q=30)
 # Apply a notch filter along distance axis to remove 5 m wavelength
filtered = pa.notch_filter(distance=0.2, q=10)
 # Apply a notch filter along both time and distance axes
filtered = pa.notch_filter(time=60, distance=0.2, q=40)
# Optionally, units can be specified for a more expressive API.
from dascore.units import m, ft, s, Hz
# Apply a notch filter along time axis to remove 60 Hz
filtered = pa.notch_filter(time=60 * Hz, q=30)
# Apply a notch filter along distance axis to remove 5 m wavelength
filtered = pa.notch_filter(distance=5 * m, q=30)