VDIFPayload

class baseband.vdif.payload.VDIFPayload(words, header=None, sample_shape=(1,), bps=2, complex_data=False)[source] [edit on github]

Bases: PayloadBase

Container for decoding and encoding VDIF payloads.

Parameters:
wordsndarray

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

headerVDIFHeader

If given, used to infer the number of channels, bps, and whether the data are complex.

sample_shapetuple

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

bpsint, optional

Bits per elementary sample, used if header is not given. Default: 2.

complex_databool, optional

Whether the data are complex, used if header is not given. Default: False.

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, edv])

Encode data as payload, using header information.

fromfile(fh[, header, payload_nbytes, ...])

Read payload from filehandle and decode it into data.

tofile(fh)

Write payload to filehandle.

Attributes Documentation

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 Documentation

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

Encode data as payload, using header information.

Parameters:
datandarray

Values to be encoded.

headerVDIFHeader, optional

If given, used to infer the encoding, and to verify the number of channels and whether the data are complex.

bpsint, optional

Bits per elementary sample, used if header is not given. Default: 2.

edvint, optional

Should be given if header is not given and the payload is encoded as Mark 5B data (i.e., edv=0xab).

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

Read payload from filehandle and decode it into data.

Parameters:
fhfilehandle

From which data is read.

headerheader instance, optional

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

payload_nbytesint, optional

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]

Write payload to filehandle.