VLBIFileReaderBase¶
-
class
baseband.vlbi_base.base.
VLBIFileReaderBase
(fh_raw)[source] [edit on github]¶ Bases:
baseband.vlbi_base.base.VLBIFileBase
VLBI wrapped file reader base class.
Typically, a subclass will define
read_header
,read_frame
, andfind_header
methods. This baseclass includes aget_frame_rate
method which determines the frame rate by scanning the file for headers, looking for the maximum frame number that occurs before the jump down for the next second. This method requires the subclass to define aread_header
method and assumes headers have a ‘frame_nr’ item, and define apayload_nbytes
property (as do all standard VLBI formats).Parameters: fh_raw : filehandle
Filehandle of the raw binary data file.
Attributes Summary
info
Standardized information on file readers. Methods Summary
close
()get_frame_rate
()Determine the number of frames per second. Attributes Documentation
-
info
¶ Standardized information on file readers.
The
info
descriptor has a number of standard attributes, which are determined from arguments passed in opening the file, from the first header (info.header0
) and from possibly scanning the file to determine the duration of frames.Examples
The most common use is simply to print information:
>>> from baseband.data import SAMPLE_MARK5B >>> from baseband import mark5b >>> fh = mark5b.open(SAMPLE_MARK5B, 'rb') >>> fh.info File information: format = mark5b frame_rate = 6400.0 Hz bps = 2 complex_data = False missing: nchan: needed to determine sample shape and rate. kday, ref_time: needed to infer full times. >>> fh.close() >>> fh = mark5b.open(SAMPLE_MARK5B, 'rb', kday=56000, nchan=8) >>> fh.info File information: format = mark5b frame_rate = 6400.0 Hz sample_rate = 32.0 MHz samples_per_frame = 5000 sample_shape = (8,) bps = 2 complex_data = False start_time = 2014-06-13T05:30:01.000000000 >>> fh.close()
Attributes
format (str or None
) File format, orNone
if the underlying file cannot be parsed.frame_rate ( Quantity
) Number of data frames per unit of time.sample_rate ( Quantity
) Complete samples per unit of time.samples_per_frame (int) Number of complete samples in each frame. sample_shape (tuple) Dimensions of each complete sample (e.g., (nchan,)
).bps (int) Number of bits used to encode each elementary sample. complex_data (bool) Whether the data are complex. start_time ( Time
) Time of the first complete sample.missing (dict) Entries are keyed by names of arguments that should be passed to the file reader to obtain full information. The associated entries explain why these arguments are needed.
Methods Documentation
-
close
() [edit on github]¶
-
get_frame_rate
()[source] [edit on github]¶ Determine the number of frames per second.
The method cycles through headers, starting from the start of the file, finding the largest frame number before it jumps back to 0 for a new second.
Returns: frame_rate :
Quantity
Frames per second.
Raises: `EOFError`
If the file contains less than one second of data.
-