LinkedEarth / Pyleoclim_util

Python Package for the Analysis of Paleoclimate Data. Documentation at
https://pyleoclim-util.readthedocs.io
GNU General Public License v3.0
88 stars 33 forks source link

Wavelet significance (`ar1asym`) #268

Closed Mattriks closed 1 year ago

Mattriks commented 2 years ago

Describe the bug
For ar1asym, wavelet and wavelet signif_test have different defaults wrt standardizing the time series i.e. wavelet() standardizes the time series, but signif_test(method='ar1asym') assumes the time series is not standardized i.e. $\text{Var}(time\text{ }series)$ is taken into account in the test. Currently, for method='ar1asym' the default settings will only work if $\text{Var}(time\text{ }series) \sim 1$.

To Reproduce
Example below

Expected behaviour
The white signficance contour on the right plot should "look" the same as on the left (irrespective of time series variance).

Solutions
Make signif_test respond to wavelet(settings={'standardize':Bool})

Notes
I didn't see any instructions that say you have to set {'standardize':False} in wavelet for the wavelet signif_test to plot properly. Otherwise it seems to easy to produce an incorrect plot using default settings.

Mattriks commented 2 years ago

Example:


# This is Li et al. (2013) Nino3.4 series
# Here I rescale n34a5 = n34a*0.5

n34a = pyleo.Series(time=Dli.Year.values, value=Dli.N34a.values, time_name='Year (CE)', label='Nino3.4')
n34a5= pyleo.Series(time=Dli.Year.values, value=0.5*Dli.N34a.values, time_name='Year (CE)', label='Nino3.4')
# [n34a.value.std(), n34a5.value.std()]

wav1 = n34a.wavelet()
wav1_sig = wav1.signif_test(method='ar1asym', qs=[0.9])
wav1_sig.plot(title='σ ~ 1', ax=ax1, cbar_style={'label':''})

wav2 = n34a5.wavelet(settings={'standardize':True}) # the default
wav2_sig = wav2.signif_test(method='ar1asym', qs=[0.9])
wav2_sig.plot(title='σ ~ 0.5 ', ax=ax2, ylabel='')

wavar1

khider commented 2 years ago

Which version are you using?

Mattriks commented 2 years ago

v0.9.1. The relevant code lines (on master) are here and here. If wavelet(settings={'standardize':True}), then the variance should be changed to 1.

khider commented 1 year ago

Fixed in 5f7019. Will release with v0.9.2