salvus.project.tools.processing.block_processing.resample
Resampling modelled after https://ccrma.stanford.edu/~jos/resample/.
Functions
resample()
resample()def resample(
data: numpy.ndarray,
t_in: numpy.ndarray,
t_out: numpy.ndarray,
window_params: salvus.project.tools.processing.block_processing.resample.ResamplingFilterParams = ResamplingFilterParams(
num_zeros=32, precision=9, window=numpy.blackman, rolloff=0.945
),
n_threads: int = 1,
) -> numpy.ndarray:
...Resample a receiver array from one time axis to another.
Uses a fast band-limited resampling algorithm described in https://ccrma.stanford.edu/~jos/resample/ and influenced via the open-source implementations listed therein.
Parameters
datanumpy.ndarray — The data to resample. Will be checked to ensure that it is of the correct shape (n_rec, n_cmp, n_samples).t_innumpy.ndarray — The time axis of the input samples. Must be strictly increasing.t_outnumpy.ndarray — The desired time axis of the output samples. Must be strictly increasing, and must be fully contained within the input time axis.window_paramssalvus.project.tools.processing.block_processing.resample.ResamplingFilterParams — The parameters controlling the resampling filter.n_threadsint — The number of threads to run the resampling on. For nontrivial data sizes, one should expect a linear speedup with the number of threads.
Returns numpy.ndarray — The receiver data resampled along the time axis.
Classes
ResamplingFilterParams
ResamplingFilterParamsclass ResamplingFilterParams(builtins.object):
def __init__(
self,
num_zeros: int = 32,
precision: int = 9,
window: Callable[[int], numpy.ndarray] = numpy.blackman,
rolloff: float = 0.945,
) -> None:
...Filter parameters for resampling.
Default values were gathered from the inspection of some common use cases. Note that the filter width is quite a bit smaller than that used by default in resampy (num_zeros = 512). This looks to allow for a significant speedup without a significant reduction in quality for our use cases. Nevertheless, it is always good to check these parameters when working with a new dataset to ensure that they remain optimal.
Parameters
num_zerosint — The number of zero-crossings that are considered in the sinc filter.precisionint — The number of digits of precision for the linear window interpolation. Precision here is related to the relative difference input / output sampling rates.windowCallable[[int], numpy.ndarray] — The type of window used to truncate the sinc function.rollofffloat — Rolloff.