GalSim icon indicating copy to clipboard operation
GalSim copied to clipboard

Add Quantity as a valid value_type in config

Open rmjarvis opened this issue 2 years ago • 1 comments

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:

  1. A float value as currently with the documented assumed units.
  2. An astropy.Quantity with whatever units the user wants (so long as dimensionally compatible ofc).
  3. A string that can eval into an astropy.Quantity
  4. A "Quantity" type that has two items: value and unit. This lets the value (a float) be further processed by the normal config processing, if that is desired.

rmjarvis avatar Nov 17 '22 14:11 rmjarvis

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.

rmandelb avatar Nov 21 '22 01:11 rmandelb