-
Notifications
You must be signed in to change notification settings - Fork 66
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
More pint + cf-xarray usage in examples #325
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
View / edit / reply to this conversation on ReviewNB navidcy commented on 2024-02-27T10:41:56Z What's all these warnings?? Should we pay attention to them?? Seems like xarray is trying to tell us something anton-seaice commented on 2024-02-27T22:24:50Z This warning means that the dask chunks are smaller than the chunks in the source netcdf file. This is inefficient because it means the same chunk in the source file needs to be read multiple times.
I think, the workaround is to manually set chunks in the getvar : e.g.
The fix is to update the cookbook, but I don't think anyone is working on the cookbook anymore.
navidcy commented on 2024-02-28T09:54:18Z yeap, let's leave this for the cookbook to deal with. |
This warning means that the dask chunks are smaller than the chunks in the source netcdf file. This is inefficient because it means the same chunk in the source file needs to be read multiple times.
I think, the workaround is to manually set chunks in the getvar : e.g.
The fix is to update the cookbook, but I don't think anyone is working on the cookbook anymore.
View entire conversation on ReviewNB |
View / edit / reply to this conversation on ReviewNB anton-seaice commented on 2024-02-27T22:56:23Z Line #25. u = u.pint.quantify() Maybe a note to say what this means is good? navidcy commented on 2024-02-28T09:54:05Z ok, done |
View / edit / reply to this conversation on ReviewNB anton-seaice commented on 2024-02-27T22:56:24Z 'We
I don't understand what is being said here? navidcy commented on 2024-02-28T09:53:58Z Indeed it was convoluted. I rephrased. |
View / edit / reply to this conversation on ReviewNB anton-seaice commented on 2024-02-27T22:56:24Z I think we should do something about the tripole ... at least acknowledge the plots are wrong above 65N, or fix the plots navidcy commented on 2024-02-28T09:53:31Z The plots looks alright, even north of 65N. I believe I took care of that by using anton-seaice commented on 2024-02-28T22:54:37Z There is data missing north of Western Russia and Eastern Canada/Greenland but it blends in well due to the color scale. And some data is hidden under the land too.
Labelling xu_ocean as longitutude, and yu_ocean as latitude is a bit of a shortcut, because on the tripole grid, at North of 65N these grids no longer follow normal lat/lon.
I think for our cf labels of latitude and longitude to be strictly correct, we would need to load geolat and geolon, and assign them as coordinates and add the cf attributes to those.
anton-seaice commented on 2024-02-28T22:55:23Z The example using contourf is in https://cosima-recipes.readthedocs.io/en/latest/DocumentedExamples/SeaIce_Plot_Example.html#Making-Maps EDIT: Thankyou to Aidan for the correction below :) |
View / edit / reply to this conversation on ReviewNB anton-seaice commented on 2024-02-27T23:00:59Z Line #24. axes[2].set_title('ACCESS-OM-010 regridded on 1 I think this change was accidental? navidcy commented on 2024-02-28T09:35:14Z indeed! |
View / edit / reply to this conversation on ReviewNB anton-seaice commented on 2024-02-27T23:01:00Z Linking to https://cosima-recipes.readthedocs.io/en/latest/DocumentedExamples/SeaIce_Obs_Model_Compare.html#Sea-Ice-Concentration-Anomalies would keep this in-house navidcy commented on 2024-02-28T09:44:55Z I added both! |
indeed! View entire conversation on ReviewNB |
I added both! View entire conversation on ReviewNB |
The plots looks alright, even north of 65N. I believe I took care of that by using View entire conversation on ReviewNB |
Indeed it was convoluted. I rephrased. View entire conversation on ReviewNB |
ok, done View entire conversation on ReviewNB |
yeap, let's leave this for the cookbook to deal with. View entire conversation on ReviewNB |
Thanks @anton-seaice. I think I dealt with everything you raised. Can you have a second look? |
There is data missing north of Western Russia and Eastern Canada/Greenland but it blends in well due to the color scale. And some data is hidden under the land too.
Labelling xu_ocean as longitutude, and yu_ocean as latitude is a bit of a shortcut, because on the tripole grid, at North of 65N these grids no longer follow normal lat/lon.
I think for our cf labels of latitude and longitude to be strictly correct, we would need to load geolat and geolon, and assign them as coordinates and add the cf attributes to those.
View entire conversation on ReviewNB |
The example using contourf is in https://cosima-recipes.readthedocs.io/en/latest/DocumentedExamples/SeaIce_Plot_Example.html#Making-Maps View entire conversation on ReviewNB |
Agreed that proper projection is required for plotting the tripole, but as long as there are no missing coordinate values the https://cosima-recipes.readthedocs.io/en/latest/Tutorials/Spatial_selection.html |
View / edit / reply to this conversation on ReviewNB aidanheerdegen commented on 2024-02-29T07:02:17Z Line #14. for coord in [u.xu_ocean, v.xu_ocean]: Part of the reason to use
In the same way anything accessing navidcy commented on 2024-02-29T07:25:09Z But I'm doing this, e.g.,
We weren't careful enough to use CF metadata when outputting ACCESS-OM2? Is this why?f |
But I'm doing this, e.g.,
We weren't careful enough to use CF metadata when outputting ACCESS-OM2? Is this why? View entire conversation on ReviewNB |
You are very correct! Good pick up, I was convinced about that for some reason. @navidcy : I realise this is only half in scope for what you are trying to change ... but I think we should be loading geolat and geolon and using those as the cf coordinates for lat and lon. But there are some other places in the recipes that would have the same issue :) |
In lots of cases the ocean files had essentially broken coordinates: they had missing/masked values. When that happens the normal plot stuff will not work. It is an odd interaction between the So it is difficult to predict, as essentially the same config can produce fine coordinate data, or broken ones, and all it depends on is the Once you do encounter the problem though, it is a real pain, and completely understandable that you would develop the intuition that Might even be worth creating a script to check for this condition to avoid people trying stuff that doesn't work, or better yet use it as a check for model configurations so we're producing good quality outputs. |
Ah, right sorry. My mistake. Point still stands for the
to
In a nutshell. Yes. |
I went back and looked at where I had tried this (e.g.
and it is because the default behaviour (in the intake cat) if you search for 'geolat_t' or 'geolon_t' is to get them from the CICE output files. But in the output files the geolat and geolon have a landmask applied: If you load the CICE input grid (as done in the Spatial Selection example), and get use the lat/lon fields from there, then it works ok. p.s. It is a slightly odd behavior in matplotlib ... the mask is the same in the source data and the x and y coords |
Ah right. Yeah, I think that was the only reliable method because, as you point out, the coordinates are masked in the ice data. My recollection was the ocean data was as I said, where it depended on |
I could be misunderstanding what you're saying, but I think you'll only find As already agreed, it's probably best to get the ice grid from the ice input grid. Especially since the MOM and CICE grids may not actually be the same. |
Yes you are right. (It turns out I am loading these from the output file, not from intake cat directly). The masking is very similar to the CICE masking, and trying to plot using 'TLON' and 'TLAT' from cice output gives the same error. |
I've been thinking that 2D unmasked coords should be loaded automatically by But that's a bit irrelevant for this PR. Could/should we merge this PR and continue the discussion in an issue either in this repo or in the cookbook? |
View / edit / reply to this conversation on ReviewNB anton-seaice commented on 2024-03-07T03:14:55Z Line #15. coord.attrs['standard_name'] = 'longitude' 'grid_longitude' and 'grid_latitude' would be more appropriate (per https://cfconventions.org/Data/cf-standard-names/current/build/cf-standard-name-table.html)
navidcy commented on 2024-03-14T12:49:07Z Done |
View / edit / reply to this conversation on ReviewNB anton-seaice commented on 2024-03-07T03:14:56Z Line #16. coord.attrs['units'] = 'degrees' Per https://cfconventions.org/Data/cf-standard-names/current/build/cf-standard-name-table.html it should be 'degree' not 'degrees' navidcy commented on 2024-03-14T12:49:02Z Done |
Done View entire conversation on ReviewNB |
Done View entire conversation on ReviewNB |
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.
Approving, noteing that our handling of the tripole is a bit messy, and would be simplified by loading the geographic grids with every variable :)
Actually with the CF-compliances now you can't do u.cf['latitude'] but you have to do u.cf['grid_latitude'] which is counter-intuitive and brings back some "trauma" from having coordinate names like Can we resolve this? |
Yeah - loading the true lat/lon from the ice grid file. See example in https://cosima-recipes.readthedocs.io/en/latest/Tutorials/Spatial_selection.html#Load-data |
OK, I admit I'm a bit worn out from this PR so I'm merging without resolving this last issue... :( I think the proper solution is to have the cookbook assign the unmasked 2D lat-lon coordinates on every variable it returns! See COSIMA/cosima-cookbook#336 |
No description provided.