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 unit conversion from degrees to radians, address isssue #309 #311

Merged
merged 5 commits into from
Jul 15, 2020

Conversation

climbfuji
Copy link
Collaborator

@climbfuji climbfuji commented Jul 9, 2020

This PR contains the following changes:

@climbfuji
Copy link
Collaborator Author

@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 radian and degree (singular, as for kg - you don't say "100 kilograms", but "100 kilogram"), but most websites use radians and degrees (plural; this is also how the units are used currently in FV3 and ccpp-physics).

@gold2718
Copy link
Collaborator

gold2718 commented Jul 9, 2020

Glad you asked. For radians, it is radian.
For latitude in degrees, it is degrees_north.
For longitude, in degrees, it is degrees_east.
Area should be steradian or radian2

Note these are all from UDUNITS which also accepts things like degree_north, degreeN, degree_N, degreesN, and degrees_N.

@climbfuji
Copy link
Collaborator Author

Glad you asked. For radians, it is radian.
For latitude in degrees, it is degrees_north.
For longitude, in degrees, it is degrees_east.
Area should be steradian or radian2

Note these are all from UDUNITS which also accepts things like degree_north, degreeN, degree_N, degreesN, and degrees_N.

Now I regret that I asked ;-) that's more complicated than what I wanted to hear.

@climbfuji climbfuji force-pushed the add_degrees_to_radians_conversion branch from 405e3c2 to f375880 Compare July 9, 2020 18:28
@climbfuji
Copy link
Collaborator Author

Ok, for the moment I will implement "radian" to "degrees" (for variables that are not latitude or longitude), "degrees_north" and "degrees_east".

@gold2718
Copy link
Collaborator

gold2718 commented Jul 9, 2020

Do we have to accept everything for the CCPP? How about just radian, degrees_east, and degrees_north?

@climbfuji
Copy link
Collaborator Author

Do we have to accept everything for the CCPP? How about just radian, degrees_east, and degrees_north?

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.

@climbfuji
Copy link
Collaborator Author

@cacraigucar
Copy link
Collaborator

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.

@climbfuji
Copy link
Collaborator Author

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.

Copy link
Collaborator

@gold2718 gold2718 left a 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.

Comment on lines 122 to 128
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}'
Copy link
Collaborator

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).

Copy link
Collaborator Author

@climbfuji climbfuji Jul 10, 2020

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 ;-)

Copy link
Collaborator

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.

@grantfirl
Copy link
Collaborator

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.

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.

@climbfuji
Copy link
Collaborator Author

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.

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.

@grantfirl
Copy link
Collaborator

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.

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.

I just realized that udunits is inconsistent with plurality too. Sigh. If they accept the singular degree, though, I vote for:
degree, degree_north, degree_east, radian.

@gold2718
Copy link
Collaborator

UDUNITS accepts degree, degreeN, and degree_N (plus E for N).
There is no plural for radian

@climbfuji
Copy link
Collaborator Author

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!

@grantfirl
Copy link
Collaborator

@climbfuji Yes, I think that is the consensus.

@gold2718
Copy link
Collaborator

But those are not in UDUNITS (except for degree and radian).

@grantfirl
Copy link
Collaborator

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?

@gold2718
Copy link
Collaborator

Yow, it looks like my version is out of date. I am okay with this selection as an 'official' CCPP list.

@climbfuji
Copy link
Collaborator Author

climbfuji commented Jul 13, 2020 via email

Copy link
Collaborator

@gold2718 gold2718 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@climbfuji climbfuji merged commit 209f1c9 into NCAR:master Jul 15, 2020
@climbfuji climbfuji deleted the add_degrees_to_radians_conversion branch June 27, 2022 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants