hdf5 icon indicating copy to clipboard operation
hdf5 copied to clipboard

Can't open attributes on the root group

Open braunsonm opened this issue 7 years ago • 4 comments

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

braunsonm avatar Jul 27 '18 18:07 braunsonm

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!

donkahlero avatar Jul 30 '18 07:07 donkahlero

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

braunsonm avatar Jul 30 '18 13:07 braunsonm

@ChaosCA did you ever find a solution or workaround?

delaneyj avatar May 03 '19 21:05 delaneyj

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.

braunsonm avatar May 03 '19 21:05 braunsonm