xgcm
General Circulation Model Postprocessing with xarray
xgcm is a python packge for working with the datasets produced by numerical General Circulation Models (GCMs) and similar gridded datasets that are amenable to finite volume analysis. In these datasets, different variables are located at different positions with respect to a volume or area element (e.g. cell center, cell face, etc.) xgcm solves the problem of how to interpolate and difference these variables from one position to another.
https://github.com/xgcm/xgcm
Official Documents
xgcm: General Circulation Model Postprocessing with xarray — xgcm 0.2.0+44.gcac66af documentation
https://xgcm.readthedocs.io/en/latest/
MITgcm Example
https://xgcm.readthedocs.io/en/latest/example_mitgcm.html
Tutorials
PyVideo.org · Xgcm: Analyzing General Circulation Models in Python | SciPy 2019 | Ryan Abernathey
https://pyvideo.org/scipy-2019/xgcm-analyzing-general-circulation-models-in-python-scipy-2019-ryan-abernathey.html
Examples
ECCOv4
Vector calculus in ECCO: The Transport, divergence, vorticity and the Barotropic Vorticity Budget
https://ecco-v4-python-tutorial.readthedocs.io/VectorCalculus_ECCO_barotropicVorticity.html
ECCOv4 budgets
https://ecco-v4-python-tutorial.readthedocs.io/ecco_budgets.html
code:python
ds = xr.Dataset({"u":("y_c","x_g",np.ma.masked_array(u,u<-100.)),
"v":("y_g","x_c",np.ma.masked_array(v,v<-100.))},
coords={'x_c': ('x_c',, lonv, {'axis': 'X'}),
'x_g': ('x_g',, lonu,
{'axis': 'X', 'c_grid_axis_shift': -0.5}),
'y_c': ('y_c',, latu, {'axis': 'Y'}),
'y_g': ('y_g',, latv,
{'axis': 'Y', 'c_grid_axis_shift': -0.5})
},
)
grid=xgcm.Grid(ds,periodic=False)
print(grid)
See also
xmitgcm: python package for reading MITgcm binary MDS files into xarray data structures.