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

Proper handling of units in examples #267

Open
navidcy opened this issue Sep 2, 2023 · 2 comments
Open

Proper handling of units in examples #267

navidcy opened this issue Sep 2, 2023 · 2 comments

Comments

@navidcy
Copy link
Collaborator

navidcy commented Sep 2, 2023

Often we see things like:

transport = ty_trans / 1034 / 1e5

to convert, e.g., ty_trans from kg/s to Sverdrup. (E.g. see https://cosima-recipes.readthedocs.io/en/latest/DocumentedExamples/Zonally_Averaged_Global_Meridional_Overturning_Circulation.html) But these conversions are ad hoc and one can easily make a mistake and forget a factor. A usual trick to see if we are missing a factor (e.g., forgot to divide by the depth of the fluid or by density) is to check the units. But if we are converting things like above there are no units attached.

pint and cf-xarray provide a way to attach units on variables.

Our aim is to have all documented examples use pint/cf-xarray for proper unit handling

The tutorial:
https://cosima-recipes.readthedocs.io/en/latest/Tutorials/Model_Agnostic_Analysis.html

and the example:
https://cosima-recipes.readthedocs.io/en/latest/DocumentedExamples/Transport_Through_Straits.html

are good starting points.

@navidcy
Copy link
Collaborator Author

navidcy commented Sep 2, 2023

If during Hackathon v3.0, you wanna tackle updating one of the documented examples to use pint/cf-xarray then:

  • create an issue title "Update example blah blah to properly handle units via pint/cf-xarray.
  • add label "Hackathon v3.0"
  • add project "Hackathon v3.0"
  • start working on it and open a PR when you think it's ready!

@navidcy
Copy link
Collaborator Author

navidcy commented Feb 26, 2024

#316, #322 move towards this direction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment