Mark4Frame¶
-
class
baseband.mark4.
Mark4Frame
(header, payload, valid=None, verify=True)[source] [edit on github]¶ Bases:
baseband.vlbi_base.frame.VLBIFrameBase
Representation of a Mark 4 frame, consisting of a header and payload.
Parameters: header :
Mark4Header
Wrapper around the encoded header words, providing access to the header information.
payload :
Mark4Payload
Wrapper around the payload, provding mechanisms to decode it.
valid : bool or None, optional
verify : bool, optional
Whether or not to do basic assertions that check the integrity (e.g., that channel information and number of tracks are consistent between header and data). Default:
True
.Notes
The Frame can also be read instantiated using class methods:
fromfile : read header and payload from a filehandle
fromdata : encode data as payload
Of course, one can also do the opposite:
tofile : method to write header and payload to filehandle
data : property that yields full decoded payload
One can decode part of the payload by indexing or slicing the frame. If the frame does not contain valid data, all values returned are set to
self.fill_value
.A number of properties are defined:
shape
,dtype
andsize
are the shape, type and number of complete samples of the data array, andnbytes
the frame size in bytes. Furthermore, the frame acts as a dictionary, with keys those of the header. Any attribute that is not defined on the frame itself, such as.time
will be looked up on the header as well.Attributes Summary
data
Full decoded frame, with header part filled in. dtype
Numeric type of the frame data. fill_value
Value to replace invalid data in the frame. nbytes
Size of the encoded frame in bytes. ndim
Number of dimensions of the frame data. sample_shape
Shape of a sample in the frame (nchan,). shape
Shape of the frame data. size
Total number of component samples in the frame data. valid
Whether frame contains valid data. Methods Summary
fromdata
(data[, header, verify])Construct frame from data and header. fromfile
(fh, ntrack[, decade, ref_time, verify])Read a frame from a filehandle. keys
()tofile
(fh)Write encoded frame to filehandle. verify
()Simple verification. Attributes Documentation
-
data
¶ Full decoded frame, with header part filled in.
-
dtype
¶ Numeric type of the frame data.
-
fill_value
¶ Value to replace invalid data in the frame.
-
nbytes
¶ Size of the encoded frame in bytes.
-
ndim
¶ Number of dimensions of the frame data.
-
sample_shape
¶ Shape of a sample in the frame (nchan,).
-
shape
¶ Shape of the frame data.
-
size
¶ Total number of component samples in the frame data.
-
valid
¶ Whether frame contains valid data.
None of the error flags are set.
Methods Documentation
-
classmethod
fromdata
(data, header=None, verify=True, **kwargs)[source] [edit on github]¶ Construct frame from data and header.
Parameters: data :
ndarray
Array holding complex or real data to be encoded. This should have the full size of a data frame, even though the part covered by the header will be ignored.
header :
Mark4Header
or NoneIf not given, will attempt to generate one using the keywords.
verify : bool, optional
Whether to do basic checks of frame integrity (default:
True
).
-
classmethod
fromfile
(fh, ntrack, decade=None, ref_time=None, verify=True)[source] [edit on github]¶ Read a frame from a filehandle.
Parameters: fh : filehandle
To read header from.
ntrack : int
Number of Mark 4 bitstreams.
decade : int or None
Decade in which the observations were taken. Can instead pass an approximate
ref_time
.ref_time :
Time
or NoneReference time within 4 years of the observation time. Used only if
decade
is not given.verify : bool, optional
Whether to do basic verification of integrity. Default:
True
.
-
keys
() [edit on github]¶
-
tofile
(fh) [edit on github]¶ Write encoded frame to filehandle.
-
verify
() [edit on github]¶ Simple verification. To be added to by subclasses.
-