sigpyproc.io.sigproc#

Sigproc-style header parsing and editing.

This module contains functions for parsing and editing Sigproc-style headers.

Classes

FileInfo

Class to handle individual file information.

HeaderField

Class to handle sigproc header schema fields.

StreamInfo

Class to handle stream information as a list of FileInfo objects.

Functions

edit_header

Edit a sigproc style header directly in place for the given file.

encode_header

Encode sigproc header dict in binary format.

encode_key

Encode single SIGPROC header key to a bytes string.

match_header

Match header keywords between two parsed sigproc headers.

parse_header

Parse the metadata from a single Sigproc-style filterbank file.

parse_header_multi

Parse the metadata from Sigproc-style file/sequential files.

parse_radec

Parse Sigproc format RADEC float as Astropy SkyCoord.

Module Attributes

SIGPROC_SCHEMA

Header keys recognised by the sigproc package.

telescope_ids

Telescope IDs recognised by the sigproc package.

machine_ids

Machine IDs recognised by the sigproc package.

sigpyproc.io.sigproc.SIGPROC_SCHEMA#

Header keys recognised by the sigproc package.

SIGPROC Header Schema#

Key

Binary format

Description

az_start

<d (8 bytes)

Telescope azimuth at start of scan (degrees)

barycentric

<I (4 bytes)

Whether the data are barycentric (1) or otherwise (0)

data_type

<I (4 bytes)

Numeric data type identifier

fch1

<d (8 bytes)

Centre frequency (MHz) of first filterbank channel

foff

<d (8 bytes)

Filterbank channel bandwidth (MHz)

ibeam

<I (4 bytes)

Beam number of the observation

machine_id

<I (4 bytes)

Numeric machine identifier

nbeams

<I (4 bytes)

Number of beams in the observation

nbits

<I (4 bytes)

Number of bits per time sample

nchans

<I (4 bytes)

Number of frequency channels

nifs

<I (4 bytes)

Number of seperate IF channels

nsamples

<I (4 bytes)

Number of time samples in the data file (rarely used)

period

<d (8 bytes)

Pulsar folding period (s)

pulsarcentric

<I (4 bytes)

Whether the data are pulsarcentric (1) or otherwise (0)

rawdatafile

string

Name of the original data file

refdm

<d (8 bytes)

Reference Dispersion Measure (pc/cm^3)

signed

b (1 bytes)

Sign convention of 8-bit data samples

source_name

string

Name of the observed source

src_dej

<d (8 bytes)

Declination of source (DDMMSS.S)

src_raj

<d (8 bytes)

Right ascension (J2000) of source (HHMMSS.S)

telescope_id

<I (4 bytes)

Numeric telescope identifier

tsamp

<d (8 bytes)

Time interval between samples (s)

tstart

<d (8 bytes)

Time stamp (MJD) of first sample

za_start

<d (8 bytes)

Telescope zenith angle at start of scan (degrees)

sigpyproc.io.sigproc.telescope_ids#

Telescope IDs recognised by the sigproc package.

Radio Telescope IDs#

Radio Telescope

SIGPROC ID

Fake

0

Arecibo

1

Ooty

2

Nancay

3

Parkes

4

Jodrell

5

GBT

6

GMRT

7

Effelsberg

8

Effelsberg LOFAR

9

SRT

10

LOFAR

11

VLA

12

CHIME

20

MWA

30

NC

40

NGNC

41

MeerKAT

64

sigpyproc.io.sigproc.machine_ids#

Machine IDs recognised by the sigproc package.

Telescope Backend IDs#

Radio Telescope Backend

SIGPROC ID

FAKE

0

PSPM

1

WAPP

2

AOFTM

3

BPP

4

OOTY

5

SCAMP

6

GMRTFB

7

PULSAR2000

8

PARSPEC

9

BPSR

10

COBALT

11

GMRTNEW

14

CHIME

20

MWA-VCS

30

MWAX-VCS

31

MWAX-RTB

32

ADU

40

iTPM

41

class sigpyproc.io.sigproc.FileInfo(*, filename, hdrlen, datalen, nsamples, tstart, tsamp)[source]#

Bases: object

Class to handle individual file information.

Attributes:
datalen
filename
hdrlen
nsamples
tend

Get the end time of the file.

tsamp
tstart

Methods

from_dict

filename#
hdrlen#
datalen#
nsamples#
tstart#
tsamp#
property tend#

Get the end time of the file.

classmethod from_dict(info)[source]#
class sigpyproc.io.sigproc.HeaderField(*, fmt, doc)[source]#

Bases: object

Class to handle sigproc header schema fields.

Attributes:
fmtstruct.Struct or None

Format struct; None for string fields.

docstr

Human-readable description of the field.

fmt#
doc#
class sigpyproc.io.sigproc.StreamInfo(entries=<factory>)[source]#

Bases: object

Class to handle stream information as a list of FileInfo objects.

Attributes:
cumsum_datalens

Get the cumulative sum of datalen for all entries.

entries
time_gaps

Get the time gaps between files.

Methods

add_entry(finfo)

Add a FileInfo entry to the StreamInfo object.

check_contiguity()

Check if the files in the stream are contiguous/sequential.

get_combined(key)

Get the combined value of a key for all entries.

get_info_list(key)

Get list of values for a given key for all entries.

entries#
property cumsum_datalens#

Get the cumulative sum of datalen for all entries.

property time_gaps#

Get the time gaps between files.

add_entry(finfo)[source]#

Add a FileInfo entry to the StreamInfo object.

get_combined(key)[source]#

Get the combined value of a key for all entries.

get_info_list(key)[source]#

Get list of values for a given key for all entries.

check_contiguity()[source]#

Check if the files in the stream are contiguous/sequential.

sigpyproc.io.sigproc.edit_header(filename, key, value)[source]#

Edit a sigproc style header directly in place for the given file.

Parameters:
filenamestr | Path

Name of the sigproc file to modify header.

keystr

Name of parameter to change (must be a valid sigproc key)

valueint or float or str

new value to enter into header

Raises:
ValueError

if the new header to be written to file is longer or shorter than the header that was previously in the file.

Notes

It is up to the user to be responsible with this function, as it will directly change the file on which it is being operated.

sigpyproc.io.sigproc.encode_header(header, *, allow_nsamples_overwrite=False)[source]#

Encode sigproc header dict in binary format.

Returns:
bytes

header in binary format

sigpyproc.io.sigproc.encode_key(key, value=None)[source]#

Encode single SIGPROC header key to a bytes string.

Parameters:
keystr

header key

valueint or float or str, optional

value of the header key, by default None

Returns:
bytes

bytes encoded string

sigpyproc.io.sigproc.match_header(header1, header2)[source]#

Match header keywords between two parsed sigproc headers.

Parameters:
header1dict

parsed header from file 1.

header2dict

parsed header from file 2.

Raises:
ValueError

if key values do not match.

sigpyproc.io.sigproc.parse_header(filename)[source]#

Parse the metadata from a single Sigproc-style filterbank file.

Parameters:
filenamestr | Path

Path to the sigproc filterbank file.

Returns:
dict[str, float | int | str]

Observational metadata, plus computed keys.

Raises:
OSError

If the file header is not in sigproc format, is empty, or is truncated mid-header.

ValueError

If required keys (nbits, nchans) are missing or nsamples is zero.

sigpyproc.io.sigproc.parse_header_multi(filenames, *, check_contiguity=True)[source]#

Parse the metadata from Sigproc-style file/sequential files.

Parameters:
filenamesstr | Path | Sequence[str | Path]

sigproc filterbank files containing the header

Returns:
tuple[dict[str, float | int | str], StreamInfo]

observational metadata and stream info

sigpyproc.io.sigproc.parse_radec(src_raj, src_dej)[source]#

Parse Sigproc format RADEC float as Astropy SkyCoord.

Parameters:
src_rajfloat

Sigproc style HHMMSS.SSSS right ascension

src_dejfloat

Sigproc style DDMMSS.SSSS declination

Returns:
SkyCoord

Astropy coordinate class