-
Notifications
You must be signed in to change notification settings - Fork 41
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
Update add_bounds
to support 2D coordinate variables.
#71
Comments
Is that pop specific? I think that we could really use a package/module that is general and does these things + estimate grid metrics from curvilinear grids. But I guess this is not really within the limits of cf-conventions (if it goes beyond a simple multiplication of metrics)? |
If you have the corners, the bounds should be trivially just be interpolated between them? |
The xgcm has a function to calculate the boundary. Please see this example. |
Nice! A PR would be very welcome though we don't want to add an xgcm dependency. In fact, perhaps xgcm can depend on cf-xarray instead for bounds generation (cc @jbusecke ) |
Hey @zxdawn, the autogenerate module is somewhat defunct (since it relies on an 'extrapolate' boundary handling, which our newest refactor does not support anymore xgcm/xgcm#497). This is not well documented on our end, sorry. Overall I want to move this functionality out of xgcm entirely! Instead I think the community needs a specific tool (maybe this is cf-xarray?) that achieves the following things:
There are several use cases that could enter this logic at various stages:
full_grid_ds = calculate_metrics(cmip6_c_grid_ds)
grid = Grid(full_grid_ds) # metrics should ultimately be encoded in metadata and parsed automatically
argo_finite_grid = infer_grid_positions(argo_gridded_ds)
full_grid_ds = calculate_metrics(argo_finite_grid)
grid = Grid(full_grid_ds)
target_grid = grid_global(..., center_only=False) # In a simple case of a regular lon/lat grid this should already produce the cell corners?
regridder = xe.Regridder(some_ds, target_grid, ...) All of this does not actually need xgcm or xesmf (I think this can be achieved with pure xarray), but it would be tremendous if the result of this could readily be parsed by both xgcm (we might need to do some work over there on updating our parsing) and xesmf. For me the question here is firstly: Do all of these stages fit into the scope of cf-xarray? I think 1. and 2. should definitely fit, but does 3.? If not is it worth to have a separate package for that? I have long been wondering how to do the recalculation for metrics 'properly'. GCMs do that routinely, right? Can we extract that logic somehow? |
I feel there might be some synergy with pytroll/pyresample#440 (comment) here. |
The "convention" is sgrid AFAICT though it always confuses me! and bounds to corners and corners to bounds are totally within scope here IMO. We already have it! Only thing that is missing is 2D autogeneration and am definitely happy to add that.
IMO xgcm should interpret sgrid and do this. |
I am not quite decided on whether this functionality should be living in xgcm but I think we have some consensus on the fact that the other elements should indeed live in cf-xarray (which we can add as a dependency in xgcm)? |
Should we change the name of this function?
Some relevant existing code is here: https://github.com/NCAR/pop-tools/blob/d771f8d7280696c890bb6a21255c5ad298c8b373/pop_tools/grid.py#L324-L363
cc @huard
The text was updated successfully, but these errors were encountered: