Mark5BFileReader¶
-
class
baseband.mark5b.base.
Mark5BFileReader
(fh_raw, kday=None, ref_time=None, nchan=None, bps=2)[source] [edit on github]¶ Bases:
baseband.vlbi_base.base.VLBIFileReaderBase
Simple reader for Mark 5B files.
Wraps a binary filehandle, providing methods to help interpret the data, such as
read_frame
andget_frame_rate
.Parameters: fh_raw : filehandle
Filehandle of the raw binary data file.
kday : int or None
Explicit thousands of MJD of the observation time. Can instead pass an approximate
ref_time
.ref_time :
Time
or NoneReference time within 500 days of the observation time, used to infer the full MJD. Used only if
kday
is not given.nchan : int, optional
Number of channels. Default: 1.
bps : int, optional
Bits per elementary sample. Default: 2.
Attributes Summary
info
Methods Summary
close
()find_header
([forward, maximum])Find the nearest header from the current position. get_frame_rate
()Determine the number of frames per second. read_frame
([verify])Read a single frame (header plus payload). read_header
()Read a single header from the file. Attributes Documentation
-
info
¶
Methods Documentation
-
close
() [edit on github]¶
-
find_header
(forward=True, maximum=None)[source] [edit on github]¶ Find the nearest header from the current position.
If successful, the file pointer is left at the start of the header.
Parameters: forward : bool, optional
maximum : int, optional
Maximum number of bytes to search through. Default: twice the frame size of 10016 bytes.
Returns: header :
Mark5BHeader
or NoneRetrieved Mark 5B header, or
None
if nothing found.
-
get_frame_rate
()[source] [edit on github]¶ Determine the number of frames per second.
This method first tries to determine the frame rate by looking for the highest frame number in the first second of data. If that fails, it uses the time difference between two consecutive frames. This can fail if the headers do not store fractional seconds, or if the data rate is above 512 Mbps.
Returns: frame_rate :
Quantity
Frames per second.
-
read_frame
(verify=True)[source] [edit on github]¶ Read a single frame (header plus payload).
Returns: frame :
Mark5BFrame
With
header
anddata
properties that return theMark5BHeader
and data encoded in the frame, respectively.verify : bool, optional
Whether to do basic checks of frame integrity. Default:
True
.
-
read_header
()[source] [edit on github]¶ Read a single header from the file.
Returns: header : Mark5BHeader
-