GSBHeader¶
- class baseband.gsb.GSBHeader(words=None, mode=None, nbytes=None, utc_offset=<Quantity 5.5 h>, verify=True)[source] [edit on github]¶
Bases:
ParsedHeaderBase
GSB Header, based on a line from a timestamp file.
- Parameters:
- wordslist of str, or None
If
None
, set to a list of empty strings for later initialisation.- modestr or None, optional
Mode in which data was taken: ‘phased’ or ‘rawdump’. If
None
, it is determined from the words.- nbytesint or None, optional
Number of characters in the header, including trailing blank spaces and carriage returns. If
None
, is determined from the words assuming one trailing blank space and one CR.- verifybool, optional
Whether to do basic verification of integrity. Default:
True
.
- Returns:
- header
GSBHeader
subclass As appropriate for the mode.
- header
Attributes Summary
Mode in which data was taken: 'phased' or 'rawdump'.
Whether the header can be modified.
Size of the header in characters.
Methods Summary
copy
(**kwargs)Create a mutable and independent copy of the header.
fromfile
(fh, *args, **kwargs)Read GSB Header from a line from a timestamp file.
fromkeys
([mode, nbytes])Initialise a header from parsed values.
fromvalues
([mode, nbytes])Initialise a header from parsed values.
keys
()All keys defined for this header.
seek_offset
(n[, nbytes])Offset in bytes needed to move a file pointer to another header.
tofile
(fh)Write GSB header as a line to the filehandle.
update
(*[, verify])Update the header by setting keywords or properties.
verify
()Base verification always passes.
Attributes Documentation
- mode¶
Mode in which data was taken: ‘phased’ or ‘rawdump’.
- mutable¶
Whether the header can be modified.
- nbytes¶
Size of the header in characters.
Assumes the string terminates in one blank space and one carriage return.
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 GSB Header from a line from a timestamp file.
Arguments are the same as for class initialisation. The header constructed will be immutable.
- classmethod fromkeys(mode=None, nbytes=None, *args, **kwargs)[source] [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(mode=None, nbytes=None, *args, **kwargs)[source] [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.
- keys() [edit on github]¶
All keys defined for this header.
- seek_offset(n, nbytes=None)[source] [edit on github]¶
Offset in bytes needed to move a file pointer to another header.
Some GSB headers have variable size and hence one cannot trivially jump to another entry in a timestamp file. This routine allows one to calculate the offset required to move the file pointer
n
headers.- Parameters:
- nint
The number of headers to move to, relative to the present header.
- nbytesint, optional
The size in bytes of the present header (if not given, will use the header’s
nbytes
property).
- tofile(fh)[source] [edit on github]¶
Write GSB header as a line to the 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]¶
Base verification always passes.
Only here for subclasses to be able to do super().