xarray-contrib / cf-xarray

an accessor for xarray objects that interprets CF attributes
https://cf-xarray.readthedocs.io/
Apache License 2.0
159 stars 40 forks source link

sgrid helper utilities #204

Open dcherian opened 3 years ago

dcherian commented 3 years ago

Copied from #201 re: https://sgrid.github.io/sgrid/

I think there's an opportunity for better metadata handling around gridded, xgcm, sgrid, xesmf with cf_xarray providing a little helper function layer to consolidate the code.

It seems a common issue is figuring out cell metrics; and cell centers and corner points. This is needed by xgcm, maybe cmip6_preprocessing, and probably xesmf (definitely needed to specify xesmf inputs).

I think cf_xarray can provide a tiny sgrid module that helps autoguess some sgrid parameters and maybe parses the sgrid attributes and lets them be used in a convenient way. We can take inspiration from (and maybe copy over) https://noaa-orr-erd.github.io/gridded/gridded.pysgrid.html

I think a call some time in the next two weeks would be good to sort this out, and make a plan.

cc @aulemahal @mgrover1 @malmans2

mgrover1 commented 3 years ago

This is a great idea - can we try to set something up for next week?

malmans2 commented 3 years ago

I think a call some time in the next two weeks would be good to sort this out, and make a plan.

Good idea!

aulemahal commented 3 years ago

Interesting! I am available for a call in the next two weeks.

mgrover1 commented 3 years ago

What day works well for people this week?

dcherian commented 3 years ago

Thursday/Friday with Friday preferred.

mgrover1 commented 3 years ago

Would 10 AM MST on Friday April 23 work well for everyone?

dcherian commented 3 years ago

cc @jbusecke @raphaeldussin

jbusecke commented 3 years ago

Yes I can make that! Thanks for organizing.

dcherian commented 3 years ago

See https://github.com/xgcm/xgcm/issues/109 for things that xgcm needs.

mgrover1 commented 3 years ago

I created a Google Calendar event for Friday.

Here is a link to the event

Within the event, you will find a document which will serve as the agenda - feel free to make edits to that!

jbusecke commented 3 years ago

That link does not seem to work for me @mgrover1. Could you resend it?

mgrover1 commented 3 years ago

Meet

Notes

mgrover1 commented 3 years ago

Meet meet.google.com/uab-gvff-mdk

dcherian commented 2 years ago

https://ioos.github.io/ioos_code_lab/content/code_gallery/data_analysis_and_visualization_notebooks/2016-11-16-CF-UGRID-SGRID-conventions.html

Some useful stuff here.

dcherian commented 1 year ago

From https://sgrid.github.io/sgrid/#roms

int grid ;
        grid:cf_role = grid_topology
        grid:topology_dimension = 2 ;
        grid:node_dimensions = "xi_psi eta_psi" ;
        grid:face_dimensions = "xi_rho: xi_psi (padding: both) eta_rho: eta_psi (padding: both)" ;
        grid:edge1_dimensions = "xi_u: xi_psi eta_u: eta_psi (padding: both)" ;
        grid:edge2_dimensions = "xi_v: xi_psi (padding: both) eta_v: eta_psi" ;
        grid:node_coordinates = "lon_psi lat_psi" ;
        grid:face_coordinates = "lon_rho lat_rho" ;
        grid:edge1_coordinates = "lon_u lat_u" ;
        grid:edge2_coordinates = "lon_v lat_v" ;
        grid:vertical_dimensions = "s_rho: s_w (padding: none)" ;

One thing we could do is parse this to understand that xi_*, eta_*, s_* are axes X, Y, Z even though they don't have the axes attribute set. In particular this helps with xi_*, eta_* which are "virtual variables" i.e. there is no data associated with them, or they are "unlabeled dimensions" with no associated coordinate variable or attrs.