Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the performance of PrecomputedLowfreqPowerSpectrum #20

Open
JanJereczek opened this issue Mar 14, 2023 · 1 comment
Open

Improve the performance of PrecomputedLowfreqPowerSpectrum #20

JanJereczek opened this issue Mar 14, 2023 · 1 comment

Comments

@JanJereczek
Copy link
Contributor

Indicator summary

Compute ratio between low-frequency power spectrum and total power spectrum. What is "low-frequency"? Defined by user but standard is something like 10 lowest percent of the total power spectrum. Performs well wherever CSD is expected (conversely bad wherever CSD might be "hidden", e.g. by high signal-to-noise ratio).

Reference

Bury et al. (2020), Detecting and distinguishing tipping points using spectral early warning signals.

Codebase

Rely on FFTW for FFT

Implementation plan

struct LowfreqPowerSpectrum <: Function
    plan::Any
    i_lofreq::Int
end

function LowfreqPowerSpectrum(x::AbstractVector, width::Int; q_lofreq = 0.1)
    p = plan_rfft(x[1:width+1])
    fft_x = p*x
    i_lofreq = Int(round(length(fft_x) * q_lofreq))
    return LowfreqPowerSpectrum(p, i_lofreq)
end

function (lfps::LowfreqPowerSpectrum)(x::AbstractVector)
    ps = abs.(lfps.plan * x)
    return sum(ps[1:lfps.i_lofreq])
end
@JanJereczek JanJereczek added the new indicator Suggestion for a new transition indicator label Mar 14, 2023
@JanJereczek
Copy link
Contributor Author

Is now part of the code but needs to be made more performant. In particular, the FFTs have to be performed in place.

@JanJereczek JanJereczek added performance and removed new indicator Suggestion for a new transition indicator labels Mar 13, 2024
@JanJereczek JanJereczek changed the title Low-frequency power spectrum Improve the performance of PrecomputedLowfreqPowerSpectrum Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant