pulsarbat.Signal#

class pulsarbat.Signal(z, /, *, sample_rate, start_time=None, meta=None)[source]#

Base class for all signals.

A signal is sufficiently described by an array of samples (z), and a sampling rate (sample_rate). Optionally, a start_time can be provided to specify the time stamp at the first sample of the signal.

The signal data (z) must have at least 1 dimension where the zeroth axis (axis=0) refers to time. That is, z[i] is the i-th sample of the signal, and the sample shape (z[i].shape) can be arbitrary.

Parameters:
zarray-like

The signal data. Must be at least 1-dimensional with shape (nsample, ...), and must have non-zero size.

sample_rateQuantity

The number of samples per second. Must be in units of frequency.

start_timeTime, optional

The start time of the signal (that is, the time at the first sample of the signal).

metadict, optional

Any metadata that the user might want to attach to the signal.

Attributes

axes_labels

Dictionary of axes labels.

data

The signal data.

dt

Sample spacing of the signal (1 / sample_rate).

dtype

Data type of the signal.

meta

Signal metadata.

ndim

Number of dimensions in data.

sample_rate

Sample rate of the signal.

sample_shape

Shape of a sample.

shape

Shape of the signal.

start_time

Start time of the signal (Time at first sample).

stop_time

Stop time of the signal (Time at sample after the last sample).

time_length

Length of signal in time units.

Methods

compute(**kwargs)

Returns signal with computed data.

contains(t, /)

Whether time(s) are within the bounds of the signal.

get_axis(axis)

Axis number from an integer or axis label.

like(obj[, z])

Returns a signal object "like" given signal object.

persist(**kwargs)

Returns signal with data persisted in memory.

rechunk([chunks])

Rechunks signal data if stored as a Dask array.

to_dask_array()

Returns signal with data as a Dask array.

compute(**kwargs)[source]#

Returns signal with computed data.

Has no effect unless data is stored as a Dask Array. kwargs are passed on to the dask.compute() function.

contains(t, /)[source]#

Whether time(s) are within the bounds of the signal.

get_axis(axis)[source]#

Axis number from an integer or axis label.

classmethod like(obj, z=None, /, **kwargs)[source]#

Returns a signal object “like” given signal object.

This classmethod inspects the class signature and creates a signal object like the given reference object. The signal data (as an array) must always be provided as well as any other arguments that are intended to be different than the reference object. All arguments required by the class signature that are not provided are acquired from attributes of the same name in the reference object.

Parameters:
objSignal

The reference signal object.

zarray-like

The signal data.

**kwargs

Additional keyword arguments to pass on to the target class.

persist(**kwargs)[source]#

Returns signal with data persisted in memory.

Has no effect unless data is stored as a Dask Array. kwargs are passed on to the dask.persist() function.

rechunk(chunks=None, **kwargs)[source]#

Rechunks signal data if stored as a Dask array.

If the underlying data is not a Dask array, it is converted to one first. By default, there is no chunking along the first dimension and other dimensions are automatically chunked based on the default chunk size set in Dask’s configuration. kwargs are passed along to dask.array.rechunk().

to_dask_array()[source]#

Returns signal with data as a Dask array.

Uses dask.array.asanyarray() to convert signal data to a Dask array.