HeaderParser¶
-
class
baseband.vlbi_base.header.
HeaderParser
(*args, **kwargs)[source] [edit on github]¶ Bases:
collections.OrderedDict
Parser & setter for VLBI header keywords.
An ordered dict of header keywords, with values that describe how they are encoded in a given VLBI header. Initialisation is as a normal OrderedDict, with a key, value pairs. The value should be a tuple containing:
- word_indexint
Index into the header words for this key.
- bit_indexint
Index to the starting bit of the part used for this key.
- bit_lengthint
Number of bits.
- defaultint or bool or None
Possible default value to use in initialisation (e.g., a sync pattern).
The class provides dict-like properties
parsers
,setters
, anddefaults
, which return functions that get a given keyword from header words, set the corresponding part of the header words to a value, or return the default value (if defined). To speed up access to those, they are precalculated on first access rather than calculated on the fly.By default, the parsers and setters are calculated from the header definitions using
make_parser
andmake_setter
, and the defaults inferred usingget_default
. Those can be overridden by passing other functions in as keyword arguments with the same name.Attributes Summary
Lazily evaluated dict of defaults
Lazily evaluated dict of parsers
Lazily evaluated dict of setters
Methods Summary
clear
()copy
(self)Make an independent copy.
fromkeys
(iterable[, value])Create a new ordered dictionary with keys from iterable and values set to value.
get
(self, key[, default])Return the value for key if key is in the dictionary, else default.
items
()keys
()move_to_end
(self, /, key[, last])Move an existing element to the end (or beginning if last is false).
pop
()value.
popitem
(self, /[, last])Remove and return a (key, value) pair from the dictionary.
setdefault
(self, /, key[, default])Insert key with a value of default if key is not in the dictionary.
update
()If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values
()Attributes Documentation
-
defaults
¶ Lazily evaluated dict of defaults
-
parsers
¶ Lazily evaluated dict of parsers
-
setters
¶ Lazily evaluated dict of setters
Methods Documentation
-
clear
()¶
-
copy
(self)[source] [edit on github]¶ Make an independent copy.
-
fromkeys
(iterable, value=None)¶ Create a new ordered dictionary with keys from iterable and values set to value.
-
get
(self, key, default=None, /)¶ Return the value for key if key is in the dictionary, else default.
-
items
()¶
-
keys
()¶
-
move_to_end
(self, /, key, last=True)¶ Move an existing element to the end (or beginning if last is false).
Raise KeyError if the element does not exist.
-
pop
()¶ value. If key is not found, d is returned if given, otherwise KeyError is raised.
-
popitem
(self, /, last=True)¶ Remove and return a (key, value) pair from the dictionary.
Pairs are returned in LIFO order if last is true or FIFO order if false.
-
setdefault
(self, /, key, default=None)¶ Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
-
update
()¶ If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
-
values
()¶