uwacan.TimeData#

class TimeData(data, time=None, start_time=None, samplerate=None, dims='time', coords=None, attrs=None, **kwargs)[source]#

Bases: DataArrayWrap

Handing data which varies over time.

This class is mainly used to wrap time-signals of sampled sounds. As such, the time data is assumed to be sampled at a constant samplerate.

Parameters:
dataarray_like

A numpy.ndarray or a xarray.DataArray with the time data.

timearray_like, optional

A numpy.ndarray with dtype=datetime64[ns] containing time stamps for the samples.

start_timetime_like, optional

The start time for the first sample in the signal. This should ideally be a proper time type, but it will be parsed if it is a string. Defaults to “now” if not given.

sampleratefloat, optional

The samplerate for this data, in Hz. If the data is a numpy.ndarray, this has to be given. If the data is a xarray.DataArray which already has a time coordinate, this can be omitted.

dimsstr or [str], default=”time”

The dimensions of the data. Must have the same length as the number of dimensions in the data. Only used for numpy inputs.

coordsxarray.DataArray.coords

Additional coordinates for this data.

attrsdict, optional

Additional attributes to store with this data.

Methods

from_dataset(dataset)

Instantiate the class from a dataset.

listen([downsampling, upsampling, headroom])

Play back this time data over speakers.

rolling([duration, step, overlap, squeeze_time])

Generate rolling windows of this data.

subwindow([time, start, stop, center, ...])

Select a subset of the data over time.

Inherited methods

apply(func, *args, **kwargs)

Apply some function to the contained data.

groupby(group)

isel([indexers, drop, missing_dims, drop_allnan])

Select a subset of the data from the coordinate indices.

load(path[, lookup_class])

Load data from a Zarr file and optionally restore the original class.

make_figure(**kwargs)

Create a plotly figure, styled for this data.

max([dim])

Maximum of this data, along some dimension.

mean([dim])

Average of this data, along some dimension.

min([dim])

Minimum of this data, along some dimension.

reduce(func, dim, **kwargs)

Apply a reduction function along some dimension in this data.

save(path[, append_dim])

Save the data to a Zarr file at the specified path.

sel([indexers, method, tolerance, drop, ...])

Select a subset of the data from the coordinate labels.

std([dim])

Standard deviation of this data, along some dimension.

sum([dim])

Sum of this data, along some dimension.

where(cond[, other, drop])

Filter elements from this object according to a condition.

Attributes

attrs

Attributes stored in the data.

coords

The coordinate (dimension) arrays for this data.

data

The contained data.

dims

The dimensions of this data.

samplerate

sizes

Mapping from dimension names to lengths.

time

Time coordinates for this data.

time_window

A TimeWindow describing when the data start and stops.