In some configurations (llc, cube-sphere,...) the model's grid is provided in a set of input binary files rather than being defined in the namelist. In such configurations, land processors elimination results in blank areas in the XC, YC,... fields outputed by the model. In some cases (regridding, plotting,...), it can be useful to retrieve directly the original fields. To do so, we can use the xmitgcm.utils.get_grid_from_input function.
In [1]:
#We're going to download a sample grid from figshare
!wget https://ndownloader.figshare.com/files/14072594
!tar -xf 14072594
In [2]:
import xmitgcm
In [3]:
# We generate the extra metadata needed for multi-faceted grids
llc90_extra_metadata = xmitgcm.utils.get_extra_metadata(domain='llc', nx=90)
# Then we read the grid from the input files
grid = xmitgcm.utils.get_grid_from_input('./grid_llc90/tile<NFACET>.mitgrid',
geometry='llc',
extra_metadata=llc90_extra_metadata)
grid is a xarray dataset that contains lat/lon (XC, YC, XG, YG) and the grid's scale factors:
In [4]:
grid
Out[4]:
The obtained dataset is then ready for use for the desired application:
In [5]:
%matplotlib inline
In [6]:
grid['XC'].sel(face=4).plot()
Out[6]:
In [7]:
!wget https://ndownloader.figshare.com/files/14072591
!tar -xf 14072591
In [8]:
# We generate the extra metadata needed for multi-faceted grids
aste_extra_metadata = xmitgcm.utils.get_extra_metadata(domain='aste', nx=270)
# Then we read the grid from the input files
grid_aste = xmitgcm.utils.get_grid_from_input('./grid_aste270/tile<NFACET>.mitgrid',
geometry='llc',
extra_metadata=aste_extra_metadata)
In [9]:
grid_aste
Out[9]:
In [11]:
grid_aste['YC'].sel(face=2).plot()
Out[11]: