Mark5BHeader

class baseband.mark5b.header.Mark5BHeader(words, kday=None, ref_time=None, verify=True, **kwargs)[source] [edit on github]

Bases: baseband.vlbi_base.header.VLBIHeaderBase

Decoder/encoder of a Mark5B Frame Header.

See page 15 of http://www.haystack.edu/tech/vlbi/mark5/docs/Mark%205B%20users%20manual.pdf

Parameters:

words : tuple of int, or None

Four 32-bit unsigned int header words. If None, set to a tuple of zeros for later initialisation.

kday : int or None

Explicit thousands of MJD of the observation time (needed to remove ambiguity in the Mark 5B time stamp). Can instead pass an approximate ref_time.

ref_time : Time or None

Reference time within 500 days of the observation time, used to infer the full MJD. Used only if kday is not given.

verify : bool, optional

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

Returns:

header : Mark5BHeader

Attributes Summary

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.
payload_nbytes Size of the payload in bytes.
seconds Integer seconds on day (decoded from ‘bcd_seconds’).
time Convert year, BCD time code to Time object.

Methods Summary

copy(**kwargs) Create a mutable and independent copy of the header.
fromfile(fh, *args, **kwargs) Read VLBI Header from file.
fromkeys(*args, **kwargs) Initialise a header from parsed values.
fromvalues(**kwargs) Initialise a header from parsed values.
get_time([frame_rate]) Convert year, BCD time code to Time object.
infer_kday(ref_time) Uses a reference time to set a header’s kday.
keys()
set_time(time[, frame_rate]) Convert Time object to BCD timestamp elements and ‘frame_nr’.
tofile(fh) Write VLBI frame header to filehandle.
update(**kwargs) Update the header by setting keywords or properties.
verify() Verify header integrity.

Attributes Documentation

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.

payload_nbytes

Size of the payload in bytes.

seconds

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

time

Convert year, BCD time code to Time object.

Calculate time using jday, seconds, and fraction properties (which reflect the bcd-encoded ‘bcd_jday’, ‘bcd_seconds’ and ‘bcd_fraction’ header items), plus kday from the initialisation. See http://www.haystack.edu/tech/vlbi/mark5/docs/Mark%205B%20users%20manual.pdf

Note that some non-compliant files do not have ‘bcd_fraction’ set. For those, the time can still be calculated using the header’s ‘frame_nr’ by passing in a frame 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 higher rates, it is no longer guaranteed that subsequent frames have unique fraction, and one should pass in an explicit frame rate instead.

Parameters:

frame_rate : Quantity, optional

Used to calculate the fractional second from the frame number instead of from the header’s fraction.

Returns:

Time

Methods Documentation

copy(**kwargs)[source] [edit on github]

Create a mutable and independent copy of the header.

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

classmethod fromfile(fh, *args, **kwargs) [edit on github]

Read VLBI Header from file.

Arguments are the same as for class initialisation. The header constructed will be immutable.

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

Initialise a header from parsed values.

Like fromvalues, but without any interpretation of keywords.

Raises:KeyError : if not all keys required are present in kwargs
classmethod fromvalues(**kwargs)[source] [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 Mark5BHeader.fromkeys() class method, data can also be set using arguments named after methods, such as jday and seconds.

Given defaults:

sync_pattern : 0xABADDEED

Values set by other keyword arguments (if present):

bcd_jday : from jday or time bcd_seconds : from seconds or time bcd_fraction : from fraction or time (may need frame_rate) frame_nr : from time (may need frame_rate)

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

Convert year, BCD time code to Time object.

Calculate time using jday, seconds, and fraction properties (which reflect the bcd-encoded ‘bcd_jday’, ‘bcd_seconds’ and ‘bcd_fraction’ header items), plus kday from the initialisation. See http://www.haystack.edu/tech/vlbi/mark5/docs/Mark%205B%20users%20manual.pdf

Note that some non-compliant files do not have ‘bcd_fraction’ set. For those, the time can still be calculated using the header’s ‘frame_nr’ by passing in a frame 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 higher rates, it is no longer guaranteed that subsequent frames have unique fraction, and one should pass in an explicit frame rate instead.

Parameters:

frame_rate : Quantity, optional

Used to calculate the fractional second from the frame number instead of from the header’s fraction.

Returns:

Time

infer_kday(ref_time)[source] [edit on github]

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

Parameters:

ref_time : Time

Reference time within 500 days of the observation time.

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

Convert Time object to BCD timestamp elements and ‘frame_nr’.

For non-integer seconds, the frame number will be calculated if not given explicitly. Doing so requires the frame rate.

Parameters:

time : Time

The time to use for this header.

frame_rate : Quantity, optional

For calculating ‘frame_nr’ from the fractional seconds.

tofile(fh) [edit on github]

Write VLBI frame header to filehandle.

update(**kwargs)[source] [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:

crc : int or None, optional

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

verify : bool, optional

If True (default), verify integrity after updating.

**kwargs

Arguments used to set keywords and properties.

verify()[source] [edit on github]

Verify header integrity.