-
Notifications
You must be signed in to change notification settings - Fork 33
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
[Bug]: AttributeError: module 'scipy.signal' has no attribute 'cwt'
(deprecated, use PyWavelets instead)
#912
Comments
@tomvothecoder, @chengzhuzhang, @whannah1, I would prefer not to delay Unified testing for this. Could we consider constraining A second question: do you all have a strategy for detecting deprecation warnings like this (e.g. as outputs from your testing) so they can be addressed before they become a last-minute problem? I know tests spit out a lot of deprecation warnings and sometimes they're related to other tools (like xarray) but they can sometimes be a helpful indication that something like this is coming. |
@chengzhuzhang @tomvothecoder In case you miss it on the zppy side, note my comments on E3SM-Project/zppy#634 (reply in thread) as well. |
Yes, I agree with constraining
The QBO wavelets feature is relatively new (I think around Oct/2024) and SciPy 1.15.0 was released early Jan/2025. The integration tests spits out deprecation warnings and I normally document them to address ahead of time. This one unfortunately slipped through the cracks somehow. We'll stay more on top of it moving forward. |
Okay, thanks for the context. I just wouldn't want this kind of surprise to catch us on a regular basis. |
Just now seeing this - We've always been aware of this issue, and we've been comparing our wavelet analysis using both scipy and pywavelets. There is some sort of internal normalization going on that causes the two results to differ in magnitude slightly. This is why we didn't use pywavelets for the initial implementation of the QBO wavelet spectra. However, in practice, this difference doesn't matter at all as long as all spectra are computed with the same package, so I don't see a problem updating things to use pywavelets whenever someone has time. |
@tomvothecoder how should I proceed with zppy's release candidate?
|
@whannah1 thank you for your insights! Good to know that both methods have been tested and using pywavelets would work just fine. I'm wondering if you could provide the equivalent |
I think 1. is fine. We'll merge PR #907 with the constraint for |
To be clear, we never found an "equivalent" implementation due to the magnitude issue I mentioned previously. Here's some python routines I used when investigating the differences that might be helpful: import scipy, pywt
#---------------------------------------------------------------------------------------------------
def get_psd_from_wavelet_scipy(data):
deg = 6
period = np.arange(1, longest_period + 1)
freq = 1 / period
widths = deg / (2 * np.pi * freq)
cwtmatr = scipy.signal.cwt(data, scipy.signal.morlet2, widths=widths, w=deg)
psd = np.mean( np.square( np.abs(cwtmatr) ), axis=1)
return (period, psd)
#---------------------------------------------------------------------------------------------------
def get_psd_from_wavelet_pywt(data):
deg = 6
period = np.arange(1, longest_period + 1)
widths = deg / ( 2 * np.pi / period )
[cfs, freq] = pywt.cwt(data, scales=widths, wavelet='cmor1.5-1.0')
psd = np.mean( np.square( np.abs(cfs) ), axis=1)
period = 1 / freq
return (period, psd)
#--------------------------------------------------------------------------------------------------- |
@whannah1 thanks a lot! |
What happened?
Per https://docs.scipy.org/doc/scipy-1.12.0/reference/generated/scipy.signal.cwt.html:
What did you expect to happen? Are there are possible answers you came across?
dev.yml
,ci.yml
andpyproject.toml
scipy.signal.cwt
with PyWaveletse3sm_diags/e3sm_diags/driver/qbo_driver.py
Lines 410 to 421 in df10271
Minimal Complete Verifiable Example (MVCE)
No response
Relevant log output
Anything else we need to know?
Found in PR #907, where integration tests are breaking due to this issue.
Related SciPy docs:
Related PyWavelets docs:
Environment
Latest
e3sm_diags
onmain
scipy=1.15.1
The text was updated successfully, but these errors were encountered: