-
Notifications
You must be signed in to change notification settings - Fork 415
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
'gpm' is not a defined unit #907
Comments
I guess I should say I would expect the code not to crash, as gpm and m are technically not the same. |
I've come across this quite often as well (with both
@dopplershift and @jrleeman, should we add these units that commonly come across in THREDDS converted files ( |
Does pint do anything with |
Damn yankee--why not 'grams / minute'? 'gpm' is a bit of an abomination as it's not technically CF-compliant. One option is to add the units as aliases in pint, though that feels like a bit of a hack. Another option is to have |
If we add the following to units.define('geopotential_meter = meter = gpm') Then we get something like >>> h = 5000 * units('gpm')
>>> h.units
<Unit('geopotential_meter')>
>>> h.to_base_units()
<Quantity(5000.0, 'meter')> To me, this seems like the cleanest solution given how prevalent this bizarre unit is (but I could be convinced otherwise as well). |
That looks ok to me...but is it strictly correct? |
At least between (geometric) height and geopotential height, no, it is only approximately correct...here's the exact formula: (Wallace and Hobbs 3.22) But, in most cases in practice I've seen height and geopotential height assumed to be equal in the troposphere. Along with that, the unit I've usually seen for geopotential height is just regular meters. If we're going with correctness of the unit entity itself, I would think so, since this defines a new unit |
So the downside of not just forcing it to meters is that when (if?) we use the |
Having "meters" and "special meters" seems... silly, but that's a different rant. If the dimensionality is meters, then I think we stick to that. caveat emptor |
I think it is best to see the 'gpm' as essentially a marker that this distance is the result of a particular approximation. A common operation would be to multiply geopotential height by g0 to compute geopotential, and the result of that computation should have units of m2/s2 (or J/kg), with no gpm in sight. Although I could see someone studying the mesosphere wanting to convert gpm to actual m, there is the extra complication that height differences will vary depending on z (i.e., a delta Z of 1 gpm is very close to a delta z of 1 m in the troposphere, but is something like a delta z of 0.97 m in the mesosphere, if I'm doing my math right). Or, in math terms, delta Z = (g/g0) delta z, where g is the actual gravitational acceleration (a function of height). |
After working on some more examples with this and looking at past discussions, I want to alter my previous comment on the correctness of 'geopotential_meter' as a unit. While I can definitely see usefulness in a marker/placeholder to represent that it isn't a true geometric length, I'm not really sure that the unit itself a good place to do that, since 'geopotential_meter' or 'gpm' isn't a proper unit in the sense of unit arithmetic (i.e. how can we know what we are multiplying by should or should not cancel out 'gpm' by units alone) or CF-compliance/UDUNITS compatibility. So, I think I'd now prefer the solution of "fixing" the unit in (Also, I'm sorry for keeping on coming back to this, but it has been bothering me and I'd like to see a fix for it.) |
The following code:
generates this output:
I expected the height units to be considered interchangeable with meters.
Python 3.6.5
0.8.0+53.g20f507e
The text was updated successfully, but these errors were encountered: