fhs / pyhdf

Python wrapper around the NCSA HDF version 4 library
https://pypi.org/project/pyhdf/
Other
46 stars 15 forks source link

How to get group attributes #42

Open daxinnan opened 4 years ago

daxinnan commented 4 years ago

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

pyhdf version: 0.10.2 HDF4 C library version: 4.2.13 Python version: 3.7.6

What operating system are you using?

Ubuntu 20.04

What did you do?

I use pyhdf to read CloudSat data, I just get some 2D datasets by SD and 1D data by HDF, How can I get the group attributes shown as following, I can't find the suitable usage or documents.

from pyhdf.SD import SD, SDC
from pyhdf import HDF, VS, V
import numpy as np
FILE_NAME = "2014068005444_41824_CS_2B-GEOPROF_GRANULE_P1_R05_E06_F00.hdf"
hdf = SD(FILE_NAME, SDC.READ)

# Read datasets.
DATAFIELD_NAME = 'Radar_Reflectivity'
dset = hdf.select(DATAFIELD_NAME)
data = dset[:, :]
h = HDF.HDF(FILE_NAME)
vs = h.vstart()

xid = vs.find('Latitude')
latid = vs.attach(xid)
latid.setfields('Latitude')
nrecs, _, _, _, _ = latid.inquire()
latitude = latid.read(nRec=nrecs)
latid.detach()

image

What did you expect to see?

What did you see instead?

gopikrishnangs44 commented 7 months ago

@daxinnan Did you find a solution for the same