FireDynamics / fdsreader

Python reader for FDS data
GNU General Public License v3.0
44 stars 18 forks source link

Error: module 'numpy' has no attribute 'math' in get_nearest_timestep #80

Open CBAlmeida13 opened 1 month ago

CBAlmeida13 commented 1 month ago

Dear fdsreader team,

I am learning how to use your tool with a simple example. Currently, I am figuring out how to display the slice information and came across an issue that I'm hoping you can help me with. Whenever I try to get the nearest time step, I get the following error:

Traceback (most recent call last): File "c:\Users\almeida\Documents\02_Studien_Literatur\02_Studien\08_fdsviewer\Trial_Room\Test_fdsreader.py", line 34, in it = slc.get_nearest_timestep(time=200) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\almeida\venv\Lib\site-packages\fdsreader\slcf\slice.py", line 314, in get_nearest_timestep if time > 0 and (idx == len(self.times) or np.math.fabs( ^^^^^^^ File "C:\Users\almeida\venv\Lib\site-packages\numpy__init.py", line 424, in getattr__ raise AttributeError("module {!r} has no attribute " AttributeError: module 'numpy' has no attribute 'math'. Did you mean: 'emath'?

My script Note that my goal is to eventually plot the information, following the example provided in your lecture materials. The rest of the code was omitted for simplicity.

import fdsreader as fds
import matplotlib.pyplot as plt
import numpy as np
from IPython.display import display
from PIL import Image

# Path to simulation data
path_to_sim_data = r'.\02_Studien_Literatur\02_Studien\08_fdsviewer\Trial_Room\Sim_Files'
sim = fds.Simulation(path_to_sim_data)

# Get the nearest slice
slc = sim.slices.get_nearest(x=2, z=2)

# Get the nearest timestep
it = slc.get_nearest_timestep(time=200)

Environment:

Python version: 3.12.2 numpy version: 2.0 FDS Version: 6.9.1

Could you provide some guidance on how to solve this issue? Is there any step I am missing? Your assistance would be greatly appreciated.

Thank you!

lu-kas commented 1 month ago

Since a few weeks, we started having issues, which we believe could be to the new major version of numpy. I will look into your issue, which we have not seen before. Yet, as an intermediate workaround, could you please give it a try with a 1.* version of numpy? Thanks.

CBAlmeida13 commented 1 month ago

Thank you for the quick reply!

I have tested with numpy 1.26.4, and the issue does not occur. This workaround resolves my problem for now.

Should I leave the issue open for further investigation into compatibility with numpy 2.0, or would you prefer to close it?