writing netcdf files

From: Wendi Madsen <Wendi.B.Madsen_at_nyahnyahspammersnyahnyah>
Date: Tue, 08 Aug 2006 14:52:57 -0600

Good Afternoon

I am trying to write some netcdf files using Nio. I can create the
file, and create the dimensions and variables and add attributes to the
various variables, but I can't seem to get any data into the file. here
is the code i am using:

        ncFileName = NCFileName[j] + "." + timeStr + "00" + ".nc"
        outNCFile = Nio.open_file(ncFileName, "c")
        outNCFile.create_dimension("lon", 144)
        outNCFile.create_dimension("lat", 73)
        outNCFile.create_dimension("level", 12)
        outNCFile.create_dimension("time", 0)
        outNCFile.create_dimension("chid", 4)
        outNCFile.create_variable("lon", 'f', ('lon',))
        outNCFile.variables['lon'].units = "degrees_east"
        outNCFile.variables['lon'].long_name = "Longitude"
        outNCFile.create_variable('lat', 'f', ('lat',))
        outNCFile.variables['lat'].units = "degrees_north"
        outNCFile.variables['lat'].long_name = "Latitude"
        outNCFile.create_variable('level', 'f', ('level',))
        outNCFile.variables['level'].units = "millibar"
        outNCFile.variables['level'].positive = "down"
        outNCFile.variables['level'].long_name = "Level"
        outNCFile.variables['level'].desc = "Level here actually
describes an ensemble forescst identifer, (see levids variable)"
        outNCFile.create_variable('time', 'd', ('time',))
        outNCFile.variables['time'].units = "hours since 1-1-1 00:00:0.0"
        outNCFile.variables['time'].title = "Valid Time"
        outNCFile.variables['time'].delta_t = "000-00-00 12:00:00"
        outNCFile.create_variable('levids', 'c', ('level', 'chid'))
        outNCFile.variables['levids'].long_name = "Level Identifier"
        outNCFile.variables['levids'].desc = "Used to map Level with
ensemble member Id"
        outNCFile.create_variable(NCVarName[j], 's', ('time', 'level',
'lat', 'lon'))
        outNCFile.variables['lon'].assign_value(lngData)
        outNCFile.variables['lat'][:] = latData
        outNCFile.close()

thanks for your assistance

Wendi Madsen

_______________________________________________
pyngl-talk mailing list
pyngl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/pyngl-talk

Received on Tue Aug 08 2006 - 14:52:57 MDT

This archive was generated by hypermail 2.2.0 : Wed Aug 09 2006 - 08:42:58 MDT