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

Use pint to properly deal with unit conversions in "Barotropic streamfunction" example #316

Merged
merged 7 commits into from
Mar 1, 2024

Conversation

navidcy
Copy link
Collaborator

@navidcy navidcy commented Feb 21, 2024

This PR showcases how we can use pint to properly deal with unit conversions e.g. when we want to convert from mass to volume transport or when we want to convert from m^3/s to Sverdrup.

There are heaps of warnings that xarray spits out and

import warnings
warnings.simplefilter(action='ignore', category=UserWarning)

at the beginning seems to have no effect... I don't know how to remove them or what do they are really trying to say (I mean, I can read them but I don't know what I should do...). If anyone has any idea is welcome!

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@navidcy
Copy link
Collaborator Author

navidcy commented Feb 21, 2024

I removed the warnings by passing chunks={'time': 3}) to the cc.get_variable.

@navidcy
Copy link
Collaborator Author

navidcy commented Feb 21, 2024

@julia-neme, I don't know if it was you who defined the shift_colormap(). I deleted the shift_colormap() since it was never used! feel free to put it back and use it if you like! :)

@navidcy navidcy added 🛸 updating An existing notebook needs to be updated and removed 🧜🏽‍♀️ enhancement New feature or request labels Feb 22, 2024
@navidcy navidcy requested a review from lidefi87 February 23, 2024 05:41
Copy link
Collaborator

@lidefi87 lidefi87 left a comment

Choose a reason for hiding this comment

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

Sorry for the delay in getting back to you. I was flat out this week, and thanks again for being on top of keeping the examples up to date.

I checked the notebook and it runs, but if I am honest, I do not really understand what it does because I do not know what a barotropic streamfunction is. Perhaps it would be clearer to a physical oceanographer, which I am not.

I do have a question/request. Is it important to highlight positive and negative values in the map? At the moment is a continuous colourmap and I cannot distinguish positive from negative values. If this is important, maybe a divergent colourmap would be more appropriate (maybe the delta palette from cmocean, which has blues/yellows/green).

If it is not important to make this distinction, let me know and I will approve it so this can be merged.

@navidcy
Copy link
Collaborator Author

navidcy commented Mar 1, 2024

hi @lidefi87! the stream function is a quantity whose derivatives give you the velocities... thus its actual value is irrelevant, only its gradients matter. you can think of it like pressure.

the colormap was actually a divergent one but because it was highlighting the value ψ=0 as a "special one" I decided to change to this non-diverging colormap.

Copy link
Collaborator

@lidefi87 lidefi87 left a comment

Choose a reason for hiding this comment

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

Ah. Got it now. Thanks for explaining it. I'm approving it now 😊

@navidcy navidcy merged commit b59b71d into main Mar 1, 2024
3 checks passed
@navidcy navidcy deleted the ncc/pint branch March 1, 2024 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MOM5+MOM6 ❤️ 🛸 updating An existing notebook needs to be updated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants