# Example 1: Compare slope filtered patch to Non-filtered.
import matplotlib.pyplot as plt
import numpy as np
import dascore as dc
from dascore.units import Hz
# Apply taper function and bandpass filter along time axis from 1 to 500 Hz
= (
patch 'example_event_1')
dc.get_example_patch(='m', time='s')
.set_units(distance=0.05)
.taper(time=(1*Hz, 500*Hz))
.pass_filter(time
)= np.array([2e3,2.2e3,8e3,2e4])
filt # Apply fk filter
= patch.slope_filter(
patch_filtered =filt,
filt=False,
directional=False
notch
)# Plot results
= plt.subplots(1, 2, figsize=(12, 8))
fig, (ax1, ax2) = patch.viz.waterfall(ax=ax1, scale=0.5)
ax1 = ax1.set_title('Raw')
_ = patch_filtered.viz.waterfall(ax=ax2, scale=0.5)
ax2 = ax2.set_title('Filtered')
_
# Example 2: Notch filter
= patch.slope_filter(filt=filt, notch=True)
patch_filtered
# Example 3: specify units
= np.array([2e3,2.2e3,8e3,2e4]) * dc.get_unit("m/s")
filt = patch.slope_filter(filt=filt) patch_filtered
slope_filter
slope_filter(
patch: Patch ,
filt: collections.abc.Sequence[float] ,
dims: tuple[str, str] = (‘distance’, ‘time’),
directional: bool = False,
notch: bool = False,
)-> ‘PatchType’
Filter the patch over certain slopes in the 2D Fourier domain.
Most commonly this used as an F-K (frequency wavenumber) filter to attenuate energy with specified apparent velocities.
Parameters
Parameter | Description |
---|---|
patch | The patch to filter. |
filt |
A length 4 array of the form [va, vb, vc, vd]. If notch is False, the filter selects the apparent velocites between ‘vb’ and ‘vc’ with tapering boundaries from ‘va’ to ‘vb’ and from ‘vc’ to ‘vd’. |
dims |
The dimensions used to determine slope. The first dim is in the numerator and the second in the denominator. (eg distance, time) represents a velocity since distance/time has units of |L|/|T| (commonly m/s). |
directional |
If True, the filter should be considered direction. That is to say, the sign of the values in filt indicate the direction (towards oraway) with increasing coordinate values. This can be used for up-down/left-right separation, assuming a near-linear fiber layoyt. |
notch |
If True, the filter represents a notch, meaning the slopes specified by the inner filt parameterse are attenuated ratherthan those outside of them. |