Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Quantity as a valid value_type in config #1194

Open
rmjarvis opened this issue Nov 17, 2022 · 1 comment
Open

Add Quantity as a valid value_type in config #1194

rmjarvis opened this issue Nov 17, 2022 · 1 comment
Labels
config Related to the config-processing functionality. desc Of possible interest to LSST DESC members looking for a project notation/conventions Related to choices of units, names of things, other semi-arbitrary conventions

Comments

@rmjarvis
Copy link
Member

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 rmjarvis added notation/conventions Related to choices of units, names of things, other semi-arbitrary conventions config Related to the config-processing functionality. desc Of possible interest to LSST DESC members looking for a project labels Nov 18, 2022
@rmandelb
Copy link
Member

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 rmandelb added this to the v2.6 milestone Jul 17, 2024
@rmjarvis rmjarvis removed this from the v2.6 milestone Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config Related to the config-processing functionality. desc Of possible interest to LSST DESC members looking for a project notation/conventions Related to choices of units, names of things, other semi-arbitrary conventions
Projects
None yet
Development

No branches or pull requests

2 participants