GSBFrame¶
-
class
baseband.gsb.frame.
GSBFrame
(header, payload, valid=True, verify=True)[source] [edit on github]¶ Bases:
baseband.vlbi_base.frame.VLBIFrameBase
Frame encapsulating GSB rawdump or phased data.
For rawdump data, lines in the timestamp file are associated with single blocks of raw data. For phased data, the lines are associated with one or two polarisations, each consisting of two blocks of raw data. Hence, the raw data come from two or four files.
Parameters: header :
GSBHeader
Based on line from rawdump or phased timestamp file.
payload :
GSBPayload
Based on a single block of rawdump data, or the combined blocks for phased data.
valid : bool, optional
Whether the data are valid. Default:
True
.verify : bool, optional
Whether to verify consistency of the frame parts. Default:
True
.Notes
GSB 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 read instantiated using class methods:
fromfile : read header and payload from their respective filehandles
fromdata : encode data as payload
Of course, one can also do the opposite:
- tofile : method to write header and payload to filehandles (splitting
- payload in the appropriate files).
data : property that yields full decoded payload
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. dtype
Numeric type of the frame data. fill_value
Value to replace invalid data in the frame. nbytes
Size of the encoded frame in the raw data file 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, *args, **kwargs)Construct frame from data and header. fromfile
(fh_ts, fh_raw[, payload_nbytes, …])Read a frame from timestamp and raw data filehandles. keys
()tofile
(fh_ts, fh_raw)Write encoded frame to timestamp and raw data filehandles. verify
()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 the raw data file 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, *args, **kwargs) [edit on github]¶ Construct frame from data and header.
Parameters: data :
ndarray
Array holding data to be encoded.
header :
VLBIHeaderBase
Header for the frame.
*args, **kwargs :
Any arguments beyond the filehandle are used to help initialize the payload, except for
valid
andverify
, which are passed on to the header and class initializers.
-
classmethod
fromfile
(fh_ts, fh_raw, payload_nbytes=16777216, nchan=1, bps=4, complex_data=False, valid=True, verify=True)[source] [edit on github]¶ Read a frame from timestamp and raw data filehandles.
Any arguments beyond the filehandle are used to help initialize the payload, except for
valid
andverify
, which are passed on to the header and class initializers.Parameters: fh_ts : filehandle
To the timestamp file. The next line will be read.
fh_raw : file_handle or tuple
Should be a single handle for a rawdump data frame, or a tuple containing tuples with pairs of handles for a phased one. E.g.,
((L1, L2), (R1, R2))
for left and right polarisations.payload_nbytes : int, optional
Size of the individual payloads in bytes. Default:
2**24
(16 MB).nchan : int, optional
Number of channels. Default: 1.
bps : int, optional
Bits per elementary sample. Default: 4.
complex_data : bool, optional
Whether data are complex. Default:
False
.valid : bool, optional
verify : bool, optional
Whether to verify consistency of the frame parts. Default:
True
.
-
keys
() [edit on github]¶
-
tofile
(fh_ts, fh_raw)[source] [edit on github]¶ Write encoded frame to timestamp and raw data filehandles.
Parameters: fh_ts : filehandle
To the timestamp file. A line will be added to it.
fh_raw : file_handle or tuple
Should be a single handle for a rawdump data frame, or a tuple containing tuples with pairs of handles for a phased one. E.g.,
((L1, L2), (R1, R2))
for left and right polarisations.
-
verify
() [edit on github]¶ Simple verification. To be added to by subclasses.