Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSIDReader has issues when trying to import hdf5 file with multiple files #130

Open
ramav87 opened this issue Jun 5, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@ramav87
Copy link
Contributor

ramav87 commented Jun 5, 2024

When a hdf5 file has multiple files, NSIDReader appears to fail.

Additionally, it is not possible to provide a HDF group when instantiating the reader, contrary to the documentation. Both of these are critical level functions that need to be fixed. For example, in the Intro to pycroscopy notebook, attempting to recover the fitted IV spectra from the generated hf5 file is impossible.

@ramav87 ramav87 added the bug Something isn't working label Jun 5, 2024
@ramav87 ramav87 self-assigned this Jun 5, 2024
@ramav87
Copy link
Contributor Author

ramav87 commented Jun 6, 2024

I have narrowed this down to a single line in pyNSID: line 143 in hdf_utils.py

setattr(dataset, key, h5_group_to_dict(dset.parent[key])[key])

Commenting out this line appears to solve the issue, however, this is clearly not ideal. The function already checks if dset.parent[key] is a h5group, but why it fails for some groups needs to be investigated.

File ~/Github/sidpy/sidpy/hdf/hdf_utils.py:818, in h5_group_to_dict(group_iter, group_dict)
    815 group_dict[group_iter.name.split('/')[-1]] = dict(group_iter.attrs)
    817 for key in group_iter.keys():
--> 818     h5_group_to_dict(group_iter[key], group_dict[group_iter.name.split('/')[-1]])
    819 return group_dict

File ~/Github/sidpy/sidpy/hdf/hdf_utils.py:811, in h5_group_to_dict(group_iter, group_dict)
    796 """ 
    797 Reads a hdf5 group into a nested dictionary
    798 
   (...)
    807 group_dict: dict
    808 """
    810 if not isinstance(group_iter, h5py.Group):
--> 811     raise TypeError('we need a h5py group to read from. Type given was {}'.format(type(group_iter)))
    812 if not isinstance(group_dict, dict):
    813     raise TypeError('group_dict needs to be a python dictionary')

TypeError: we need a h5py group to read from. Type given was <class 'h5py._hl.dataset.Dataset'>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant