hyperion-rt / hyperion

Hyperion Radiative Transfer Code
http://www.hyperion-rt.org
BSD 2-Clause "Simplified" License
52 stars 26 forks source link

m.write() not working #233

Open astrofroger opened 1 year ago

astrofroger commented 1 year ago

Hi Thomas!

I am trying to run the model following http://docs.hyperion-rt.org/en/stable/tutorials/example_class1.html but it fails with: ###################################################

m.write('class1_example1.rtin') /home/user/.local/lib/python3.11/site-packages/hyperion/densities/ulrich_envelope.py:434: RuntimeWarning: invalid value encountered in log

  • (np.log((np.sqrt(gamma_1) + 1) / (1. - np.sqrt(gamma_1))) Traceback (most recent call last): File "", line 1, in File "/home/user/.local/lib/python3.11/site-packages/hyperion/model/analytical_yso_model.py", line 862, in write m = self.to_model(merge_if_possible=merge_if_possible) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/.local/lib/python3.11/site-packages/hyperion/model/analytical_yso_model.py", line 729, in to_model g = virtual_file() ^^^^^^^^^^^^^^ File "/home/user/.local/lib/python3.11/site-packages/hyperion/util/functions.py", line 24, in virtual_file return h5py.File(random_id(), driver='core', backing_store=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib64/python3.11/site-packages/h5py/_hl/files.py", line 533, in init fid = make_fid(name, mode, userblock_size, fapl, fcpl, swmr=swmr) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib64/python3.11/site-packages/h5py/_hl/files.py", line 226, in make_fid fid = h5f.open(name, flags, fapl=fapl) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper File "h5py/h5f.pyx", line 106, in h5py.h5f.open OSError: Unable to open file (unable to open file) ###################################################

Actually it worked before, but failed after a reinstallation of Hyperion (0.9.10) and updating of the system baded python (3.11 currently).

Any way to fix this? Thanks a lot!

astrofroger commented 1 year ago

My solution to this issue is to change ####################################### return h5py.File(random_id(), driver='core', backing_store=False) ####################################### to ####################################### return h5py.File(random_id(), 'w', driver='core', backing_store=False) ####################################### Is it ok? Thanks!