import numpy as np
import dascore as dc
= dc.get_example_patch()
epatch = epatch.new(data=np.ones_like(epatch.data))
patch
# Taper values outside of specified times to zero
= dc.to_datetime64("2017-09-18T00:00:04")
t1 = dc.to_datetime64("2017-09-18T00:00:07")
t2 = patch.taper_range(time=(t1, t2))
patch_tapered_1
# Taper values inside specified range to 0
= patch.taper_range(time=(t1, t2), invert=True)
patch_tapered_2
# 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.taper_range(
patch_tapered_3 =(1, 2, 5, 5),
time=True,
relative
)
# Use samples rather than absolute time values.
= patch.taper_range(
patch_tapered_4 =(10, 80),
distance=True
samples
)
# Apply two non-overlapping tapers
= ((25,50,100,125), (150,175,200,225))
taper_range = patch.taper_range(distance=taper_range) patch_tapered_5
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.