Task

class baseband_tasks.base.Task(ih, task, method=None, **kwargs)[source] [edit on github]

Bases: baseband_tasks.base.TaskBase

Apply a user-supplied callable to a stream.

The task can either behave like a function or a method. If a function, it will be passed just the frame data read from the underlying file or task; if a method, it will be passed the Task instance (with its offset at the correct sample) as well as the frame data read.

Note that for common functions it is recommended to instead define a new subclass of TaskBase in which a task (static)method is defined.

Parameters
ihfilehandle

Source of data, or another task, from which samples are read.

taskcallable

The function or method-like callable.

methodbool, optional

Whether task is a method (two arguments) or a function (one argument). Default: inferred by inspection.

**kwargs

Additional arguments and metadata to be passed on to the base class.

— Possible arguments(see TaskBase)
shapetuple, optional

Overall shape of the stream, with first entry the total number of complete samples, and the remainder the sample shape. By default, the shape of the underlying stream, possibly adjusted for a difference of sample rate.

sample_rateQuantity, optional

With units of a rate. If not given, taken from the underlying stream. Should be passed in if the function reduces or expands the number of elements.

samples_per_frameint, optional

Number of samples which should be fed to the function in one go. If not given, by default the number from the underlying file, possibly adjusted for a difference in sample rate.

dtypedtype, optional

Output dtype. If not given, the dtype of the underlying file.

— Possible metadata(see BaseTaskBase)
frequencyQuantity, optional

Frequencies for each channel. Should be broadcastable to the sample shape. Default: taken from the underlying stream, if available.

sidebandarray, optional

Whether frequencies are upper (+1) or lower (-1) sideband. Should be broadcastable to the sample shape. Default: taken from the underlying stream, if available.

polarizationarray or (nested) list of char, optional

Polarization labels. Should broadcast to the sample shape, i.e., the labels are in the correct axis. For instance, ['X', 'Y'], or [['L'], ['R']]. Default: taken from the underlying stream, if available.

Raises
TypeError

If inspection of the task does not work.

AssertionError

If the task has zero or more than 2 arguments.