TaperRange

class of dascore.proc.taper
inherits from: dascore.proc.taper._Envelope, PatchProcessor, DascoreBaseModel, pydantic.main.BaseModel
source

TaperRange(
    *args ,
    window_type: Any = hann,
    invert: Any = False,
    relative: Any = False,
    samples: Any = False,
    **kwargs ,
)-> None

Taper a range inside the patch.

Parameters

Parameter Description
patch A patch instance.
window_type The window whose edge the taper takes. Supported options are:
barthann
bartlett
blackman
blackmanharris
bohman
boxcar
cos
hamming
hann
nuttall
parzen
ramp
triang
or any name or (name, parameter) tuple scipy.signal.get_window
accepts, such as ("tukey", 0.5).
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 relative 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.

See Also

Patch.taper

Examples

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)

Methods

Name Description
check Refuse a patch which does not carry what the operation needs.
get_metadata Return the envelope, shaped to broadcast along its axis.
kernel Return the data times the envelope.
model_copy Copy the model, dropping cached values the update invalidates.
new Create new instance with some attributed updated.
taper_range Taper a range inside the patch.
reconcile Return metadata or a patch holding the final data; default as is.
run Run the operation: check, get_metadata, kernel, reconcile, record.