DADAFrame¶
-
class
baseband.dada.frame.
DADAFrame
(header, payload, valid=True, verify=True)[source] [edit on github]¶ Bases:
baseband.vlbi_base.frame.VLBIFrameBase
Representation of a DADA file, consisting of a header and payload.
- Parameters
- header
DADAHeader
Wrapper around the header lines, providing access to the values.
- payload
DADAPayload
Wrapper around the payload, provding mechanisms to decode it.
- validbool, optional
Whether the data are valid. Default:
True
.- verifybool, optional
Whether to do basic verification of integrity. Default:
True
.
- header
Notes
DADA files do not support storing whether data are valid or not on disk. Hence, this has to be determined independently. If
valid=False
, any decoded data are set tocls.fill_value
(by default, 0).The Frame can also be instantiated using class methods:
fromfile : read header and map or read 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.
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
fromdata
(data[, header, valid, verify])Construct frame from data and header.
fromfile
(fh[, memmap, valid, verify])Read a frame from a filehandle, possible mapping the payload.
keys
(self)tofile
(self, fh)Write encoded frame to filehandle.
verify
(self)Simple verification.
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.
Methods Documentation
-
classmethod
fromdata
(data, header=None, valid=True, verify=True, **kwargs)[source] [edit on github]¶ Construct frame from data and header.
Note that since DADA files are generally very large, one would normally map the file, and then set pieces of it by assigning to slices of the frame. See
memmap_frame
.- Parameters
- data
ndarray
Array holding complex or real data to be encoded.
- header
DADAHeader
or None If not given, will attempt to generate one using the keywords.
- validbool, optional
Whether the data are valid (default:
True
). Note that this information cannot be written to disk.- verifybool, optional
Whether or not to do basic assertions that check the integrity. Default:
True
.- **kwargs
If
header
is not given, these are used to initialize one.
- data
-
classmethod
fromfile
(fh, memmap=True, valid=True, verify=True)[source] [edit on github]¶ Read a frame from a filehandle, possible mapping the payload.
- Parameters
- fhfilehandle
To read header from.
- memmapbool, optional
If
True
(default), usememmap
to map the payload. IfFalse
, just read it from disk.- validbool, optional
Whether the data are valid (default:
True
). Note that this cannot be inferred from the header or payload itself. IfFalse
, any data read will be set tocls.fill_value
.- verifybool, optional
Whether to do basic verification of integrity. Default:
True
.
-
keys
(self) [edit on github]¶
-
tofile
(self, fh) [edit on github]¶ Write encoded frame to filehandle.
-
verify
(self) [edit on github]¶ Simple verification. To be added to by subclasses.