DADAFileWriter¶
- class baseband.dada.base.DADAFileWriter(fh_raw)[source] [edit on github]¶
Bases:
FileBase
Simple writer/mapper for DADA files.
Adds
write_frame
andmemmap_frame
methods to the binary file wrapper. The latter allows one to encode data in pieces, writing to disk as needed.Attributes Summary
Methods Summary
close
()memmap_frame
([header])Get frame by writing the header to disk and mapping its payload.
temporary_offset
([offset, whence])Context manager for temporarily seeking to another file position.
write_frame
(data[, header])Write a single frame (header plus payload).
Attributes Documentation
- fh_raw = None¶
Methods Documentation
- close() [edit on github]¶
- memmap_frame(header=None, **kwargs)[source] [edit on github]¶
Get frame by writing the header to disk and mapping its payload.
The header is written to disk immediately, but the payload is mapped, so that it can be filled in pieces, by setting slices of the frame.
- Parameters:
- header
DADAHeader
Written to disk immediately. Can instead give keyword arguments to construct a header.
- **kwargs
If
header
is not given, these are used to initialize one.
- header
- Returns:
- frame:
DADAFrame
By assigning slices to data, the payload can be encoded piecewise.
- frame:
- temporary_offset(offset=None, whence=0) [edit on github]¶
Context manager for temporarily seeking to another file position.
To be used as part of a
with
statement:with fh_raw.temporary_offset() [as fh_raw]: with-block
On exiting the
with-block
, the file pointer is moved back to its original position. As a convenience, one can pass on the offset to seek to when entering the context manager. Parameters are as forio.IOBase.seek()
.
- write_frame(data, header=None, **kwargs)[source] [edit on github]¶
Write a single frame (header plus payload).
- Parameters:
- data
ndarray
orDADAFrame
If an array, a
header
should be given, which will be used to get the information needed to encode the array, and to construct the DADA frame.- header
DADAHeader
Can instead give keyword arguments to construct a header. Ignored if
data
is aDADAFrame
instance.- **kwargs
If
header
is not given, these are used to initialize one.
- data