GSBHeader

class baseband.gsb.header.GSBHeader(words, mode=None, nbytes=None, utc_offset=<Quantity 5.5 h>, verify=True)[source] [edit on github]

Bases: baseband.vlbi_base.header.VLBIHeaderBase

GSB Header, based on a line from a timestamp file.

Parameters:

words : list of str, or None

If None, set to a list of empty strings for later initialisation.

mode : str or None, optional

Mode in which data was taken: ‘phased’ or ‘rawdump’. If None, it is determined from the words.

nbytes : int 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.

verify : bool, optional

Whether to do basic verification of integrity. Default: True.

Returns:

header : GSBHeader subclass

As appropriate for the mode.

Attributes Summary

mode Mode in which data was taken: ‘phased’ or ‘rawdump’.
mutable Whether the header can be modified.
nbytes 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()
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(**kwargs) Update the header by setting keywords or properties.
verify() Verify that the length of the words is consistent.

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:KeyError : if not all keys required are present in kwargs
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 as time.

Parameters:

*args

Possible arguments required to initialize an empty header.

**kwargs

Values used to initialize header keys or methods.

keys() [edit on github]
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:

n : int

The number of headers to move to, relative to the present header.

nbytes : int, 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(**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:

verify : bool, 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.