sigpyproc.timeseries#
Classes for handling 1D time series data.
This module contains the TimeSeries class for handling 1D time series data.
Classes
Container for 1-D time series data. |
- class sigpyproc.timeseries.TimeSeries(data, header)[source]#
Bases:
objectContainer for 1-D time series data.
- Parameters:
- Attributes:
Methods
apply_boxcar(width)Apply a square-normalized boxcar filter to the time series.
correlate(other)Perform cross correlation with another time series using FFTs.
deredden([method, window, fast])Remove low-frequency red noise using a moving filter.
downsample(factor[, filter_method])Downsample the time series.
fold(period[, accel, nbins, nints])Fold time series into discrete phase and sub-integration bins.
from_dat(datfile[, inffile])Read a Presto format
.datfile.from_tim(timfile)Read a sigproc format
.timfile.normalise([loc_method, scale_method])Normalise/standardise the time series.
pad(npad[, mode])Pad a time series with mean valued data.
resample(accel)Perform time domain resampling to remove acceleration.
rfft([fftn])Perform 1-D real to complex forward FFT.
to_dat([basename])Write time series in presto
.datformat.to_tim([filename])Write time series in sigproc format.
- normalise(loc_method='mean', scale_method='std')[source]#
Normalise/standardise the time series.
Normalisation is performed by subtracting the loc estimate, and dividing by the scale estimate of the data.
- Parameters:
- loc_method{“mean”, “median”}, optional
Method to estimate location to subtract, by default “mean”.
- scale_method{“std”, “iqr”, “mad”}, optional
Method to estimate scale to divide by, by default “std”.
- Returns:
TimeSeriesNormalised time series.
- downsample(factor, filter_method='mean')[source]#
Downsample the time series.
Returned time series is of size
nsamples // factor.- Parameters:
- factor
int Factor by which to downsample the time series.
- filter_method{“mean”, “median”}, optional
Method to downsample, by default ‘mean’.
- factor
- Returns:
TimeSeriesDownsampled time series.
- deredden(method='mean', window=0.5, *, fast=False)[source]#
Remove low-frequency red noise using a moving filter.
- Parameters:
- Returns:
TimeSeriesDe-reddened time series.
- Raises:
ValueErrorIf
window < 0.
- fold(period, accel=0, nbins=50, nints=32)[source]#
Fold time series into discrete phase and sub-integration bins.
- Parameters:
- Returns:
FoldedDataData cube containing the folded data.
- Raises:
ValueErrorIf
nbins * nintsis too large for length of the data.
- rfft(fftn=None)[source]#
Perform 1-D real to complex forward FFT.
Time series is zero-padded to the next good size for the FFT.
- Parameters:
- fftn
Callable[[np.ndarray],np.ndarray], optional The fft function to use. Own fft implementations can be used, e.g,
pyfftw.interfaces.numpy_fft.rfft, ormkl_fft.interfaces.numpy_fft.rfft, by default None.
- fftn
- Returns:
FourierSeriesFourier transform of the time series.
- apply_boxcar(width)[source]#
Apply a square-normalized boxcar filter to the time series.
- Parameters:
- width
int Width of boxcar to apply in bins.
- width
- Returns:
TimeSeriesFiltered time series.
- Raises:
ValueErrorIf
width < 1.
Notes
Time series returned is normalized in units of S/N.
- resample(accel)[source]#
Perform time domain resampling to remove acceleration.
- Parameters:
- accel
float Acceleration to remove from the time series.
- accel
- Returns:
TimeSeriesResampled time series.
- correlate(other)[source]#
Perform cross correlation with another time series using FFTs.
This method implements correlation equivalent to
scipy.signal.correlatewithmode='full'andmethod='fft'. Correlation lags will benp.arange(-len(other) + 1, nsamples).- Parameters:
- other
TimeSeries|np.ndarray Array to correlate with.
- other
- Returns:
TimeSeriesTime series containing the full correlation.
- Raises:
OSErrorIf input array
otheris notTimeSeriesorndarray.
- to_dat(basename=None)[source]#
Write time series in presto
.datformat.- Parameters:
- basename
str, optional File basename for output
.datand.inffiles, by default None.
- basename
- Returns:
strOutput
.datfile name.
Notes
Method also writes a corresponding .inf file from the header data.
- classmethod from_dat(datfile, inffile=None)[source]#
Read a Presto format
.datfile.- Parameters:
- Returns:
TimeSeriesTimeSeries object.
Notes
If
inffileis None, then the associated .inf file must be in the same directory.
- classmethod from_tim(timfile)[source]#
Read a sigproc format
.timfile.- Parameters:
- Returns:
TimeSeriesTimeSeries object.