uwacan.analysis.Spectrogram#

class Spectrogram(data, time=None, start_time=None, samplerate=None, frequency=None, frequency_band_lower=None, frequency_band_upper=None, bandwidth=None, dims=None, coords=None, attrs=None, **kwargs)[source]#

Bases: TimeFrequencyData

Handling of spectrogram data, both linear and banded.

Parameters:
dataarray_like

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

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. This is not the samplerate of the underlying time signal, but time steps of the time axis on the time-frequency data. 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.

frequencyarray_like, optional

The frequencies corresponding to the data. Mandatory if data is a numpy.ndarray.

bandwidtharray_like, optional

The bandwidth of each data point. Can be an array with per-frequency bandwidth or a single value valid for all frequencies.

dimsstr or [str], optional

The dimensions of the data. Must have the same length as the number of dimensions in the data. Mandatory used for numpy inputs, not used for xarray inputs.

coordsxarray.DataArray.coords

Additional coordinates for this data.

attrsdict, optional

Additional attributes to store with this data.

Methods

analyze_timedata(time_data, *[, ...])

Compute a spectrogram from time data.

from_dataset(data, **kwargs)

Instantiate the class from a dataset.

plot(**kwargs)

Make a heatmap trace of this data.

Inherited methods

apply(func, *args, **kwargs)

Apply some function to the contained data.

estimate_bandwidth()

Estimate the bandwidth of the frequency vector.

groupby(group)

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

Select a subset of the data from the coordinate indices.

listen([downsampling, upsampling, headroom])

Play back this time data over speakers.

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.

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

Generate rolling windows of 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.

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

Select a subset of the data over time.

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.

bandwidth

Compute bandwidth from frequency band edges.

coords

The coordinate (dimension) arrays for this data.

data

The contained data.

dims

The dimensions of this data.

frequency

The frequencies for the 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.