ncclamp is a command-line tool for NetCDF files that allows you to replace values in-place by specifying the variable, the old value to be replaced, the new value, and a comparison operator. The change is applied across all of the variable's dimensions, including the record dimension if any.
The following example would mask a variable "topography" to be Not-a-Number every below sea level.
ncclamp foo.nc topography 0 nan ltThis example would replace a value with -infinity.
ncclamp foo.nc var1 -1e9 -inf eqThis would create a binary mask of a variable.
ncclamp foo.nc veg -9999 0 '==' ncclamp foo.nc veg 0 1 '<>'
Source Code: ncclamp-0.1.tar.gz
make make test cp ncclamp /usr/local/bin make clean
ncclamp 0.1: Change values with another value using a comparison operator. Usage: ncclamp path varid oldvalue newvalue operator path: name of the NetCDF file. varid: id (or name) of the variable. oldvalue: old value such as 1e-10, 1.234, nan, -inf, or inf. newvalue: new value such as 1e-10, 1.234, nan, -inf, or inf. operator: '==', '<>', '!=', '<', '<=', '>', '>=', eq, neq, lt, le, gt, ge. Examples: ncclamp ncfoo.nc land nan -1e9 eq ncclamp ncfoo.nc topo 0 0 le
Version 0.1 * Added support for symbolic comparison operators, such as '==', '!=', '<>', '<=', etc.