cutcutcodec.core.signal.psd.welch

cutcutcodec.core.signal.psd.welch(signal: Tensor, freq_resol: Real = None) Tensor[source]

Estimate the power spectral density (PSD) with the Welch method.

Parameters

signaltorch.Tensor

The stationary signal on witch we evaluate the PSD. The tensor can be batched, so the shape is (…, n).

freq_resolfloat, default=10

The norlised frequency resolution in Hz, assuming a sample rate of 1. It is the lowest denoised frequency as well. Higher it is, better is the resolution but noiser it is.

Returns

psdtorch.Tensor

An estimation of the power spectral density, of shape (…, m).

Examples

>>> import torch
>>> from cutcutcodec.core.signal.psd import welch
>>> signal = torch.randn((32, 2, 768000))
>>> psd = welch(signal)
>>>
>>> # freq = torch.fft.rfftfreq(2*psd.shape[-1]-1, 1/48000)
>>> # import matplotlib.pyplot as plt
>>> # _ = plt.plot(freq, psd[0].T)
>>> # plt.show()
>>>