-
Notifications
You must be signed in to change notification settings - Fork 48
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
integration with xgcm.Grid #13
Comments
Thanks for bringing this up! A good way to track cell boundaries will be very useful for xESMF. In xgcm's examples I only notice rectilinear grids. Do you have examples for curvilinear grids? More specifically, I am very interested in those functionalities (all assume general curvilinear grids): All those are only for conservative regridding. But conservation is so important in Earth science and deserves special care. A robust algorithm for (1) might be done in the Cartesian space instead of spherical coordinate, to avoid the polar singularity. This is also how ESMF calculates regridding weights. At some point I might code up this center-bound switching on my own, but if xgcm supports that it would be a great time saving! |
Related issue: pydata/xarray#1475. This is really my major, perhaps only, complaint about xarray... |
Not all of the features you want are already part of xgcm right now. But they are all things I also want in xgcm. So I am trying to convince you to collaborate with me!
It works with logically rectangular grids. The underlying geometry can be curvilinear. And once xgcm/xgcm#88 is merged, it will support exchanging data in cubed-sphere-type geometries.
Yes, this is currently supported in the grid generation module.
Right now, the coordinates are generated, but they are not kept in the
What you can do now is slice an xarray dataset first and then generate an In general, there is a lot of room to improve the autogeneration of finite volume grids within |
This is all I need. And I don't think xarray's data model can go beyond logically rectangular (such as MPAS's hexagonal mesh).
I would appreciate a simple demo for inferring the bounds of curvilinear grids. Can be as simple as this artificial grid in xESMF doc. More challenging grids would be better, like the rasm demo data which span over the pole.
This is exactly what I like. I am interested in xgcm's boundary utility, but the input arguments for In any case, I definitely like a better boundary handling. I'll only need a stable&robust center-bound switching functionality from xgcm. There should be no dependency on the vector calculation part. |
Just an update: we now have documentation in xgcm about the grid autogeneration. This is mostly @jbusecke's work: Very much a work in progress, but it is a starting point. |
Hi @JiaweiZhuang, thanks for the interest in the autogenerate module. I will report back when I get to this (might be a few days, since I am traveling). |
Ok I did a quick test here. In short, there seem to be problems at the pole when using the RASM example from xarray. @JiaweiZhuang do you have a similar dataset that actually has boundary coordinates? That way I could compare the generated output (like I did for the simple example). On a related note: @rabernat this exercise exposed a clunkyness of the autogenerate module. We do not need to create any coordinates within that function. Once the dimensions are generated, everything can be done 'as normal' with xgcm. Will refactor this soon. |
@jbusecke Thanks very much! Great to see the first example on a 2D curvilinear mesh.
The cubedsphere package is able to compute both cell centers and boundaries. See this gist as a testing framework for you to plug-in xgcm code. Two polar panels of the cubed-sphere grid are very similar to the RASM grid. Inferring boundaries, or any general interpolation/extrapolation operations, can often be buggy near the poles. A more robust way is to convert |
There is also a subtle issue with non-uniform 1D grid. Say the cell centers are: The actual boundaries that generate the above center values are: xgcm currently gives: Values near two end points are slightly wrong, due to the simple extrapolation algorithm at end points. See this gist for the full code. A mathematically rigorous way would be solving a set of linear equations:
where The situation becomes quite tricky in 2D cases, but we probably don't need to be too rigorous for 2D curvilinear grids, where the definition of "the center of a cell" is not very clear. |
Another minor question: Does the key of |
No these are just the names of the logical axes, they could be |
Also, thanks a lot for the examples.
Could we use that internal machinery to get a better result here? I am not sure how much of this logic we want to be adding to
@rabernat Could we integrate this in |
Add ESMPy v8 to requirements, fixes JiaweiZhuang#13
xESMF is awesome!
I have spent quite a bit of effort in creating an xarray-friendly data model for finite volume GCM data in xgcm:
http://xgcm.readthedocs.io/en/latest/grids.html
It seems like this data model could help resolve some other issues in xESMF, in particular, the generalization of coordinate names (#5) and the specification of cell boundaries vs centers.
I wanted to open this issue just to discuss how we can make these two packages more mutually compatible and potentially avoid solving the same problems twice.
The text was updated successfully, but these errors were encountered: