sl.grid.writeCDO | R Documentation |
Write a spheRlab grid to a grid description file that makes unstructured-mesh data readable by the Climate Data Operators (CDO).
sl.grid.writeCDO(grid, ofile = "~/sl.grid.nc", netcdf = TRUE, netcdf.prec = "double", ascii.digits = Inf, overwrite = FALSE, verbose = TRUE, cell_area = TRUE, node_node_links = TRUE, triag_nodes = TRUE, coast = TRUE, depth = TRUE, ofile.ZAXIS = paste0(ofile,"_zaxis.txt"), fesom2velocities = FALSE, conventions = "original")
grid |
a spheRlab grid list as returned by |
ofile |
a character specifying the path and file name of the output file. |
netcdf |
a logical value indicating whether or not to write directly to NetCDF (default). If |
netcdf.prec |
a character defining the precision at which the (non-integer) variables are written. Reasonable options are |
ascii.digits |
a scalar giving the number of digits after which coordinates are truncated (rounded). Used only if |
overwrite |
a logical value indicating whether or not to overwrite an already existing file. |
verbose |
a logical value indicating whether or not print statements shall report on the function progess. |
cell_area |
a logical value indicating whether or not to add cell (stamp polygon) areas (from |
node_node_links |
a logical value indicating whether or not to add node-node links (from |
triag_nodes |
a logical value indicating whether or not to add triangular element triplets (from |
coast |
a logical value indicating whether or not to add coast information (from |
depth |
a logical value indicating whether or not to add a vector with the depth of each grid level (from |
ofile.ZAXIS |
a character specifying the z-axis ascii output file. Used only if |
fesom2velocities |
a logical value indicating whether or not a grid description for values defined at the centroids of the triangular elements (like horizontal velocities in FESOM2) instead of at the vertices shall be generated. Implemented only for |
conventions |
a character influencing the variable, dimension, and unit naming conventions. Set this to |
This is a special function that is typically used when converting FESOM grid information to a CDO-readable format. To use the resulting file with CDOs, use the operator 'setgrid', e.g., 'CDO setgrid,gridfile.nc ifile.nc ofile.nc', where 'gridfile.nc' is the file generated with sl.grid.writeCDO()
and 'ifile.nc' is a FESOM output file.
See also the CDO operator 'setzaxis' to set the z-axis with the also generated z-axis description file (if applicable).
Note that in case of 3D data (including several depth levels), depending on the exact format of the original FESOM output file, it might be necessary to add information directly to the NetCDF file about the order in which the dimensions are stored before 'setgrid' can be applied. For example, if the dimensions in original FESOM2 output are stored in the unusual order time-horizontal-vertical (most tools expect time-vertical-horizontal) and the z-axis is not identifyable by certain attributes, this information must be added to the relevant variables, e.g. with the NCOs as follows:
ncatted -a axis,<varname>,c,c,"T-Z" fesom_output.nc
Helge Goessling
sl.grid.readFESOM
, sl.grid.writeZAXIS
## Not run:
# In this example a 'backward rotation' is performed, assuming that the original mesh coordinates are rotated;
# if that's not the case (which is now default), set 'rot=FALSE' or leave it unspecified (default is FALSE).
grid = sl.grid.readFESOM(griddir="PATH-TO-YOUR-FESOM-GRID",rot=TRUE,rot.invert=TRUE,rot.abg=c(50,15,-90))
# Write a grid description that is valid for quantities defined at nodes:
sl.grid.writeCDO(grid,ofile="~/sl.grid.scalars.nc")
# Write a grid description that is valid for quantities defined at element centers (or representative for elements):
sl.grid.writeCDO(grid,ofile="~/sl.grid.vectors.nc",fesom2velocities=TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.