pulsarbat.time_shift#

pulsarbat.time_shift(z, /, shift, crop=False)[source]#

Shift signal data by given number of samples or time.

This function shifts the signal data in time via FFT by multiplying by a phase gradient in frequency domain. This usually only makes sense if z is a BasebandSignal. For non-baseband signals, the output might not be meaningful.

Parameters:
zSignal

Input signal.

shiftint, float, array-like or Quantity

Shift amount. If a number (int or float), the signal is shifted by that number of samples. An astropy Quantity with units of time can also be passed, in which case the signal will be shifted by dt * z.sample_rate samples. If an array, must have shape such that axes with length more than 1 match z.sample_shape.

cropbool, optional

Whether the returned signal is cropped to eliminate out-of-bounds data. Default is False.

Returns:
outSignal

Shifted signal. If the crop parameter is False, will have the same shape and start_time as input signal. If crop is True, start_time will change by max(0, shift.max()) * z.dt.

Notes

Since an FFT is used, it is efficient to provide a signal with a fast FFT length via pulsarbat.fast_len().