GalSim
GalSim copied to clipboard
Add Quantity as a valid value_type in config
There are a few places in GalSim where we have unit-ful values as parameters to various things, which are documented to assume a particular unit. (E.g. our wavelengths are all in nm.) It would be nice if the user could pass an astropy.Quantity for such things and specify their units without worrying about whether their assumption matches ours. This is even more true for some imsim values where both m and mm are plausible units for various distances in the telescope.
Proposal: Let such parameters be specified in a config dict as:
- A float value as currently with the documented assumed units.
- An astropy.Quantity with whatever units the user wants (so long as dimensionally compatible ofc).
- A string that can eval into an astropy.Quantity
- A "Quantity" type that has two items:
value
andunit
. This lets thevalue
(a float) be further processed by the normal config processing, if that is desired.
As I understand it, astropy is already a dependency for GalSim, so this makes sense to me - it'll help some users and not complicate the installation.
Does astropy have convenience routines to check dimensional compatibility? At a quick glance, it looks like it does (since for example they've defined this error: https://docs.astropy.org/en/stable/api/astropy.units.UnitConversionError.html#astropy.units.UnitConversionError) so we wouldn't have to do any of that checking ourselves.