DADAHeader¶
-
class
baseband.dada.
DADAHeader
(*args, **kwargs)[source] [edit on github]¶ Bases:
collections.OrderedDict
DADA baseband file format header.
Defines a number of routines common to all baseband format headers.
Parameters: *args : str or iterable
If a string, parsed as a DADA header from a file, otherwise as for the OrderedDict baseclass.
verify : bool, optional
Whether to do minimal verification that the header is consistent with the DADA standard. Default:
True
.mutable : bool, optional
Whether to allow the header to be changed after initialisation. Default:
True
.**kwargs
Any further header keywords to be set. If any value is a 2-item tuple, the second one will be considered a comment.
Notes
Like
OrderedDict
, in order to ensure keywords are kept in the right order, one should pass on values as a tuple, not as a dict. E.g., to copy a header, one should not doDADAHeader(**header)
, but rather:DADAHeader(((key, header[key]) for key in header))
or, to also keep the comments:
DADAHeader(((key, (header[key], header.comments[key])) for key in header))
Attributes Summary
bps
Bits per elementary sample. complex_data
Whether the data are complex. frame_nbytes
Size of the frame in bytes. nbytes
Size of the header in bytes. offset
Offset from start of observation in units of time. payload_nbytes
Size of the payload in bytes. sample_rate
Number of complete samples per second. sample_shape
Shape of a sample in the payload (npol, nchan). samples_per_frame
Number of complete samples in the frame. sideband
True if upper sideband. start_time
Start time of the observation. time
Start time of the part of the observation covered by this header. Methods Summary
clear
()copy
()Create a mutable and independent copy of the header. fromfile
(fh[, verify])Reads in DADA header block from a file. fromkeys
(*args, **kwargs)Initialise a header from keyword values. fromvalues
(**kwargs)Initialise a header from parsed values. get
(k[,d])has_key
(k)items
()iteritems
()od.iteritems -> an iterator over the (key, value) pairs in od iterkeys
()itervalues
()od.itervalues -> an iterator over the values in od keys
()pop
(k[,d])value. popitem
()Pairs are returned in LIFO order if last is true or FIFO order if false. setdefault
(k[,d])tofile
(fh)Write DADA file header to filehandle. update
(**kwargs)Update the header with new values. values
()verify
()Basic check of integrity. viewitems
()viewkeys
()viewvalues
()Attributes Documentation
-
bps
¶ Bits per elementary sample.
-
complex_data
¶ Whether the data are complex.
-
frame_nbytes
¶ Size of the frame in bytes.
-
nbytes
¶ Size of the header in bytes.
-
offset
¶ Offset from start of observation in units of time.
-
payload_nbytes
¶ Size of the payload in bytes.
-
sample_rate
¶ Number of complete samples per second.
Can be set with a negative quantity to set
sideband
.
-
sample_shape
¶ Shape of a sample in the payload (npol, nchan).
-
samples_per_frame
¶ Number of complete samples in the frame.
-
sideband
¶ True if upper sideband.
-
start_time
¶ Start time of the observation.
-
time
¶ Start time of the part of the observation covered by this header.
Methods Documentation
-
clear
() → None. Remove all items from od. [edit on github]¶
-
copy
()[source] [edit on github]¶ Create a mutable and independent copy of the header.
-
classmethod
fromfile
(fh, verify=True)[source] [edit on github]¶ Reads in DADA header block from a file.
The file pointer should be at the start.
Parameters: fh : filehandle
To read data from.
verify: bool, optional
Whether to do basic checks on whether the header is valid. Default:
True
.
-
classmethod
fromkeys
(*args, **kwargs)[source] [edit on github]¶ Initialise a header from keyword values.
Like fromvalues, but without any interpretation of keywords.
This just calls the class initializer; it is present for compatibility with other header classes only.
-
classmethod
fromvalues
(**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.fromvalues(**header) == header
.However, unlike for the
fromkeys
class method, data can also be set using arguments named after header methods, such astime
.Furthermore, some header defaults are set in
DADAHeader._defaults
.
-
get
(k[, d]) → D[k] if k in D, else d. d defaults to None.¶
-
has_key
(k) → True if D has a key k, else False¶
-
items
() → list of (key, value) pairs in od [edit on github]¶
-
iteritems
() [edit on github]¶ od.iteritems -> an iterator over the (key, value) pairs in od
-
iterkeys
() → an iterator over the keys in od [edit on github]¶
-
itervalues
() [edit on github]¶ od.itervalues -> an iterator over the values in od
-
keys
() → list of keys in od [edit on github]¶
-
pop
(k[, d]) → v, remove specified key and return the corresponding [edit on github]¶ value. If key is not found, d is returned if given, otherwise KeyError is raised.
-
popitem
() → (k, v), return and remove a (key, value) pair. [edit on github]¶ Pairs are returned in LIFO order if last is true or FIFO order if false.
-
setdefault
(k[, d]) → od.get(k,d), also set od[k]=d if k not in od [edit on github]¶
-
tofile
(fh)[source] [edit on github]¶ Write DADA file header to filehandle.
Parts of the header beyond the ascii lines are filled with 0x00. Note that file should in principle be at the start, but we don’t check for that since that would break SequentialFileWriter.
-
update
(**kwargs)[source] [edit on github]¶ Update the header with new values.
Here, any keywords matching properties are processed as well, in the order set by the class (in
_properties
), and after all other keywords have been processed.Parameters: verify : bool, optional
If
True
(default), verify integrity after updating.**kwargs
Arguments used to set keywords and properties.
-
values
() → list of values in od [edit on github]¶
-
verify
()[source] [edit on github]¶ Basic check of integrity.
-
viewitems
() → a set-like object providing a view on od's items [edit on github]¶
-
viewkeys
() → a set-like object providing a view on od's keys [edit on github]¶
-
viewvalues
() → an object providing a view on od's values [edit on github]¶
-