HDF5 (baseband_tasks.io.hdf5
)¶
hdf5
contains interfaces for reading and writing
an internal HDF5 format that is suitable for storing intermediate
steps of pipelines. A writer can conveniently be used as the output
argument for any reader, automatically writing in the relevant block size.
For instance:
.. doctest-requires:: h5py, pyyaml
>>> from baseband import data, vdif
>>> from baseband_tasks.functions import Square
>>> from baseband_tasks.io import hdf5
>>> fh = vdif.open(data.SAMPLE_VDIF, 'rs')
>>> square = Square(fh)
>>> squared = square.read()
>>> h5w = hdf5.open('squared.hdf5', 'w', template=square)
>>> square.seek(0)
0
>>> square.read(out=h5w)
<HDF5StreamWriter name=squared.hdf5 offset=40000
sample_rate=32.0 MHz, samples_per_frame=40000,
sample_shape=(8,), dtype=float32,
start_time=2014-06-16T05:56:07.000000000>
>>> h5w.close()
>>> fh.close()
>>> h5r = hdf5.open('squared.hdf5', 'r')
>>> recovered = h5r.read()
>>> (squared == recovered).all()
True
It is also possible to stored data encoding using the standard
vdif
schemes by passing in bps
and complex_data
.
Alternatively, half-precision floats can be used by passing in
encoded_dtype='f2'
or 'c4'
.
Reference/API¶
baseband_tasks.io.hdf5 Package¶
Functions¶
|
Open an HDF5 file as a stream. |
Classes¶
|
Representation of a HDF5 frame, consisting of a header and payload. |
|
HDF5 format header. |
|
Container for decoding and encoding HDF5 payloads. |
Class Inheritance Diagram¶
baseband_tasks.io.hdf5.header Module¶
Definitions for HDF5 general storage headers.
Implements a HDF5Header class used to store header definitions, and provides methods to initialize from a stream template, and to write to and read from an HDF5 Dataset, encoded as yaml file.
Classes¶
|
HDF5 format header. |
|
|
|
Class Inheritance Diagram¶
baseband_tasks.io.hdf5.payload Module¶
Payload for HDF5 format.
Classes¶
|
Container for decoding and encoding HDF5 payloads. |
|
|
|
|
|
Make a HDF5 Dataset look a bit more like ndarray. |
Variables¶
Numpy dtype used to encode half-precision complex numbers. |
Class Inheritance Diagram¶
baseband_tasks.io.hdf5.base Module¶
Interfaces for reading and writing from an internal HDF5 format.
In this format, each HDF5 File
has ‘header’ and ‘payload’
h5py.Dataset
instances, with the header consisting of yaml-encoded
keywords describing the start time, sample rate, etc., and the payload
consisting of either plain numpy data, or data encoded following the
VDIF standard.
Functions¶
|
Open an HDF5 file as a stream. |
Classes¶
|
|
|
|
|