[pyngl-talk] writing a numpy array to a file

whannah whannah at rsmas.miami.edu
Wed Sep 3 12:06:29 MDT 2014


I'm trying to develop some code that will write new data to a file once 
a day. The "time" dimension is unlimited.

Here are some snippets of code that I thought should work

    outfile = nio.open_file(ofile, "w")
    fvar = outfile.create_variable('test', 'f', ('time','lat','lon'))

    fvar[0,:,:] = np.ones( (nlat,nlon) , dtype=float )

The last line throws this error:

    NIOError: type or dimensional mismatch writing to variable (test)

if I use a constant value

    fvar[0,:,:] = 1.

or I don't specify the indices of "fvar":

    fvar = np.ones( (nlat,nlon) , dtype=float )

I don't have any problems. But I really need to specify the time index. 
How do I write different numpy arrays to fvar[0,:,:] and fvar[1,:,:]?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/pyngl-talk/attachments/20140903/7f467f77/attachment.html 

More information about the pyngl-talk mailing list