-
Notifications
You must be signed in to change notification settings - Fork 64
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 unit conversion from degrees to radians, address isssue #309 #311
Add unit conversion from degrees to radians, address isssue #309 #311
Conversation
@gold2718 @davegill @cacraigucar @grantfirl here is an interesting question - what are the official units to use for radians and degrees? I googled around to get some idea on what is used most. Some websites say |
Glad you asked. For radians, it is Note these are all from UDUNITS which also accepts things like |
Now I regret that I asked ;-) that's more complicated than what I wanted to hear. |
…ees to radians and vice versa
405e3c2
to
f375880
Compare
Ok, for the moment I will implement "radian" to "degrees" (for variables that are not latitude or longitude), "degrees_north" and "degrees_east". |
Do we have to accept everything for the CCPP? How about just |
I would be ok with limiting it to those three, but we also need to have just "degree" if you think about variables such as the angle between the wind normal component on an MPAS edge and the meridional component, for example. |
I'd recommend we be consistent with the use or non-use of "s" for degree(s) and radian(s). Either "degree_east", "degree_north", "degree" and "radian" or "degrees_east", "degrees_north", "degrees" and "radians". Since we are choosing specifically for CCPP, I personally like the plural better, but feel more strongly about there being consistency than I do on which flavor. |
That was my feeling, too - use plural for both. But as @gold2718 said udunits as a de-facto-standard (?) has radian singular and degrees plural. It's fine if we depart from that, but we all need to agree on this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks okay. Comment for future consideration.
def radian__to__degrees(): | ||
"""Convert radian to degrees""" | ||
return '57.295779513{kind}*{var}' | ||
|
||
def degrees__to__radian(): | ||
"""Convert degrees to radian""" | ||
return '{var}/57.295779513{kind}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While correct, this will eventually run afoul of efforts to standardize constants.
We should revisit (e.g., via pi / 180.0{kind}
and its inverse) this then (i.e., when a universal value for pi is available to CCPP modules).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree. I was wondering if I should plug in the value of math.pi and then "calculate" 57.x as 180.0/pi, but that seemed to be unnecessary to me. Rather implement it correctly once pi is defined and available as a Fortran constant through the CCPP framework. Then one can set pi = 1 and the world suddenly looks a lot more familiar ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should definitely add that to the physical constants dictionary. What good would it be if there was no version with c == ℏ == 1?
c == ℏ == π == 1 is only for advanced users.
FWIW, in this case, I don't agree with the standard (plural just sounds better to the ear), but I think we should adhere to standards where possible, so my vote is to follow udunits. |
Thanks. We need to decide early next week, because this PR is next or second in row in the commit queue. |
I just realized that udunits is inconsistent with plurality too. Sigh. If they accept the singular degree, though, I vote for: |
UDUNITS accepts |
So, is the conclusion to go for "degree", "degree_north", "degree_east", and "radian"? If so, I'll update the PRs and unit conversion entries, we are next in line to commit. Thanks! |
@climbfuji Yes, I think that is the consensus. |
But those are not in UDUNITS (except for |
degree_north and degree_east look like they are in this udunits list as aliases: https://www.unidata.ucar.edu/software/udunits/udunits-current/udunits/udunits2-common.xml Is that good enough? @gold2718 Where are you looking for udunits inclusion? |
Yow, it looks like my version is out of date. I am okay with this selection as an 'official' CCPP list. |
Ok, thanks, will proceed with this selection!
… On Jul 13, 2020, at 11:15 AM, goldy ***@***.***> wrote:
Yow, it looks like my version is out of date. I am okay with this selection as an 'official' CCPP list.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#311 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AB5C2RKEB4BX2JCA4Y64C2LR3M6KTANCNFSM4OVW5SCQ>.
|
…ramework into add_degrees_to_radians_conversion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
This PR contains the following changes:
scripts/conversion_tools/unit_conversion.py
: add conversion from degrees to radians and vice versa, address issue Follow-up changes for PR https://github.com/NCAR/ccpp-framework/pull/307 #309scripts/ccpp_prebuild.py
,scripts/mkcap.py
: address issue Follow-up changes for PR https://github.com/NCAR/ccpp-framework/pull/307 #309 (use correct Python syntax to test if a variable is a list or a dictionary)metadata2html.py
(fix a bug to avoid reading keys in metadata2html.py #312)