Skip to content

Spectra and spectrograms

powerspectrum and energyspectrum compute one-sided spectra of regular time series via the FFT, returning an AbstractSpectrum whose lookup is frequency. Units carry through: a V-valued series sampled in s returns V^2/Hz for the power spectrum.

julia
using TimeseriesTools, Random
Random.seed!(0)
x = Timeseries(sin.( * 5 .* (0.0:0.001:9.999)) .+ 0.2randn(10000), 0.0:0.001:9.999)
S = powerspectrum(x, 0.1)
5001-element ToolsArray{Float64, 1}
├─────────────────────────────────────┴──────────────────────── dims ┐
𝑓 Sampled{Float64} 0.0:0.1:500.0 ForwardOrdered Regular Points
└────────────────────────────────────────────────────────────────────┘
   0.0  1.63034e-5
   0.1  1.65637e-5
   0.2  2.4919e-5
   0.3  1.99362e-5
   0.4  5.14178e-6

 499.6  1.58189e-5
 499.7  1.3494e-5
 499.8  1.72574e-5
 499.9  1.40631e-5
 500.0  2.44228e-6

The second argument is the minimum frequency to resolve (lower → longer windows). When the input is multivariate, each column is spectrally analysed independently and the result keeps the foreign dimensions.

Wavelet spectrograms

waveletspectrogram (enabled by using ContinuousWavelets) returns an AbstractSpectrogram with both time and frequency dimensions. A CUDA backend is available via using CUDA, ContinuousWavelets. See Extensions.

julia
using ContinuousWavelets
W = waveletspectrogram(x; β = 1.0)

Reference

TimeseriesTools.powerspectrum Function
julia
powerspectrum(x::AbstractTimeseries, f_min=samplingrate(x)/min(length(x)÷4, 1000); kwargs...)

Computes the average power spectrum of a time series x using the Welch periodogram method.

source
TimeseriesTools.energyspectrum Function
julia
energyspectrum(x::RegularTimeseries, f_min=0; kwargs...)

Computes the average energy spectrum of a regularly sampled time series x. f_min determines the minimum frequency that will be resolved in the spectrum. See _energyspectrum.

source

Missing docstring.

Missing docstring for waveletspectrogram. Check Documenter's build log for details.