sigpyproc.Readers

class sigpyproc.Readers.FilReader(filename)[source]

Bases: sigpyproc.Filterbank.Filterbank

Class to handle the reading of sigproc format filterbank files

Parameters

filename (str()) – name of filterbank file

Note

To be considered as a Sigproc format filterbank file the header must only contain keywords found in the HeaderParams.header_keys dictionary.

readBlock(start, nsamps, as_filterbankBlock=True)[source]

Read a block of filterbank data.

Parameters
  • start (int) – first time sample of the block to be read

  • nsamps (int) – number of samples in the block (i.e. block will be nsamps*nchans in size)

  • as_filterbankBlock (bool) – whether to read data as filterbankBlock or numpy array

Returns

2-D array of filterbank data

Return type

FilterbankBlock

readDedispersedBlock(start, nsamps, dm, as_filterbankBlock=True, small_reads=True)[source]
Read a block of dedispersed filterbank data, best used in cases where

I/O time dominates reading a block of data.

Parameters
  • start (int) – first time sample of the block to be read

  • nsamps (int) – number of samples in the block (i.e. block will be nsamps*nchans in size)

  • dm (float) – dispersion measure to dedisperse at

  • as_filterbankBlock (bool) – whether to read data as filterbankBlock or numpy array

  • small_reads (bool) – if the datum size is greater than 1 byte, only read the data needed instead of every frequency of every sample

Returns

2-D array of filterbank data

Return type

FilterbankBlock

readPlan(gulp, skipback=0, start=0, nsamps=None, tqdm_desc=None, verbose=True)[source]

A generator used to perform filterbank reading.

Parameters
  • gulp (int) – number of samples in each read

  • skipback (int) – number of samples to skip back after each read (def=0)

  • start (int) – first sample to read from filterbank (def=start of file)

  • nsamps (int) – total number samples to read (def=end of file)

  • verbose (bool) – flag for display of reading plan information (def=True)

Returns

An generator that can read through the file.

Return type

generator object

Note

For each read, the generator yields a tuple x, where:

  • x[0] is the number of samples read

  • x[1] is the index of the read (i.e. x[1]=0 is the first read)

  • x[2] is a 1-D numpy array containing the data that was read

The normal calling syntax for this is function is:

for nsamps, ii, data in self.readPlan(*args,**kwargs):
    # do something

where data always has contains nchans*nsamps points.

sigpyproc.Readers.parseInfHeader(filename)[source]

Parse the metadata from a presto .inf file.

Parameters

filename (str()) – file containing the header

Returns

observational metadata

Return type

Header

sigpyproc.Readers.parseSigprocHeader(filename)[source]

Parse the metadata from a Sigproc-style file header.

Parameters

filename (str()) – file containing the header

Returns

observational metadata

Return type

Header

sigpyproc.Readers.readDat(filename, inf=None)[source]

Read a presto format .dat file.

Parameters

filename (str()) – the name of the file to read

Params inf

the name of the corresponding .inf file (def=None)

Returns

an array containing the whole dat file contents

Return type

TimeSeries

Note

If inf=None, the function will look for a corresponding file with the same basename which has the .inf file extension.

sigpyproc.Readers.readFFT(filename, inf=None)[source]

Read a presto .fft format file.

Parameters

filename (str()) – the name of the file to read

Params inf

the name of the corresponding .inf file (def=None)

Returns

an array containing the whole file contents

Return type

FourierSeries

Note

If inf=None, the function will look for a corresponding file with the same basename which has the .inf file extension.

sigpyproc.Readers.readSpec(filename)[source]

Read a sigpyproc format spec file.

Parameters

filename (str()) – the name of the file to read

Returns

an array containing the whole file contents

Return type

FourierSeries

Note

This is not setup to handle .spec files such as are created by Sigprocs seek module. To do this would require a new header parser for that file format.

sigpyproc.Readers.readTim(filename)[source]

Read a sigproc format time series from file.

Parameters

filename (str()) – the name of the file to read

Returns

an array containing the whole file contents

Return type

TimeSeries