SeismicData / pyasdf

Python Interface to ASDF based on ObsPy
http://seismicdata.github.io/pyasdf/
BSD 3-Clause "New" or "Revised" License
52 stars 30 forks source link

newer versions h5py > 2.1 will break pyasdf events #69

Closed danielpeter closed 3 years ago

danielpeter commented 3 years ago

it looks like newer versions of h5py don't support the Dataset.value property anymore: https://docs.h5py.org/en/stable/whatsnew/2.1.html

this will break pyasdf when listing events: in asdf_data_set.py

data = self.__file["QuakeML"]
if not len(data.value):
    return obspy.core.event.Catalog()

and in utils.py

return data.value.tostring().strip(b"\x00 ").strip()

a workaround would be to use numpy indexing data[()] instead of data.value:

if not len(data[()]):
    return obspy.core.event.Catalog()

and

return data[()].tobytes().strip(b"\x00 ").strip()

seems to work. not sure if more occurrences of data.value can be found though.

fixing the above two locations allows at least to print file infos again:

ds = pyasdf.ASDFDataSet(filename)
print(ds)
krischer commented 3 years ago

Hi Daniel,

sorry for my late reply on this.

Which version of pyasdf are you running? Because I think these issues should have been fixed quite some time ago and I also cannot find the offending lines in the current code base. I also just ran the test suite with h5py 3.2.1 and it seems to work for me.

danielpeter commented 3 years ago

great, sorry my bad...

i see it was a very old pyasdf version 0.4.0, still in use on my mac. updating it to the current version 0.7.5 fixes it.

many thanks, daniel