Cannot convert MTSpectrum{Nothing,Nothing,Nothing} to series data for plotting error with welch

Issue #29 resolved
Robert Guggenberger created an issue
using Plots
using Multitaper
x = range(0.001, stop=1,length=1000)
y = sin.(x * 10 * 2 * pi)
S = welch(y, 1)
plot(S)

Also, S is

(MTSpectrum{Nothing,Nothing,Nothing}(0.0:0.001001001001001001:0.4994994994994995, [0.015936772535655598, 0.015925387520743562, 0.015752379880627148, 0.014819418884591625, 0.011260355324828943, 0.001761777483172212, 0.7591078724053393, 34.5005845577547, 35.90861575165726, 36.393440928830685  …  1.8212043266627503e-9, 1.8168338541773601e-9, 1.812951072005789e-9, 1.8095552445075884e-9, 1.8066457284109755e-9, 1.8042219727005936e-9, 1.8022835184591299e-9, 1.8008299987331564e-9, 1.799861138381087e-9, 1.7993767540365368e-9], nothing, MTParameters(4.0, 6, 1000, 1.0, 999, 1, 0.0), nothing, nothing, nothing, nothing), NaN)

and shouldn’t the first field be 0.0:1.0:500? Furthermore, the fields of the structure can not be accessed as they could with the output from multispec

Comments (2)

  1. Chris Geoga

    Hi Robert---the first field there is actually a frequency grid, which is parameterized to be on [0,1). This function returns a tuple, so the call might be better written as

    (S, effective_bandwidth) = welch(y, 1)
    

    from which point you could interact with S as usual. Commit 124359a adds a note in the documentation about this and fixes the NaN edge case that your snippet also reveals.

    I’m going to mark this resolved, but please let me know if I’ve missed your point or you think there’s a better mitigation or documentation for this behavior.

  2. Log in to comment