HDF5Frame

class baseband_tasks.io.hdf5.HDF5Frame(header, payload, valid=None, verify=True)[source] [edit on github]

Bases: baseband.base.frame.FrameBase

Representation of a HDF5 frame, consisting of a header and payload.

Parameters
headerHDF5Header

Wrapper around the yaml-encoded header information.

payloadHDF5Payload

Wrapper around the payload, provding mechanisms to decode it.

validbool or None

Whether the data are valid.

verifybool

Whether to do basic verification of integrity (default: True)

Notes

The Frame can also be read instantiated using class methods:

fromfile : read header and payload from a filehandle

fromdata : encode data as payload

Of course, one can also do the opposite:

tofile : method to write header and payload to filehandle

data : property that yields full decoded payload

A number of properties are defined: shape, dtype and size are the shape, type and number of complete samples of the data array, and nbytes the frame size in bytes. Furthermore, the frame acts as a dictionary, with keys those of the header. Any attribute that is not defined on the frame itself, such as .time will be looked up on the header as well.

Attributes Summary

data

Full decoded frame.

dtype

Numeric type of the frame data.

fill_value

Value to replace invalid data in the frame.

nbytes

Size of the encoded frame in bytes.

ndim

Number of dimensions of the frame data.

sample_shape

Shape of a sample in the frame (nchan,).

shape

Shape of the frame data.

size

Total number of component samples in the frame data.

valid

Whether frame contains valid data.

Methods Summary

fromdata(data[, header])

Construct frame from data and header.

fromfile(fh[, valid, verify])

Read a frame from a filehandle.

keys()

tofile(fh)

Write encoded frame to filehandle.

verify()

Simple verification.

Attributes Documentation

data

Full decoded frame.

dtype

Numeric type of the frame data.

fill_value

Value to replace invalid data in the frame.

nbytes

Size of the encoded frame in bytes.

ndim

Number of dimensions of the frame data.

sample_shape

Shape of a sample in the frame (nchan,).

shape

Shape of the frame data.

size

Total number of component samples in the frame data.

valid

Whether frame contains valid data.

Methods Documentation

classmethod fromdata(data, header=None)[source] [edit on github]

Construct frame from data and header.

Parameters
datandarray

Array holding data to be encoded.

headerheader instance, optional

Header for the frame.

validbool, optional

Whether the data are valid. Default: inferred from header if possible, otherwise True.

verifybool, optional

Whether to verify the header and frame correctness.

**kwargs

Used to initialize the header, if not given.

classmethod fromfile(fh, valid=True, verify=True)[source] [edit on github]

Read a frame from a filehandle.

Parameters
fhfilehandle

To read the header and payload from.

validbool

Whether the data are valid. Default: True.

verifybool

Whether to do basic checks of frame integrity (default: True).

keys() [edit on github]
tofile(fh)[source] [edit on github]

Write encoded frame to filehandle.

verify() [edit on github]

Simple verification. To be added to by subclasses.