sigpyproc.readers

sigpyproc.readers

class sigpyproc.readers.FilReader(filenames, check_contiguity=True)

Bases: sigpyproc.base.Filterbank

A class to handle the reading of sigproc format filterbank files.

Parameters
  • filenames (str or list of str) – filterbank file or list of filterbank files

  • check_contiguity (bool, optional) – whether to check if files are contiguous, by default True

Returns

Base container of filterbank data with observational metadata

Return type

Filterbank

Notes

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

property header

Header metadata of input file.

Type

Header

property filename

Name of the input file (first file in case of multiple input files).

Type

str

property bitsinfo

Bits info of input file data.

Type

BitsInfo

property sampsize

Sample byte stride in input data.

Type

int

read_block(start, nsamps)

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)

Returns

2-D array of filterbank data with observational metadata

Return type

FilterbankBlock

Raises

ValueError – if requested samples are out of range

read_dedisp_block(start, nsamps, dm)

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

Returns

2-D array of filterbank data with observational metadata

Return type

FilterbankBlock

Raises

ValueError – if requested dedispersed samples are out of range

read_plan(gulp=16384, start=0, nsamps=None, skipback=0, description=None, verbose=False)

A generator used to perform filterbank reading.

Parameters
  • gulp (int, optional) – number of samples in each read, by default 16384

  • start (int, optional) – first sample to read from filterbank, by default 0 (start of file)

  • nsamps (int, optional) – total number of samples to read, by default None (end of the file)

  • skipback (int, optional) – number of samples to skip back after each read, by default 0

  • description (str, optional) – description of task show next to progress bar (rich), by default Calling Stack

  • verbose (bool, optional) – whether to display progress bar, by default False

Yields

Iterator (tuple(int, int, ndarray)) – An iterable of the values in the sequence.

Raises

ValueError – If read samples < skipback.

Notes

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

Examples

The normal calling syntax for this is function is:

>>> for nsamps, ii, data in self.read_plan(**plan_kwargs):
        # do something
where data always has contains ``nchans*nsamps`` points.