VLBIHeaderBase¶
- class baseband.base.header.VLBIHeaderBase(words, verify=True)[source] [edit on github]¶
Bases:
ParsedHeaderBase
Base class for all VLBI headers.
Defines a number of common routines.
Generally, the actual class should define:
_struct :
Struct
instance that can pack/unpack header words._header_parser :
HeaderParser
instance corresponding to this class._properties : tuple of properties accessible/usable in initialisation
_invariants : set of keys of invariant header parts for a given type.
_stream_invarants : set of keys of invariant header parts for a stream.
It also should define properties that tell the size (getters and setters, or use a
baseband.base.utils.fixedvalue
if the value is the same for all instances):payload_nbytes : number of bytes used by payload
frame_nbytes : total number of bytes for header + payload
- get_time, set_time, and a corresponding time property :
time at start of payload
- Parameters:
- wordstuple or list of int, or None
header words (generally, 32 bit unsigned int). If given as a tuple, the header is immutable. If
None
, set to a list of zeros for later initialisation (and skip any verification).- verifybool, optional
Whether to do basic verification of integrity. For the base class, checks that the number of words is consistent with the struct size.
Attributes Summary
Whether the header can be modified.
Size of the header in bytes.
Methods Summary
copy
(**kwargs)Create a mutable and independent copy of the header.
fromfile
(fh, *args, **kwargs)Read VLBI Header from file.
fromkeys
(*args, **kwargs)Initialise a header from parsed values.
fromvalues
(*args, **kwargs)Initialise a header from parsed values.
invariant_pattern
([invariants])Pattern and mask shared between headers of a type or stream.
Set of keys of invariant header parts.
keys
()All keys defined for this header.
tofile
(fh)Write VLBI frame header to filehandle.
update
(*[, verify])Update the header by setting keywords or properties.
verify
()Verify that the length of the words is consistent.
Attributes Documentation
- mutable¶
Whether the header can be modified.
- nbytes¶
Size of the header in bytes.
Methods Documentation
- copy(**kwargs) [edit on github]¶
Create a mutable and independent copy of the header.
Keyword arguments can be passed on as needed by possible subclasses.
- classmethod fromfile(fh, *args, **kwargs)[source] [edit on github]¶
Read VLBI Header from file.
Arguments are the same as for class initialisation. The header constructed will be immutable.
- classmethod fromkeys(*args, **kwargs) [edit on github]¶
Initialise a header from parsed values.
Like fromvalues, but without any interpretation of keywords.
- Raises:
- KeyErrorif not all keys required are present in
kwargs
- KeyErrorif not all keys required are present in
- classmethod fromvalues(*args, **kwargs) [edit on github]¶
Initialise a header from parsed values.
Here, the parsed values must be given as keyword arguments, i.e., for any
header = cls(<words>)
,cls.fromvalues(**header) == header
.However, unlike for the
fromkeys
class method, data can also be set using arguments named after header methods, such astime
.- Parameters:
- *args
Possible arguments required to initialize an empty header.
- **kwargs
Values used to initialize header keys or methods.
- classmethod invariant_pattern(invariants=None, **kwargs)[source] [edit on github]¶
Pattern and mask shared between headers of a type or stream.
This is mostly for use inside
locate_frames()
.- Parameters:
- invariantsset of str, optional
Set of keys to header parts that are shared between all headers of a given type or within a given stream/file. Default: from
invariants()
.- **kwargs
Keyword arguments needed to instantiate an empty header. (Mostly for Mark 4).
- Returns:
- patternlist of int
The pattern that is shared between headers. If called on an instance, just the header words; if called on a class, words with defaults for the relevant parts set.
- masklist of int
For each entry in
pattern
a bit mask with bits set for the parts that are invariant.
- classmethod invariants()[source] [edit on github]¶
Set of keys of invariant header parts.
On the class, this returns keys of parts that are shared by all headers for the type, on an instance, those that are shared with other headers in the same file.
If neither are defined, returns ‘sync_pattern’ if the header containts that key.
- keys() [edit on github]¶
All keys defined for this header.
- tofile(fh)[source] [edit on github]¶
Write VLBI frame header to filehandle.
- update(*, verify=True, **kwargs) [edit on github]¶
Update the header by setting keywords or properties.
Here, any keywords matching header keys are applied first, and any remaining ones are used to set header properties, in the order set by the class (in
_properties
).- Parameters:
- verifybool, optional
If
True
(default), verify integrity after updating.- **kwargs
Arguments used to set keywords and properties.
- verify()[source] [edit on github]¶
Verify that the length of the words is consistent.
Subclasses should override this to do more thorough checks.