MathEXLab/PySPOD

Tutorial 2 fails in spod.get_data

Opened this issue · 8 comments

Hello,
when running the tutorial 2,in the line 138 'data = spod.get_data(data)' and the error shows up. Could anyone give me a hand to solve it?
Best wishes!
XUxu

The error log is shown as below:
Reconstructed data saved in: D:\spod\PySPOD-main\tutorials\tutorial2\spod_results\nfft730_novlp0_nblks10\coeffs_0_365\reconstructed.npy
Elapsed time: 0.45338940620422363 s.
C:\ProgramData\anaconda3\envs\spodProject\lib\site-packages\matplotlib-3.9.0-py3.9-win-amd64.egg\matplotlib\cbook.py:1762: ComplexWarning: Casting complex values to real discards the imaginary part
return math.isfinite(val)
C:\ProgramData\anaconda3\envs\spodProject\lib\site-packages\matplotlib-3.9.0-py3.9-win-amd64.egg\matplotlib\cbook.py:1398: ComplexWarning: Casting complex values to real discards the imaginary part
return np.asarray(x, float)
C:\ProgramData\anaconda3\envs\spodProject\lib\site-packages\matplotlib-3.9.0-py3.9-win-amd64.egg\matplotlib\cbook.py:1762: ComplexWarning: Casting complex values to real discards the imaginary part
return math.isfinite(val)
C:\ProgramData\anaconda3\envs\spodProject\lib\site-packages\matplotlib-3.9.0-py3.9-win-amd64.egg\matplotlib\cbook.py:1398: ComplexWarning: Casting complex values to real discards the imaginary part
return np.asarray(x, float)
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm 2023.3.2\plugins\python\helpers\pydev\pydevd.py", line 1534, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files\JetBrains\PyCharm 2023.3.2\plugins\python\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "D:\spod\PySPOD-main\tutorials\tutorial2\tutorial2.py", line 138, in
data = spod.get_data(data)
File "C:\ProgramData\anaconda3\envs\spodProject\lib\site-packages\pyspod-2.0.0-py3.9.egg\pyspod\spod\base.py", line 826, in get_data
d = d[...,np.newaxis]
File "C:\ProgramData\anaconda3\envs\spodProject\lib\site-packages\xarray-2024.6.0-py3.9.egg\xarray\core\dataarray.py", line 876, in getitem
return self.isel(indexers=self._item_key_to_dict(key))
File "C:\ProgramData\anaconda3\envs\spodProject\lib\site-packages\xarray-2024.6.0-py3.9.egg\xarray\core\dataarray.py", line 1501, in isel
ds = self._to_temp_dataset()._isel_fancy(
File "C:\ProgramData\anaconda3\envs\spodProject\lib\site-packages\xarray-2024.6.0-py3.9.egg\xarray\core\dataset.py", line 3029, in _isel_fancy
new_var = var.isel(indexers=var_indexers)
File "C:\ProgramData\anaconda3\envs\spodProject\lib\site-packages\xarray-2024.6.0-py3.9.egg\xarray\core\variable.py", line 1033, in isel
return self[key]
File "C:\ProgramData\anaconda3\envs\spodProject\lib\site-packages\xarray-2024.6.0-py3.9.egg\xarray\core\variable.py", line 797, in getitem
dims, indexer, new_order = self._broadcast_indexes(key)
File "C:\ProgramData\anaconda3\envs\spodProject\lib\site-packages\xarray-2024.6.0-py3.9.egg\xarray\core\variable.py", line 642, in _broadcast_indexes
return self._broadcast_indexes_outer(key)
File "C:\ProgramData\anaconda3\envs\spodProject\lib\site-packages\xarray-2024.6.0-py3.9.egg\xarray\core\variable.py", line 724, in _broadcast_indexes_outer
return dims, OuterIndexer(tuple(new_key)), None
File "C:\ProgramData\anaconda3\envs\spodProject\lib\site-packages\xarray-2024.6.0-py3.9.egg\xarray\core\indexing.py", line 434, in init
raise TypeError(
TypeError: invalid indexer array, does not have integer dtype: array(None, dtype=object)
python-BaseException

@MemorXuxu Thank you for raising this issue. Do you have a minimum reproducible example?

@MemorXuxu Thank you for raising this issue. Do you have a minimum reproducible example?

Hello,Mengaldo
I run the tutorial 2 (https://github.com/MathEXLab/PySPOD/tree/main/tutorials/tutorial2) under folder test and it cannot run successfully, The error occor at data = spod.get_data(data) at line 136.
Moreover, the version of numpy is 1.26.4. And I find that the newer version of numpy (2.0.0) cannot be used. I guest whether the version of numpy is wrong since the requirement of pyspod doesn't exist.

@MemorXuxu Thank you for raising this issue. Do you have a minimum reproducible example?

Interestingly, the code in test_tutorial can run scuccessfully while the single tutorial under Tutorial folder can't since the code between them is different. I think it's a small mistake and I believe the code under test is rigth!

@MemorXuxu Thank you for spotting this!
Do you want to contribute suggesting the modification needed?

@mengaldo
It's OK if it's convient ^_^. BTW,it's a great library and I'm happy that I can make a small contribution to it.

Another question, I don't whether I should create a new issus or not. When the SPOD is all calculated, how can I save all the state in JupyterBook or Python. When I need to post-processing the result, I need to perform all the calculation again which costs much time. However, in the result folder, there are many results(.npy) and I think it's the finally result of SPOD. Is it possible to just specify the results_dir data or anything eles to reload these results for postprocessing and visualization.

@MemorXuxu Thank you!
Yes, you should be able to save the results and reload them for post processing, without recalculating them every time.
Not sure however whether we show how.
To do this, we should load the .npy files of the modes, and the .npz file with the frequencies, and manually plot the modes, using the routines in post processing.

@mengaldo Thank you very much!