Mark4Header¶
-
class
baseband.mark4.
Mark4Header
(words, ntrack=None, decade=None, ref_time=None, verify=True)[source] [edit on github]¶ Bases:
baseband.mark4.header.Mark4TrackHeader
Decoder/encoder of a Mark 4 Header, containing all streams.
See http://www.haystack.mit.edu/tech/vlbi/mark5/docs/230.3.pdf
- Parameters
- words
ndarray
of int, or None Shape should be (5, number-of-tracks), and dtype np.uint32. If
None
,ntrack
should be given and words will be initialized to 0.- ntrackNone or int
Number of Mark 4 bitstreams, to help initialize
words
if needed.- decadeint or None
Decade in which the observations were taken (needed to remove ambiguity in the Mark 4 time stamp). Can instead pass an approximate
ref_time
.- ref_time
Time
or None Reference time within 4 years of the observation time, used to infer the full Mark 4 timestamp. Used only if
decade
is not given.- verifybool, optional
Whether to do basic verification of integrity. Default:
True
.
- words
- Returns
- header
Mark4Header
- header
Attributes Summary
Bits per elementary sample (either 1 or 2).
Converted ID and sideband used for each channel.
Number of samples stored in one payload item of size ntrack.
Fractional seconds (decoded from ‘bcd_fraction’).
Size of the frame in bytes.
Whether the header can be modified.
Size of the header in bytes.
Number of channels (
ntrack * fanout
) in the frame.Number of side bands used.
Number of Mark 4 bitstreams.
Size of the payload in bytes.
Number of complete samples in the frame.
Stream dtype required to hold this header’s number of tracks.
Convert BCD time code to Time object for all tracks.
Assignments of tracks to channels and fanout items.
Methods Summary
copy
(self, \*\*kwargs)Create a mutable and independent copy of the header.
fromfile
(fh, ntrack[, decade, ref_time, verify])Read Mark 4 header from file.
fromkeys
(\*args, \*\*kwargs)Initialise a header from parsed values.
fromvalues
(ntrack[, decade, ref_time])Initialise a header from parsed values.
get_time
(self)Convert BCD time code to Time object for all tracks.
infer_decade
(self, ref_time)Uses a reference time to set a header’s
decade
.keys
(self)set_time
(self, time)tofile
(self, fh)Write VLBI frame header to filehandle.
update
(self[, crc, verify])Update the header by setting keywords or properties.
verify
(self)Verify header integrity.
Attributes Documentation
-
bps
¶ Bits per elementary sample (either 1 or 2).
If set, combined with
fanout
andntrack
to update ‘magnitude_bit’ for all tracks.
-
converters
¶ Converted ID and sideband used for each channel.
Returns a structured array with numerical ‘converter’ and boolean ‘lsb’ entries (where
True
means lower sideband).Can be set with a similar structured array or a
dict
; if just an an array is passed in, it will be assumed that the sideband has been set beforehand (e.g., by settingnsb
) and that the array holds the converter IDs.
-
decade
= None¶
-
fanout
¶ Number of samples stored in one payload item of size ntrack.
If set, will update ‘fan_out’ for each track.
-
fraction
¶ Fractional seconds (decoded from ‘bcd_fraction’).
-
frame_nbytes
¶ Size of the frame in bytes.
-
mutable
¶ Whether the header can be modified.
-
nbytes
¶ Size of the header in bytes.
-
nchan
¶ Number of channels (
ntrack * fanout
) in the frame.
-
nsb
¶ Number of side bands used.
If set, assumes all converters are upper sideband for 1, and that converter IDs alternate between upper and lower sideband for 2.
-
ntrack
¶ Number of Mark 4 bitstreams.
-
payload_nbytes
¶ Size of the payload in bytes.
Note that the payloads miss pieces overwritten by the header.
-
samples_per_frame
¶ Number of complete samples in the frame.
If set, this uses the number of tracks to infer and set
fanout
.
-
stream_dtype
¶ Stream dtype required to hold this header’s number of tracks.
-
time
¶ Convert BCD time code to Time object for all tracks.
If all tracks have the same fractional seconds, only a single Time instance is returned.
Uses bcd-encoded ‘unit_year’, ‘day’, ‘hour’, ‘minute’, ‘second’ and ‘frac_sec’, plus
decade
from the initialisation to calculate the time. See http://www.haystack.mit.edu/tech/vlbi/mark5/docs/230.3.pdf
-
track_assignment
¶ Assignments of tracks to channels and fanout items.
The assignments are inferred from tables 10-14 in http://www.haystack.mit.edu/tech/vlbi/mark5/docs/230.3.pdf except that 2 has been subtracted so that tracks start at 0, and that for 64 tracks the arrays are suitably enlarged by adding another set of channels.
The returned array has shape
(fanout, nchan, bps)
.
-
track_id
¶
Methods Documentation
-
copy
(self, **kwargs) [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, ntrack, decade=None, ref_time=None, verify=True)[source] [edit on github]¶ Read Mark 4 header from file.
- Parameters
- fhfilehandle
To read header from.
- ntrackint
Number of Mark 4 bitstreams.
- decadeint or None
Decade in which the observations were taken. Can instead pass an approximate
ref_time
.- ref_time
Time
or None Reference time within 4 years of the observation time. Used only if
decade
is not given.- verifybool, optional
Whether to do basic verification of integrity. Default:
True
.
-
classmethod
fromkeys
(*args, **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 present in
kwargs
- KeyErrorif not all keys required are present in
-
classmethod
fromvalues
(ntrack, decade=None, ref_time=None, **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(<words>)
,cls.fromvalues(**header) == header
.However, unlike for the
fromkeys
class method, data can also be set using arguments named after header methods, such astime
.- Parameters
- ntrackint
Number of Mark 4 bitstreams.
- decadeint or None, optional
Decade in which the observations were taken. Can instead pass an approximate
ref_time
. Not needed iftime
is given.- ref_time
Time
or None, optional Reference time within 4 years of the observation time. Used only if
decade
is not given, and not needed iftime
is given.- **kwargs :
Values used to initialize header keys or methods.
- — Header keywords(minimum for a complete header)
- time
Time
instance Time of the first sample.
- bpsint
Bits per elementary sample.
- fanoutint
Number of tracks over which a given channel is spread out.
-
get_time
(self)[source] [edit on github]¶ Convert BCD time code to Time object for all tracks.
If all tracks have the same fractional seconds, only a single Time instance is returned.
Uses bcd-encoded ‘unit_year’, ‘day’, ‘hour’, ‘minute’, ‘second’ and ‘frac_sec’, plus
decade
from the initialisation to calculate the time. See http://www.haystack.mit.edu/tech/vlbi/mark5/docs/230.3.pdf
-
infer_decade
(self, ref_time)[source] [edit on github]¶ Uses a reference time to set a header’s
decade
.- Parameters
- ref_time
Time
Reference time within 5 years of the observation time.
- ref_time
-
keys
(self) [edit on github]¶
-
set_time
(self, time)[source] [edit on github]¶
-
tofile
(self, fh)[source] [edit on github]¶ Write VLBI frame header to filehandle.
-
update
(self, crc=None, verify=True, **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
).
-
verify
(self)[source] [edit on github]¶ Verify header integrity.