sigpyproc.header#

class sigpyproc.header.Header(*, filename, data_type, nchans, foff, fch1, nbits, tsamp, tstart, nsamples, nifs=1, coord=<SkyCoord (ICRS): (ra, dec) in deg     (0., 0.)>, azimuth=<Angle 0. deg>, zenith=<Angle 0. deg>, telescope='Fake', backend='FAKE', source='Fake', frame='topocentric', ibeam=0, nbeams=0, dm=0, period=0, accel=0, signed=False, rawdatafile='', hdrlens=_Nothing.NOTHING, datalens=_Nothing.NOTHING, filenames=_Nothing.NOTHING, nsamples_files=_Nothing.NOTHING, tstart_files=_Nothing.NOTHING)#

Bases: object

Container object to handle observation metadata.

Parameters:
  • filename (str) – filename

  • data_type (str) – data type

  • nchans (int) – Number of channels

  • foff (float) – Channel width in MHz

  • fch1 (float) – Central frequency of the first channel in MHz

  • nbits (int) – Number of bits of sample

  • tsamp (float) – Sampling time

  • tstart (float) – Start MJD

  • nsamples (int) – Number of samples

  • nifs (int) – Number of polarizations

  • coord (SkyCoord) – Sky coordinate

  • azimuth (Angle) – Telescope Azimuth

  • zenith (Angle) – Telescope Zenith angle

  • telescope (str) – Telescope name

  • backend (str) – Backend name

  • source (str) – Source name

  • frame (str) – Frame (Topocentric)

  • ibeam (int) – Beam no

  • nbeams (int) – Total beams

  • dm (float) – Reference DM

  • period (float) – Period

  • accel (float) – Acceleration

  • signed (bool) – if the data is signed

  • rawdatafile (str) – Original file name

  • hdrlens (list of int) – List of header length of files

  • datalens (list of int) – List of data length of files

  • filenames (list of str) – List of filenames

  • nsamples_files (list of int) – List of samples in each file

  • tstart_files (list of float) – List of start MJD in each file

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#
hdrlens#
datalens#
filenames#
nsamples_files#
tstart_files#
property basename#

Basename of header filename (str, read-only).

property extension#

Extension of header filename (str, read-only).

property telescope_id#

Telescope id (int, read-only).

property machine_id#

Machine id (str, read-only).

property bandwidth#

Bandwidth in MHz (float, read-only).

property ftop#

Frequency (boundary) of the top channel (float, read-only).

property fbottom#

Frequency (boundary) of the bottom channel (float, read-only).

property fcenter#

Central frequency of the whole band (float, read-only).

property chan_freqs#

Frequency (center) of each channel(ndarray, read-only).

property fmax#

Highest (center) frequency channel (float, read-only).

property fmin#

Lowest (center) frequency channel (float, read-only).

property dtype#

Type of the data (np.dtype, read-only).

property tobs#

Total time of the observation (float, read-only).

property ra#

Right Ascension (str, read-only).

property dec#

Declination (str, read-only).

property obs_date#

Observation date and time (str, read-only).

mjd_after_nsamps(nsamps)#

Find the Modified Julian Date after nsamps have elapsed.

Parameters:

nsamps (int) – number of samples elapsed since start of observation.

Returns:

Modified Julian Date

Return type:

float

get_dmdelays(dm, in_samples=True, ref_freq='ch1')#

For a given dispersion measure get the dispersive ISM delay for middle of each frequency channel.

Parameters:
  • dm (float) – dispersion measure to calculate delays for

  • in_samples (bool, optional) – flag to return delays as numbers of samples, by default True

  • ref_freq (str, optional) – reference frequency to calculate delays from, by default “ch1”

Returns:

delays for middle of each channel with respect to reference frequency

Return type:

ndarray

new_header(update_dict=None)#

Get a new instance of Header.

Parameters:

update_dict (dict, optional) – values to overide existing header values, by default None

Returns:

new header information

Return type:

Header

dedispersed_header(dm)#

Get a dedispersed version of the current header.

Parameters:

dm (float) – dispersion measure we are dedispersing to

Returns:

A dedispersed version of the header

Return type:

Header

to_dict(with_properties=True)#

Get a dict of all attributes including property attributes.

Returns:

attributes

Return type:

dict

to_sigproc(as_dict=False)#

Get sigproc format header binary header.

Returns:

header in binary format

Return type:

str

to_string()#
prep_outfile(filename, update_dict=None, nbits=None, quantize=False, interval_seconds=10, constant_offset_scale=False, **kwargs)#

Prepare a file to have sigproc format data written to it.

Parameters:
  • filename (str) – name of new file

  • update_dict (dict, optional) – values to overide existing header values, by default None

  • nbits (int, optional) – the bitsize of data points that will written to this file (1,2,4,8,32), by default None

Returns:

a prepared file

Return type:

FileWriter

make_inf(outfile=None)#

Make a presto format .inf file.

Parameters:

outfile (str, optional) – a filename to write to, by default None

Returns:

if outfile is unspecified .inf data is returned as string

Return type:

str

classmethod from_inffile(filename)#

Parse the metadata from a presto .inf file.

Parameters:

filename (str) – the name of the .inf file containing the header

Returns:

observational metadata

Return type:

Header

classmethod from_sigproc(filenames, check_contiguity=True)#

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

Parameters:

filenames (list) – sigproc filterbank files containing the header

Returns:

observational metadata

Return type:

Header

classmethod from_pfits(filename)#

Parse the metadata from a PSRFITS file.

Parameters:

filename (str) – the name of the PSRFITS file containing the header

Returns:

observational metadata

Return type:

Header