-
Notifications
You must be signed in to change notification settings - Fork 7
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
How to implement correctly type from NXdetector in hdf? #33
Comments
That is the correct way of storing variable-length strings, but I think it's the h5py default, so you probably don't have to specify a dtype at all. You could also store the string as fixed-length byte strings, because NeXus doesn't specify how strings are stored. However, variable-length strings would allow you to change the value more easily if you need to and are more flexible in handling Unicode. I would also like to suggest you have a look at the nexusformat package, which would help to ensure that you write NeXus-compliant files. It's uses h5py, but handles things like setting the class variables automatically and is more succinct. Your four lines above could be written as:
There is more documentation here. |
Dear @rayosborn Thank you very much for your quick help. Thanks for pointing out to the nexusformat package. I saw it before, but I know already h5py and it was suggested to me that I use h5py. I will make a suggestion to use the nexusformat. Again, thank you for your help. |
The nexusformat package is a thin layer on top of h5py that ensures that certain NeXus rules are obeyed, understands NeXus classes, and how to construct NXdata groups, so I personally think it makes sense to use it, particularly if you are new to NeXus, but then I am biased. You can try it out in an online Jupyter notebook if you want to see what it does. |
Dear Nexus community,
Could I ask here for advice, please?
NXdetector has an entry called type
https://manual.nexusformat.org/classes/base_classes/NXdetector.html
"Description of type such as He3 gas cylinder, He3 PSD, scintillator, fission chamber, proportion counter, ion chamber, ccd, pixel, image plate, CMOS, …"
How do I implement this with h5py correctly?
The manual for h5py does not give an example for string datasets. https://docs.h5py.org/en/stable/strings.html#storing-strings
My approach:
But I don't know if this is the correct way.
Thank you for your help.
The text was updated successfully, but these errors were encountered: