VDIFMark5BHeader

class baseband.vdif.header.VDIFMark5BHeader(words, edv=None, verify=True, **kwargs)[source] [edit on github]

Bases: baseband.vdif.header.VDIFBaseHeader, baseband.mark5b.header.Mark5BHeader

Mark 5B over VDIF (EDV=0xab).

See https://vlbi.org/wp-content/uploads/2019/03/vdif_extension_0xab.pdf

Attributes Summary

bps

Bits per elementary sample.

edv

VDIF Extended Data Version (EDV).

fraction

Fractional seconds (decoded from ‘bcd_fraction’).

frame_nbytes

Size of the frame in bytes.

jday

Last three digits of MJD (decoded from ‘bcd_jday’).

kday

mutable

Whether the header can be modified.

nbytes

Size of the header in bytes.

nchan

Number of channels in the frame.

payload_nbytes

Size of the payload in bytes.

samples_per_frame

Number of complete samples in the frame.

seconds

Integer seconds on day (decoded from ‘bcd_seconds’).

station

Station ID: two ASCII characters, or 16-bit int.

time

Convert ref_epoch, seconds, and fractional seconds to Time object.

Methods Summary

copy(self)

Create a mutable and independent copy of the header.

from_mark5b_header(mark5b_header, bps, …)

Construct an Mark5B over VDIF header (EDV=0xab).

fromfile(fh[, edv, verify])

Read VDIF Header from file.

fromkeys(\*\*kwargs)

Initialise a header from parsed values.

fromvalues([edv, verify])

Initialise a header from parsed values.

get_time(self[, frame_rate])

Convert ref_epoch, seconds, and fractional seconds to Time object.

infer_kday(self, ref_time)

Uses a reference time to set a header’s kday.

keys(self)

same_stream(self, other)

Whether header is consistent with being from the same stream.

set_time(self, time[, frame_rate])

Converts Time object to ref_epoch, seconds, and frame_nr.

tofile(self, fh)

Write VLBI frame header to filehandle.

update(self, \*[, crc, verify])

Update the header by setting keywords or properties.

verify(self)

Basic checks of header integrity.

Attributes Documentation

bps

Bits per elementary sample.

edv

VDIF Extended Data Version (EDV).

fraction

Fractional seconds (decoded from ‘bcd_fraction’).

The fraction is stored to 0.1 ms accuracy. Following mark5access, this is “unrounded” to give the exact time of the start of the frame for any total bit rate below 512 Mbps. For rates above this value, it is no longer guaranteed that subsequent frames have unique rates.

Note to the above: since a Mark5B frame contains 80000 bits, the total bit rate for which times can be unique would in principle be 800 Mbps. However, standard VLBI only uses bit rates that are powers of 2 in MHz.

frame_nbytes

Size of the frame in bytes.

jday

Last three digits of MJD (decoded from ‘bcd_jday’).

kday = None
mutable

Whether the header can be modified.

nbytes

Size of the header in bytes.

nchan

Number of channels in the frame.

payload_nbytes

Size of the payload in bytes.

samples_per_frame

Number of complete samples in the frame.

seconds

Integer seconds on day (decoded from ‘bcd_seconds’).

station

Station ID: two ASCII characters, or 16-bit int.

time

Convert ref_epoch, seconds, and fractional seconds to Time object.

Uses ‘ref_epoch’, which stores the number of half-years from 2000, and ‘seconds’, from the VDIF part of the header, and the fractional seconds from the Mark 5B part.

Since some Mark 5B headers do not store the fractional seconds, one can also calculates the offset using the current frame number by passing in a sample rate.

Furthermore, fractional seconds are stored only to 0.1 ms accuracy. In the code, this is “unrounded” to give the exact time of the start of the frame for any total bit rate below 512 Mbps. For rates above this value, it is no longer guaranteed that subsequent frames have unique rates, and one should pass in an explicit sample rate instead.

Parameters
frame_rateQuantity, optional

For non-zero ‘frame_nr’, this is used to calculate the corresponding offset.

Returns
timeTime

Methods Documentation

copy(self) [edit on github]

Create a mutable and independent copy of the header.

Keyword arguments can be passed on as needed by possible subclasses.

classmethod from_mark5b_header(mark5b_header, bps, nchan, **kwargs) [edit on github]

Construct an Mark5B over VDIF header (EDV=0xab).

See https://vlbi.org/wp-content/uploads/2019/03/vdif_extension_0xab.pdf

Note that the Mark 5B header does not encode the bits-per-sample and the number of channels used in the payload, so these need to be given separately. A complete frame can be encapsulated with from_mark5b_frame.

Parameters
mark5b_headerMark5BHeader

Used to set time, etc.

bpsint

Bits per elementary sample.

nchanint

Number of channels carried in the Mark 5B payload.

**kwargs

Any further arguments. Strictly, none are necessary to create a valid VDIF header, but this can be used to pass on, e.g., invalid_data.

classmethod fromfile(fh, edv=None, verify=True) [edit on github]

Read VDIF Header from file.

Parameters
fhfilehandle

To read data from.

edvint, False, or None, optional

Extended data version. If False, a legacy header is used. If None (default), it is determined from the header. (Given it explicitly is mostly useful for a slight speed-up.)

verifybool, optional

Whether to do basic verification of integrity. Default: True.

classmethod fromkeys(**kwargs) [edit on github]

Initialise a header from parsed values.

Like fromvalues(), but without any interpretation of keywords.

Raises
KeyErrorif not all keys required are pass in.
classmethod fromvalues(edv=False, *, verify=True, **kwargs) [edit on github]

Initialise a header from parsed values.

Here, the parsed values must be given as keyword arguments, i.e., for any header = cls(<data>), cls.fromvalues(**header) == header.

However, unlike for the fromkeys() class method, data can also be set using arguments named after methods, such as bps and time.

Given defaults:

invalid_data : False legacy_mode : False vdif_version : 1 thread_id : 0 frame_nr : 0 sync_pattern : 0xACABFEED for EDV 1 and 3, 0xa5ea5 for EDV 2

Values set by other keyword arguments (if present):

bits_per_sample : from bps frame_length : from samples_per_frame or frame_nbytes lg2_nchan : from nchan station_id : from station sampling_rate, sampling_unit : from sample_rate ref_epoch, seconds, frame_nr : from time

Note that to set time to non-integer seconds one also needs to pass in frame_rate or sample_rate.

get_time(self, frame_rate=None)[source] [edit on github]

Convert ref_epoch, seconds, and fractional seconds to Time object.

Uses ‘ref_epoch’, which stores the number of half-years from 2000, and ‘seconds’, from the VDIF part of the header, and the fractional seconds from the Mark 5B part.

Since some Mark 5B headers do not store the fractional seconds, one can also calculates the offset using the current frame number by passing in a sample rate.

Furthermore, fractional seconds are stored only to 0.1 ms accuracy. In the code, this is “unrounded” to give the exact time of the start of the frame for any total bit rate below 512 Mbps. For rates above this value, it is no longer guaranteed that subsequent frames have unique rates, and one should pass in an explicit sample rate instead.

Parameters
frame_rateQuantity, optional

For non-zero ‘frame_nr’, this is used to calculate the corresponding offset.

Returns
timeTime
infer_kday(self, ref_time) [edit on github]

Uses a reference time to set a header’s kday.

Parameters
ref_timeTime

Reference time within 500 days of the observation time.

keys(self) [edit on github]
same_stream(self, other) [edit on github]

Whether header is consistent with being from the same stream.

set_time(self, time, frame_rate=None)[source] [edit on github]

Converts Time object to ref_epoch, seconds, and frame_nr.

For non-integer seconds, a frame rate is needed to calculate the ‘frame_nr’.

Parameters
timeTime

The time to use for this header.

frame_rateQuantity, optional

For calculating ‘frame_nr’ from the fractional seconds.

tofile(self, fh) [edit on github]

Write VLBI frame header to filehandle.

update(self, *, crc=None, verify=True, **kwargs) [edit on github]

Update the header by setting keywords or properties.

Here, any keywords matching header keys are applied first, and any remaining ones are used to set header properties, in the order set by the class (in _properties).

Parameters
crcint or None, optional

If None (default), recalculate the CRC after updating.

verifybool, optional

If True (default), verify integrity after updating.

**kwargs

Arguments used to set keywords and properties.

verify(self)[source] [edit on github]

Basic checks of header integrity.