-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add to_xgcm_grid_dataset function to help read into XGCM #3
Comments
Or, another option could be altering the Dataset metadata to meet the CF & COMODO conventions so that xgcm can handle it natively. |
We could use something like the following def to_xgcm(ds):
"""
Converts an XGCM Grid
"""
_required_coords = ['XLAT_M', 'XLAT_C', 'XLONG_M', 'XLONG_C']
if not set(_required_coords).issubset(list(ds.coords)):
raise ValueError(f'Missing Required Coordinates: {_required_coords}')
grid = xgcm.Grid(ds, coords={"X":{"inner":"XLAT_M",
"outer":"XLAT_C"},
"Y":{"inner":"XLONG_M",
"outer":"XLONG_C"}
}
)
return grid This does require those coordinates to be included in the dataset... |
This doesn't work for all projections though, right? Since XGCM interpolates the data based on the coordinates, I think that you have to be careful with anything other than lat/lon runs. E.g. for lambert runs, IMO one would have to first convert the XLAT*/XLONG* coordinates to the lambert grid and then use this grid with XGCM. Also, |
I concur that that using the lats and lons only works for a lat/lon projection. Since derived dimension coords are a needed feature anyway, I strongly lean towards just using CF & COMODO attributes conventions (which is what I've worked towards in #14) instead of directly providing an Also, unsure on |
It would be helpful to have a helper function to prepare the data for XGCM
The text was updated successfully, but these errors were encountered: