sigpyproc.readers#
- class sigpyproc.readers.FilReader(filenames, check_contiguity=True)#
Bases:
FilterbankA class to handle the reading of sigproc format filterbank files.
- Parameters:
- Returns:
Base container of filterbank data with observational metadata
- Return type:
Notes
To be considered as a Sigproc format filterbank file the header must only contain keywords found in the
header_keysdictionary.- read_block(start, nsamps)#
Read a block of filterbank data.
- Parameters:
- Returns:
2-D array of filterbank data with observational metadata
- Return type:
- 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:
- Returns:
2-D array of filterbank data with observational metadata
- Return type:
- Raises:
ValueError – if requested dedispersed samples are out of range
- read_plan(gulp=16384, start=0, nsamps=None, skipback=0, description=None, quiet=False)#
A generator used to perform filterbank reading.
- Parameters:
gulp (
int, optional) – number of samples in each read, by default 16384start (
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 0description (
str, optional) – description of task show next to progress bar (rich), by default Calling Stackquiet (
bool, optional) – suppress progress bar and logging, 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 readx[1]is the index of the read (i.e.x[1]=0is 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.
- class sigpyproc.readers.PFITSReader(filename)#
Bases:
FilterbankReads a filterbank file from a FITS file.
- Parameters:
filename (
str) – Name of the input file.
- property pri_hdr#
Primary header of input file.
- Type:
- read_block(start, nsamps)#
Read a block of filterbank data.
- Parameters:
- Returns:
2-D array of filterbank data with observational metadata
- Return type:
- 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:
- Returns:
2-D array of filterbank data with observational metadata
- Return type:
- Raises:
ValueError – if requested dedispersed samples are out of range
- read_plan(gulp=16384, start=0, nsamps=None, skipback=0, description=None, quiet=False)#
A generator used to perform filterbank reading.
- Parameters:
gulp (
int, optional) – number of samples in each read, by default 16384start (
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 0description (
str, optional) – description of task show next to progress bar (rich), by default Calling Stackquiet (
bool, optional) – suppress progress bar and logging, 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 readx[1]is the index of the read (i.e.x[1]=0is 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.
- class sigpyproc.readers.PulseExtractor(filfile, pulse_toa, pulse_width, pulse_dm, min_nsamps=256, quiet=False)#
Bases:
objectExtracts a data block from a filterbank file centered on a pulse.
The extracted block is centered on the given pulse toa at the highest frequency in the band. The block is padded if the pulse is too close to the edge of the filterbank file.
- Parameters:
filfile (
str) – Name of the filterbank file.pulse_toa (
int) – Time of arrival of the pulse in samples at the highest frequency.pulse_width (
int) – Width of the pulse in samples.pulse_dm (
float) – Dispersion measure of the pulse.min_nsamps (
int, optional) – Minimum number of samples in the extracted block, by default 256quiet (
bool, optional) – If True, suppresses logging messages, by default False