import numpy as np
import dascore as dc
epatch = dc.get_example_patch()
patch = epatch.new(data=np.ones_like(epatch.data))
# Taper values outside of specified times to zero
t1 = dc.to_datetime64("2017-09-18T00:00:04")
t2 = dc.to_datetime64("2017-09-18T00:00:07")
patch_tapered_1 = patch.taper_range(time=(t1, t2))
# Taper values inside specified range to 0
patch_tapered_2 = patch.taper_range(time=(t1, t2), invert=True)
# Specify taper range (4 values) such that values outside
# that range are 0, between [0] and [1] as well as
# [2] and [3] are tapered and values inside [1] and [2] are
# not effected.
patch_tapered_3 = patch.taper_range(
time=(1, 2, 5, 5),
relative=True,
)
# Use samples rather than absolute time values.
patch_tapered_4 = patch.taper_range(
distance=(10, 80),
samples=True
)
# Apply two non-overlapping tapers
taper_range = ((25,50,100,125), (150,175,200,225))
patch_tapered_5 = patch.taper_range(distance=taper_range)taper_range
taper_range(
patch: Patch ,
window_type: str = hann,
invert = False,
relative = False,
samples = False,
**kwargs ,
)-> ‘PatchType’
Taper a range inside the patch.
Parameters
| Parameter | Description |
|---|---|
| patch | A patch instance. |
| window_type |
The type of window to use For tapering. Supported Options are: barthann bartlett blackman blackmanharris bohman cos hamming hann nuttall parzen ramp triang |
| invert |
If True, the values inside the specified range are set to zero and gradually tapered to 1. |
| samples |
If True, the values specified by the kwargs indicate samples rather than values along the indicated dimension. |
| relative |
If True, the values specified in kwargs are relateive to the start (if positive) or end (if negative) of the indicated dimension. |
| **kwargs |
Used to specify the dimension along which to taper. Values can be either a length 2 sequence or a length 4 sequence. If len == 2 then the left taper starts at [0] and ends at the start of the coordinate. The left taper starts at [1] and ends at the end of the coordinate. If len == 4, values between [1] and [2] are left alone, values between [0] and [1] as well as values between [2] and [3] are gradually tapered. Values outside of this range are set to 0. |
Returns
The tapered patch.