sigpyproc.header#
Header class for handling observation metadata.
This module contains the Header class for handling observation metadata.
Classes
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:
objectContainer object to handle observation metadata.
- Parameters:
- filename
str Name of the header file.
- data_type
str Type of data (filterbank, time series).
- nchans
int Number of frequency channels.
- foff
float Frequency channel width in MHz.
- fch1
float Central frequency of the first channel in MHz.
- nbits
int Number of bits per sample.
- tsamp
float Sampling time in seconds.
- tstart
float Start time of the observation in MJD.
- nsamples
int Number of time samples in the observation.
- nifs
int, optional Number of polarizations, by default 1.
- coord
SkyCoord, optional Source sky coordinates, by default (0, 0).
- azimuth
Angle, optional Telescope Azimuth angle, by default 0.
- zenith
Angle, optional Telescope Zenith angle, by default 0.
- telescope
str, optional Telescope name, by default “Fake”.
- backend
str, optional Telescope backend name, by default “FAKE”.
- source
str, optional Source name, by default “Fake”.
- frame
str, optional Reference frame, by default “topocentric”.
- ibeam
int, optional Telescope beam number, by default 0.
- nbeams
int, optional Number of beams, by default 0.
- dm
float, optional Reference Dispersion Measure, by default 0.
- period
float, optional Rotation period of the source, by default 0.
- accel
float, optional Binary acceleration of the source, by default 0.
- signed
bool, optional Whether the data is signed, by default False.
- rawdatafile
str, optional Name of the original raw data file, by default “”.
- stream_info
StreamInfo, optional File stream information, by default
sigproc.StreamInfo().
- filename
- Attributes:
basenameBasename of header filename.
extensionExtension of header filename.
telescope_idTelescope id in Sigproc format.
machine_idMachine id in Sigproc format.
bandwidthFrequency bandwidth in MHz.
ftopEdge frequency of the top frequency channel.
fbottomEdge frequency of the bottom frequency channel.
fcenterCentral frequency of the whole band.
chan_freqsCenter frequency of each channel.
fmaxCenter frequency of the maximum frequency channel.
fminCenter frequency of the minimum frequency channel.
dtypeType of the data in file.
tobsTotal time of the observation.
raRight Ascension in string representation.
decDeclination in string representation.
obs_dateObservation date and time in ISO format.
Methods
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
.inffile.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
.inffile.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.
Get header dictionary in Sigproc format.
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 ftop#
Edge frequency of the top frequency channel.
- Returns:
floatEdge frequency at the top of the band.
- property fbottom#
Edge frequency of the bottom frequency channel.
- Returns:
floatEdge frequency at the bottom of the band.
- property fmax#
Center frequency of the maximum frequency channel.
- Returns:
floatMaximum frequency in the band.
- property fmin#
Center frequency of the minimum frequency channel.
- Returns:
floatMinimum frequency in the band.
- property obs_time#
Observation time in Astropy Time format.
- Returns:
TimeObservation time in Astropy Time format.
- get_dmdelays(dm, ref_freq='fch1', *, in_samples=True)[source]#
Get ISM dispersion delays for given DM value(s).
- Parameters:
- dm
float|np.ndarray Dispersion measure(s) to calculate delays for.
- ref_freq
str|float, optional Reference frequency to calculate delays from, by default “fch1”. Accepted inputs are “fmax”, “fmin”, “fcenter”, “fch1” or a number in MHz.
- in_samples
bool, optional Flag to return delays as numbers of samples, by default True.
- dm
- Returns:
ndarrayDispersion 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:
- dm
float|np.ndarray Dispersion measure(s) to calculate smearing for.
- in_samples
bool, optional Flag to return smearing as numbers of samples, by default True.
- dm
- Returns:
ndarrayDM 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.
- to_sigproc()[source]#
Get header dictionary in Sigproc format.
- Returns:
dictSigproc formatted header values.
- to_string()[source]#
Get a string representation of the header.
- Returns:
strA 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:
- Returns:
FileWriterA file writer object to write data to.
- classmethod from_sigproc(filenames, *, check_contiguity=True)[source]#
Parse the metadata from Sigproc-style files.