Version:

salvus.project.tools.processing.block_processing.resample

salvus.project.tools.processing.block_processing.resample salvus project tools processing block_processing resample

Functions

resample()

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.
SIGNATURE
def resample(
    data: np.ndarray,
    t_in: np.ndarray,
    t_out: np.ndarray,
    window_params: ResamplingFilterParams = ResamplingFilterParams(
        num_zeros=32, precision=9, window=numpy.blackman, rolloff=0.945
    ),
    n_threads: int = 1,
) -> np.ndarray: ...
ARGUMENTS
Required
data
Type:np.ndarray
Description:
The data to resample. Will be checked to ensure that it is of the correct shape (n_rec, n_cmp, n_samples).
Required
t_in
Type:np.ndarray
Description:
The time axis of the input samples. Must be strictly increasing.
Required
t_out
Type:np.ndarray
Description:
The desired time axis of the output samples. Must be strictly increasing, and must be fully contained within the input time axis.
Optional
window_params
Type:ResamplingFilterParams
Default value:ResamplingFilterParams(num_zeros=32, precision=9, window=numpy.blackman, rolloff=0.945)
Description:
The parameters controlling the resampling filter.
Optional
n_threads
Type:int
Default value:1
Description:
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
Return type: np.ndarray
The receiver data resampled along the time axis.

Classes

ResamplingFilterParams

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.
SIGNATURE
class ResamplingFilterParams(builtins.object):
    def __init__(
        self,
        num_zeros: int = 32,
        precision: int = 9,
        window: typing.Callable[[int], np.ndarray] = numpy.blackman,
        rolloff: float = 0.945,
    ) -> None: ...
ARGUMENTS
Optional
num_zeros
Type:int
Default value:32
Description:
The number of zero-crossings that are considered in the sinc filter.
Optional
precision
Type:int
Default value:9
Description:
The number of digits of precision for the linear window interpolation. Precision here is related to the relative difference input / output sampling rates.
Optional
window
Type:typing.Callable[[int], np.ndarray]
Default value:numpy.blackman
Description:
The type of window used to truncate the sinc function.
Optional
rolloff
Type:float
Default value:0.945
Description:
Rolloff.

Used in tutorials

Functionality from this module is used in the following tutorials.
PAGE CONTENTS