class baseband.guppi.payload.GUPPIPayload(words, *, header=None, sample_shape=(), bps=8, complex_data=False, channels_first=True)[source] [edit on github]

Container for decoding and encoding GUPPI payloads.

Parameters
wordsndarray

Array containg LSB unsigned words (with the right size) that encode the payload.

headerGUPPIHeader

Header that provides information about how the payload is encoded. If not given, the following arguments have to be passed in.

bpsint, optional

Number of bits per sample part (i.e., per channel and per real or imaginary component). Default: 8.

sample_shapetuple, optional

Shape of the samples; e.g., (nchan,). Default: ().

complex_databool, optional

Whether data are complex. Default: False.

channels_firstbool, optional

Whether the encoded payload is stored as (nchan, nsample, npol), rather than (nsample, nchan, npol). Default: True.

Attributes Summary

 data Full decoded payload. dtype Numeric type of the decoded data array. nbytes Size of the payload in bytes. ndim Number of dimensions of the decoded data array. shape Shape of the decoded data array. size Total number of component samples in the decoded data array.

Methods Summary

 fromdata(data[, header, bps, channels_first]) Encode data as a payload. fromfile(fh[, header, payload_nbytes, …]) Read payload from filehandle and decode it into data. tofile(fh) Write payload to filehandle.

Attributes Documentation

data

dtype

Numeric type of the decoded data array.

nbytes

Size of the payload in bytes.

ndim

Number of dimensions of the decoded data array.

shape

Shape of the decoded data array.

size

Total number of component samples in the decoded data array.

Methods Documentation

classmethod fromdata(data, header=None, bps=8, channels_first=True)[source] [edit on github]

Parameters
datandarray

Data to be encoded. The last dimension is taken as the number of channels.

headerGUPPIHeader, optional

If given, used to infer the bps and channels_first.

bpsint, optional

Bits per elementary sample, used if header is None. Default: 8.

channels_firstbool, optional

Whether encoded data should be ordered as (nchan, nsample, npol), used if header is None. Default: True.

classmethod fromfile(fh, header=None, *, payload_nbytes=None, dtype=None, memmap=None, **kwargs) [edit on github]

Parameters
fhfilehandle

If given, used to infer payload_nbytes, bps, sample_shape, and complex_data. If not given, those have to be passed in.

Number of bytes to read. Except for fixed-length payloads, required if no header is given.

dtypedtype, optional

Type of words to read. Default: taken from class attribute.

memmapbool, optional

If False, read from file. Otherwise, map the file in memory (see memmap). Only useful for large payloads. Default: taken from class attribute.

Any other (keyword) arguments are passed on to the class initialiser.
tofile(fh) [edit on github]