GUPPIFileWriter¶
- class baseband.guppi.base.GUPPIFileWriter(fh_raw)[source] [edit on github]¶
Bases:
FileBaseSimple writer/mapper for GUPPI files.
Adds
write_frameandmemmap_framemethods 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
GUPPIHeader Written to disk immediately. Can instead give keyword arguments to construct a header.
- **kwargs
If
headeris not given, these are used to initialize one.
- header
- Returns:
- frame:
GUPPIFrame 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
withstatement: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
ndarrayorGUPPIFrame If an array, a
headershould be given, which will be used to get the information needed to encode the array, and to construct the GUPPI frame.- header
GUPPIHeader Can instead give keyword arguments to construct a header. Ignored if
datais aGUPPIFrameinstance.- **kwargs
If
headeris not given, these are used to initialize one.
- data