gonum / hdf5

hdf5 is a wrapper for the HDF5 library
BSD 3-Clause "New" or "Revised" License
131 stars 33 forks source link

Can't open attributes on the root group #39

Open braunsonm opened 6 years ago

braunsonm commented 6 years ago

What are you trying to do?

View an attribute on the root path of the HDF5 File "/"

What did you do?

        f, err := hdf5.OpenFile(event.Name(), hdf5.F_ACC_RDONLY)
        if err != nil {
            log.Fatalln("Panic, could not open file")
        }

        d, err := f.OpenGroup("/")
        if err != nil {
            log.Fatalln("Panic, could not open dataset")
            return
        }

        attr, err := d.OpenAttribute("file_version")

OpenAttributes on a group doesn't seem to work. You can however call CreateAttribute, just not read from it.

What did you expect to happen?

The ability to open an attribute like on a dataset.

What version of Go, Gonum, Gonum/netlib and libhdf5 are you using?

go version go1.10.2 linux/amd64

Does this issue reproduce with the current master?

Unknown

donkahlero commented 6 years ago

Hi @ChaosCA

Is it even necessary to open the group your particular example? Can you try to call f.OpenAttribute("file_version") and remove the group related code instead?

Cheers!

braunsonm commented 6 years ago

I don't believe that method exists @TacoVox I can't OpenAttributes against a file handler.

delaneyj commented 5 years ago

@ChaosCA did you ever find a solution or workaround?

braunsonm commented 5 years ago

Nope, you could directly call the C API though. I believe that is what I ended up doing. Or just defer work to the excellent Python API for HDF5.

For C, you'd open the attribute, similar to how it's done here: https://github.com/gonum/hdf5/blob/master/h5a_attribute.go#L35

And using this function: https://support.hdfgroup.org/HDF5/doc/RM/RM_H5A.html#Annot-Open

And then you'd read the data from the attribute.