[Numpy-discussion] problem calling SD.SDim.setname in pyhdf

Catherine Moroney Catherine.M.Moroney@jpl.nasa....
Mon Sep 29 17:39:29 CDT 2008


Hi,

I recently upgraded pyhdf from 0.7-3 to 0.8-2, and have noticed some
problems with the SD.SDim interface.

Specifically, the short test code attached works fine with version 0.7-3
and fails with version 0.8-2 when it's trying to assign a name
to the dimension.

I get the following error (below).  Does anybody else have similar  
problems
while trying to attach a name to an SDim object in the most recent  
version
of pyhdf?

I'm running on a Linux box, python version 2.5.

etting Dimension:  Dimension0
Traceback (most recent call last):
   File "./Test_pyhdf.py", line 35, in <module>
     main()
   File "./Test_pyhdf.py", line 27, in main
     dim.setname(dname)
   File "/usr/lib64/python2.5/site-packages/pyhdf/SD.py", line 2856,  
in setname
     _checkErr('setname', status, 'cannot execute')
   File "/usr/lib64/python2.5/site-packages/pyhdf/error.py", line 24,  
in _checkErr
     raise HDF4Error, str
pyhdf.error.HDF4Error: ('s', 'e', 't', 'n', 'a', 'm', 'e', ' ', ':',  
' ', 'c', 'a', 'n', 'n', 'o', 't', ' ', 'e', 'x', 'e', 'c', 'u', 't',  
'e')

Thanks for any help,

Catherine

#! /usr/bin/env python

from pyhdf import HDF
from pyhdf import SD

def main():

     rank = (10,20)
     flhdf = SD.SD("Test_pyhdf.hdf",HDF.HC.CREATE|HDF.HC.WRITE| 
HDF.HC.TRUNC)
     sds = flhdf.create("Test SDS",HDF.HC.INT32,rank)

     for idim in range(0,2):
         dim = sds.dim(idim)
         dname = "Dimension" + str(idim)
         print "Setting Dimension: ",dname
         dtype = HDF.HC.FLOAT32
         scale = [i for i in range(0,rank[idim])]
         dim.setname(dname)   <----- CRASHES ON THIS LINE
         dim.units = "None"
         dim.setscale(dtype, scale)

     sds.endaccess()
     flhdf.end()

if __name__ == "__main__":
     main()





More information about the Numpy-discussion mailing list