ValueError: Level value too high (max level for current data size and start_level is 1).

106 views
Skip to first unread message

sandeep...@gmail.com

unread,
Nov 12, 2022, 9:33:01 PM11/12/22
to PyWavelets
Hello friends. 

Greetings of the day

I am trying to find 1D SWT of a signal of dimension (783640, 102) using the below code:

db1=pywt.Wavelet('db1')
s=(twoD_dim[0],4*twoD_dim[1])
coefsi=np.zeros(s)
db1=pywt.Wavelet('db1')
for i in range(0,twoD_dim[0]):
temp=pywt.swt(twoD_hsi_data[i,:],db1,level=2,axis=-1)
coefsi[i,:]=np.ndarray.flatten(np.array(temp))
print(np.array(coefsi).shape)

I am getting the error ValueError: Level value too high (max level for current data size and start_level is 1).

Can anyone suggest me a possible solution for the above error.

Thank you all for your valuable time.




Deepu

unread,
May 22, 2023, 2:11:13 AM5/22/23
to PyWavelets
The error message you're encountering indicates that the level value you specified for the SWT (Stationary Wavelet Transform) is too high for the given data size and start level.

In your code snippet, you set `level=2` when calling `pywt.swt`, which means you are attempting to perform the SWT with a level of 2. However, the error suggests that the maximum level allowed for your data size and start level is 1.

To resolve this issue, you can either decrease the level value or adjust the start level. Here are a couple of possible solutions:

1. Reduce the level value:
```python
temp = pywt.swt(twoD_hsi_data[i, :], db1, level=1, axis=-1)
```
By setting `level=1`, you perform the SWT with a level of 1, which is within the allowed range.

2. Adjust the start level:
```python
temp = pywt.swt(twoD_hsi_data[i, :], db1, level=2, start_level=0, axis=-1)
```
Here, you keep the `level=2` but set `start_level=0` to start the SWT from level 0. This allows you to go up to level 1 within the allowed range.

Choose the approach that suits your requirements and the nature of your data.

Note: Keep in mind that the maximum level for the SWT is determined by the size of the data. If you need to go beyond the maximum level, you might need to downsample or resize your data to accommodate the desired level.

I hope this helps! Let me know if you have any further questions.
Message has been deleted

GUMMA SRI SOUGANDHIKA 121AD0020

unread,
Apr 4, 2024, 1:46:43 AMApr 4
to PyWavelets
I am working on a music dataset, and I have faced the same error.
I have tried with the values as follows, and it worked well.
This method has worked well for large audio dataset processing as well.

coeffs = pywt.swt(data, db1, level=1, start_level=0)

Thank you!
Reply all
Reply to author
Forward
0 new messages