VLBIStreamReaderBase¶
- class baseband.base.base.VLBIStreamReaderBase(fh_raw, header0, **kwargs)[source] [edit on github]¶
Bases:
StreamReaderBase
Base for VLBI stream readers.
This extends the base class specifically for the case that the underlying file has small subsequent frames, which may have gaps, and adds methods that allow fixing these.
Arguments are as for
StreamReaderBase
.Notes
The code assumes that the raw file reader has a
find_header
method, which can be used to find next or previous frames from any position, and thus help identify and skip bad frames. It is used in_last_header
to be sure to find a full last frame.The class also overrides the
_read_frame
method which one that checks that the frame after the one requested is the right one, and attemps recovery if anything fails, using_bad_frame(index, frame, exc)
.Subclasses can overrides parts of the class. For instance, VDIF overrides
_fh_raw_read_frame
and_bad_frame
to take care of the fact that data comes in sets of frames from multiple threads, not individual ones.Attributes Summary
Bits per elementary sample.
Whether the data are complex.
Value to use for invalid or missing data.
First header of the file.
Standardized information on stream readers.
Number of dimensions of the (squeezed/subset) stream data.
Number of complete samples per second.
Shape of a complete sample (possibly subset or squeezed).
Number of complete samples per frame.
Shape of the (squeezed/subset) stream data.
Total number of component samples in the (squeezed/subset) stream data.
Whether data arrays have dimensions with length unity removed.
Start time of the file.
Time at the end of the file, just after the last sample.
Specific components of the complete sample to decode.
Time of the sample pointer's current offset in file.
Whether to do consistency checks on frames being read.
Methods Summary
close
()read
([count, out])Read a number of complete samples.
readable
()Whether the file can be read and decoded.
seek
(offset[, whence])Change the sample pointer position.
tell
([unit])Current offset in the file.
Attributes Documentation
- bps¶
Bits per elementary sample.
- complex_data¶
Whether the data are complex.
- dtype¶
- fill_value¶
Value to use for invalid or missing data. Default: 0.
- header0¶
First header of the file.
- info¶
Standardized information on stream readers.
The
info
descriptor provides a few standard attributes, most of which can also be accessed directly on the stream filehandle, and tests basic readability of the stream. More detailed information on the underlying file is stored in its info, accessible viainfo.file_info
(and shown by__repr__
).
- ndim¶
Number of dimensions of the (squeezed/subset) stream data.
- sample_rate¶
- sample_shape¶
Shape of a complete sample (possibly subset or squeezed).
- samples_per_frame¶
Number of complete samples per frame.
- shape¶
Shape of the (squeezed/subset) stream data.
- size¶
Total number of component samples in the (squeezed/subset) stream data.
- squeeze¶
Whether data arrays have dimensions with length unity removed.
If
True
, data read out has such dimensions removed, and data passed in for writing has them inserted.
- start_time¶
Start time of the file.
See also
time
for the time of the sample pointer’s current offset, and (if available)stop_time
for the time at the end of the file.
- stop_time¶
Time at the end of the file, just after the last sample.
See also
start_time
for the start time of the file, andtime
for the time of the sample pointer’s current offset.
- subset¶
Specific components of the complete sample to decode.
The order of dimensions is the same as for
sample_shape
. Set by the class initializer.
- time¶
Time of the sample pointer’s current offset in file.
See also
start_time
for the start time, and (if available)stop_time
for the end time, of the file.
- verify¶
Whether to do consistency checks on frames being read.
Methods Documentation
- close() [edit on github]¶
- read(count=None, out=None) [edit on github]¶
Read a number of complete samples.
- Parameters:
- countint or None, optional
Number of complete samples to read. If
None
(default) or negative, the number of samples left. Ignored ifout
is given.- outNone or array, optional
Array to store the samples in. If given,
count
will be inferred from the first dimension; the remaining dimensions should equalsample_shape
.
- Returns:
- out
ndarray
of float or complex The first dimension is sample-time, and the remaining ones are as given by
sample_shape
.
- out
- readable() [edit on github]¶
Whether the file can be read and decoded.
- seek(offset, whence=0) [edit on github]¶
Change the sample pointer position.
This works like a normal filehandle seek, but the offset is in samples (or a relative or absolute time).
- Parameters:
- offsetint,
Quantity
, orTime
Offset to move to. Can be an (integer) number of samples, an offset in time units, or an absolute time. For the latter two, the pointer will be moved to the nearest integer sample.
- whence{0, 1, 2, ‘start’, ‘current’, or ‘end’}, optional
Like regular seek, the offset is taken to be from the start if
whence=0
(default), from the current position if 1, and from the end if 2. One can alternativey use ‘start’, ‘current’, or ‘end’ for 0, 1, or 2, respectively. Ignored ifoffset
is a time.
- offsetint,
- tell(unit=None) [edit on github]¶
Current offset in the file.
- Parameters:
- unit
Unit
or str, optional Time unit the offset should be returned in. By default, no unit is used, i.e., an integer enumerating samples is returned. For the special string ‘time’, the absolute time is calculated.
- unit
- Returns: