xdas.signal.resample#
- xdas.signal.resample(da, num, dim='last', window=None, domain='time', parallel=None)[source]#
Resample da to num samples using Fourier method along the given dimension.
The resampled signal starts at the same value as da but is sampled with a spacing of len(da) / num * (spacing of da). Because a Fourier method is used, the signal is assumed to be periodic.
- Parameters:
da (DataArray) – The data to be resampled.
num (int) – The number of samples in the resampled signal.
dim (str, optional) – The dimension along which to resample. Default is last.
window (array_like, callable, string, float, or tuple, optional) – Specifies the window applied to the signal in the Fourier domain. See below for details.
domain (string, optional) – A string indicating the domain of the input x: time Consider the input da as time-domain (Default), freq Consider the input da as frequency-domain.
parallel (bool or int, optional) – Number of threads to use. True uses all cores, False uses one, an int uses that many, None defers to the global xdas configuration. Default is None.
- Returns:
The resampled dataarray.
- Return type:
Notes
Splits on data discontinuities along dim.
Examples
A synthetic dataarray is resample from 300 to 100 samples along the time dimension. The ‘hamming’ window is used.
>>> import xdas.signal as xs >>> from xdas.synthetics import wavelet_wavefronts
>>> da = wavelet_wavefronts() >>> xs.resample(da, 100, dim='time', window='hamming', domain='time') <xdas.DataArray (time: 100, distance: 401)> [[ 0.039988 0.04855 -0.08251 ... 0.02539 -0.055219 -0.006693] [-0.032913 -0.016732 0.033743 ... 0.028534 -0.037685 0.032918] [ 0.01215 0.064107 -0.048831 ... 0.009131 0.053133 0.019843] ... [-0.036508 0.050059 0.015494 ... -0.012022 -0.064922 0.034198] [ 0.054003 -0.013902 -0.084095 ... 0.008979 0.080804 -0.063866] [-0.042741 -0.03524 0.122637 ... -0.013453 -0.075183 0.093055]] Coordinates: * time (time): 2023-01-01T00:00:00.000 to 2023-01-01T00:00:05.940 * distance (distance): 0.000 to 10000.000