VDIFFrame¶
-
class
baseband.vdif.
VDIFFrame
(header, payload, valid=None, verify=True)[source] [edit on github]¶ Bases:
baseband.vlbi_base.frame.VLBIFrameBase
Representation of a VDIF data frame, consisting of a header and payload.
- Parameters
- header
VDIFHeader
Wrapper around the encoded header words, providing access to the header information.
- payload
VDIFPayload
Wrapper around the payload, provding mechanisms to decode it.
- validbool or None
Whether the data are valid. If
None
(default), is inferred from header. Note thatheader
is changed in-place ifTrue
orFalse
.- verifybool
Whether or not to do basic assertions that check the integrity (e.g., that channel information and whether or not data are complex are consistent between header and data). Default:
True
.
- header
Notes
The Frame can also be 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
Full decoded frame.
Numeric type of the frame data.
Value to replace invalid data in the frame.
Size of the encoded frame in bytes.
Number of dimensions of the frame data.
Shape of a sample in the frame (nchan,).
Shape of the frame data.
Total number of component samples in the frame data.
Whether frame contains valid data.
Methods Summary
from_mark5b_frame
(mark5b_frame[, verify])Construct an Mark5B over VDIF frame (EDV=0xab).
fromdata
(data[, header, verify])Construct frame from data and header.
fromfile
(fh[, edv, verify])Read a frame from a filehandle.
keys
(self)tofile
(self, fh)Write encoded frame to filehandle.
verify
(self)Verify integrity.
Attributes Documentation
-
data
¶ Full decoded frame.
-
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.
This is just the opposite of the
invalid_data
item in the header. If set, that header item is adjusted correspondingly.
Methods Documentation
-
classmethod
from_mark5b_frame
(mark5b_frame, verify=True, **kwargs)[source] [edit on github]¶ Construct an Mark5B over VDIF frame (EDV=0xab).
Any additional keywords can be used to set VDIF header properties not found in the Mark 5B header (such as station).
See https://vlbi.org/wp-content/uploads/2019/03/vdif_extension_0xab.pdf
-
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.
- header
VDIFHeader
or None If not given, will attempt to generate one using the keywords.
- verifybool, optional
Whether or not to do basic assertions that check the integrity (e.g., that channel information and whether or not data are complex are consistent between header and data). Default:
True
.- **kwargs
If
header
is not given, these are used to initialize one.
- data
-
classmethod
fromfile
(fh, edv=None, verify=True)[source] [edit on github]¶ Read a frame from a filehandle.
- Parameters
- fhfilehandle
From which the header and payload are read.
- edvint, False, or None, optional
Extended Data Version.
False
is for legacy headers. IfNone
(default), it will be determined from the words themselves.- verifybool, optional
Whether or not to do basic assertions that check the integrity (e.g., that channel information and whether or not data are complex are consistent between header and data). Default:
True
.
-
keys
(self) [edit on github]¶
-
tofile
(self, fh) [edit on github]¶ Write encoded frame to filehandle.
-
verify
(self)[source] [edit on github]¶ Verify integrity.
Checks consistency between the header information and payload data shape and type.