SNEWS2 / snewpy

A Python package for working with supernova neutrinos
https://snewpy.readthedocs.io
BSD 3-Clause "New" or "Revised" License
26 stars 19 forks source link

snowglobes.SimpleRate - remove hardcoded binning #218

Closed Sheshuk closed 1 year ago

Sheshuk commented 1 year ago

What I want

As the developer I want our snowglobes_interface to be easily adaptable for the new materials in SNOwGLoBES. New materials can have different energy binning, so I'd like SimpleRate to be able to read the binning from SNOwGLoBES and use it when computing the rate

What we have now

I see that the energy binning in SimpleRate is defined as https://github.com/SNEWS2/snewpy/blob/b35379952fe18aedc28cdb106f1ee9e7ad08b082/python/snewpy/snowglobes_interface.py#L161-L163

What I suggest

We are already reading this binning for each material: https://github.com/SNEWS2/snewpy/blob/b35379952fe18aedc28cdb106f1ee9e7ad08b082/python/snewpy/snowglobes_interface.py#L101-L107 so there is no need to guess energies from the material name - we could use self.binning[material] - after we transform it to the binning array(s).

JostMigenda commented 1 year ago

Sounds good to me.

Just to make sure I understand this correctly: This would not affect any materials in the current official SNOwGLoBES version; it is only for future or custom materials, right?

Sheshuk commented 1 year ago

Just to make sure I understand this correctly: This would not affect any materials in the current official SNOwGLoBES version; it is only for future or custom materials, right?

Right. Although it will make SimpleRate read the binning for current materials as well (the same way, as SNOwGLoBES used to do it), but numerically nothing will change. Just less hardcoded values.