netCDF operator (nco, cdo)

ncrename - netCDF Renamer

Options > -a old_name, new_name Attribute renaming. The old and new names of the attribute are specified by the associated old_name and new_name values. Global attributes are treated no differently than variable attributes. This option may be specified more than once. You cannot change the attribute name for one particular variable (unless it is uniquely named); all occurrences of the attribute of a given name will be renamed. This is considered an oversight and will be addressed in a future version of NCO. -d old_name, new_name Dimension renaming. The old and new names of the dimension are specified by the associated old_name and new_name values. This option may be specified more than once. -v old_name, new_name Variable renaming. The old and new names of the variable are specified by the associated old_name and new_name values. This option may be specified more than once. -i >Interactive. ncrename will prompt for confirmation before overwriting an existing file.

Examples Rename the variable p to pressure and t to temperature in netCDF in.nc. In this case p must exist in the input file (or ncrename will abort), but the presence of t is optional:

1
$ ncrename -v p,pressure -v .t,temperature in.nc
ncrename does not automatically attach dimensions to variables of the same name. If you want to rename a coordinate variable so that it remains a coordinate variable, you must separately rename both the dimension and the variable:
1
$ ncrename -d lon,longitude -v lon,longitude in.nc

ncrcat - netCDF Record Concatenator

ncrcat concatenates record variables across an arbitrary number of input files. The final record dimension is by default the sum of the lengths of the record dimensions in the input files.

1
2
3
$ ncrcat -O "diag*.nc" ${path_out}
$ ncrcat 85.nc 86.nc 87.nc 88.nc 89.nc 8589.nc
$ ncrcat 8[56789].nc 8589.nc
How to Concatenate the Time Dimension of netCDF Files with NCO

Appending variables

This puts the contents yyy of bbb.nc into aaa.nc.

1
$ ncks -A -v yyy bbb.nc aaa.nc

ncdiff - netCDF Differencer

1
$ ncdiff 86_0112.nc 85_0112.nc diff.nc

cdo sub

1
$ cdo sub v1.nc v2.nc diff.nc

netCDF operator (nco, cdo)
https://waipangsze.github.io/2023/06/24/cdo/
Author
wpsze
Posted on
June 24, 2023
Updated on
October 8, 2024
Licensed under