source: TI02-CSML/trunk/csml/Examples/Parsing/ncTest.py @ 2049

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI02-CSML/trunk/csml/Examples/Parsing/ncTest.py@2049
Revision 2049, 692 bytes checked in by domlowe, 14 years ago (diff)

adding sample code - not yet revised for V2

Line 
1import csml.csmllibs.netCDFWriter as NetCDFWriter
2
3#tests netCDFWriter
4
5def main():
6    #some data
7    filename='hello.nc'
8    data=[[[1,2,3],[4,4,5],[1,2,3]],[[1,2,3],[4,4,5],[1,2,3]],[[1,2,3],[4,4,5],[1,2,3]]]
9    axes=['latitude','longitude','time']
10    varName ='snowfall'
11   
12    #initialise writer and write netcdf file
13    nc=NetCDFWriter.NCwriter(filename)
14    nc.addAxis('latitude',[90,70,50],isLan=1)
15    nc.addAxis('longitude',[60,70,80],isLon=1)
16    nc.addAxis('time',[10,50,100],isTime=1)
17    nc.addVariable(data,varName, axes,history='blah blah', units='flakesperminute',long_name='snowfall_at_surface')
18    nc.closeFinishedFile()
19    print 'file "%s" written'%filename
20
21main()
Note: See TracBrowser for help on using the repository browser.