Writing data to NetCDF (extract from one file and write to another).
Goal: Learn how to write data in CDAT.
Writing data in
CDAT is very easy, just define a variable you want to save to a file,
open file to write and enter command to write data. The output file
will be a NetCDF file with the variable data and it's annotation.
import cdms
f = cdms.open('sample.nc')
u =f('u') # read data from an input file
f.close()
# write the variable u to a new file
g = cdms.open('sample2.nc','w')
g.write(u)
g.close()