pyhdf icon indicating copy to clipboard operation
pyhdf copied to clipboard

why i get a problem "HDF4Error: SD (60): HDF Internal error"

Open cartoonistOL opened this issue 1 year ago • 1 comments

What version of pyhdf, HDF4, and Python are you using?

pyhdf version:0.10.5 HDF4 C library version: Python version:3.8

What operating system are you using?

windows

What did you do?

from pyhdf.SD import SD
hdf = SD(path)
    print(hdf.info())  
    data = hdf.datasets()
    for i in data:
        print(i)  
        img = hdf.select(i)[:] 
        plt.imshow(img, cmap='gray') 
        plt.show()

What did you expect to see?

a picture

What did you see instead?

HDF4Error                                 Traceback (most recent call last)
Input In [152], in <cell line: 1>()
----> 1 get_data("GLASS04B01.V42.A2016109.2019363.hdf",rgbpath)

Input In [146], in get_data(path, tiff)
     33 def get_data(path,tiff):
---> 35     hdf = SD(path)
     36     #print(hdf.info())  
     37     data = hdf.datasets()

File ~/miniconda3/lib/python3.8/site-packages/pyhdf/SD.py:1429, in SD.__init__(self, path, mode)
   1426     raise HDF4Error("SD: bad mode, READ or WRITE must be set")
   1428 id = _C.SDstart(path, mode)
-> 1429 _checkErr('SD', id, "cannot open %s" % path)
   1430 self._id = id

File ~/miniconda3/lib/python3.8/site-packages/pyhdf/error.py:23, in _checkErr(procName, val, msg)
     21 else:
     22     err = "%s : %s" % (procName, msg)
---> 23 raise HDF4Error(err)

HDF4Error: SD (60): HDF Internal error```

cartoonistOL avatar Aug 03 '22 06:08 cartoonistOL

i can open some .hdf files,while a few .hdf files can't be opened successfully.

cartoonistOL avatar Aug 03 '22 06:08 cartoonistOL