This guide includes a Continuous Wavelet Transform (CWT), significance tests from based on Torrence and Compo (1998) and Cross Wavelet Analysis (CWA) based on Maraun and Kurths(2004).
Replaced bottleneck with logically equivalent code. There's a section in the code which appears to be useless, and is causing significant performance issues with large time series.
In line 169: k_pos is independent of k_neg: therefore we may just replace it with its final value.
Lines 170/171 overwrite k_neg every pass. Therefore, the final value of k_neg only depends on the final value of k_pos.
I was taking a significant performance hit for time series of length > 100,000. It's obvious now from the code why: the for loop (line 168) is linear in the time series length, and unnecessarily allocates/deallocates memory repeatedly, with O(n^2) memory used, since the length of k_neg is the same as the iterator i. The exact value is something like (n / 2) (n /2 + 1) / 2 excess memory operations.
Hi @mikesha2 , thanks for pointed this out.
I confess that I write scripts without worrying with the best performance.
Thanks for the insight. Sorry it took me so long to approved it.
Mabel
Replaced bottleneck with logically equivalent code. There's a section in the code which appears to be useless, and is causing significant performance issues with large time series.
In line 169: k_pos is independent of k_neg: therefore we may just replace it with its final value.
Lines 170/171 overwrite k_neg every pass. Therefore, the final value of k_neg only depends on the final value of k_pos.
I was taking a significant performance hit for time series of length > 100,000. It's obvious now from the code why: the for loop (line 168) is linear in the time series length, and unnecessarily allocates/deallocates memory repeatedly, with O(n^2) memory used, since the length of k_neg is the same as the iterator i. The exact value is something like (n / 2) (n /2 + 1) / 2 excess memory operations.