SWIFTSIM / pipeline-configs

Configuration files for the `pipeline`, each for different simulation sub-grid models.
1 stars 9 forks source link

Pipeline errs when registering new dust properties #187

Closed EvgeniiChaikin closed 2 years ago

EvgeniiChaikin commented 2 years ago

Hi @bwvdnbro @james-trayford

After the merge #180, I get the following error when running the pipeline

Using registration functions contained in /cosma7/data/dp004/dc-chai1/pipeline-configs/colibre/registration.py
/cosma/home/dp004/dc-chai1/.local/lib/python3.6/site-packages/unyt/array.py:1754: RuntimeWarning: invalid value encountered in true_divide
  inp0.view(np.ndarray), inp1.view(np.ndarray), out=out_func, **kwargs
/cosma/home/dp004/dc-chai1/.local/lib/python3.6/site-packages/unyt/array.py:1754: RuntimeWarning: divide by zero encountered in true_divide
  inp0.view(np.ndarray), inp1.view(np.ndarray), out=out_func, **kwargs
/cosma7/data/dp004/dc-chai1/velociraptor-python/velociraptor/catalogue/derived.py:1198: RuntimeWarning: divide by zero encountered in log
Traceback (most recent call last):
  File "/cosma7/data/dp004/dc-chai1/pipeline/swift-pipeline", line 297, in <module>
    registration_file_path=registration_filename,
  File "/cosma7/data/dp004/dc-chai1/velociraptor-python/velociraptor/__init__.py", line 86, in load
    catalogue.register_derived_quantities(registration_file_path)
  File "/cosma7/data/dp004/dc-chai1/velociraptor-python/velociraptor/catalogue/catalogue.py", line 429, in register_derived_quantities
    self.derived_quantities = DerivedQuantities(registration_file_path, self)
  File "/cosma7/data/dp004/dc-chai1/velociraptor-python/velociraptor/catalogue/derived.py", line 96, in __init__
    self._register_quantities()
  File "/cosma7/data/dp004/dc-chai1/velociraptor-python/velociraptor/catalogue/derived.py", line 110, in _register_quantities
    exec(handle.read())
  File "<string>", line 1240, in <module>
  File "<string>", line 240, in register_dust
UnboundLocalError: local variable 'dust_mass_total_hi' referenced before assignment

This happens because in the function register_dust(self, catalogue, aperture_sizes, Z_sun, twelve_plus_log_OH_solar) in colibre/registration.py, some variables are defined inside thetry branch of a try except block but then are referenced outside the block. Thus, if the code enters the except branch instead of the try branch, the variables remain undefined, which later in the code results in the error described above.

Looking at what the velociraptor tries to register in the try branch, I can see that now we have, e.g., small_grain_mass_{aperture_size}_kpc computed in apertures but I can't find any fields with similar names in the VR config (https://gitlab.cosma.dur.ac.uk/EAGLE/swift-colibre/-/blob/master/examples/COLIBRE_ICs/vrconfig_3dfof_subhalos_SO_hydro.cfg). This makes me think that the latter needs an update.

bwvdnbro commented 2 years ago

I have created a fix that will just set the missing fields to zero.

We discussed updating the VR config file in #180, but I don't know what happened to that in the end.

MatthieuSchaller commented 2 years ago

The VR config should have been merged when merging the new dust model into master. If not, then we should fix the config we use in the repository.

james-trayford commented 2 years ago

Here is the VR config in question with updated fields https://gitlab.cosma.dur.ac.uk/EAGLE/swift-colibre/-/blob/hawk-scaling-test/examples/COLIBRE_ICs/vrconfig_3dfof_subhalos_SO_hydro.cfg

james-trayford commented 2 years ago

We discussed updating the VR config file in https://github.com/SWIFTSIM/pipeline-configs/pull/180, but I don't know what happened to that in the end.

This was merged into the code repo but not the pipeline I think, My impression was that the pipeline config vr config was minimal for backward compatibility, while the repo was up to date with latest code and post-processing script, though happy to merge the config files