reading HDF4 file with python - more than one dataset with same name
Question: I have a HDF4 file I need to read with python. For this I use `pyhdf`. In most
cases I am quite happy to use `SD` class to open the file:

    
    
    import pyhdf.SD  as SD
    hdf = SD.SD(hdfFile)
    

and then continue with

    
    
    v1 = hdf.select('Data set 1')
    v2 = hdf.select('Data set 2')
    

However I have several groups in the HDF file and some variables appear in
more than one group having the same name:

In `Group 1` I have `Data set 3` and in `Group 2` I have `Data set 3` so my
`select` command will only select one of then I guess (without me knowing
which one?).

Is there a simple way of selecting (reading) `Data set 3` from `Group 1` and
then from `Group 2`?

I have looked at the `V` and `VS` modules. I found an example script that will
loop through all groups and subgroups etc. and find all variables (data sets).
But I have now Idea of how to connect those variables to the parent, as for me
to know into which group they belong.


Answer: I think that pyhdf might not be the best choice for this particular task. Have
you looked at [PyNIO](https://www.pyngl.ucar.edu/Nio.shtml)?

From the [HDF section of their
documentation](https://www.pyngl.ucar.edu/NioFormats.shtml#HDF):

> PyNIO has a read-only ability to understand HDF Vgroups. When a variable
> that is part of a Vgroup is encountered, PyNIO appends a double underscore
> and the group number to the end of the variable name. This ensures that the
> variable will have a unique name, relative to variables that belong to other
> Vgroups. It also provides two additional attributes to the variable:
> hdf_group, whose value is the HDF string name of the group, and
> hdf_group_id, whose value is the same as the group number appended to the
> end of the variable name.

