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

Errors with NX_BOOLEAN for h5py #34

Open
domna opened this issue Jul 28, 2022 · 3 comments
Open

Errors with NX_BOOLEAN for h5py #34

domna opened this issue Jul 28, 2022 · 3 comments

Comments

@domna
Copy link

domna commented Jul 28, 2022

I'm using h5py for storing a file in NeXus format and I'm having problems with values stored in NX_BOOLEAN type.
h5py stores boolean values as a H5T_ENUM according to their FAQ, which creates an error for me when validating a file:

definition=NXmpes.nxdl.xml message="Data type mismatch, expected NX_BOOLEAN, got H5T_ENUM {
      H5T_STD_I8LE;
      "FALSE"            0;
      "TRUE"             1;
   }" 
... nxdlPath=/NXentry/NXprocess/NXcalibration/applied 
... sev=error dataPath=/entry/process/energy_calibration/applied dataFile=MoTe.mpes.nxs

It would be really nice if nxvalidate would also accept this exact enum as a form of NX_BOOLEAN.

@domna domna changed the title Errors on NX_BOOLEAN for h5py Errors with NX_BOOLEAN for h5py Jul 28, 2022
@mkoennecke
Copy link
Contributor

NeXus interprets NX_BOOLEAN differently than h5py. NeXus uses an integer of 1 byte for NX_BOOLEAN. This is an int8 or uint8. The reason for this is historically: this has been defined before h5py existed and before the HDF group defined a H5T_ENUM for booleans.

@rayosborn
Copy link

I think it would be appropriate for cnxvalidate to allow uint8s when a NX_BOOLEAN is required, since many NeXus files are written by h5py.

@prjemian
Copy link
Contributor

Note that NX_BOOLEAN allows more than just integer representations:

	<xs:simpleType name="NX_BOOLEAN">
		<xs:annotation>
			<xs:documentation>true/false value ( true | 1 | false | 0 )</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:boolean" />
	</xs:simpleType>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants