VLBIPayloadBase

class baseband.vlbi_base.payload.VLBIPayloadBase(words, sample_shape=(), bps=2, complex_data=False)[source] [edit on github]

Bases: object

Container for decoding and encoding VLBI payloads.

Any subclass should define dictionaries _decoders and _encoders, which hold functions that decode/encode the payload words to/from ndarray. These dictionaries are assumed to be indexed by bps.

Parameters
wordsndarray

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

sample_shapetuple

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

bpsint

Bits per elementary sample, i.e., per channel and per real or imaginary component. Default: 2.

complex_databool

Whether the data are complex. 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])

Encode data as a payload.

fromfile(fh, \*args[, payload_nbytes])

Read payload from filehandle and decode it into data.

tofile(self, 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)[source] [edit on github]

Encode data as a payload.

Parameters
datandarray

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

headerheader instance, optional

If given, used to infer the bps.

bpsint, optional

Bits per elementary sample, i.e., per channel and per real or imaginary component, used if header is not given. Default: 2.

classmethod fromfile(fh, *args, payload_nbytes=None, **kwargs)[source] [edit on github]

Read payload from filehandle and decode it into data.

Parameters
fhfilehandle

From which data is read.

payload_nbytesint

Number of bytes to read (default: as given in cls._nbytes).

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

Write payload to filehandle.