uwacan.analysis.SpectralProbabilitySeries#

class SpectralProbabilitySeries(data, levels=None, binwidth=None, frequency=None, frequency_band_lower=None, frequency_band_upper=None, bandwidth=None, scaling=None, num_frames=None, averaging_time=None, time=None, start_time=None, samplerate=None, **kwargs)[source]#

Bases: SpectralProbability, TimeData

Handling of spectral probability series data.

The spectral probability series is a series of specral probabilites computed from shorter segments of time data, i.e., a time-series of spectral probabilites. As such, it describes a time-varying spectral probability, e.g., the probability density function (histogram) at a certain frequency band as a function of sound pressure level, but varying over time.

Parameters:
dataarray_like

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

timearray_like, optional

A numpy.ndarray with dtype=datetime64[ns] containing time stamps for each spectral probability.

start_timetime_like, optional

The start time for the first spectral probability. 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 refers to the rate of the spectral probabilities, not the time signal used to compute the spectra. 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.

levelsarray_like, optional

The dB level represented by the bins. Mandatory if data is a numpy.ndarray.

binwidthfloat, optional

The width of the bins. Computed from the levels if not given.

frequencyarray_like, optional

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

frequency_band_lowerarray_like, optional

The lower edge of each frequency band. Must be provided together with frequency_band_upper. This is the preferred method for specifying frequency band information.

frequency_band_upperarray_like, optional

The upper edge of each frequency band. Must be provided together with frequency_band_lower. This is the preferred method for specifying frequency band information.

bandwidthfloat, optional

A single bandwidth value valid for all frequencies. This is a convenience method that assumes centered frequency bands. For per-frequency bandwidth, use frequency_band_lower/frequency_band_upper instead.

scalingstr, default=”density”

The scaling of the probabilities for the level bins in each frequency band. Must be one of:

  • "counts": the number of frames with that level;

  • "probability": how often a certain level occurred, i.e., counts / num_frames;

  • "density": the probability density at a certain level, i.e., probability / binwidth.

Note that the sum of counts (at a given frequency) is the total number of frames, the sum of probability is 1, and the integral of the density is 1.

num_framesint

The number of spectra used to compute each spectral probability.

averaging_timefloat

The duration from which each spectrum was averaged over. This is separate from the duration that each specral probability covers.

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_spectrogram(data, *[, binwidth, ...])

Compute spectral probability segments from a spectrogram.

analyze_timedata(data, *, filterbank[, ...])

Compute spectral probability segments in a recording.

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.

plot_percentile(percentile, **kwargs)

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.

with_probability_scale(new_scale)

Rescale the probability data according to a new scaling method.

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.

levels

The dB levels the probabilities are for.

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.