You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, all. Typically we want to have a nice geo-referenced plot of our model output, with maps and geographical locations and everything. This is difficult for native-grid output from an irregular grid with two-dimensional lat-lon coordinates, like that created by FV3 and other cubed-sphere dynamical cores, so usually we regrid to a lat-lon grid. Regridding can be done with tools like our own excellent FREGrid, although this can be cumbersome and can distort the native grid structure.
I am happy to report that many tools for viewing NetCDF files, including ncview and Panoply, support the ability to show structured but irregular coordinates on their native grids! This is done by a standard CF attribute that permits two-dimensional longitudes and latitudes, and can be easily implemented in the history files of an FV3-based model using standard NCO tools. This is especially useful for nested and regional domains that can be severely distorted in lat-lon coordinates.
To do this, you will first need to write out the lat-lon coordinates of cell centroids. This is easily done by adding these lines to your diag_table:
(Note that this grid_spec.tileN.nc is different from the grid_spec.nc used in the FMSCoupler mosaic or by FREGrid, which is instead defined on the FMS supergrid.)
Then, after running the model, you can copy the fields grid_lont and grid_latt containing the lon-lat coordinates on a given tile into your history file, here called atmos_hourly.tileN.nc:
ncks -A -v grid_lont,grid_latt grid_spec.tileN.nc atmos_hourly.tileN.nc
Make sure to specify the -A switch to ncks to prevent the file from being completely overwritten.
Then, for each variable, specify the coordinates attribute. Here, I add the attribute to the cloud-top height variable in C-SHiELD:
ncatted -a coordinates,HGTctp,c,c,"grid_lont grid_latt" atmos_hourly.tileN.nc
And then you are done! See figures below for a few examples.
There are a few extra steps for some packages:
ncview
Since for some grids (especially nests and regional domains) the orientation is upside-down, ncview displays the plot backwards. This is however easy to fix for the whole file:
ncpdq -A -a -grid_yt,-grid_xt atmos_hourly.tileN.nc atmos_hourly.tileN.nc
Although ncpdq can be slow for large files, you only need to do it once.
ncview has the advantage that it automatically shows the plot on the native gnomonic projection, since the grid_lont/grid_latt are in the gnomonic projection.
Panoply
The variable coordinate plot works immediately in GISS's excellent Panoply software, and projects it to whichever map projection you like. Panoply can even project onto a gnomonic coordinate, but it might be a little distorted unless you make some appropriate changes. On the 'map' tab choose the "Gnomonic" projection and add your 'target_lon' and 'target_lat' from your namelist (or modify appropriately if you are using one of the other tiles) to the 'center on' boxes. You can play with 'edge radius' to change the area shown in the map. Also, since Panoply can merge two variables with different grids, you can easily plot both the nest and its parent(s) on the same grid.
A few notes:
I have not yet tested this in XArray but presume that it should work since XArray is usually up on CF-compliance. I also don't know how it would work in GrADS. It may take some control-file magic.
I haven't tried this for a 4D variable with a Z coordinate yet but presume it would work similarly.
The CF standard includes a similar attribute for vertical coordinates, which may allow for easy plotting of cross-sections in proper coordinates (height, pressure, theta, etc.).
Since coordinates need to be specified on a variable-by-variable basis, this could mean that we could also show staggered grid variables (U, V, divergence) at their native locations too.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, all. Typically we want to have a nice geo-referenced plot of our model output, with maps and geographical locations and everything. This is difficult for native-grid output from an irregular grid with two-dimensional lat-lon coordinates, like that created by FV3 and other cubed-sphere dynamical cores, so usually we regrid to a lat-lon grid. Regridding can be done with tools like our own excellent FREGrid, although this can be cumbersome and can distort the native grid structure.
I am happy to report that many tools for viewing NetCDF files, including ncview and Panoply, support the ability to show structured but irregular coordinates on their native grids! This is done by a standard CF attribute that permits two-dimensional longitudes and latitudes, and can be easily implemented in the history files of an FV3-based model using standard NCO tools. This is especially useful for nested and regional domains that can be severely distorted in lat-lon coordinates.
To do this, you will first need to write out the lat-lon coordinates of cell centroids. This is easily done by adding these lines to your diag_table:
(Note that this
grid_spec.tileN.nc
is different from thegrid_spec.nc
used in the FMSCoupler mosaic or by FREGrid, which is instead defined on the FMS supergrid.)Then, after running the model, you can copy the fields
grid_lont
andgrid_latt
containing the lon-lat coordinates on a given tile into your history file, here calledatmos_hourly.tileN.nc
:Make sure to specify the
-A
switch toncks
to prevent the file from being completely overwritten.Then, for each variable, specify the
coordinates
attribute. Here, I add the attribute to the cloud-top height variable in C-SHiELD:And then you are done! See figures below for a few examples.
There are a few extra steps for some packages:
ncview
Since for some grids (especially nests and regional domains) the orientation is upside-down,
ncview
displays the plot backwards. This is however easy to fix for the whole file:Although
ncpdq
can be slow for large files, you only need to do it once.ncview
has the advantage that it automatically shows the plot on the native gnomonic projection, since thegrid_lont
/grid_latt
are in the gnomonic projection.Panoply
The variable coordinate plot works immediately in GISS's excellent
Panoply
software, and projects it to whichever map projection you like.Panoply
can even project onto a gnomonic coordinate, but it might be a little distorted unless you make some appropriate changes. On the 'map' tab choose the "Gnomonic" projection and add your 'target_lon' and 'target_lat' from your namelist (or modify appropriately if you are using one of the other tiles) to the 'center on' boxes. You can play with 'edge radius' to change the area shown in the map. Also, since Panoply can merge two variables with different grids, you can easily plot both the nest and its parent(s) on the same grid.A few notes:
Happy hacking.
Lucas
Beta Was this translation helpful? Give feedback.
All reactions