pulsarbat.readers.BasebandReader#
- class pulsarbat.readers.BasebandReader(name, /, *, signal_type=<class 'pulsarbat.core.Signal'>, signal_kwargs={}, intensity=None, lower_sideband=False, **kwargs)[source]#
Wrapper around StreamReader from the
baseband
package.- Parameters:
- name, **kwargs
Arguments to pass on to
baseband.open()
to create a reader viabaseband.open(name, 'rs', **kwargs)
.- signal_typesubclass of
Signal
, default:Signal
Type of signal that will be returned by
read()
.- signal_kwargs
dict
, optional Additional
kwargs
to pass on tosignal_type
when creating a Signal object. Must not includesample_rate
orstart_time
as dictionary fields.- intensitybool, optional
Whether the data is intensity data. If
signal_type
is a subclass ofIntensitySignal
, assumed to be True. Ifsignal_type
is a subclass ofBasebandSignal
, assumed to be False. Default is False.- lower_sidebandbool or array-like, optional
Whether the data is lower-sideband (LSB) data. Default is False. If not a boolean, must be an array-like of booleans with the same shape as the
sample_shape
of original data as read by thebaseband
StreamReader.
Attributes
complex_data
Whether the data is complex-valued.
dt
Sample spacing (
1 / sample_rate
).dtype
Data-type of data.
intensity
Where the data is intensity data (as opposed to raw baseband).
lower_sideband
Whether data is lower sideband (LSB) data.
ndim
Number of dimensions in data.
real_baseband
Whether the data is real-valued baseband data.
sample_rate
Sample rate of the signal data.
sample_shape
Shape of a sample.
shape
Shape of data.
start_time
Timestamp at first sample.
stop_time
Timestamp after last sample.
time_length
Length of signal in time units.
Methods
contains
(t, /)Whether time(s) are within the bounds of the signal.
dask_read
(offset, n, /, **kwargs)Read n samples from given offset using Dask arrays.
offset_at
(t, /)Returns nearest integer offset at given time.
read
(offset, n, /, **kwargs)Read n samples from given offset.
time_at
(offset, /[, unit])Returns time at given offset.
- contains(t, /)#
Whether time(s) are within the bounds of the signal.
- dask_read(offset, n, /, **kwargs)#
Read n samples from given offset using Dask arrays.
A convenience method equivalent to the
read()
method withuse_dask=True
.
- offset_at(t, /)#
Returns nearest integer offset at given time.
- read(offset, n, /, **kwargs)[source]#
Read n samples from given offset.
- Parameters:
- offset
int
Position to read from. Must be non-negative.
- n
int
Number of samples to read. Must be non-negative.
- **kwargs
Currently supported keyword arguments:
use_dask
– Whether to use dask arrays.chunks
– Chunk sizes if using dask arrays. By default, there is no chunking along the zeroth dimension.lock
– A lock object to prevent concurrent reads. Must be a context manager.
- offset
- Returns:
Signal
Signal of length n containing data that was read.
- time_at(offset, /, unit=None)#
Returns time at given offset.
- Parameters:
- Returns: