WikiPrint - from Polar Technologies

Summary

Examples

Ncml could be a useful tool to manipulate netcdf files. In this example, we are going to describe how to modify the values of a particular variable (rlat) in an existing netcdf file (tas.nc).

For this purpuse it is necessary to generate a ncml that refers to that particular netcdf, by adding a location argument. Then, we just need to specify the variable name that we want to change, their values and the separator between them. The ncml file will look something like this:

<?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2" location="tas.nc">
  <variable name="rlat">
    <values start="0.883846282958984" incr="0.22"/>
  </variable>
</netcdf>

In order to save the changes in a new netcdf file, we can use toolsUI.

java -cp /software/meteo/jar/toolsUI-4.6.5.jar ucar.nc2.write.Nccopy --input rlat_new.ncml --output tas_new.nc --format netcdf4_classic -d 4 -sh