Specify _FillValue for created variable

From: Carl Drews <drews_at_nyahnyahspammersnyahnyah>
Date: Fri Mar 25 2011 - 14:37:45 MDT

Using Nio and Python, how do I create a variable that looks like this
ncdump -h:

         float Hwave(ocean_time, eta_rho, xi_rho) ;
                 Hwave:long_name = "wind-induced significant wave height" ;
                 Hwave:units = "meter" ;
                 Hwave:time = "ocean_time" ;
                 Hwave:coordinates = "x_rho y_rho ocean_time" ;
                 Hwave:field = "Hwave, scalar, series" ;
                 Hwave:_FillValue = 1.e+37f ;

Here's what I'm trying:

    varName = 'Hwave'
    newVar = file.create_variable(varName, 'd', ('eta_rho','xi_rho'))
    newVar.long_name = 'wind-induced significant wave height'
    newVar.units = 'meter'
    newVar.coordinates = 'x_rho y_rho ocean_time'
    newVar.field = 'Hwave, scalar, series'
    newVar._FillValue = 1.e+37

and I get this run-time error message:

Traceback (most recent call last):
   File "waves.py", line 227, in <module>
     createWaveFile(outFile, sigHeight, avgLength, avgDirection)
   File "waves.py", line 148, in createWaveFile
     newVar._FillValue = 1.e+37
   File "/usr/local/python/lib/python2.5/site-packages/PyNIO/Nio.py",
line 188, in __setattr__
     setattr(self._obj,attrib,value)
NIOError: Memory allocation error

Carl Drews
_______________________________________________
pyngl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
Received on Fri Mar 25 14:37:48 2011

This archive was generated by hypermail 2.1.8 : Wed May 18 2011 - 12:00:50 MDT