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 coherence order #452

Open shiness11 opened 1 year ago

shiness11 commented 1 year ago

Describe the bug When performing the wavelet coherence analysis on two datasets (a d13C record and eNd record from the same sediment core), the order that the timeseries are placed in the calculation gives slightly different scalograms.

To Reproduce Steps to reproduce the behavior: @CommonClimate has a copy of the notebook I have been working on, along with the relevant datasets. The two lines of code which should give the same result are: 1) coh = eNd1479_MPT.wavelet_coherence(d13C1479_MPT.flip()) and 2) coh = d13C1479_MPT.wavelet_coherence(eNd1479_MPT.flip()) Screenshots corresponding to lines 1 and 2 are below.

Expected behavior Based on conversations with @CommonClimate, the function should be reversible (other than the phase, which would be of opposite sign), so it's not clear why the two scalograms look slightly different.

Screenshots From line 1: Screen Shot 2023-07-05 at 11 56 05 AM From line 2: Screen Shot 2023-07-05 at 11 56 58 AM

Desktop (please complete the following information):

khider commented 6 months ago

The tau vector is calculated from the first time series, creating slightly different values.

CommonClimate commented 6 months ago

Thanks @khider! @shiness11 this explains the mystery. At some point we will improve the choice of a common tau vector (the time values at which the coherence is evaluated), but since it does not appear to make a material difference in most applications I've seen (including yours), this is not a high priority.