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,TimeDataHandling 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.ndarrayor axarray.DataArraywith the data.- timearray_like, optional
A
numpy.ndarraywithdtype=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
datais anumpy.ndarray, this has to be given. If thedatais axarray.DataArraywhich already has a time coordinate, this can be omitted.- levelsarray_like, optional
The dB level represented by the bins. Mandatory if
datais anumpy.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
datais anumpy.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_upperinstead.- 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
numpyinputs, not used forxarrayinputs.- coords
xarray.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 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
attrsAttributes stored in the data.
bandwidthCompute bandwidth from frequency band edges.
coordsThe coordinate (dimension) arrays for this data.
dataThe contained data.
dimsThe dimensions of this data.
frequencyThe frequencies for the data.
levelsThe dB levels the probabilities are for.
sampleratesizesMapping from dimension names to lengths.
timeTime coordinates for this data.
time_windowA
TimeWindowdescribing when the data start and stops.