# resample a patch along time dimension to 10 ms
import numpy as np
import dascore as dc
= dc.get_example_patch()
patch = patch.resample(time=np.timedelta64(10, 'ms'))
new # Resample time dimension to 50 Hz
from dascore.units import Hz
= patch.resample(time=(50 * Hz))
new # Resample distance dimension to a sampling period of 15m
from dascore.units import m
= patch.resample(distance=15 * m)
new # Resample time axis such that there are 50 samples total
= patch.resample(time=50, samples=True) new
resample
resample(
patch: Patch ,
window = None,
interp_kind = linear,
samples = False,
**kwargs ,
)-> ‘PatchType’
Resample along a single dimension using Fourier Method and interpolation.
The dimension which should be resampled is passed as kwargs. The key is the dimension name and the value is the new sampling period.
Since Fourier methods only support adding or removing an integer number of frequency bins, the exact desired sampling rate is often not achievable with resampling alone. If the fourier resampling doesn’t produce the exact result, an interpolation (see interpolate) is used to achieve the desired sampling rate.
Parameters
Parameter | Description |
---|---|
patch | The patch to resample. |
window |
The Fourier-domain window that tapers the Fourier spectrum. See scipy.signal.resample for details. Only used if method == ‘fft’. |
interp_kind |
The interpolation type if output of fourier resampling doesn’t produce exactly the right sampling rate. |
samples |
If true, the values in kwargs represent the number of samples along The specified dimension. |
**kwargs |
keyword arguments to specify dimension and new sampling value. Units can also be used to specify sampling_period or frequency. |
Note
- Unless
samples
isTrue
, this function requires a sampling_period. - The resulting Patch can be slightly shorter than the input Patch.