Mark4FileReaderInfo¶
- class baseband.mark4.file_info.Mark4FileReaderInfo(parent=None)[source] [edit on github]¶
Bases:
FileReaderInfo
Standardized information on Mark 4 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. This class has two additional attributes specific to Mark 4 files (ntrack
andoffset0
, see below).Examples
The most common use is simply to print information:
>>> from baseband.data import SAMPLE_MARK4 >>> from baseband import mark4 >>> fh = mark4.open(SAMPLE_MARK4, 'rb') >>> fh.info Mark4File information: format = mark4 number_of_frames = 2 frame_rate = 400.0 Hz sample_rate = 32.0 MHz samples_per_frame = 80000 sample_shape = (8,) bps = 2 complex_data = False readable = True ntrack = 64 offset0 = 2696 missing: decade, ref_time: needed to infer full times. checks: decodable: True >>> fh.close() >>> fh = mark4.open(SAMPLE_MARK4, 'rb', decade=2010) >>> fh.info Mark4File information: format = mark4 number_of_frames = 2 frame_rate = 400.0 Hz sample_rate = 32.0 MHz samples_per_frame = 80000 sample_shape = (8,) bps = 2 complex_data = False start_time = 2014-06-16T07:38:12.475000000 readable = True ntrack = 64 offset0 = 2696 checks: decodable: True >>> fh.close()
Attributes Summary
Attributes that the container provides.
Number of bits used to encode each elementary sample.
dict of checks for readability.
Whether parent is closed
Whether the data are complex.
Decade in which the observations were taken
Whether decoding the first frame worked.
dict of attributes that raised errors.
Like a lazy property, evaluated only once.
Like a lazy property, evaluated only once.
Number of frames per unit time.
Like a lazy property, evaluated only once.
dict of missing attributes.
Number of "tape tracks" simulated in the disk file.
Total number of frames.
Offset in bytes to the location of the first header.
Whether the file is readable and decodable.
Reference time within 4 years of the observation time
Rate of complete samples per unit time.
Shape of each complete sample (e.g.,
(nchan,)
).Number of complete samples in each frame.
Time of the first sample.
Additional time info needed to get the start time.
dict of attributes that gave warnings.
Methods Summary
__call__
()Create a dict with file information.
Attributes Documentation
- attr_names = ('format', 'number_of_frames', 'frame_rate', 'sample_rate', 'samples_per_frame', 'sample_shape', 'bps', 'complex_data', 'start_time', 'readable', 'ntrack', 'offset0', 'missing', 'checks', 'errors', 'warnings')¶
Attributes that the container provides.
- bps¶
Number of bits used to encode each elementary sample.
- checks¶
dict of checks for readability.
- closed¶
Whether parent is closed
- complex_data¶
Whether the data are complex.
- decade¶
Decade in which the observations were taken
- decodable¶
Whether decoding the first frame worked.
- errors¶
dict of attributes that raised errors.
- format¶
Like a lazy property, evaluated only once.
Can be used as a decorator.
It replaces itself with the evaluation of the function, i.e., it is not a data descriptor.
Any errors encountered during the evaluation are stored in the instances
errors
dict.- Parameters:
- attrstr or callable, optional
If a string, assumes we will get that attribute from
needs
. If a callable, it will be called with the instance as its argument to calculate the value (i.e., it will behave like a property). Ifattr
is not given, its is set after the fact by applying the instance to a function (i.e., using it as a decorator), or by defining it as an attribute of a class.- needsstr or tuple of str
The attributes that need to be present to get or calculate
attr
. Ifattr
is a string, this should be where the attribute should be gotten from (e.g., ‘header0’ or ‘_parent’); if not given, the attribute will simply be set todefault
.- defaultvalue, optional
The value to return if the needs are not met. Default:
None
.- docstr, optional
Docstring of the descriptor. If not given will be taken from
attr
if a function, otherwise constructed. (Hard to access from within python, but useful for sphinx documentation.)- missingstr, optional
If the value could be calculated or retrieved, but is
None
, then add this string to themissing
attribute of the instance. Used, e.g., for Mark 5B to give a helpful message ifbps
is not found on the file reader instance.- copybool
Whether the copy the value if it is retrieved. This can be useful, e.g., if the value is expected to be a
dict
and an independent copy should be made.
- frame0¶
Like a lazy property, evaluated only once.
Can be used as a decorator.
It replaces itself with the evaluation of the function, i.e., it is not a data descriptor.
Any errors encountered during the evaluation are stored in the instances
errors
dict.- Parameters:
- attrstr or callable, optional
If a string, assumes we will get that attribute from
needs
. If a callable, it will be called with the instance as its argument to calculate the value (i.e., it will behave like a property). Ifattr
is not given, its is set after the fact by applying the instance to a function (i.e., using it as a decorator), or by defining it as an attribute of a class.- needsstr or tuple of str
The attributes that need to be present to get or calculate
attr
. Ifattr
is a string, this should be where the attribute should be gotten from (e.g., ‘header0’ or ‘_parent’); if not given, the attribute will simply be set todefault
.- defaultvalue, optional
The value to return if the needs are not met. Default:
None
.- docstr, optional
Docstring of the descriptor. If not given will be taken from
attr
if a function, otherwise constructed. (Hard to access from within python, but useful for sphinx documentation.)- missingstr, optional
If the value could be calculated or retrieved, but is
None
, then add this string to themissing
attribute of the instance. Used, e.g., for Mark 5B to give a helpful message ifbps
is not found on the file reader instance.- copybool
Whether the copy the value if it is retrieved. This can be useful, e.g., if the value is expected to be a
dict
and an independent copy should be made.
- frame_rate¶
Number of frames per unit time.
- header0¶
Like a lazy property, evaluated only once.
Can be used as a decorator.
It replaces itself with the evaluation of the function, i.e., it is not a data descriptor.
Any errors encountered during the evaluation are stored in the instances
errors
dict.- Parameters:
- attrstr or callable, optional
If a string, assumes we will get that attribute from
needs
. If a callable, it will be called with the instance as its argument to calculate the value (i.e., it will behave like a property). Ifattr
is not given, its is set after the fact by applying the instance to a function (i.e., using it as a decorator), or by defining it as an attribute of a class.- needsstr or tuple of str
The attributes that need to be present to get or calculate
attr
. Ifattr
is a string, this should be where the attribute should be gotten from (e.g., ‘header0’ or ‘_parent’); if not given, the attribute will simply be set todefault
.- defaultvalue, optional
The value to return if the needs are not met. Default:
None
.- docstr, optional
Docstring of the descriptor. If not given will be taken from
attr
if a function, otherwise constructed. (Hard to access from within python, but useful for sphinx documentation.)- missingstr, optional
If the value could be calculated or retrieved, but is
None
, then add this string to themissing
attribute of the instance. Used, e.g., for Mark 5B to give a helpful message ifbps
is not found on the file reader instance.- copybool
Whether the copy the value if it is retrieved. This can be useful, e.g., if the value is expected to be a
dict
and an independent copy should be made.
- missing¶
dict of missing attributes.
- ntrack¶
Number of “tape tracks” simulated in the disk file.
- number_of_frames¶
Total number of frames.
- offset0¶
Offset in bytes to the location of the first header.
- readable¶
Whether the file is readable and decodable.
- ref_time¶
Reference time within 4 years of the observation time
- sample_rate¶
Rate of complete samples per unit time.
- sample_shape¶
Shape of each complete sample (e.g.,
(nchan,)
).
- samples_per_frame¶
Number of complete samples in each frame.
- start_time¶
Time of the first sample.
- time_info¶
Additional time info needed to get the start time.
- warnings¶
dict of attributes that gave warnings.
Methods Documentation
- __call__() [edit on github]¶
Create a dict with file information.
This includes information about checks done, possible missing information, as well as possible warnings and errors.