sigpyproc.timeseries#

class sigpyproc.timeseries.TimeSeries(input_array, header)#

Bases: ndarray

An array class to handle pulsar/FRB data in time series.

Parameters:
  • input_array (ArrayLike) – 1 dimensional array of shape (nsamples)

  • header (Header) – observational metadata

Returns:

1 dimensional time series array with header metadata

Return type:

ndarray

Notes

Data is converted to 32-bit floats regardless of original type.

fold(period, accel=0, nbins=50, nints=32)#

Fold time series into discrete phase and subintegration bins.

Parameters:
  • period (float) – period in seconds to fold with

  • accel (float, optional) – The acceleration to fold the time series, by default 0

  • nbins (int, optional) – number of phase bins in output, by default 50

  • nints (int, optional) – number of subintegrations in output, by default 32

Returns:

data cube containing the folded data

Return type:

FoldedData

Raises:

ValueError – If nbins * nints is too large for length of the data.

rfft()#

Perform 1-D real to complex forward FFT.

Returns:

output of One-Dimensional DFTs of Real Data

Return type:

FourierSeries

running_mean(window=10001)#

Filter time series with a running mean.

Parameters:

window (int, optional) – width in bins of running mean filter, by default 10001

Returns:

filtered time series

Return type:

TimeSeries

Raises:

ValueError – If window size < 1

Notes

Window edges is dealt by reflecting about the edges of the time series.

running_median(window=10001)#

Filter time series with a running median.

Parameters:

window (int, optional) – width in bins of running median filter, by default 10001

Returns:

filtered time series

Return type:

TimeSeries

Notes

Window edges is dealt by reflecting about the edges of the time series.

apply_boxcar(width)#

Apply a square-normalized boxcar filter to the time series.

Parameters:

width (int) – width of boxcar to apply in bins

Returns:

filtered time series

Return type:

TimeSeries

Raises:

ValueError – If boxcar width < 1

Notes

Time series returned is normalized in units of S/N.

downsample(factor)#

Downsample the time series.

Parameters:

factor (int) – factor by which time series will be downsampled

Returns:

downsampled time series

Return type:

TimeSeries

Notes

Returned time series is of size nsamples // factor

pad(npad, mode='mean', **pad_kwargs)#

Pad a time series with mean valued data.

Parameters:
  • npad (int) – number of padding points (bins) to add at the end of the time series

  • mode (str, optional) – mode of padding (as used by numpy.pad()), by default ‘mean’

  • **pad_kwargs (dict) – Keyword arguments for numpy.pad()

Returns:

padded time series

Return type:

TimeSeries

resample(accel, jerk=0)#

Perform time domain resampling to remove acceleration and jerk.

Parameters:
  • accel (float) – The acceleration to remove from the time series

  • jerk (float, optional) – The jerk/jolt to remove from the time series, by default 0

Returns:

resampled time series

Return type:

TimeSeries

correlate(other)#

Cross correlate with another time series of the same length.

Parameters:

other (TimeSeries or ArrayLike) – array to correlate with

Returns:

time series containing the correlation

Return type:

TimeSeries

Raises:

IOError – if input array other is not array like

to_dat(basename)#

Write time series in presto .dat format.

Parameters:

basename (str) – file basename for output .dat and .inf files

Returns:

.dat file name and .inf file name

Return type:

tuple of str

Notes

Method also writes a corresponding .inf file from the header data

to_file(filename=None)#

Write time series in sigproc format.

Parameters:

filename (str, optional) – name of file to write to, by default basename.tim

Returns:

output file name

Return type:

str

classmethod read_dat(datfile, inffile=None)#

Read a presto format .dat file.

Parameters:
  • datfile (str) – the name of the .dat file to read

  • inffile (str, optional) – the name of the corresponding .inf file, by default None

Returns:

a new TimeSeries object

Return type:

TimeSeries

Raises:

IOError – If no .inf file found in the same directory of .dat file.

Notes

If inf is None, then the associated .inf file must be in the same directory.

classmethod read_tim(timfile)#

Read a sigproc format .tim file.

Parameters:

timfile (str) – the name of the .tim file to read

Returns:

a new TimeSeries object

Return type:

TimeSeries