NCAR / ccpp-framework

Common Community Physics Package (CCPP)
http://www.dtcenter.org/community-code/common-community-physics-package-ccpp/
Other
26 stars 64 forks source link

CCPP does not support units that are used by high-altitude physics #603

Closed climbfuji closed 4 weeks ago

climbfuji commented 1 month ago

Description

A while back we discussed the use of units for lightning indices, flashes per 5 minutes. Those units were rejected and the units changed to flashes min-1. This should have been just min-1 since it's just a rate (counting something), but that's not the point.

I am updating the CCPP framework for NEPTUNE, which has high altitute physics hooked up through CCPP. The CCPP framework complains about invalid units 2nT (2 nanotesla), which are in fact the correct units for that quantity (AP index): https://www.geomag.bgs.ac.uk/data_service/data/magnetic_indices/apindex.html#:~:text=The%203-hourly%20ap%20and%20the%20daily%20Ap%20indices,planetary%20magnetic%20activity%20indices%2C%20with%20units%20of%202nT.

What do we do? Force the physics developers to use non-standard units for their field? It would be possible to ask them to scale everything by a factor of 2 / 0.5 back and forth, but this variable is present in so many schemes, and 2nT is indeed the official unit for it.

Steps to Reproduce

Add a variable with unit 2nT to any metadata file and run capgen or prebuild on it

Additional Context

n/a

Output

parse_source.CCPPError: Invalid 'units' property value, '2nT', at ion_neutral_physics.meta:230
peverwhee commented 1 month ago

I'd vote for loosening the regex restrictions to allow the 2nT (allow leading numbers)

climbfuji commented 1 month ago

I'd vote for loosening the regex restrictions to allow the 2nT (allow leading numbers)

I wonder if a month later or so, we come across a case kg 2m s-1 for some other physics, or erg (3.14s)-1 ?

mkavulich commented 1 month ago

I don't know how I feel about a "compromise" position here. We should either allow for this weirdness or not. I lean towards "not", but I could be persuaded by extraordinary circumstances.

The Ap Index, strictly via the mathematics of how it's derived, does indeed technically have units of 2nT. But the definition is also quite ad hoc, as can be seen here. I would feel justified in calling this "unitless", since it is really an index strictly defined by another discrete index (Kp). And indeed I was able to find at least one paper that attests to it being unitless in some contexts:

To this end, Kp is converted to the linear ap, the three-hourly equivalent planetary amplitude according to Table 3. Sometimes, and to a certain degree confusingly, ap is assigned a unit of 2 nT, sometimes it is regarded as an index without units (Siebert, 1971). b Siebert (1971) recommends to regard ap as dimension-less index and to ignore the unit of 2 nT.

mwaxmonsky commented 1 month ago

Are there any units library that parse this natively? If not, then I'm leaning toward not as well.

climbfuji commented 1 month ago

@mkavulich Thanks for looking into this. I agree with your assessment, and the HA physics developers at NRL also brought up the idea of treating it as unitless if necessary.

dustinswales commented 4 weeks ago

If 2nT is a valid unit, then we should allow it. What is the harm in expanding the REGEX to allow this? Or going to the extreme, what if we allowed anything as a valid unit? What would happen? (I don't think anything, but maybe I'm missing something fundamental?)

climbfuji commented 4 weeks ago

Thankfully, we can kick that can down the road as we've agreed to make the AP index unitless. I'll close this, but likely a similar discussion will come up in the future.