sigpyproc.header#

Header class for handling observation metadata.

This module contains the Header class for handling observation metadata.

Classes

Header

Container object to handle observation metadata.

class sigpyproc.header.Header(*, filename, data_type, nchans, foff, fch1, nbits, tsamp, tstart, nsamples, nifs=attr_dict['nifs'].default, coord=attr_dict['coord'].default, azimuth=attr_dict['azimuth'].default, zenith=attr_dict['zenith'].default, telescope=attr_dict['telescope'].default, backend=attr_dict['backend'].default, source=attr_dict['source'].default, frame=attr_dict['frame'].default, ibeam=attr_dict['ibeam'].default, nbeams=attr_dict['nbeams'].default, dm=attr_dict['dm'].default, period=attr_dict['period'].default, accel=attr_dict['accel'].default, signed=attr_dict['signed'].default, rawdatafile=attr_dict['rawdatafile'].default, stream_info=attr_dict['stream_info'].default)[source]#

Bases: object

Container object to handle observation metadata.

Parameters:
filenamestr

Name of the header file.

data_typestr

Type of data (filterbank, time series).

nchansint

Number of frequency channels.

fofffloat

Frequency channel width in MHz.

fch1float

Central frequency of the first channel in MHz.

nbitsint

Number of bits per sample.

tsampfloat

Sampling time in seconds.

tstartfloat

Start time of the observation in MJD.

nsamplesint

Number of time samples in the observation.

nifsint, optional

Number of polarizations, by default 1.

coordSkyCoord, optional

Source sky coordinates, by default (0, 0).

azimuthAngle, optional

Telescope Azimuth angle, by default 0.

zenithAngle, optional

Telescope Zenith angle, by default 0.

telescopestr, optional

Telescope name, by default “Fake”.

backendstr, optional

Telescope backend name, by default “FAKE”.

sourcestr, optional

Source name, by default “Fake”.

framestr, optional

Reference frame, by default “topocentric”.

ibeamint, optional

Telescope beam number, by default 0.

nbeamsint, optional

Number of beams, by default 0.

dmfloat, optional

Reference Dispersion Measure, by default 0.

periodfloat, optional

Rotation period of the source, by default 0.

accelfloat, optional

Binary acceleration of the source, by default 0.

signedbool, optional

Whether the data is signed, by default False.

rawdatafilestr, optional

Name of the original raw data file, by default “”.

stream_infoStreamInfo, optional

File stream information, by default sigproc.StreamInfo().

Attributes:
basename

Basename of header filename.

extension

Extension of header filename.

telescope_id

Telescope id in Sigproc format.

machine_id

Machine id in Sigproc format.

bandwidth

Frequency bandwidth in MHz.

ftop

Edge frequency of the top frequency channel.

fbottom

Edge frequency of the bottom frequency channel.

fcenter

Central frequency of the whole band.

chan_freqs

Center frequency of each channel.

fmax

Center frequency of the maximum frequency channel.

fmin

Center frequency of the minimum frequency channel.

dtype

Type of the data in file.

tobs

Total time of the observation.

ra

Right Ascension in string representation.

dec

Declination in string representation.

obs_date

Observation date and time in ISO format.

Methods

dedispersed_header(dm)

Get a dedispersed version of the current header.

from_fbh5(filename)

Parse the metadata from a filterbank HDF5 file.

from_inffile(filename)

Parse the metadata from a presto .inf file.

from_pfits(filename)

Parse the metadata from a PSRFITS file.

from_sigproc(filenames, *[, check_contiguity])

Parse the metadata from Sigproc-style files.

get_dmdelays(dm[, ref_freq, in_samples])

Get ISM dispersion delays for given DM value(s).

get_dmsmearing(dm, *[, in_samples])

Get ISM smearing for given DM value(s).

make_inf([outfile])

Make a presto format .inf file.

mjd_after_nsamps(nsamps)

Compute the MJD after nsamps have elapsed.

new_header([update_dict])

Get a new updated instance of Header.

prep_outfile(filename, *[, updates, nbits, ...])

Prepare a file with Sigproc format data.

to_dict(*[, with_properties])

Get a dictionary of all attributes.

to_sigproc()

Get header dictionary in Sigproc format.

to_string()

Get a string representation of the header.

filename#
data_type#
nchans#
foff#
fch1#
nbits#
tsamp#
tstart#
nsamples#
nifs#
coord#
azimuth#
zenith#
telescope#
backend#
source#
frame#
ibeam#
nbeams#
dm#
period#
accel#
signed#
rawdatafile#
stream_info#
property basename#

Basename of header filename.

Returns:
str

Header filename without extension.

property extension#

Extension of header filename.

Returns:
str

Header filename extension.

property telescope_id#

Telescope id in Sigproc format.

Returns:
int

Sigproc telescope id.

property machine_id#

Machine id in Sigproc format.

Returns:
int

Sigproc machine id.

property bandwidth#

Frequency bandwidth in MHz.

Returns:
float

Bandwidth in MHz.

property ftop#

Edge frequency of the top frequency channel.

Returns:
float

Edge frequency at the top of the band.

property fbottom#

Edge frequency of the bottom frequency channel.

Returns:
float

Edge frequency at the bottom of the band.

property fcenter#

Central frequency of the whole band.

Returns:
float

Central frequency.

property chan_freqs#

Center frequency of each channel.

Returns:
ndarray

Channel center frequencies.

property fmax#

Center frequency of the maximum frequency channel.

Returns:
float

Maximum frequency in the band.

property fmin#

Center frequency of the minimum frequency channel.

Returns:
float

Minimum frequency in the band.

property dtype#

Type of the data in file.

Returns:
dtype

Data type.

property tobs#

Total time of the observation.

Returns:
float

Observation time.

property ra#

Right Ascension in string representation.

Returns:
str

Right Ascension.

property dec#

Declination in string representation.

Returns:
str

Declination.

property obs_time#

Observation time in Astropy Time format.

Returns:
Time

Observation time in Astropy Time format.

property obs_date#

Observation date and time in ISO format.

Returns:
str

Observation date and time.

mjd_after_nsamps(nsamps)[source]#

Compute the MJD after nsamps have elapsed.

Parameters:
nsampsint

Number of samples elapsed since start of observation.

Returns:
float

Modified Julian Date.

get_dmdelays(dm, ref_freq='fch1', *, in_samples=True)[source]#

Get ISM dispersion delays for given DM value(s).

Parameters:
dmfloat | np.ndarray

Dispersion measure(s) to calculate delays for.

ref_freqstr | float, optional

Reference frequency to calculate delays from, by default “fch1”. Accepted inputs are “fmax”, “fmin”, “fcenter”, “fch1” or a number in MHz.

in_samplesbool, optional

Flag to return delays as numbers of samples, by default True.

Returns:
ndarray

Dispersion delays at middle of each channel with respect to ref_freq.

If dm is a scalar, returns a 1D array of delays. If dm is an array, returns a 2D array with shape (len(dm), len(freqs)).

get_dmsmearing(dm, *, in_samples=True)[source]#

Get ISM smearing for given DM value(s).

Parameters:
dmfloat | np.ndarray

Dispersion measure(s) to calculate smearing for.

in_samplesbool, optional

Flag to return smearing as numbers of samples, by default True.

Returns:
ndarray

DM smearing in the frequency channels due to finite bandwidth.

If dm is a scalar, returns a 1D array of smearing. If dm is an array, returns a 2D array with shape (len(dm), len(freqs)).

new_header(update_dict=None)[source]#

Get a new updated instance of Header.

This is the preferred way to update the header.

Parameters:
update_dictdict, optional

Values to overide existing header values, by default None.

Returns:
Header

A new instance of the header with updated values.

dedispersed_header(dm)[source]#

Get a dedispersed version of the current header.

Parameters:
dmfloat

Dispersion measure to dedisperse to.

Returns:
Header

A new header with updated DM value.

to_dict(*, with_properties=True)[source]#

Get a dictionary of all attributes.

Parameters:
with_propertiesbool, optional

Whether to include properties in the output, by default True.

Returns:
dict[str, Any]

All attributes of the header.

to_sigproc()[source]#

Get header dictionary in Sigproc format.

Returns:
dict

Sigproc formatted header values.

to_string()[source]#

Get a string representation of the header.

Returns:
str

A string representation of the header.

prep_outfile(filename, *, updates=None, nbits=None, rescale=False)[source]#

Prepare a file with Sigproc format data.

This is the preferred way to write a new Sigproc file.

Parameters:
filenamestr

Name of new file.

updatesdict, optional

Values to overide existing header values, by default None.

nbitsint, optional

Number of bits per output sample, by default None.

rescalebool, optional

Whether to rescale the data using the nbit-dependent values, by default True.

Returns:
FileWriter

A file writer object to write data to.

make_inf(outfile=None)[source]#

Make a presto format .inf file.

Parameters:
outfilestr, optional

Name of the output file, by default None.

Returns:
str

A string representation of .inf data.

classmethod from_inffile(filename)[source]#

Parse the metadata from a presto .inf file.

Parameters:
filenamestr | Path

Name of the .inf file containing the header.

Returns:
Header

Observational metadata.

classmethod from_sigproc(filenames, *, check_contiguity=True)[source]#

Parse the metadata from Sigproc-style files.

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

Sigproc filterbank files containing the header.

check_contiguitybool, optional

Check if the files are contiguous, by default True.

Returns:
Header

Observational metadata.

classmethod from_pfits(filename)[source]#

Parse the metadata from a PSRFITS file.

Parameters:
filenamestr

Name of the PSRFITS file containing the header.

Returns:
Header

Observational metadata.

classmethod from_fbh5(filename)[source]#

Parse the metadata from a filterbank HDF5 file.

Parameters:
filenamestr

Name of the HDF5 file containing the header.

Returns:
Header

Observational metadata.