Type mismatch trying to save 8-bit integer

From: Sourish Basu <S.Basu_at_nyahnyahspammersnyahnyah>
Date: Mon Aug 23 2010 - 08:03:24 MDT

Hi all,

     I'm trying to save an array of 8-bit integers to a NetCDF/HDF file.
Sample script:

from numpy import *
from Nio import open_file
fid = open_file('test.nc','w')
fid.create_dimension('dummy', 3)
var = fid.create_variable('dummy_var', 'b', ('dummy',))
var[:] = array([1, 2, 3], int8)

     at which point I get the following error (same for test.hdf):

NIOError Traceback (most recent call last)

/var/autofs/hd/data/GOSAT data/L2/<ipython console> in <module>()

/usr/local/lib/python2.6/site-packages/PyNIO/Nio.pyc in
__setitem__(self, xsel, value)
     362
     363 if not isinstance(xsel, xSelect) or xsel.isbasic:
--> 364 self._obj[xsel] = value
     365 else:
     366 bb = xsel.bndbox()

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

     I don't understand the source of this error. Why can't I save 8-bit
integers? I'm using python 2.6.5, numpy 1.3.0 and PyNio 1.3.0b4.

     As an aside, is there a way to save a logical variable to a
NetCDF/HDF file? The variable I want to save is just a yes/no (1/0)
flag, so even using 8 bits seems like a waste.

Thanks in advance,

Sourish Basu

_______________________________________________
pyngl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/pyngl-talk

Received on Mon Aug 23 08:02:23 2010

This archive was generated by hypermail 2.1.8 : Thu Sep 09 2010 - 15:43:50 MDT