diff --git a/.gitignore b/.gitignore index ee3d1d9..7e82c6d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ # Microsoft VSCode settings.json launch.json + +#pyCharm +.idea diff --git a/autogenerated_examples/nxdl/applications/NXarchive.hdf5 b/autogenerated_examples/nxdl/applications/NXarchive.h5 similarity index 89% rename from autogenerated_examples/nxdl/applications/NXarchive.hdf5 rename to autogenerated_examples/nxdl/applications/NXarchive.h5 index ca542b4..3e6eb45 100644 Binary files a/autogenerated_examples/nxdl/applications/NXarchive.hdf5 and b/autogenerated_examples/nxdl/applications/NXarchive.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXarpes.hdf5 b/autogenerated_examples/nxdl/applications/NXarpes.h5 similarity index 94% rename from autogenerated_examples/nxdl/applications/NXarpes.hdf5 rename to autogenerated_examples/nxdl/applications/NXarpes.h5 index 698f872..1ba4164 100644 Binary files a/autogenerated_examples/nxdl/applications/NXarpes.hdf5 and b/autogenerated_examples/nxdl/applications/NXarpes.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXcanSAS.hdf5 b/autogenerated_examples/nxdl/applications/NXcanSAS.h5 similarity index 83% rename from autogenerated_examples/nxdl/applications/NXcanSAS.hdf5 rename to autogenerated_examples/nxdl/applications/NXcanSAS.h5 index a6b9b6c..c12ab9c 100644 Binary files a/autogenerated_examples/nxdl/applications/NXcanSAS.hdf5 and b/autogenerated_examples/nxdl/applications/NXcanSAS.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXdirecttof.hdf5 b/autogenerated_examples/nxdl/applications/NXdirecttof.h5 similarity index 94% rename from autogenerated_examples/nxdl/applications/NXdirecttof.hdf5 rename to autogenerated_examples/nxdl/applications/NXdirecttof.h5 index bbcfaa1..9ed1637 100644 Binary files a/autogenerated_examples/nxdl/applications/NXdirecttof.hdf5 and b/autogenerated_examples/nxdl/applications/NXdirecttof.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXfluo.hdf5 b/autogenerated_examples/nxdl/applications/NXfluo.h5 similarity index 94% rename from autogenerated_examples/nxdl/applications/NXfluo.hdf5 rename to autogenerated_examples/nxdl/applications/NXfluo.h5 index e60c462..a815e0d 100644 Binary files a/autogenerated_examples/nxdl/applications/NXfluo.hdf5 and b/autogenerated_examples/nxdl/applications/NXfluo.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXindirecttof.hdf5 b/autogenerated_examples/nxdl/applications/NXindirecttof.h5 similarity index 94% rename from autogenerated_examples/nxdl/applications/NXindirecttof.hdf5 rename to autogenerated_examples/nxdl/applications/NXindirecttof.h5 index 4964aa6..c4c0f63 100644 Binary files a/autogenerated_examples/nxdl/applications/NXindirecttof.hdf5 and b/autogenerated_examples/nxdl/applications/NXindirecttof.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXiqproc.hdf5 b/autogenerated_examples/nxdl/applications/NXiqproc.h5 similarity index 95% rename from autogenerated_examples/nxdl/applications/NXiqproc.hdf5 rename to autogenerated_examples/nxdl/applications/NXiqproc.h5 index 2dd0fef..19d2f56 100644 Binary files a/autogenerated_examples/nxdl/applications/NXiqproc.hdf5 and b/autogenerated_examples/nxdl/applications/NXiqproc.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXlauetof.hdf5 b/autogenerated_examples/nxdl/applications/NXlauetof.h5 similarity index 91% rename from autogenerated_examples/nxdl/applications/NXlauetof.hdf5 rename to autogenerated_examples/nxdl/applications/NXlauetof.h5 index b0a3ce2..9149347 100644 Binary files a/autogenerated_examples/nxdl/applications/NXlauetof.hdf5 and b/autogenerated_examples/nxdl/applications/NXlauetof.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXmonopd.hdf5 b/autogenerated_examples/nxdl/applications/NXmonopd.h5 similarity index 94% rename from autogenerated_examples/nxdl/applications/NXmonopd.hdf5 rename to autogenerated_examples/nxdl/applications/NXmonopd.h5 index 61d450c..736a0c3 100644 Binary files a/autogenerated_examples/nxdl/applications/NXmonopd.hdf5 and b/autogenerated_examples/nxdl/applications/NXmonopd.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXmx.hdf5 b/autogenerated_examples/nxdl/applications/NXmx.h5 similarity index 87% rename from autogenerated_examples/nxdl/applications/NXmx.hdf5 rename to autogenerated_examples/nxdl/applications/NXmx.h5 index b7de82e..f765220 100644 Binary files a/autogenerated_examples/nxdl/applications/NXmx.hdf5 and b/autogenerated_examples/nxdl/applications/NXmx.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXrefscan.hdf5 b/autogenerated_examples/nxdl/applications/NXrefscan.h5 similarity index 83% rename from autogenerated_examples/nxdl/applications/NXrefscan.hdf5 rename to autogenerated_examples/nxdl/applications/NXrefscan.h5 index ff2733b..9638d6c 100644 Binary files a/autogenerated_examples/nxdl/applications/NXrefscan.hdf5 and b/autogenerated_examples/nxdl/applications/NXrefscan.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXreftof.hdf5 b/autogenerated_examples/nxdl/applications/NXreftof.h5 similarity index 93% rename from autogenerated_examples/nxdl/applications/NXreftof.hdf5 rename to autogenerated_examples/nxdl/applications/NXreftof.h5 index e10b3cd..ae2b55e 100644 Binary files a/autogenerated_examples/nxdl/applications/NXreftof.hdf5 and b/autogenerated_examples/nxdl/applications/NXreftof.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXsas.hdf5 b/autogenerated_examples/nxdl/applications/NXsas.h5 similarity index 94% rename from autogenerated_examples/nxdl/applications/NXsas.hdf5 rename to autogenerated_examples/nxdl/applications/NXsas.h5 index 915a535..daf4c22 100644 Binary files a/autogenerated_examples/nxdl/applications/NXsas.hdf5 and b/autogenerated_examples/nxdl/applications/NXsas.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXsastof.hdf5 b/autogenerated_examples/nxdl/applications/NXsastof.h5 similarity index 93% rename from autogenerated_examples/nxdl/applications/NXsastof.hdf5 rename to autogenerated_examples/nxdl/applications/NXsastof.h5 index 5317890..222489f 100644 Binary files a/autogenerated_examples/nxdl/applications/NXsastof.hdf5 and b/autogenerated_examples/nxdl/applications/NXsastof.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXscan.hdf5 b/autogenerated_examples/nxdl/applications/NXscan.h5 similarity index 94% rename from autogenerated_examples/nxdl/applications/NXscan.hdf5 rename to autogenerated_examples/nxdl/applications/NXscan.h5 index 9b2804b..c051d33 100644 Binary files a/autogenerated_examples/nxdl/applications/NXscan.hdf5 and b/autogenerated_examples/nxdl/applications/NXscan.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXspe.hdf5 b/autogenerated_examples/nxdl/applications/NXspe.h5 similarity index 93% rename from autogenerated_examples/nxdl/applications/NXspe.hdf5 rename to autogenerated_examples/nxdl/applications/NXspe.h5 index a7e7c01..ccf1689 100644 Binary files a/autogenerated_examples/nxdl/applications/NXspe.hdf5 and b/autogenerated_examples/nxdl/applications/NXspe.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXsqom.hdf5 b/autogenerated_examples/nxdl/applications/NXsqom.h5 similarity index 95% rename from autogenerated_examples/nxdl/applications/NXsqom.hdf5 rename to autogenerated_examples/nxdl/applications/NXsqom.h5 index 4c1b066..f13531b 100644 Binary files a/autogenerated_examples/nxdl/applications/NXsqom.hdf5 and b/autogenerated_examples/nxdl/applications/NXsqom.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXstxm.hdf5 b/autogenerated_examples/nxdl/applications/NXstxm.h5 similarity index 94% rename from autogenerated_examples/nxdl/applications/NXstxm.hdf5 rename to autogenerated_examples/nxdl/applications/NXstxm.h5 index 9f456dc..6252beb 100644 Binary files a/autogenerated_examples/nxdl/applications/NXstxm.hdf5 and b/autogenerated_examples/nxdl/applications/NXstxm.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXtas.hdf5 b/autogenerated_examples/nxdl/applications/NXtas.h5 similarity index 93% rename from autogenerated_examples/nxdl/applications/NXtas.hdf5 rename to autogenerated_examples/nxdl/applications/NXtas.h5 index 928a9b0..e24c563 100644 Binary files a/autogenerated_examples/nxdl/applications/NXtas.hdf5 and b/autogenerated_examples/nxdl/applications/NXtas.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXtofnpd.hdf5 b/autogenerated_examples/nxdl/applications/NXtofnpd.h5 similarity index 94% rename from autogenerated_examples/nxdl/applications/NXtofnpd.hdf5 rename to autogenerated_examples/nxdl/applications/NXtofnpd.h5 index e6bbf64..3d8e2b0 100644 Binary files a/autogenerated_examples/nxdl/applications/NXtofnpd.hdf5 and b/autogenerated_examples/nxdl/applications/NXtofnpd.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXtofraw.hdf5 b/autogenerated_examples/nxdl/applications/NXtofraw.h5 similarity index 93% rename from autogenerated_examples/nxdl/applications/NXtofraw.hdf5 rename to autogenerated_examples/nxdl/applications/NXtofraw.h5 index 4236545..f20c064 100644 Binary files a/autogenerated_examples/nxdl/applications/NXtofraw.hdf5 and b/autogenerated_examples/nxdl/applications/NXtofraw.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXtofsingle.hdf5 b/autogenerated_examples/nxdl/applications/NXtofsingle.h5 similarity index 94% rename from autogenerated_examples/nxdl/applications/NXtofsingle.hdf5 rename to autogenerated_examples/nxdl/applications/NXtofsingle.h5 index 5cf1af3..73548d3 100644 Binary files a/autogenerated_examples/nxdl/applications/NXtofsingle.hdf5 and b/autogenerated_examples/nxdl/applications/NXtofsingle.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXtomo.hdf5 b/autogenerated_examples/nxdl/applications/NXtomo.h5 similarity index 94% rename from autogenerated_examples/nxdl/applications/NXtomo.hdf5 rename to autogenerated_examples/nxdl/applications/NXtomo.h5 index bf4d8b7..d9f3b43 100644 Binary files a/autogenerated_examples/nxdl/applications/NXtomo.hdf5 and b/autogenerated_examples/nxdl/applications/NXtomo.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXtomophase.hdf5 b/autogenerated_examples/nxdl/applications/NXtomophase.h5 similarity index 94% rename from autogenerated_examples/nxdl/applications/NXtomophase.hdf5 rename to autogenerated_examples/nxdl/applications/NXtomophase.h5 index 5b22290..56b00e4 100644 Binary files a/autogenerated_examples/nxdl/applications/NXtomophase.hdf5 and b/autogenerated_examples/nxdl/applications/NXtomophase.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXtomoproc.hdf5 b/autogenerated_examples/nxdl/applications/NXtomoproc.h5 similarity index 95% rename from autogenerated_examples/nxdl/applications/NXtomoproc.hdf5 rename to autogenerated_examples/nxdl/applications/NXtomoproc.h5 index 67a686b..4dcf608 100644 Binary files a/autogenerated_examples/nxdl/applications/NXtomoproc.hdf5 and b/autogenerated_examples/nxdl/applications/NXtomoproc.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXxas.hdf5 b/autogenerated_examples/nxdl/applications/NXxas.h5 similarity index 94% rename from autogenerated_examples/nxdl/applications/NXxas.hdf5 rename to autogenerated_examples/nxdl/applications/NXxas.h5 index 45dde21..df485c4 100644 Binary files a/autogenerated_examples/nxdl/applications/NXxas.hdf5 and b/autogenerated_examples/nxdl/applications/NXxas.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXxasproc.hdf5 b/autogenerated_examples/nxdl/applications/NXxasproc.h5 similarity index 80% rename from autogenerated_examples/nxdl/applications/NXxasproc.hdf5 rename to autogenerated_examples/nxdl/applications/NXxasproc.h5 index e430ac8..d959688 100644 Binary files a/autogenerated_examples/nxdl/applications/NXxasproc.hdf5 and b/autogenerated_examples/nxdl/applications/NXxasproc.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXxbase.hdf5 b/autogenerated_examples/nxdl/applications/NXxbase.h5 similarity index 90% rename from autogenerated_examples/nxdl/applications/NXxbase.hdf5 rename to autogenerated_examples/nxdl/applications/NXxbase.h5 index ed582dc..7babf5c 100644 Binary files a/autogenerated_examples/nxdl/applications/NXxbase.hdf5 and b/autogenerated_examples/nxdl/applications/NXxbase.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXxeuler.hdf5 b/autogenerated_examples/nxdl/applications/NXxeuler.h5 similarity index 89% rename from autogenerated_examples/nxdl/applications/NXxeuler.hdf5 rename to autogenerated_examples/nxdl/applications/NXxeuler.h5 index 9679484..23c7db1 100644 Binary files a/autogenerated_examples/nxdl/applications/NXxeuler.hdf5 and b/autogenerated_examples/nxdl/applications/NXxeuler.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXxkappa.hdf5 b/autogenerated_examples/nxdl/applications/NXxkappa.h5 similarity index 89% rename from autogenerated_examples/nxdl/applications/NXxkappa.hdf5 rename to autogenerated_examples/nxdl/applications/NXxkappa.h5 index 016115d..81bf6af 100644 Binary files a/autogenerated_examples/nxdl/applications/NXxkappa.hdf5 and b/autogenerated_examples/nxdl/applications/NXxkappa.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXxlaue.hdf5 b/autogenerated_examples/nxdl/applications/NXxlaue.h5 similarity index 89% rename from autogenerated_examples/nxdl/applications/NXxlaue.hdf5 rename to autogenerated_examples/nxdl/applications/NXxlaue.h5 index 106d6d4..9d83af6 100644 Binary files a/autogenerated_examples/nxdl/applications/NXxlaue.hdf5 and b/autogenerated_examples/nxdl/applications/NXxlaue.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXxlaueplate.hdf5 b/autogenerated_examples/nxdl/applications/NXxlaueplate.h5 similarity index 89% rename from autogenerated_examples/nxdl/applications/NXxlaueplate.hdf5 rename to autogenerated_examples/nxdl/applications/NXxlaueplate.h5 index 74dc307..fbca075 100644 Binary files a/autogenerated_examples/nxdl/applications/NXxlaueplate.hdf5 and b/autogenerated_examples/nxdl/applications/NXxlaueplate.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXxnb.hdf5 b/autogenerated_examples/nxdl/applications/NXxnb.h5 similarity index 90% rename from autogenerated_examples/nxdl/applications/NXxnb.hdf5 rename to autogenerated_examples/nxdl/applications/NXxnb.h5 index f90bfb1..b3081f5 100644 Binary files a/autogenerated_examples/nxdl/applications/NXxnb.hdf5 and b/autogenerated_examples/nxdl/applications/NXxnb.h5 differ diff --git a/autogenerated_examples/nxdl/applications/NXxrot.hdf5 b/autogenerated_examples/nxdl/applications/NXxrot.h5 similarity index 89% rename from autogenerated_examples/nxdl/applications/NXxrot.hdf5 rename to autogenerated_examples/nxdl/applications/NXxrot.h5 index 62c00b1..a82e418 100644 Binary files a/autogenerated_examples/nxdl/applications/NXxrot.hdf5 and b/autogenerated_examples/nxdl/applications/NXxrot.h5 differ diff --git a/autogenerated_examples/nxdl/contributed_definitions/NXcontainer.h5 b/autogenerated_examples/nxdl/contributed_definitions/NXcontainer.h5 new file mode 100644 index 0000000..547b9b4 Binary files /dev/null and b/autogenerated_examples/nxdl/contributed_definitions/NXcontainer.h5 differ diff --git a/autogenerated_examples/nxdl/contributed_definitions/NXcsg.h5 b/autogenerated_examples/nxdl/contributed_definitions/NXcsg.h5 new file mode 100644 index 0000000..af1e8c3 Binary files /dev/null and b/autogenerated_examples/nxdl/contributed_definitions/NXcsg.h5 differ diff --git a/autogenerated_examples/nxdl/contributed_definitions/NXcxi_ptycho.h5 b/autogenerated_examples/nxdl/contributed_definitions/NXcxi_ptycho.h5 new file mode 100644 index 0000000..6c14769 Binary files /dev/null and b/autogenerated_examples/nxdl/contributed_definitions/NXcxi_ptycho.h5 differ diff --git a/autogenerated_examples/nxdl/contributed_definitions/NXelectrostatic_kicker.h5 b/autogenerated_examples/nxdl/contributed_definitions/NXelectrostatic_kicker.h5 new file mode 100644 index 0000000..6590801 Binary files /dev/null and b/autogenerated_examples/nxdl/contributed_definitions/NXelectrostatic_kicker.h5 differ diff --git a/autogenerated_examples/nxdl/contributed_definitions/NXmagnetic_kicker.h5 b/autogenerated_examples/nxdl/contributed_definitions/NXmagnetic_kicker.h5 new file mode 100644 index 0000000..0ada931 Binary files /dev/null and b/autogenerated_examples/nxdl/contributed_definitions/NXmagnetic_kicker.h5 differ diff --git a/autogenerated_examples/nxdl/contributed_definitions/NXquadric.h5 b/autogenerated_examples/nxdl/contributed_definitions/NXquadric.h5 new file mode 100644 index 0000000..570b15d Binary files /dev/null and b/autogenerated_examples/nxdl/contributed_definitions/NXquadric.h5 differ diff --git a/autogenerated_examples/nxdl/contributed_definitions/NXquadrupole_magnet.h5 b/autogenerated_examples/nxdl/contributed_definitions/NXquadrupole_magnet.h5 new file mode 100644 index 0000000..3f207e9 Binary files /dev/null and b/autogenerated_examples/nxdl/contributed_definitions/NXquadrupole_magnet.h5 differ diff --git a/autogenerated_examples/nxdl/contributed_definitions/NXseparator.h5 b/autogenerated_examples/nxdl/contributed_definitions/NXseparator.h5 new file mode 100644 index 0000000..466c456 Binary files /dev/null and b/autogenerated_examples/nxdl/contributed_definitions/NXseparator.h5 differ diff --git a/autogenerated_examples/nxdl/contributed_definitions/NXsnsevent.h5 b/autogenerated_examples/nxdl/contributed_definitions/NXsnsevent.h5 new file mode 100644 index 0000000..7729017 Binary files /dev/null and b/autogenerated_examples/nxdl/contributed_definitions/NXsnsevent.h5 differ diff --git a/autogenerated_examples/nxdl/contributed_definitions/NXsnshisto.h5 b/autogenerated_examples/nxdl/contributed_definitions/NXsnshisto.h5 new file mode 100644 index 0000000..e70f782 Binary files /dev/null and b/autogenerated_examples/nxdl/contributed_definitions/NXsnshisto.h5 differ diff --git a/autogenerated_examples/nxdl/contributed_definitions/NXsolenoid_magnet.h5 b/autogenerated_examples/nxdl/contributed_definitions/NXsolenoid_magnet.h5 new file mode 100644 index 0000000..ea6c3a9 Binary files /dev/null and b/autogenerated_examples/nxdl/contributed_definitions/NXsolenoid_magnet.h5 differ diff --git a/autogenerated_examples/nxdl/contributed_definitions/NXsolid_geometry.h5 b/autogenerated_examples/nxdl/contributed_definitions/NXsolid_geometry.h5 new file mode 100644 index 0000000..21f5739 Binary files /dev/null and b/autogenerated_examples/nxdl/contributed_definitions/NXsolid_geometry.h5 differ diff --git a/autogenerated_examples/nxdl/contributed_definitions/NXspecdata.h5 b/autogenerated_examples/nxdl/contributed_definitions/NXspecdata.h5 new file mode 100644 index 0000000..fe0b8cc Binary files /dev/null and b/autogenerated_examples/nxdl/contributed_definitions/NXspecdata.h5 differ diff --git a/autogenerated_examples/nxdl/contributed_definitions/NXspin_rotator.h5 b/autogenerated_examples/nxdl/contributed_definitions/NXspin_rotator.h5 new file mode 100644 index 0000000..820ef3a Binary files /dev/null and b/autogenerated_examples/nxdl/contributed_definitions/NXspin_rotator.h5 differ diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXarchive.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXarchive.py index 86f3df8..b33bcb4 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXarchive.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXarchive.py @@ -57,11 +57,11 @@ root['/entry/entry_identifier'].attrs['type'] = 'NX_CHAR' root['/entry/entry_identifier'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='start_time', data='2021-03-29T15:51:33.227367', maxshape=None) +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:32.205127', maxshape=None) root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='end_time', data='2021-03-29T15:51:33.233370', maxshape=None) +root['/entry'].create_dataset(name='end_time', data='2022-03-04T14:56:32.220782', maxshape=None) root['/entry/end_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/end_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXarpes.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXarpes.py index 69964dc..106f433 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXarpes.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXarpes.py @@ -45,7 +45,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='start_time', data='2021-03-29T15:51:33.838489', maxshape=None) +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:32.376970', maxshape=None) root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXcanSAS.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXcanSAS.py index fba0355..72f104c 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXcanSAS.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXcanSAS.py @@ -315,7 +315,7 @@ root['/entry/process/name'].attrs['type'] = 'NX_CHAR' root['/entry/process/name'].attrs['EX_required'] = 'false' -root['/entry/process'].create_dataset(name='date', data='2021-03-29T15:51:36.547895', maxshape=None) +root['/entry/process'].create_dataset(name='date', data='2022-03-04T14:56:33.595457', maxshape=None) root['/entry/process/date'].attrs['type'] = 'NX_DATE_TIME' root['/entry/process/date'].attrs['EX_required'] = 'false' @@ -346,15 +346,15 @@ # Create the DOC strings root['/entry'].attrs['EX_doc'] = '.. index:: NXcanSAS (applications); SASentry Place the canSAS ``SASentry`` group as a child of a NeXus ``NXentry`` group (when data from multiple techniques are being stored) or as a replacement for the ``NXentry`` group. Note: It is required for all numerical objects to provide a *units* attribute that describes the engineering units. Use the Unidata UDunits [#]_ specification as this is compatible with various community standards. .. [#] The UDunits specification also includes instructions for derived units. ' root['/entry/definition'].attrs['EX_doc'] = 'Official NeXus NXDL schema to which this subentry conforms. ' -root['/entry/data'].attrs['EX_doc'] = 'A *SASData* group contains a single reduced small-angle scattering data set that can be represented as :math:`I(\vec{Q})` or :math:`I(|\vec{Q}|)`. *Q* can be either a vector (:math:`\vec{Q}`) or a vector magnitude (:math:`|\vec{Q}|`) The name of each *SASdata* group must be unique within a SASentry group. Suggest using names such as ``sasdata01``. NOTE: For the first *SASdata* group, be sure to write the chosen name into the `SASentry/@default` attribute, as in:: SASentry/@default="sasdata01" A *SASdata* group has several attributes: * I_axes * Q_indices * Mask_indices To indicate the dependency relationships of other varied parameters, use attributes similar to ``@Mask_indices`` (such as ``@Temperature_indices`` or ``@Pressure_indices``). ' -root['/entry/data/Q'].attrs['EX_doc'] = '.. index:: NXcanSAS (applications); Q Array of :math:`Q` data to accompany :math:`I`. .. figure:: canSAS/Q-geometry.jpg :width: 60% The :math:`\vec{Q}` geometry. (:download:`full image `) :math:`Q` may be represented as either the three-dimensional scattering vector :math:`\vec{Q}` or the magnitude of the scattering vector, :math:`|\vec{Q}|`. .. math:: |\vec{Q}| = (4\pi/\lambda) sin(\theta) When we write :math:`Q`, we may refer to either or both of :math:`|\vec{Q}|` or :math:`\vec{Q}`, depending on the context. ' -root['/entry/data/I'].attrs['EX_doc'] = '.. index:: NXcanSAS (applications); I Array of intensity (:math:`I`) data. The intensity may be represented in one of these forms: **absolute units**: :math:`d\Sigma/d\Omega(Q)` differential cross-section per unit volume per unit solid angle (such as: 1/cm/sr or 1/m/sr) **absolute units**: :math:`d\sigma/d\Omega(Q)` differential cross-section per unit atom per unit solid angle (such as: cm^2 or m^2) **arbitrary units**: :math:`I(Q)` usually a ratio of two detectors but units are meaningless (such as: a.u. or counts) This presents a few problems for analysis software to sort out when reading the data. Fortunately, it is possible to analyze the *units* to determine which type of intensity is being reported and make choices at the time the file is read. But this is an area for consideration and possible improvement. One problem arises with software that automatically converts data into some canonical units used by that software. The software should not convert units between these different types of intensity indiscriminately. A second problem is that when arbitrary units are used, then the set of possible analytical results is restricted. With such units, no meaningful volume fraction or number density can be determined directly from :math:`I(Q)`. In some cases, it is possible to apply a factor to convert the arbitrary units to an absolute scale. This should be considered as a possibility of the analysis process. Where this documentation says *typical units*, it is possible that small-angle data may be presented in other units and still be consistent with NeXus. See the :ref:`design-units` section. ' -root['/entry/data/Idev'].attrs['EX_doc'] = '.. index:: NXcanSAS (applications); Idev Estimated **uncertainty** (usually standard deviation) in :math:`I`. Must have the same units as :math:`I`. When present, the name of this field is also recorded in the *uncertainties* attribute of *I*, as in:: I/@uncertainties="Idev" ' -root['/entry/data/Qdev'].attrs['EX_doc'] = '.. index:: NXcanSAS (applications); Qdev Estimated :math:`Q` **resolution** (usually standard deviation). Must have the same units as :math:`Q`. When present, the name of this field is also recorded in the *resolutions* attribute of *Q*, as in:: Q/@resolutions="Qdev" or:: Q/@resolutions="dQw", "dQl" ' -root['/entry/data/dQw'].attrs['EX_doc'] = '.. index:: NXcanSAS (applications); dQw :math:`Q` **resolution** along the axis of scanning (the high-resolution *slit width* direction). Useful for defining resolution data from slit-smearing instruments such as Bonse-Hart geometry. Must have the same units as :math:`Q`. When present, the name of this field is also recorded in the *resolutions* attribute of *Q*, as in:: Q/@resolutions="dQw", "dQl" ' -root['/entry/data/dQl'].attrs['EX_doc'] = '.. index:: NXcanSAS (applications); dQl :math:`Q` **resolution** perpendicular to the axis of scanning (the low-resolution *slit length* direction). Useful for defining resolution data from slit-smearing instruments such as Bonse-Hart geometry. Must have the same units as :math:`Q`. When present, the name of this field is also recorded in the *resolutions* attribute of *Q*, as in:: Q/@resolutions="dQw", "dQl" ' +root['/entry/data'].attrs['EX_doc'] = '@default="sasdata01" A *SASdata* group has several attributes: * I_axes * Q_indices * Mask_indices To indicate the dependency relationships of other varied parameters, use attributes similar to ``@Mask_indices`` (such as ``@Temperature_indices`` or ``@Pressure_indices``). ' +root['/entry/data/Q'].attrs['EX_doc'] = '\lambda) sin(\theta) When we write :math:`Q`, we may refer to either or both of :math:`|\vec{Q}|` or :math:`\vec{Q}`, depending on the context. ' +root['/entry/data/I'].attrs['EX_doc'] = 'd\Omega(Q)` differential cross-section per unit atom per unit solid angle (such as: cm^2 or m^2) **arbitrary units**: :math:`I(Q)` usually a ratio of two detectors but units are meaningless (such as: a.u. or counts) This presents a few problems for analysis software to sort out when reading the data. Fortunately, it is possible to analyze the *units* to determine which type of intensity is being reported and make choices at the time the file is read. But this is an area for consideration and possible improvement. One problem arises with software that automatically converts data into some canonical units used by that software. The software should not convert units between these different types of intensity indiscriminately. A second problem is that when arbitrary units are used, then the set of possible analytical results is restricted. With such units, no meaningful volume fraction or number density can be determined directly from :math:`I(Q)`. In some cases, it is possible to apply a factor to convert the arbitrary units to an absolute scale. This should be considered as a possibility of the analysis process. Where this documentation says *typical units*, it is possible that small-angle data may be presented in other units and still be consistent with NeXus. See the :ref:`design-units` section. ' +root['/entry/data/Idev'].attrs['EX_doc'] = '@uncertainties="Idev" ' +root['/entry/data/Qdev'].attrs['EX_doc'] = '@resolutions="dQw", "dQl" ' +root['/entry/data/dQw'].attrs['EX_doc'] = '@resolutions="dQw", "dQl" ' +root['/entry/data/dQl'].attrs['EX_doc'] = '@resolutions="dQw", "dQl" ' root['/entry/data/Qmean'].attrs['EX_doc'] = 'Mean value of :math:`Q` for this data point. Useful when describing data that has been binned from higher-resolution data. It is expected that ``Q`` is provided and that both ``Q`` and ``Qmean`` will have the same units. ' -root['/entry/data/ShadowFactor'].attrs['EX_doc'] = 'A numerical factor applied to pixels affected by the beam stop penumbra. Used in data files from NIST/NCNR instruments. See: J.G. Barker and J.S. Pedersen (1995) *J. Appl. Cryst.* **28**, 105-114. ' +root['/entry/data/ShadowFactor'].attrs['EX_doc'] = 'NCNR instruments. See: J.G. Barker and J.S. Pedersen (1995) *J. Appl. Cryst.* **28**, 105-114. ' root['/entry/title'].attrs['EX_doc'] = 'Title of this *SASentry*. Make it so that you can recognize the data by its title. Could be the name of the sample, the name for the measured data, or something else representative. ' root['/entry/run'].attrs['EX_doc'] = 'Run identification for this *SASentry*. For many facilities, this is an integer, such as en experiment number. Use multiple instances of ``run`` as needed, keeping in mind that HDF5 requires unique names for all entities in a group. ' root['/entry/instrument'].attrs['EX_doc'] = 'Description of the small-angle scattering instrument. Consider, carefully, the relevance to the SAS data analysis process when adding subgroups in this **NXinstrument** group. Additional information can be added but will likely be ignored by standardized data anlysis processes. The NeXus :ref:`NXbeam` base class may be added as a subgroup of this **NXinstrument** group *or* as a subgroup of the **NXsample** group to describe properties of the beam at any point downstream from the source. ' @@ -363,7 +363,7 @@ root['/entry/instrument/aperture/x_gap'].attrs['EX_doc'] = 'opening along the :math:`x` axis ' root['/entry/instrument/aperture/y_gap'].attrs['EX_doc'] = 'opening along the :math:`y` axis ' root['/entry/instrument/collimator'].attrs['EX_doc'] = 'Description of a collimating element (defines the divergence of the beam) in the instrument. To document a slit, pinhole, or the beam, refer to the documentation of the ``NXinstrument`` group above. ' -root['/entry/instrument/collimator/length'].attrs['EX_doc'] = 'Amount/length of collimation inserted (as on a SANS instrument) ' +root['/entry/instrument/collimator/length'].attrs['EX_doc'] = 'length of collimation inserted (as on a SANS instrument) ' root['/entry/instrument/collimator/distance'].attrs['EX_doc'] = 'Distance from this collimation element to the sample ' root['/entry/instrument/detector'].attrs['EX_doc'] = 'Description of a detector in the instrument. ' root['/entry/instrument/detector/name'].attrs['EX_doc'] = 'Identifies the name of this detector ' @@ -390,7 +390,7 @@ root['/entry/sample'].attrs['EX_doc'] = 'Description of the sample. ' root['/entry/sample/name'].attrs['EX_doc'] = '**ID**: Text string that identifies this sample. ' root['/entry/sample/thickness'].attrs['EX_doc'] = 'Thickness of this sample ' -root['/entry/sample/transmission'].attrs['EX_doc'] = 'Transmission (:math:`I/I_0`) of this sample. There is no *units* attribute as this number is dimensionless. Note: the ability to store a transmission *spectrum*, instead of a single value, is provided elsewhere in the structure, in the *SAStransmission_spectrum* element. ' +root['/entry/sample/transmission'].attrs['EX_doc'] = 'I_0`) of this sample. There is no *units* attribute as this number is dimensionless. Note: the ability to store a transmission *spectrum*, instead of a single value, is provided elsewhere in the structure, in the *SAStransmission_spectrum* element. ' root['/entry/sample/temperature'].attrs['EX_doc'] = 'Temperature of this sample. ' root['/entry/sample/details'].attrs['EX_doc'] = 'Any additional sample details. ' root['/entry/sample/x_position'].attrs['EX_doc'] = 'Location of the sample in :math:`x` ' @@ -400,7 +400,7 @@ root['/entry/sample/yaw'].attrs['EX_doc'] = 'Rotation of the sample about the :math:`y` axis (yaw) ' root['/entry/process'].attrs['EX_doc'] = 'Description of a processing or analysis step. Add additional fields as needed to describe value(s) of any variable, parameter, or term related to the *SASprocess* step. Be sure to include *units* attributes for all numerical fields. ' root['/entry/process/name'].attrs['EX_doc'] = 'Optional name for this data processing or analysis step ' -root['/entry/process/date'].attrs['EX_doc'] = 'Optional date for this data processing or analysis step. [#iso8601]_ .. [#iso8601] ISO-8601 standard time representation. NeXus dates and times are reported in ISO-8601 (e.g., ``yyyy-mm-ddThh:mm:ss``) or modified ISO-8601 (e.g., ``yyyy-mm-dd hh:mm:ss``). See: http://www.w3.org/TR/NOTE-datetime or http://en.wikipedia.org/wiki/ISO_8601 for more details. ' +root['/entry/process/date'].attrs['EX_doc'] = 'ISO_8601 for more details. ' root['/entry/process/description'].attrs['EX_doc'] = 'Optional description for this data processing or analysis step ' root['/entry/process/term'].attrs['EX_doc'] = 'Specifies the value of a single variable, parameter, or term (while defined here as a string, it could be a number) related to the *SASprocess* step. Note: The name *term* is not required, it could take any name, as long as the name is unique within this group. ' root['/entry/process/note'].attrs['EX_doc'] = 'Any additional notes or subprocessing steps will be documented here. An **NXnote** group can be added to any NeXus group at or below the **NXentry** group. It is shown here as a suggestion of a good place to *consider* its use. ' @@ -408,48 +408,135 @@ root['/entry/collection'].attrs['EX_doc'] = 'Free form description of anything not covered by other elements. ' root['/entry/TRANSMISSION_SPECTRUM'].attrs['EX_doc'] = 'The *SAStransmission_spectrum* element This describes certain data obtained from a variable-wavelength source such as pulsed-neutron source. ' root['/entry/TRANSMISSION_SPECTRUM/lambda'].attrs['EX_doc'] = 'Wavelength of the radiation. This array is of the same shape as ``T`` and ``Tdev``. ' -root['/entry/TRANSMISSION_SPECTRUM/T'].attrs['EX_doc'] = 'Transmission values (:math:`I/I_0`) as a function of wavelength. This array is of the same shape as ``lambda`` and ``Tdev``. ' -root['/entry/TRANSMISSION_SPECTRUM/Tdev'].attrs['EX_doc'] = '.. index:: NXcanSAS (applications); Tdev Estimated uncertainty (usually standard deviation) in :math:`T`. Must have the same units as :math:`T`. This is the field is named in the *uncertainties* attribute of *T*, as in:: T/@uncertainties="Tdev" This array is of the same shape as ``lambda`` and ``T``. ' +root['/entry/TRANSMISSION_SPECTRUM/T'].attrs['EX_doc'] = 'I_0`) as a function of wavelength. This array is of the same shape as ``lambda`` and ``Tdev``. ' +root['/entry/TRANSMISSION_SPECTRUM/Tdev'].attrs['EX_doc'] = '@uncertainties="Tdev" This array is of the same shape as ``lambda`` and ``T``. ' # Create the ATTRIBUTES root['/entry'].attrs['default'] = 'SAMPLE-CHAR-DATA' -root['/entry'].attrs['canSAS_class'] = 'SAMPLE-CHAR-DATA' -root['/entry'].attrs['version'] = 'SAMPLE-CHAR-DATA' -root['/entry/data'].attrs['canSAS_class'] = 'SAMPLE-CHAR-DATA' -root['/entry/data'].attrs['signal'] = 'SAMPLE-CHAR-DATA' + +# Valid enumeration values for root['/entry']['canSAS_class'] are: +# SASentry +root['/entry'].attrs['canSAS_class'] = 'SASentry' + +# Valid enumeration values for root['/entry']['version'] are: +# 1.1 +root['/entry'].attrs['version'] = '1.1' + +# Valid enumeration values for root['/entry/data']['canSAS_class'] are: +# SASdata +root['/entry/data'].attrs['canSAS_class'] = 'SASdata' + +# Valid enumeration values for root['/entry/data']['signal'] are: +# I +root['/entry/data'].attrs['signal'] = 'I' root['/entry/data'].attrs['I_axes'] = 'SAMPLE-CHAR-DATA' -root['/entry/data'].attrs['Q_indices'] = '1' +root['/entry/data'].attrs['Q_indices'] = 'SAMPLE-CHAR-DATA' root['/entry/data'].attrs['mask'] = 'SAMPLE-CHAR-DATA' root['/entry/data'].attrs['Mask_indices'] = 'SAMPLE-CHAR-DATA' -root['/entry/data'].attrs['timestamp'] = '2021-03-29T15:51:36.601894' -root['/entry/data/Q'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root['/entry/data'].attrs['timestamp'] = 'SAMPLE-CHAR-DATA' + +# Valid enumeration values for root['/entry/data/Q']['units'] are: +# 1/m +# 1/nm +# 1/angstrom +root['/entry/data/Q'].attrs['units'] = 'm' root['/entry/data/Q'].attrs['uncertainties'] = 'SAMPLE-CHAR-DATA' root['/entry/data/Q'].attrs['resolutions'] = 'SAMPLE-CHAR-DATA' root['/entry/data/Q'].attrs['resolutions_description'] = 'SAMPLE-CHAR-DATA' -root['/entry/data/I'].attrs['units'] = 'SAMPLE-CHAR-DATA' + +# Valid enumeration values for root['/entry/data/I']['units'] are: +# 1/m +# 1/cm +# m2/g +# cm2/g +# arbitrary +root['/entry/data/I'].attrs['units'] = 'm' root['/entry/data/I'].attrs['uncertainties'] = 'SAMPLE-CHAR-DATA' root['/entry/data/I'].attrs['scaling_factor'] = 'SAMPLE-CHAR-DATA' -root['/entry/data/Idev'].attrs['units'] = 'SAMPLE-CHAR-DATA' -root['/entry/data/Qdev'].attrs['units'] = 'SAMPLE-CHAR-DATA' -root['/entry/data/dQw'].attrs['units'] = 'SAMPLE-CHAR-DATA' -root['/entry/data/dQl'].attrs['units'] = 'SAMPLE-CHAR-DATA' -root['/entry/data/Qmean'].attrs['units'] = 'SAMPLE-CHAR-DATA' + +# Valid enumeration values for root['/entry/data/Idev']['units'] are: +# 1/m +# 1/cm +# m2/g +# cm2/g +# arbitrary +root['/entry/data/Idev'].attrs['units'] = 'm' + +# Valid enumeration values for root['/entry/data/Qdev']['units'] are: +# 1/m +# 1/nm +# 1/angstrom +root['/entry/data/Qdev'].attrs['units'] = 'm' + +# Valid enumeration values for root['/entry/data/dQw']['units'] are: +# 1/m +# 1/nm +# 1/angstrom +root['/entry/data/dQw'].attrs['units'] = 'm' + +# Valid enumeration values for root['/entry/data/dQl']['units'] are: +# 1/m +# 1/nm +# 1/angstrom +root['/entry/data/dQl'].attrs['units'] = 'm' + +# Valid enumeration values for root['/entry/data/Qmean']['units'] are: +# 1/m +# 1/nm +# 1/angstrom +root['/entry/data/Qmean'].attrs['units'] = 'm' root['/entry/run'].attrs['name'] = 'SAMPLE-CHAR-DATA' -root['/entry/instrument'].attrs['canSAS_class'] = 'SAMPLE-CHAR-DATA' -root['/entry/instrument/aperture'].attrs['canSAS_class'] = 'SAMPLE-CHAR-DATA' -root['/entry/instrument/collimator'].attrs['canSAS_class'] = 'SAMPLE-CHAR-DATA' -root['/entry/instrument/detector'].attrs['canSAS_class'] = 'SAMPLE-CHAR-DATA' -root['/entry/instrument/source'].attrs['canSAS_class'] = 'SAMPLE-CHAR-DATA' -root['/entry/sample'].attrs['canSAS_class'] = 'SAMPLE-CHAR-DATA' -root['/entry/process'].attrs['canSAS_class'] = 'SAMPLE-CHAR-DATA' -root['/entry/process/collection'].attrs['canSAS_class'] = 'SAMPLE-CHAR-DATA' -root['/entry/collection'].attrs['canSAS_class'] = 'SAMPLE-CHAR-DATA' -root['/entry/TRANSMISSION_SPECTRUM'].attrs['canSAS_class'] = 'SAMPLE-CHAR-DATA' -root['/entry/TRANSMISSION_SPECTRUM'].attrs['signal'] = 'SAMPLE-CHAR-DATA' -root['/entry/TRANSMISSION_SPECTRUM'].attrs['T_axes'] = 'SAMPLE-CHAR-DATA' + +# Valid enumeration values for root['/entry/instrument']['canSAS_class'] are: +# SASinstrument +root['/entry/instrument'].attrs['canSAS_class'] = 'SASinstrument' + +# Valid enumeration values for root['/entry/instrument/aperture']['canSAS_class'] are: +# SASaperture +root['/entry/instrument/aperture'].attrs['canSAS_class'] = 'SASaperture' + +# Valid enumeration values for root['/entry/instrument/collimator']['canSAS_class'] are: +# SAScollimation +root['/entry/instrument/collimator'].attrs['canSAS_class'] = 'SAScollimation' + +# Valid enumeration values for root['/entry/instrument/detector']['canSAS_class'] are: +# SASdetector +root['/entry/instrument/detector'].attrs['canSAS_class'] = 'SASdetector' + +# Valid enumeration values for root['/entry/instrument/source']['canSAS_class'] are: +# SASsource +root['/entry/instrument/source'].attrs['canSAS_class'] = 'SASsource' + +# Valid enumeration values for root['/entry/sample']['canSAS_class'] are: +# SASsample +root['/entry/sample'].attrs['canSAS_class'] = 'SASsample' + +# Valid enumeration values for root['/entry/process']['canSAS_class'] are: +# SASprocess +root['/entry/process'].attrs['canSAS_class'] = 'SASprocess' + +# Valid enumeration values for root['/entry/process/collection']['canSAS_class'] are: +# SASprocessnote +root['/entry/process/collection'].attrs['canSAS_class'] = 'SASprocessnote' + +# Valid enumeration values for root['/entry/collection']['canSAS_class'] are: +# SASnote +root['/entry/collection'].attrs['canSAS_class'] = 'SASnote' + +# Valid enumeration values for root['/entry/TRANSMISSION_SPECTRUM']['canSAS_class'] are: +# SAStransmission_spectrum +root['/entry/TRANSMISSION_SPECTRUM'].attrs['canSAS_class'] = 'SAStransmission_spectrum' + +# Valid enumeration values for root['/entry/TRANSMISSION_SPECTRUM']['signal'] are: +# T +root['/entry/TRANSMISSION_SPECTRUM'].attrs['signal'] = 'T' + +# Valid enumeration values for root['/entry/TRANSMISSION_SPECTRUM']['T_axes'] are: +# T +root['/entry/TRANSMISSION_SPECTRUM'].attrs['T_axes'] = 'T' root['/entry/TRANSMISSION_SPECTRUM'].attrs['name'] = 'SAMPLE-CHAR-DATA' -root['/entry/TRANSMISSION_SPECTRUM'].attrs['timestamp'] = '2021-03-29T15:51:36.609872' +root['/entry/TRANSMISSION_SPECTRUM'].attrs['timestamp'] = 'SAMPLE-CHAR-DATA' root['/entry/TRANSMISSION_SPECTRUM/T'].attrs['uncertainties'] = 'SAMPLE-CHAR-DATA' root['/'].attrs['default'] = 'entry' root['/entry'].attrs['default'] = 'TRANSMISSION_SPECTRUM' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXcxi_ptycho.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXcxi_ptycho.py new file mode 100644 index 0000000..8f21ed4 --- /dev/null +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXcxi_ptycho.py @@ -0,0 +1,179 @@ + +import numpy as np +import datetime +import h5py +import os + +# Note this example script was generated by nxdl_to_hdf5.py using the current +# installed version of the NEXUS definitions ver[v2020.10] + +root = h5py.File('NXcxi_ptycho.h5', 'w') + +# Create the GROUPS + +root.create_group('entry_1') +root['/entry_1'].attrs['NX_class'] = 'NXentry' +root['/entry_1'].attrs['EX_required'] = 'false' + +root['/entry_1/'].create_group('instrument_1') +root['/entry_1/instrument_1'].attrs['NX_class'] = 'NXinstrument' +root['/entry_1/instrument_1'].attrs['EX_required'] = 'true' + +root['/entry_1/instrument_1/'].create_group('source_1') +root['/entry_1/instrument_1/source_1'].attrs['NX_class'] = 'NXsource' +root['/entry_1/instrument_1/source_1'].attrs['EX_required'] = 'true' + +root['/entry_1/instrument_1/'].create_group('beam_1') +root['/entry_1/instrument_1/beam_1'].attrs['NX_class'] = 'NXbeam' +root['/entry_1/instrument_1/beam_1'].attrs['EX_required'] = 'true' + +root['/entry_1/instrument_1/'].create_group('detector_1') +root['/entry_1/instrument_1/detector_1'].attrs['NX_class'] = 'NXdetector' +root['/entry_1/instrument_1/detector_1'].attrs['EX_required'] = 'true' + +root['/entry_1/instrument_1/detector_1/'].create_group('transformations') +root['/entry_1/instrument_1/detector_1/transformations'].attrs['NX_class'] = 'NXtransformations' +root['/entry_1/instrument_1/detector_1/transformations'].attrs['EX_required'] = 'false' + +root['/entry_1/instrument_1/'].create_group('monitor') +root['/entry_1/instrument_1/monitor'].attrs['NX_class'] = 'NXmonitor' +root['/entry_1/instrument_1/monitor'].attrs['EX_required'] = 'false' + +# Create the FIELDS + +root['/entry_1'].create_dataset(name='title', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry_1/title'].attrs['type'] = 'NX_CHAR' +root['/entry_1/title'].attrs['EX_required'] = 'false' + +root['/entry_1'].create_dataset(name='start_time', data='2022-03-04T14:56:23.795988', maxshape=None) +root['/entry_1/start_time'].attrs['type'] = 'NX_DATE_TIME' +root['/entry_1/start_time'].attrs['EX_required'] = 'false' + +root['/entry_1'].create_dataset(name='end_time', data='2022-03-04T14:56:23.795988', maxshape=None) +root['/entry_1/end_time'].attrs['type'] = 'NX_DATE_TIME' +root['/entry_1/end_time'].attrs['EX_required'] = 'false' + +# Valid enumeration values for root['/entry_1']['definition'] are: +# NXcxi_ptycho + +root['/entry_1'].create_dataset(name='definition', data='NXcxi_ptycho', maxshape=None) +root['/entry_1/definition'].attrs['type'] = 'NX_CHAR' +root['/entry_1/definition'].attrs['EX_required'] = 'true' + +root['/entry_1/instrument_1/source_1'].create_dataset(name='name', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry_1/instrument_1/source_1/name'].attrs['type'] = 'NX_CHAR' +root['/entry_1/instrument_1/source_1/name'].attrs['EX_required'] = 'true' + +root['/entry_1/instrument_1/source_1'].create_dataset(name='energy', data=1.0, maxshape=None) +root['/entry_1/instrument_1/source_1/energy'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/source_1/energy'].attrs['EX_required'] = 'true' + +root['/entry_1/instrument_1/source_1'].create_dataset(name='probe', data=1.0, maxshape=None) +root['/entry_1/instrument_1/source_1/probe'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/source_1/probe'].attrs['EX_required'] = 'true' + +root['/entry_1/instrument_1/source_1'].create_dataset(name='type', data=1.0, maxshape=None) +root['/entry_1/instrument_1/source_1/type'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/source_1/type'].attrs['EX_required'] = 'true' + +root['/entry_1/instrument_1/beam_1'].create_dataset(name='energy', data=1.0, maxshape=None) +root['/entry_1/instrument_1/beam_1/energy'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/beam_1/energy'].attrs['EX_required'] = 'true' + +root['/entry_1/instrument_1/beam_1'].create_dataset(name='extent', data=1.0, maxshape=None) +root['/entry_1/instrument_1/beam_1/extent'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/beam_1/extent'].attrs['EX_required'] = 'false' + +root['/entry_1/instrument_1/beam_1'].create_dataset(name='incident_beam_divergence', data=1.0, maxshape=None) +root['/entry_1/instrument_1/beam_1/incident_beam_divergence'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/beam_1/incident_beam_divergence'].attrs['EX_required'] = 'false' + +root['/entry_1/instrument_1/beam_1'].create_dataset(name='incident_beam_energy', data=1.0, maxshape=None) +root['/entry_1/instrument_1/beam_1/incident_beam_energy'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/beam_1/incident_beam_energy'].attrs['EX_required'] = 'true' + +root['/entry_1/instrument_1/beam_1'].create_dataset(name='incident_energy_spread', data=1.0, maxshape=None) +root['/entry_1/instrument_1/beam_1/incident_energy_spread'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/beam_1/incident_energy_spread'].attrs['EX_required'] = 'true' + +root['/entry_1/instrument_1/detector_1/transformations'].create_dataset(name='vector', data=1.0, maxshape=None) +root['/entry_1/instrument_1/detector_1/transformations/vector'].attrs['type'] = 'NX_NUMBER' +root['/entry_1/instrument_1/detector_1/transformations/vector'].attrs['EX_required'] = 'true' + +root['/entry_1/instrument_1/detector_1'].create_dataset(name='translation', data=1.0, maxshape=None) +root['/entry_1/instrument_1/detector_1/translation'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/detector_1/translation'].attrs['EX_required'] = 'true' +root['/entry_1/instrument_1/detector_1/translation'].attrs['units'] = 'NX_LENGTH' + +root['/entry_1/instrument_1/detector_1'].create_dataset(name='data', data=1, maxshape=None) +root['/entry_1/instrument_1/detector_1/data'].attrs['type'] = 'NX_INT' +root['/entry_1/instrument_1/detector_1/data'].attrs['EX_required'] = 'true' +root['/entry_1/instrument_1/detector_1/data'].attrs['signal'] = '1' + +root['/entry_1/instrument_1/detector_1'].create_dataset(name='x_pixel_size', data=1.0, maxshape=None) +root['/entry_1/instrument_1/detector_1/x_pixel_size'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/detector_1/x_pixel_size'].attrs['EX_required'] = 'true' +root['/entry_1/instrument_1/detector_1/x_pixel_size'].attrs['units'] = 'NX_LENGTH' + +root['/entry_1/instrument_1/detector_1'].create_dataset(name='y_pixel_size', data=1.0, maxshape=None) +root['/entry_1/instrument_1/detector_1/y_pixel_size'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/detector_1/y_pixel_size'].attrs['EX_required'] = 'true' +root['/entry_1/instrument_1/detector_1/y_pixel_size'].attrs['units'] = 'NX_LENGTH' + +root['/entry_1/instrument_1/detector_1'].create_dataset(name='distance', data=1.0, maxshape=None) +root['/entry_1/instrument_1/detector_1/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/detector_1/distance'].attrs['EX_required'] = 'true' +root['/entry_1/instrument_1/detector_1/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry_1/instrument_1/detector_1'].create_dataset(name='beam_center_x', data=1.0, maxshape=None) +root['/entry_1/instrument_1/detector_1/beam_center_x'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/detector_1/beam_center_x'].attrs['EX_required'] = 'false' +root['/entry_1/instrument_1/detector_1/beam_center_x'].attrs['units'] = 'NX_LENGTH' + +root['/entry_1/instrument_1/detector_1'].create_dataset(name='beam_center_y', data=1.0, maxshape=None) +root['/entry_1/instrument_1/detector_1/beam_center_y'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/detector_1/beam_center_y'].attrs['EX_required'] = 'false' +root['/entry_1/instrument_1/detector_1/beam_center_y'].attrs['units'] = 'NX_LENGTH' + +root['/entry_1/instrument_1/monitor'].create_dataset(name='data', data=1.0, maxshape=None) +root['/entry_1/instrument_1/monitor/data'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/monitor/data'].attrs['EX_required'] = 'false' + +# Create the LINKS +root['/entry_1/instrument_1/detector_1/data_1'] = h5py.SoftLink('/entry_1/title') +root['/entry_1/instrument_1/detector_1/data_1/'].attrs['target'] = '/entry/instrument/detector/data' + +# Create the DOC strings +root['/entry_1/definition'].attrs['EX_doc'] = 'Official NeXus NXDL schema to which this file conforms ' +root['/entry_1/instrument_1/source_1/energy'].attrs['EX_doc'] = 'This is the energy of the machine, not the beamline. ' +root['/entry_1/instrument_1/detector_1/translation'].attrs['EX_doc'] = 'This is an array of shape (npts_x*npts_y, 3) and can be a Virtual Dataset of x and y ' +root['/entry_1/instrument_1/detector_1/data_1'].attrs['EX_doc'] = 'This data must always have shape (npts_x*npts_y, frame_size_x, frame_size_y) regardless of the scan pattern. Use hdf5 virtual dataset to achieve this. ' +root['/entry_1/instrument_1/detector_1/distance'].attrs['EX_doc'] = 'The distance between the detector and the sample ' + + +# Create the ATTRIBUTES +root['/entry_1/instrument_1/beam_1/energy'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/beam_1/extent'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/beam_1/incident_beam_divergence'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/beam_1/incident_beam_energy'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/beam_1/incident_energy_spread'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/detector_1'].attrs['axes'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/detector_1'].attrs['signal'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/detector_1/translation'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/detector_1/translation'].attrs['axes'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/detector_1/translation'].attrs['interpretation'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/detector_1/x_pixel_size'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/detector_1/y_pixel_size'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/detector_1/distance'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/detector_1/beam_center_x'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/detector_1/beam_center_y'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root['/'].attrs['default'] = 'entry_1' +root.attrs['file_name'] = os.path.abspath('NXcxi_ptycho') +root.attrs['file_time'] = datetime.datetime.now().isoformat() +root.attrs['h5py_version'] = h5py.version.version +root.attrs['HDF5_Version'] = h5py.version.hdf5_version + +# Close the file +root.close() + + diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXdirecttof.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXdirecttof.py index 3d77526..de4fc35 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXdirecttof.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXdirecttof.py @@ -53,7 +53,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='start_time', data='2021-03-29T15:51:37.033456', maxshape=None) +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:33.860983', maxshape=None) root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXfluo.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXfluo.py index 5074518..7e600f6 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXfluo.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXfluo.py @@ -49,7 +49,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='start_time', data='2021-03-29T15:51:37.263456', maxshape=None) +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:33.985974', maxshape=None) root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXindirecttof.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXindirecttof.py index d7d15df..743ab15 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXindirecttof.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXindirecttof.py @@ -49,7 +49,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='start_time', data='2021-03-29T15:51:37.731456', maxshape=None) +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:34.220274', maxshape=None) root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXlauetof.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXlauetof.py index 03d1e47..98cc39c 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXlauetof.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXlauetof.py @@ -134,6 +134,9 @@ # Create the ATTRIBUTES + +# Valid enumeration values for root['/entry/instrument/detector/data']['signal'] are: +# 1 root['/entry/instrument/detector/data'].attrs['signal'] = '1' root['/'].attrs['default'] = 'entry' root['/entry'].attrs['default'] = 'name' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXmonopd.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXmonopd.py index f60cd60..9c339e4 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXmonopd.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXmonopd.py @@ -49,7 +49,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='start_time', data='2021-03-29T15:51:38.596455', maxshape=None) +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:34.657669', maxshape=None) root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' @@ -135,8 +135,8 @@ root['/entry/monitor/mode'].attrs['EX_doc'] = 'Count to a preset value based on either clock time (timer) or received monitor counts (monitor). ' root['/entry/monitor/preset'].attrs['EX_doc'] = 'preset value for time or monitor ' root['/entry/monitor/integral'].attrs['EX_doc'] = 'Total integral monitor counts ' -root['/entry/data/polar_angle'].attrs['EX_doc'] = 'Link to polar angle in /NXentry/NXinstrument/NXdetector ' -root['/entry/data/data'].attrs['EX_doc'] = 'Link to data in /NXentry/NXinstrument/NXdetector ' +root['/entry/data/polar_angle'].attrs['EX_doc'] = 'NXdetector ' +root['/entry/data/data'].attrs['EX_doc'] = 'NXdetector ' # Create the ATTRIBUTES diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXmx.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXmx.py index 94f1b19..fd0fa4b 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXmx.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXmx.py @@ -73,15 +73,15 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'false' -root['/entry'].create_dataset(name='start_time', data='2021-03-29T15:51:40.027458', maxshape=None) +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:35.329416', maxshape=None) root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='end_time', data='2021-03-29T15:51:40.030457', maxshape=None) +root['/entry'].create_dataset(name='end_time', data='2022-03-04T14:56:35.329416', maxshape=None) root['/entry/end_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/end_time'].attrs['EX_required'] = 'false' -root['/entry'].create_dataset(name='end_time_estimated', data='2021-03-29T15:51:40.039474', maxshape=None) +root['/entry'].create_dataset(name='end_time_estimated', data='2022-03-04T14:56:35.345038', maxshape=None) root['/entry/end_time_estimated'].attrs['type'] = 'NX_DATE_TIME' root['/entry/end_time_estimated'].attrs['EX_required'] = 'true' @@ -113,7 +113,7 @@ root['/entry/instrument/name'].attrs['type'] = 'NX_CHAR' root['/entry/instrument/name'].attrs['EX_required'] = 'true' -root['/entry/instrument'].create_dataset(name='time_zone', data='2021-03-29T15:51:40.065477', maxshape=None) +root['/entry/instrument'].create_dataset(name='time_zone', data='2022-03-04T14:56:35.345038', maxshape=None) root['/entry/instrument/time_zone'].attrs['type'] = 'NX_DATE_TIME' root['/entry/instrument/time_zone'].attrs['EX_required'] = 'true' @@ -344,15 +344,15 @@ # Create the DOC strings root['/entry'].attrs['EX_doc'] = 'Note, it is recommended that ``file_name`` and ``file_time`` are included as attributes at the root of a file that includes :ref:`NXmx`. See :ref:`NXroot`. ' -root['/entry/start_time'].attrs['EX_doc'] = 'ISO 8601 time/date of the first data point collected in UTC, using the Z suffix to avoid confusion with local time. Note that the time zone of the beamline should be provided in NXentry/NXinstrument/time_zone. ' -root['/entry/end_time'].attrs['EX_doc'] = 'ISO 8601 time/date of the last data point collected in UTC, using the Z suffix to avoid confusion with local time. Note that the time zone of the beamline should be provided in NXentry/NXinstrument/time_zone. This field should only be filled when the value is accurately observed. If the data collection aborts or otherwise prevents accurate recording of the end_time, this field should be omitted. ' -root['/entry/end_time_estimated'].attrs['EX_doc'] = 'ISO 8601 time/date of the last data point collected in UTC, using the Z suffix to avoid confusion with local time. Note that the time zone of the beamline should be provided in NXentry/NXinstrument/time_zone. This field may be filled with a value estimated before an observed value is available. ' +root['/entry/start_time'].attrs['EX_doc'] = 'time_zone. ' +root['/entry/end_time'].attrs['EX_doc'] = 'time_zone. This field should only be filled when the value is accurately observed. If the data collection aborts or otherwise prevents accurate recording of the end_time, this field should be omitted. ' +root['/entry/end_time_estimated'].attrs['EX_doc'] = 'time_zone. This field may be filled with a value estimated before an observed value is available. ' root['/entry/definition'].attrs['EX_doc'] = 'NeXus NXDL schema to which this file conforms ' root['/entry/data/data'].attrs['EX_doc'] = 'For a dimension-2 detector, the rank of the data array will be 3. For a dimension-3 detector, the rank of the data array will be 4. This allows for the introduction of the frame number as the first index. ' root['/entry/sample/name'].attrs['EX_doc'] = 'Descriptive name of sample ' root['/entry/sample/depends_on'].attrs['EX_doc'] = 'This is a requirement to describe for any scan experiment. The axis on which the sample position depends may be stored anywhere, but is normally stored in the NXtransformations group within the NXsample group. If there is no goniometer, e.g. with a jet, depends_on should be set to "." ' root['/entry/sample/transformations'].attrs['EX_doc'] = 'This is the recommended location for sample goniometer and other related axes. This is a requirement to describe for any scan experiment. The reason it is optional is mainly to accommodate XFEL single shot exposures. Use of the depends_on field and the NXtransformations group is strongly recommended. As noted above this should be an absolute requirement to have for any scan experiment. The reason it is optional is mainly to accommodate XFEL single shot exposures. ' -root['/entry/instrument/name'].attrs['EX_doc'] = 'Name of instrument. Consistency with the controlled vocabulary beamline naming in https://mmcif.wwpdb.org/dictionaries/mmcif_pdbx_v50.dic/Items/_diffrn_source.pdbx_synchrotron_beamline.html and https://mmcif.wwpdb.org/dictionaries/mmcif_pdbx_v50.dic/Items/_diffrn_source.type.html is highly recommended. ' +root['/entry/instrument/name'].attrs['EX_doc'] = '_diffrn_source.type.html is highly recommended. ' root['/entry/instrument/time_zone'].attrs['EX_doc'] = 'ISO 8601 time_zone offset from UTC. ' root['/entry/instrument/NXdetector_group'].attrs['EX_doc'] = 'Optional logical grouping of detectors. Each detector is represented as an NXdetector with its own detector data array. Each detector data array may be further decomposed into array sections by use of NXdetector_module groups. Detectors can be grouped logically together using NXdetector_group. Groups can be further grouped hierarchically in a single NXdetector_group (for example, if there are multiple detectors at an endstation or multiple endstations at a facility). Alternatively, multiple NXdetector_groups can be provided. The groups are defined hierarchically, with names given in the group_names field, unique identifying indices given in the field group_index, and the level in the hierarchy given in the group_parent field. For example if an x-ray detector group, DET, consists of four detectors in a rectangular array:: DTL DTR DLL DLR We could have:: group_names: ["DET", "DTL", "DTR", "DLL", "DLR"] group_index: [1, 2, 3, 4, 5] group_parent: [-1, 1, 1, 1, 1] ' root['/entry/instrument/NXdetector_group/group_names'].attrs['EX_doc'] = 'An array of the names of the detectors or the names of hierarchical groupings of detectors. ' @@ -363,7 +363,7 @@ root['/entry/instrument/detector/transformations'].attrs['EX_doc'] = 'Location for axes (transformations) to do with the detector. In the case of a single-module detector, the axes of the detector axis chain may be stored here. ' root['/entry/instrument/detector/collection'].attrs['EX_doc'] = 'Suggested container for detailed non-standard detector information like corrections applied automatically or performance settings. ' root['/entry/instrument/detector/data'].attrs['EX_doc'] = 'For a dimension-2 detector, the rank of the data array will be 3. For a dimension-3 detector, the rank of the data array will be 4. This allows for the introduction of the frame number as the first index. ' -root['/entry/instrument/detector/description'].attrs['EX_doc'] = 'name/manufacturer/model/etc. information. ' +root['/entry/instrument/detector/description'].attrs['EX_doc'] = 'etc. information. ' root['/entry/instrument/detector/time_per_channel'].attrs['EX_doc'] = 'For a time-of-flight detector this is the scaling factor to convert from the numeric value reported to the flight time for a given measurement. ' root['/entry/instrument/detector/NXdetector_module'].attrs['EX_doc'] = 'Many detectors consist of multiple smaller modules that are operated in sync and store their data in a common dataset. To allow consistent parsing of the experimental geometry, this application definiton requires all detectors to define a detector module, even if there is only one. This group specifies the hyperslab of data in the data array associated with the detector that contains the data for this module. If the module is associated with a full data array, rather than with a hyperslab within a larger array, then a single module should be defined, spanning the entire array. ' root['/entry/instrument/detector/NXdetector_module/data_origin'].attrs['EX_doc'] = 'A dimension-2 or dimension-3 field which gives the indices of the origin of the hyperslab of data for this module in the main area detector image in the parent NXdetector module. The data_origin is 0-based. The frame number dimension (nP) is omitted. Thus the data_origin field for a dimension-2 dataset with indices (nP, i, j) will be an array with indices (i, j), and for a dimension-3 dataset with indices (nP, i, j, k) will be an array with indices (i, j, k). The :ref:`order ` of indices (i, j or i, j, k) is slow to fast. ' @@ -406,24 +406,36 @@ root['/entry/instrument/beam/total_flux'].attrs['EX_doc'] = 'Flux incident on beam plane in photons per second. In the case of a beam that varies in total flux shot-to-shot, this is an array of values, one for each recorded shot. ' root['/entry/instrument/beam/incident_beam_size'].attrs['EX_doc'] = 'Two-element array of FWHM (if Gaussian or Airy function) or diameters (if top hat) or widths (if rectangular) of the beam in the order x, y ' root['/entry/instrument/beam/profile'].attrs['EX_doc'] = 'The beam profile, Gaussian, Airy function, top-hat or rectangular. The profile is given in the plane of incidence of the beam on the sample. ' -root['/entry/source'].attrs['EX_doc'] = 'The neutron or x-ray storage ring/facility. Note, the NXsource base class has many more fields available, but at present we only require the name. ' -root['/entry/source/name'].attrs['EX_doc'] = 'Name of source. Consistency with the naming in https://mmcif.wwpdb.org/dictionaries/mmcif_pdbx_v50.dic/Items/_diffrn_source.pdbx_synchrotron_site.html controlled vocabulary is highly recommended. ' +root['/entry/source'].attrs['EX_doc'] = 'facility. Note, the NXsource base class has many more fields available, but at present we only require the name. ' +root['/entry/source/name'].attrs['EX_doc'] = '_diffrn_source.pdbx_synchrotron_site.html controlled vocabulary is highly recommended. ' # Create the ATTRIBUTES -root['/entry'].attrs['version'] = 'SAMPLE-CHAR-DATA' + +# Valid enumeration values for root['/entry']['version'] are: +# 1.0 +root['/entry'].attrs['version'] = '1.0' root['/entry/instrument/name'].attrs['short_name'] = 'SAMPLE-CHAR-DATA' -root['/entry/instrument/detector/NXdetector_module/module_offset'].attrs['transformation_type'] = 'SAMPLE-CHAR-DATA' -root['/entry/instrument/detector/NXdetector_module/module_offset'].attrs['vector'] = '1.0' -root['/entry/instrument/detector/NXdetector_module/module_offset'].attrs['offset'] = '1.0' + +# Valid enumeration values for root['/entry/instrument/detector/NXdetector_module/module_offset']['transformation_type'] are: +# translation +root['/entry/instrument/detector/NXdetector_module/module_offset'].attrs['transformation_type'] = 'translation' +root['/entry/instrument/detector/NXdetector_module/module_offset'].attrs['vector'] = 'SAMPLE-CHAR-DATA' +root['/entry/instrument/detector/NXdetector_module/module_offset'].attrs['offset'] = 'SAMPLE-CHAR-DATA' root['/entry/instrument/detector/NXdetector_module/module_offset'].attrs['depends_on'] = 'SAMPLE-CHAR-DATA' -root['/entry/instrument/detector/NXdetector_module/fast_pixel_direction'].attrs['transformation_type'] = 'SAMPLE-CHAR-DATA' -root['/entry/instrument/detector/NXdetector_module/fast_pixel_direction'].attrs['vector'] = '1.0' -root['/entry/instrument/detector/NXdetector_module/fast_pixel_direction'].attrs['offset'] = '1.0' + +# Valid enumeration values for root['/entry/instrument/detector/NXdetector_module/fast_pixel_direction']['transformation_type'] are: +# translation +root['/entry/instrument/detector/NXdetector_module/fast_pixel_direction'].attrs['transformation_type'] = 'translation' +root['/entry/instrument/detector/NXdetector_module/fast_pixel_direction'].attrs['vector'] = 'SAMPLE-CHAR-DATA' +root['/entry/instrument/detector/NXdetector_module/fast_pixel_direction'].attrs['offset'] = 'SAMPLE-CHAR-DATA' root['/entry/instrument/detector/NXdetector_module/fast_pixel_direction'].attrs['depends_on'] = 'SAMPLE-CHAR-DATA' -root['/entry/instrument/detector/NXdetector_module/slow_pixel_direction'].attrs['transformation_type'] = 'SAMPLE-CHAR-DATA' -root['/entry/instrument/detector/NXdetector_module/slow_pixel_direction'].attrs['vector'] = '1.0' -root['/entry/instrument/detector/NXdetector_module/slow_pixel_direction'].attrs['offset'] = '1.0' + +# Valid enumeration values for root['/entry/instrument/detector/NXdetector_module/slow_pixel_direction']['transformation_type'] are: +# translation +root['/entry/instrument/detector/NXdetector_module/slow_pixel_direction'].attrs['transformation_type'] = 'translation' +root['/entry/instrument/detector/NXdetector_module/slow_pixel_direction'].attrs['vector'] = 'SAMPLE-CHAR-DATA' +root['/entry/instrument/detector/NXdetector_module/slow_pixel_direction'].attrs['offset'] = 'SAMPLE-CHAR-DATA' root['/entry/instrument/detector/NXdetector_module/slow_pixel_direction'].attrs['depends_on'] = 'SAMPLE-CHAR-DATA' root['/entry/source/name'].attrs['short_name'] = 'SAMPLE-CHAR-DATA' root['/'].attrs['default'] = 'entry' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXrefscan.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXrefscan.py index 499466b..b699bfe 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXrefscan.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXrefscan.py @@ -49,11 +49,11 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='start_time', data='2021-03-29T15:51:40.531791', maxshape=None) +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:35.594947', maxshape=None) root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='end_time', data='2021-03-29T15:51:40.534797', maxshape=None) +root['/entry'].create_dataset(name='end_time', data='2022-03-04T14:56:35.594947', maxshape=None) root['/entry/end_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/end_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXreftof.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXreftof.py index 9464053..db4f37c 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXreftof.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXreftof.py @@ -45,11 +45,11 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='start_time', data='2021-03-29T15:51:40.907789', maxshape=None) +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:35.735539', maxshape=None) root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='end_time', data='2021-03-29T15:51:40.911793', maxshape=None) +root['/entry'].create_dataset(name='end_time', data='2022-03-04T14:56:35.735539', maxshape=None) root['/entry/end_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/end_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXsas.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXsas.py index d038baf..1bbb79b 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXsas.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXsas.py @@ -61,11 +61,11 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='start_time', data='2021-03-29T15:51:41.340791', maxshape=None) +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:35.922993', maxshape=None) root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='end_time', data='2021-03-29T15:51:41.343788', maxshape=None) +root['/entry'].create_dataset(name='end_time', data='2022-03-04T14:56:35.938622', maxshape=None) root['/entry/end_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/end_time'].attrs['EX_required'] = 'true' @@ -203,7 +203,7 @@ root['/entry/instrument/source/type'].attrs['EX_doc'] = 'type of radiation source ' root['/entry/instrument/source/name'].attrs['EX_doc'] = 'Name of the radiation source ' root['/entry/instrument/monochromator/wavelength'].attrs['EX_doc'] = 'The wavelength of the radiation ' -root['/entry/instrument/monochromator/wavelength_spread'].attrs['EX_doc'] = 'delta_lambda/lambda (:math:`\Delta\lambda/\lambda`): Important for resolution calculations ' +root['/entry/instrument/monochromator/wavelength_spread'].attrs['EX_doc'] = '\lambda`): Important for resolution calculations ' root['/entry/instrument/collimator/geometry/shape/size'].attrs['EX_doc'] = 'The collimation length ' root['/entry/instrument/detector/data'].attrs['EX_doc'] = 'This is area detector data, of number of x-pixel versus number of y-pixels. Since the beam center is to be determined as a step of data reduction, it is not necessary to document or assume the position of the beam center in acquired data. ' root['/entry/instrument/detector/distance'].attrs['EX_doc'] = 'The distance between detector and sample ' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXsastof.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXsastof.py index c32a892..44ca01d 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXsastof.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXsastof.py @@ -57,7 +57,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='start_time', data='2021-03-29T15:51:41.758791', maxshape=None) +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:36.157313', maxshape=None) root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXscan.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXscan.py index 3db3fec..1a109e7 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXscan.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXscan.py @@ -41,11 +41,11 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='start_time', data='2021-03-29T15:51:41.971096', maxshape=None) +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:36.266661', maxshape=None) root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='end_time', data='2021-03-29T15:51:41.974077', maxshape=None) +root['/entry'].create_dataset(name='end_time', data='2022-03-04T14:56:36.266661', maxshape=None) root['/entry/end_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/end_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXsnsevent.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXsnsevent.py new file mode 100644 index 0000000..28d60cb --- /dev/null +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXsnsevent.py @@ -0,0 +1,620 @@ + +import numpy as np +import datetime +import h5py +import os + +# Note this example script was generated by nxdl_to_hdf5.py using the current +# installed version of the NEXUS definitions ver[v2020.10] + +root = h5py.File('NXsnsevent.h5', 'w') + +# Create the GROUPS + +root.create_group('entry') +root['/entry'].attrs['NX_class'] = 'NXentry' +root['/entry'].attrs['EX_required'] = 'true' + +root['/entry/'].create_group('DASlogs') +root['/entry/DASlogs'].attrs['NX_class'] = 'NXcollection' +root['/entry/DASlogs'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/'].create_group('log') +root['/entry/DASlogs/log'].attrs['NX_class'] = 'NXlog' +root['/entry/DASlogs/log'].attrs['EX_required'] = 'true' + +root['/entry/DASlogs/'].create_group('positioner') +root['/entry/DASlogs/positioner'].attrs['NX_class'] = 'NXpositioner' +root['/entry/DASlogs/positioner'].attrs['EX_required'] = 'false' + +root['/entry/'].create_group('SNSHistoTool') +root['/entry/SNSHistoTool'].attrs['NX_class'] = 'NXnote' +root['/entry/SNSHistoTool'].attrs['EX_required'] = 'false' + +root['/entry/'].create_group('data') +root['/entry/data'].attrs['NX_class'] = 'NXdata' +root['/entry/data'].attrs['EX_required'] = 'true' + +root['/entry/'].create_group('NXevent_data') +root['/entry/NXevent_data'].attrs['NX_class'] = 'NXevent_data' +root['/entry/NXevent_data'].attrs['EX_required'] = 'true' + +root['/entry/'].create_group('instrument') +root['/entry/instrument'].attrs['NX_class'] = 'NXinstrument' +root['/entry/instrument'].attrs['EX_required'] = 'false' + +root['/entry/instrument/'].create_group('SNS') +root['/entry/instrument/SNS'].attrs['NX_class'] = 'NXsource' +root['/entry/instrument/SNS'].attrs['EX_required'] = 'false' + +root['/entry/instrument/'].create_group('detector') +root['/entry/instrument/detector'].attrs['NX_class'] = 'NXdetector' +root['/entry/instrument/detector'].attrs['EX_required'] = 'true' + +root['/entry/instrument/detector/'].create_group('origin') +root['/entry/instrument/detector/origin'].attrs['NX_class'] = 'NXgeometry' +root['/entry/instrument/detector/origin'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector/origin/'].create_group('orientation') +root['/entry/instrument/detector/origin/orientation'].attrs['NX_class'] = 'NXorientation' +root['/entry/instrument/detector/origin/orientation'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector/origin/'].create_group('shape') +root['/entry/instrument/detector/origin/shape'].attrs['NX_class'] = 'NXshape' +root['/entry/instrument/detector/origin/shape'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector/origin/'].create_group('translation') +root['/entry/instrument/detector/origin/translation'].attrs['NX_class'] = 'NXtranslation' +root['/entry/instrument/detector/origin/translation'].attrs['EX_required'] = 'false' + +root['/entry/instrument/'].create_group('NXdisk_chopper') +root['/entry/instrument/NXdisk_chopper'].attrs['NX_class'] = 'NXdisk_chopper' +root['/entry/instrument/NXdisk_chopper'].attrs['EX_required'] = 'false' + +root['/entry/instrument/'].create_group('moderator') +root['/entry/instrument/moderator'].attrs['NX_class'] = 'NXmoderator' +root['/entry/instrument/moderator'].attrs['EX_required'] = 'false' + +root['/entry/instrument/'].create_group('aperture') +root['/entry/instrument/aperture'].attrs['NX_class'] = 'NXaperture' +root['/entry/instrument/aperture'].attrs['EX_required'] = 'false' + +root['/entry/instrument/aperture/'].create_group('origin') +root['/entry/instrument/aperture/origin'].attrs['NX_class'] = 'NXgeometry' +root['/entry/instrument/aperture/origin'].attrs['EX_required'] = 'false' + +root['/entry/instrument/aperture/origin/'].create_group('orientation') +root['/entry/instrument/aperture/origin/orientation'].attrs['NX_class'] = 'NXorientation' +root['/entry/instrument/aperture/origin/orientation'].attrs['EX_required'] = 'false' + +root['/entry/instrument/aperture/origin/'].create_group('shape') +root['/entry/instrument/aperture/origin/shape'].attrs['NX_class'] = 'NXshape' +root['/entry/instrument/aperture/origin/shape'].attrs['EX_required'] = 'false' + +root['/entry/instrument/aperture/origin/'].create_group('translation') +root['/entry/instrument/aperture/origin/translation'].attrs['NX_class'] = 'NXtranslation' +root['/entry/instrument/aperture/origin/translation'].attrs['EX_required'] = 'false' + +root['/entry/instrument/'].create_group('attenuator') +root['/entry/instrument/attenuator'].attrs['NX_class'] = 'NXattenuator' +root['/entry/instrument/attenuator'].attrs['EX_required'] = 'false' + +root['/entry/instrument/'].create_group('polarizer') +root['/entry/instrument/polarizer'].attrs['NX_class'] = 'NXpolarizer' +root['/entry/instrument/polarizer'].attrs['EX_required'] = 'false' + +root['/entry/instrument/'].create_group('crystal') +root['/entry/instrument/crystal'].attrs['NX_class'] = 'NXcrystal' +root['/entry/instrument/crystal'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal/'].create_group('origin') +root['/entry/instrument/crystal/origin'].attrs['NX_class'] = 'NXgeometry' +root['/entry/instrument/crystal/origin'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal/origin/'].create_group('orientation') +root['/entry/instrument/crystal/origin/orientation'].attrs['NX_class'] = 'NXorientation' +root['/entry/instrument/crystal/origin/orientation'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal/origin/'].create_group('shape') +root['/entry/instrument/crystal/origin/shape'].attrs['NX_class'] = 'NXshape' +root['/entry/instrument/crystal/origin/shape'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal/origin/'].create_group('translation') +root['/entry/instrument/crystal/origin/translation'].attrs['NX_class'] = 'NXtranslation' +root['/entry/instrument/crystal/origin/translation'].attrs['EX_required'] = 'false' + +root['/entry/'].create_group('monitor') +root['/entry/monitor'].attrs['NX_class'] = 'NXmonitor' +root['/entry/monitor'].attrs['EX_required'] = 'false' + +root['/entry/'].create_group('sample') +root['/entry/sample'].attrs['NX_class'] = 'NXsample' +root['/entry/sample'].attrs['EX_required'] = 'false' + +root['/entry/'].create_group('user') +root['/entry/user'].attrs['NX_class'] = 'NXuser' +root['/entry/user'].attrs['EX_required'] = 'true' + +# Create the FIELDS + +root['/entry/DASlogs/log'].create_dataset(name='average_value', data=1.0, maxshape=None) +root['/entry/DASlogs/log/average_value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/average_value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log'].create_dataset(name='average_value_error', data=1.0, maxshape=None) +root['/entry/DASlogs/log/average_value_error'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/average_value_error'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log'].create_dataset(name='average_value_errors', data=1.0, maxshape=None) +root['/entry/DASlogs/log/average_value_errors'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/average_value_errors'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log'].create_dataset(name='description', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/DASlogs/log/description'].attrs['type'] = 'NX_CHAR' +root['/entry/DASlogs/log/description'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log'].create_dataset(name='duration', data=1.0, maxshape=None) +root['/entry/DASlogs/log/duration'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/duration'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log'].create_dataset(name='maximum_value', data=1.0, maxshape=None) +root['/entry/DASlogs/log/maximum_value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/maximum_value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log'].create_dataset(name='minimum_value', data=1.0, maxshape=None) +root['/entry/DASlogs/log/minimum_value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/minimum_value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log'].create_dataset(name='time', data=1.0, maxshape=None) +root['/entry/DASlogs/log/time'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/time'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log'].create_dataset(name='value', data=1.0, maxshape=None) +root['/entry/DASlogs/log/value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner'].create_dataset(name='average_value', data=1.0, maxshape=None) +root['/entry/DASlogs/positioner/average_value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/average_value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner'].create_dataset(name='average_value_error', data=1.0, maxshape=None) +root['/entry/DASlogs/positioner/average_value_error'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/average_value_error'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner'].create_dataset(name='average_value_errors', data=1.0, maxshape=None) +root['/entry/DASlogs/positioner/average_value_errors'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/average_value_errors'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner'].create_dataset(name='description', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/DASlogs/positioner/description'].attrs['type'] = 'NX_CHAR' +root['/entry/DASlogs/positioner/description'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner'].create_dataset(name='duration', data=1.0, maxshape=None) +root['/entry/DASlogs/positioner/duration'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/duration'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner'].create_dataset(name='maximum_value', data=1.0, maxshape=None) +root['/entry/DASlogs/positioner/maximum_value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/maximum_value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner'].create_dataset(name='minimum_value', data=1.0, maxshape=None) +root['/entry/DASlogs/positioner/minimum_value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/minimum_value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner'].create_dataset(name='time', data=1.0, maxshape=None) +root['/entry/DASlogs/positioner/time'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/time'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner'].create_dataset(name='value', data=1.0, maxshape=None) +root['/entry/DASlogs/positioner/value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/value'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool'].create_dataset(name='SNSbanking_file_name', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/SNSHistoTool/SNSbanking_file_name'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/SNSbanking_file_name'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool'].create_dataset(name='SNSmapping_file_name', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/SNSHistoTool/SNSmapping_file_name'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/SNSmapping_file_name'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool'].create_dataset(name='author', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/SNSHistoTool/author'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/author'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool'].create_dataset(name='command1', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/SNSHistoTool/command1'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/command1'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool'].create_dataset(name='date', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/SNSHistoTool/date'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/date'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool'].create_dataset(name='description', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/SNSHistoTool/description'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/description'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool'].create_dataset(name='version', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/SNSHistoTool/version'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/version'].attrs['EX_required'] = 'false' + +root['/entry'].create_dataset(name='collection_identifier', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/collection_identifier'].attrs['type'] = 'NX_CHAR' +root['/entry/collection_identifier'].attrs['EX_required'] = 'false' + +root['/entry'].create_dataset(name='collection_title', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/collection_title'].attrs['type'] = 'NX_CHAR' +root['/entry/collection_title'].attrs['EX_required'] = 'false' + +# Valid enumeration values for root['/entry']['definition'] are: +# NXsnsevent + +root['/entry'].create_dataset(name='definition', data='NXsnsevent', maxshape=None) +root['/entry/definition'].attrs['type'] = 'NX_CHAR' +root['/entry/definition'].attrs['EX_required'] = 'false' + +root['/entry'].create_dataset(name='duration', data=1.0, maxshape=None) +root['/entry/duration'].attrs['type'] = 'NX_FLOAT' +root['/entry/duration'].attrs['EX_required'] = 'false' +root['/entry/duration'].attrs['units'] = 'NX_TIME' + +root['/entry'].create_dataset(name='end_time', data='2022-03-04T14:56:24.498980', maxshape=None) +root['/entry/end_time'].attrs['type'] = 'NX_DATE_TIME' +root['/entry/end_time'].attrs['EX_required'] = 'false' + +root['/entry'].create_dataset(name='entry_identifier', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/entry_identifier'].attrs['type'] = 'NX_CHAR' +root['/entry/entry_identifier'].attrs['EX_required'] = 'false' + +root['/entry'].create_dataset(name='experiment_identifier', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/experiment_identifier'].attrs['type'] = 'NX_CHAR' +root['/entry/experiment_identifier'].attrs['EX_required'] = 'false' + +root['/entry/instrument/SNS'].create_dataset(name='frequency', data=1.0, maxshape=None) +root['/entry/instrument/SNS/frequency'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/SNS/frequency'].attrs['EX_required'] = 'false' +root['/entry/instrument/SNS/frequency'].attrs['units'] = 'NX_FREQUENCY' + +root['/entry/instrument/SNS'].create_dataset(name='name', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/SNS/name'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/SNS/name'].attrs['EX_required'] = 'false' + +root['/entry/instrument/SNS'].create_dataset(name='probe', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/SNS/probe'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/SNS/probe'].attrs['EX_required'] = 'false' + +root['/entry/instrument/SNS'].create_dataset(name='type', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/SNS/type'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/SNS/type'].attrs['EX_required'] = 'false' + +root['/entry/instrument'].create_dataset(name='SNSdetector_calibration_id', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/SNSdetector_calibration_id'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/SNSdetector_calibration_id'].attrs['EX_required'] = 'false' + +root['/entry/instrument'].create_dataset(name='SNSgeometry_file_name', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/SNSgeometry_file_name'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/SNSgeometry_file_name'].attrs['EX_required'] = 'false' + +root['/entry/instrument'].create_dataset(name='SNStranslation_service', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/SNStranslation_service'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/SNStranslation_service'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector'].create_dataset(name='azimuthal_angle', data=1.0, maxshape=None) +root['/entry/instrument/detector/azimuthal_angle'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/azimuthal_angle'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/azimuthal_angle'].attrs['units'] = 'NX_ANGLE' + +root['/entry/instrument/detector'].create_dataset(name='data_x_y', data=np.ushort(1), maxshape=None) +root['/entry/instrument/detector/data_x_y'].attrs['type'] = 'NX_UINT' +root['/entry/instrument/detector/data_x_y'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector'].create_dataset(name='distance', data=1.0, maxshape=None) +root['/entry/instrument/detector/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/detector'].create_dataset(name='event_index', data=np.ushort(1), maxshape=None) +root['/entry/instrument/detector/event_index'].attrs['type'] = 'NX_UINT' +root['/entry/instrument/detector/event_index'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector'].create_dataset(name='event_pixel_id', data=np.ushort(1), maxshape=None) +root['/entry/instrument/detector/event_pixel_id'].attrs['type'] = 'NX_UINT' +root['/entry/instrument/detector/event_pixel_id'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector'].create_dataset(name='event_time_of_flight', data=1.0, maxshape=None) +root['/entry/instrument/detector/event_time_of_flight'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/event_time_of_flight'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/event_time_of_flight'].attrs['units'] = 'NX_TIME_OF_FLIGHT' + +root['/entry/instrument/detector/origin/orientation'].create_dataset(name='value', data=1.0, maxshape=None) +root['/entry/instrument/detector/origin/orientation/value'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/origin/orientation/value'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector/origin/shape'].create_dataset(name='description', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/detector/origin/shape/description'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/detector/origin/shape/description'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector/origin/shape'].create_dataset(name='shape', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/detector/origin/shape/shape'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/detector/origin/shape/shape'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector/origin/shape'].create_dataset(name='size', data=1.0, maxshape=None) +root['/entry/instrument/detector/origin/shape/size'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/origin/shape/size'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/origin/shape/size'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/detector/origin/translation'].create_dataset(name='distance', data=1.0, maxshape=None) +root['/entry/instrument/detector/origin/translation/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/origin/translation/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/origin/translation/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/detector'].create_dataset(name='pixel_id', data=np.ushort(1), maxshape=None) +root['/entry/instrument/detector/pixel_id'].attrs['type'] = 'NX_UINT' +root['/entry/instrument/detector/pixel_id'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector'].create_dataset(name='polar_angle', data=1.0, maxshape=None) +root['/entry/instrument/detector/polar_angle'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/polar_angle'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/polar_angle'].attrs['units'] = 'NX_ANGLE' + +root['/entry/instrument/detector'].create_dataset(name='pulse_time', data=1.0, maxshape=None) +root['/entry/instrument/detector/pulse_time'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/pulse_time'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/pulse_time'].attrs['units'] = 'NX_TIME' + +root['/entry/instrument/detector'].create_dataset(name='total_counts', data=np.ushort(1), maxshape=None) +root['/entry/instrument/detector/total_counts'].attrs['type'] = 'NX_UINT' +root['/entry/instrument/detector/total_counts'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector'].create_dataset(name='x_pixel_offset', data=1.0, maxshape=None) +root['/entry/instrument/detector/x_pixel_offset'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/x_pixel_offset'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/x_pixel_offset'].attrs['axis'] = '1' +root['/entry/instrument/detector/x_pixel_offset'].attrs['primary'] = '1' +root['/entry/instrument/detector/x_pixel_offset'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/detector'].create_dataset(name='y_pixel_offset', data=1.0, maxshape=None) +root['/entry/instrument/detector/y_pixel_offset'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/y_pixel_offset'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/y_pixel_offset'].attrs['axis'] = '2' +root['/entry/instrument/detector/y_pixel_offset'].attrs['primary'] = '1' +root['/entry/instrument/detector/y_pixel_offset'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument'].create_dataset(name='beamline', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/beamline'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/beamline'].attrs['EX_required'] = 'false' + +root['/entry/instrument/NXdisk_chopper'].create_dataset(name='distance', data=1.0, maxshape=None) +root['/entry/instrument/NXdisk_chopper/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/NXdisk_chopper/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/NXdisk_chopper/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/moderator'].create_dataset(name='coupling_material', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/moderator/coupling_material'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/moderator/coupling_material'].attrs['EX_required'] = 'false' + +root['/entry/instrument/moderator'].create_dataset(name='distance', data=1.0, maxshape=None) +root['/entry/instrument/moderator/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/moderator/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/moderator/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/moderator'].create_dataset(name='temperature', data=1.0, maxshape=None) +root['/entry/instrument/moderator/temperature'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/moderator/temperature'].attrs['EX_required'] = 'false' +root['/entry/instrument/moderator/temperature'].attrs['units'] = 'NX_TEMPERATURE' + +root['/entry/instrument/moderator'].create_dataset(name='type', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/moderator/type'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/moderator/type'].attrs['EX_required'] = 'false' + +root['/entry/instrument'].create_dataset(name='name', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/name'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/name'].attrs['EX_required'] = 'false' + +root['/entry/instrument/aperture/origin/orientation'].create_dataset(name='value', data=1.0, maxshape=None) +root['/entry/instrument/aperture/origin/orientation/value'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/aperture/origin/orientation/value'].attrs['EX_required'] = 'false' + +root['/entry/instrument/aperture/origin/shape'].create_dataset(name='description', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/aperture/origin/shape/description'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/aperture/origin/shape/description'].attrs['EX_required'] = 'false' + +root['/entry/instrument/aperture/origin/shape'].create_dataset(name='shape', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/aperture/origin/shape/shape'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/aperture/origin/shape/shape'].attrs['EX_required'] = 'false' + +root['/entry/instrument/aperture/origin/shape'].create_dataset(name='size', data=1.0, maxshape=None) +root['/entry/instrument/aperture/origin/shape/size'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/aperture/origin/shape/size'].attrs['EX_required'] = 'false' +root['/entry/instrument/aperture/origin/shape/size'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/aperture/origin/translation'].create_dataset(name='distance', data=1.0, maxshape=None) +root['/entry/instrument/aperture/origin/translation/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/aperture/origin/translation/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/aperture/origin/translation/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/aperture'].create_dataset(name='x_pixel_offset', data=1.0, maxshape=None) +root['/entry/instrument/aperture/x_pixel_offset'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/aperture/x_pixel_offset'].attrs['EX_required'] = 'false' +root['/entry/instrument/aperture/x_pixel_offset'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/attenuator'].create_dataset(name='distance', data=1.0, maxshape=None) +root['/entry/instrument/attenuator/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/attenuator/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/attenuator/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/crystal/origin'].create_dataset(name='description', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/crystal/origin/description'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/crystal/origin/description'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal/origin/orientation'].create_dataset(name='value', data=1.0, maxshape=None) +root['/entry/instrument/crystal/origin/orientation/value'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/crystal/origin/orientation/value'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal/origin/shape'].create_dataset(name='description', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/crystal/origin/shape/description'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/crystal/origin/shape/description'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal/origin/shape'].create_dataset(name='shape', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/crystal/origin/shape/shape'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/crystal/origin/shape/shape'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal/origin/shape'].create_dataset(name='size', data=1.0, maxshape=None) +root['/entry/instrument/crystal/origin/shape/size'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/crystal/origin/shape/size'].attrs['EX_required'] = 'false' +root['/entry/instrument/crystal/origin/shape/size'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/crystal/origin/translation'].create_dataset(name='distance', data=1.0, maxshape=None) +root['/entry/instrument/crystal/origin/translation/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/crystal/origin/translation/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/crystal/origin/translation/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/crystal'].create_dataset(name='type', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/crystal/type'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/crystal/type'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal'].create_dataset(name='wavelength', data=1.0, maxshape=None) +root['/entry/instrument/crystal/wavelength'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/crystal/wavelength'].attrs['EX_required'] = 'false' +root['/entry/instrument/crystal/wavelength'].attrs['units'] = 'NX_WAVELENGTH' + +root['/entry/monitor'].create_dataset(name='data', data=np.ushort(1), maxshape=None) +root['/entry/monitor/data'].attrs['type'] = 'NX_UINT' +root['/entry/monitor/data'].attrs['EX_required'] = 'false' + +root['/entry/monitor'].create_dataset(name='distance', data=1.0, maxshape=None) +root['/entry/monitor/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/monitor/distance'].attrs['EX_required'] = 'false' +root['/entry/monitor/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/monitor'].create_dataset(name='mode', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/monitor/mode'].attrs['type'] = 'NX_CHAR' +root['/entry/monitor/mode'].attrs['EX_required'] = 'false' + +root['/entry/monitor'].create_dataset(name='time_of_flight', data=1.0, maxshape=None) +root['/entry/monitor/time_of_flight'].attrs['type'] = 'NX_FLOAT' +root['/entry/monitor/time_of_flight'].attrs['EX_required'] = 'false' +root['/entry/monitor/time_of_flight'].attrs['units'] = 'NX_TIME' + +root['/entry'].create_dataset(name='notes', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/notes'].attrs['type'] = 'NX_CHAR' +root['/entry/notes'].attrs['EX_required'] = 'false' + +root['/entry'].create_dataset(name='proton_charge', data=1.0, maxshape=None) +root['/entry/proton_charge'].attrs['type'] = 'NX_FLOAT' +root['/entry/proton_charge'].attrs['EX_required'] = 'false' +root['/entry/proton_charge'].attrs['units'] = 'NX_CHARGE' + +root['/entry'].create_dataset(name='raw_frames', data=1, maxshape=None) +root['/entry/raw_frames'].attrs['type'] = 'NX_INT' +root['/entry/raw_frames'].attrs['EX_required'] = 'false' + +root['/entry'].create_dataset(name='run_number', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/run_number'].attrs['type'] = 'NX_CHAR' +root['/entry/run_number'].attrs['EX_required'] = 'false' + +root['/entry/sample'].create_dataset(name='changer_position', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/sample/changer_position'].attrs['type'] = 'NX_CHAR' +root['/entry/sample/changer_position'].attrs['EX_required'] = 'false' + +root['/entry/sample'].create_dataset(name='holder', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/sample/holder'].attrs['type'] = 'NX_CHAR' +root['/entry/sample/holder'].attrs['EX_required'] = 'false' + +root['/entry/sample'].create_dataset(name='identifier', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/sample/identifier'].attrs['type'] = 'NX_CHAR' +root['/entry/sample/identifier'].attrs['EX_required'] = 'false' + +root['/entry/sample'].create_dataset(name='name', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/sample/name'].attrs['type'] = 'NX_CHAR' +root['/entry/sample/name'].attrs['EX_required'] = 'false' + +root['/entry/sample'].create_dataset(name='nature', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/sample/nature'].attrs['type'] = 'NX_CHAR' +root['/entry/sample/nature'].attrs['EX_required'] = 'false' + +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:24.592709', maxshape=None) +root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' +root['/entry/start_time'].attrs['EX_required'] = 'false' + +root['/entry'].create_dataset(name='title', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/title'].attrs['type'] = 'NX_CHAR' +root['/entry/title'].attrs['EX_required'] = 'false' + +root['/entry'].create_dataset(name='total_counts', data=np.ushort(1), maxshape=None) +root['/entry/total_counts'].attrs['type'] = 'NX_UINT' +root['/entry/total_counts'].attrs['EX_required'] = 'false' +root['/entry/total_counts'].attrs['units'] = 'NX_UNITLESS' + +root['/entry'].create_dataset(name='total_uncounted_counts', data=np.ushort(1), maxshape=None) +root['/entry/total_uncounted_counts'].attrs['type'] = 'NX_UINT' +root['/entry/total_uncounted_counts'].attrs['EX_required'] = 'false' +root['/entry/total_uncounted_counts'].attrs['units'] = 'NX_UNITLESS' + +root['/entry/user'].create_dataset(name='facility_user_id', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/user/facility_user_id'].attrs['type'] = 'NX_CHAR' +root['/entry/user/facility_user_id'].attrs['EX_required'] = 'false' + +root['/entry/user'].create_dataset(name='name', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/user/name'].attrs['type'] = 'NX_CHAR' +root['/entry/user/name'].attrs['EX_required'] = 'false' + +root['/entry/user'].create_dataset(name='role', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/user/role'].attrs['type'] = 'NX_CHAR' +root['/entry/user/role'].attrs['EX_required'] = 'false' + +# Create the LINKS +root['/entry/data/data_x_y'] = h5py.SoftLink('/entry/instrument/detector/data_x_y') +root['/entry/data/data_x_y/'].attrs['target'] = '/entry/instrument/detector/data_x_y' + +# Create the LINKS +root['/entry/data/x_pixel_offset'] = h5py.SoftLink('/entry/instrument/detector/x_pixel_offset') +root['/entry/data/x_pixel_offset/'].attrs['target'] = '/entry/instrument/detector/x_pixel_offset' + +# Create the LINKS +root['/entry/data/y_pixel_offset'] = h5py.SoftLink('/entry/instrument/detector/y_pixel_offset') +root['/entry/data/y_pixel_offset/'].attrs['target'] = '/entry/instrument/detector/y_pixel_offset' + +# Create the LINKS +root['/entry/NXevent_data/event_index'] = h5py.SoftLink('/entry/instrument/detector/event_index') +root['/entry/NXevent_data/event_index/'].attrs['target'] = '/entry/instrument/detector/event_index' + +# Create the LINKS +root['/entry/NXevent_data/event_pixel_id'] = h5py.SoftLink('/entry/instrument/detector/event_pixel_id') +root['/entry/NXevent_data/event_pixel_id/'].attrs['target'] = '/entry/instrument/detector/event_pixel_id' + +# Create the LINKS +root['/entry/NXevent_data/event_time_of_flight'] = h5py.SoftLink('/entry/instrument/detector/event_time_of_flight') +root['/entry/NXevent_data/event_time_of_flight/'].attrs['target'] = '/entry/instrument/detector/event_time_of_flight' + +# Create the LINKS +root['/entry/NXevent_data/pulse_time'] = h5py.SoftLink('/entry/instrument/detector/pulse_time') +root['/entry/NXevent_data/pulse_time/'].attrs['target'] = '/entry/instrument/detector/pulse_time' + +# Create the DOC strings +root['/entry/DASlogs'].attrs['EX_doc'] = 'Details of all logs, both from cvinfo file and from HistoTool (frequency and proton_charge). ' +root['/entry/DASlogs/positioner'].attrs['EX_doc'] = 'Motor logs from cvinfo file. ' +root['/entry/SNSHistoTool/command1'].attrs['EX_doc'] = 'Command string for event2nxl. ' +root['/entry/definition'].attrs['EX_doc'] = 'Official NXDL schema after this file goes to applications. ' +root['/entry/instrument/SNSdetector_calibration_id'].attrs['EX_doc'] = 'Detector calibration id from DAS. ' +root['/entry/instrument/detector/data_x_y'].attrs['EX_doc'] = 'expect ``signal=2 axes="x_pixel_offset,y_pixel_offset``" ' +root['/entry/instrument/detector/origin/orientation/value'].attrs['EX_doc'] = 'Six out of nine rotation parameters. ' +root['/entry/instrument/aperture/origin/orientation/value'].attrs['EX_doc'] = 'Six out of nine rotation parameters. ' +root['/entry/instrument/crystal/origin/orientation/value'].attrs['EX_doc'] = 'Six out of nine rotation parameters. ' +root['/entry/monitor/data'].attrs['EX_doc'] = 'expect ``signal=1 axes="time_of_flight"`` ' +root['/entry/sample/name'].attrs['EX_doc'] = 'Descriptive name of sample ' + + +# Create the ATTRIBUTES +root['/'].attrs['default'] = 'entry' +root['/entry'].attrs['default'] = 'data' +root['/entry/data'].attrs['signal'] = 'data_x_y' +root['/entry/data/data_x_y'].attrs['signal'] = '1' +root.attrs['file_name'] = os.path.abspath('NXsnsevent') +root.attrs['file_time'] = datetime.datetime.now().isoformat() +root.attrs['h5py_version'] = h5py.version.version +root.attrs['HDF5_Version'] = h5py.version.hdf5_version + +# Close the file +root.close() + + diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXsnshisto.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXsnshisto.py new file mode 100644 index 0000000..c7b5af2 --- /dev/null +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXsnshisto.py @@ -0,0 +1,644 @@ + +import numpy as np +import datetime +import h5py +import os + +# Note this example script was generated by nxdl_to_hdf5.py using the current +# installed version of the NEXUS definitions ver[v2020.10] + +root = h5py.File('NXsnshisto.h5', 'w') + +# Create the GROUPS + +root.create_group('entry') +root['/entry'].attrs['NX_class'] = 'NXentry' +root['/entry'].attrs['EX_required'] = 'true' + +root['/entry/'].create_group('DASlogs') +root['/entry/DASlogs'].attrs['NX_class'] = 'NXcollection' +root['/entry/DASlogs'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/'].create_group('log') +root['/entry/DASlogs/log'].attrs['NX_class'] = 'NXlog' +root['/entry/DASlogs/log'].attrs['EX_required'] = 'true' + +root['/entry/DASlogs/'].create_group('positioner') +root['/entry/DASlogs/positioner'].attrs['NX_class'] = 'NXpositioner' +root['/entry/DASlogs/positioner'].attrs['EX_required'] = 'false' + +root['/entry/'].create_group('SNSHistoTool') +root['/entry/SNSHistoTool'].attrs['NX_class'] = 'NXnote' +root['/entry/SNSHistoTool'].attrs['EX_required'] = 'false' + +root['/entry/'].create_group('data') +root['/entry/data'].attrs['NX_class'] = 'NXdata' +root['/entry/data'].attrs['EX_required'] = 'true' + +root['/entry/'].create_group('instrument') +root['/entry/instrument'].attrs['NX_class'] = 'NXinstrument' +root['/entry/instrument'].attrs['EX_required'] = 'false' + +root['/entry/instrument/'].create_group('SNS') +root['/entry/instrument/SNS'].attrs['NX_class'] = 'NXsource' +root['/entry/instrument/SNS'].attrs['EX_required'] = 'false' + +root['/entry/instrument/'].create_group('detector') +root['/entry/instrument/detector'].attrs['NX_class'] = 'NXdetector' +root['/entry/instrument/detector'].attrs['EX_required'] = 'true' + +root['/entry/instrument/detector/'].create_group('origin') +root['/entry/instrument/detector/origin'].attrs['NX_class'] = 'NXgeometry' +root['/entry/instrument/detector/origin'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector/origin/'].create_group('orientation') +root['/entry/instrument/detector/origin/orientation'].attrs['NX_class'] = 'NXorientation' +root['/entry/instrument/detector/origin/orientation'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector/origin/'].create_group('shape') +root['/entry/instrument/detector/origin/shape'].attrs['NX_class'] = 'NXshape' +root['/entry/instrument/detector/origin/shape'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector/origin/'].create_group('translation') +root['/entry/instrument/detector/origin/translation'].attrs['NX_class'] = 'NXtranslation' +root['/entry/instrument/detector/origin/translation'].attrs['EX_required'] = 'false' + +root['/entry/instrument/'].create_group('NXdisk_chopper') +root['/entry/instrument/NXdisk_chopper'].attrs['NX_class'] = 'NXdisk_chopper' +root['/entry/instrument/NXdisk_chopper'].attrs['EX_required'] = 'false' + +root['/entry/instrument/'].create_group('NXfermi_chopper') +root['/entry/instrument/NXfermi_chopper'].attrs['NX_class'] = 'NXfermi_chopper' +root['/entry/instrument/NXfermi_chopper'].attrs['EX_required'] = 'false' + +root['/entry/instrument/'].create_group('moderator') +root['/entry/instrument/moderator'].attrs['NX_class'] = 'NXmoderator' +root['/entry/instrument/moderator'].attrs['EX_required'] = 'false' + +root['/entry/instrument/'].create_group('aperture') +root['/entry/instrument/aperture'].attrs['NX_class'] = 'NXaperture' +root['/entry/instrument/aperture'].attrs['EX_required'] = 'false' + +root['/entry/instrument/aperture/'].create_group('origin') +root['/entry/instrument/aperture/origin'].attrs['NX_class'] = 'NXgeometry' +root['/entry/instrument/aperture/origin'].attrs['EX_required'] = 'false' + +root['/entry/instrument/aperture/origin/'].create_group('orientation') +root['/entry/instrument/aperture/origin/orientation'].attrs['NX_class'] = 'NXorientation' +root['/entry/instrument/aperture/origin/orientation'].attrs['EX_required'] = 'false' + +root['/entry/instrument/aperture/origin/'].create_group('shape') +root['/entry/instrument/aperture/origin/shape'].attrs['NX_class'] = 'NXshape' +root['/entry/instrument/aperture/origin/shape'].attrs['EX_required'] = 'false' + +root['/entry/instrument/aperture/origin/'].create_group('translation') +root['/entry/instrument/aperture/origin/translation'].attrs['NX_class'] = 'NXtranslation' +root['/entry/instrument/aperture/origin/translation'].attrs['EX_required'] = 'false' + +root['/entry/instrument/'].create_group('attenuator') +root['/entry/instrument/attenuator'].attrs['NX_class'] = 'NXattenuator' +root['/entry/instrument/attenuator'].attrs['EX_required'] = 'false' + +root['/entry/instrument/'].create_group('polarizer') +root['/entry/instrument/polarizer'].attrs['NX_class'] = 'NXpolarizer' +root['/entry/instrument/polarizer'].attrs['EX_required'] = 'false' + +root['/entry/instrument/'].create_group('crystal') +root['/entry/instrument/crystal'].attrs['NX_class'] = 'NXcrystal' +root['/entry/instrument/crystal'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal/'].create_group('origin') +root['/entry/instrument/crystal/origin'].attrs['NX_class'] = 'NXgeometry' +root['/entry/instrument/crystal/origin'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal/origin/'].create_group('orientation') +root['/entry/instrument/crystal/origin/orientation'].attrs['NX_class'] = 'NXorientation' +root['/entry/instrument/crystal/origin/orientation'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal/origin/'].create_group('shape') +root['/entry/instrument/crystal/origin/shape'].attrs['NX_class'] = 'NXshape' +root['/entry/instrument/crystal/origin/shape'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal/origin/'].create_group('translation') +root['/entry/instrument/crystal/origin/translation'].attrs['NX_class'] = 'NXtranslation' +root['/entry/instrument/crystal/origin/translation'].attrs['EX_required'] = 'false' + +root['/entry/'].create_group('monitor') +root['/entry/monitor'].attrs['NX_class'] = 'NXmonitor' +root['/entry/monitor'].attrs['EX_required'] = 'false' + +root['/entry/'].create_group('sample') +root['/entry/sample'].attrs['NX_class'] = 'NXsample' +root['/entry/sample'].attrs['EX_required'] = 'false' + +root['/entry/'].create_group('user') +root['/entry/user'].attrs['NX_class'] = 'NXuser' +root['/entry/user'].attrs['EX_required'] = 'true' + +# Create the FIELDS + +root['/entry/DASlogs/log'].create_dataset(name='average_value', data=1.0, maxshape=None) +root['/entry/DASlogs/log/average_value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/average_value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log'].create_dataset(name='average_value_error', data=1.0, maxshape=None) +root['/entry/DASlogs/log/average_value_error'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/average_value_error'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log'].create_dataset(name='average_value_errors', data=1.0, maxshape=None) +root['/entry/DASlogs/log/average_value_errors'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/average_value_errors'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log'].create_dataset(name='description', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/DASlogs/log/description'].attrs['type'] = 'NX_CHAR' +root['/entry/DASlogs/log/description'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log'].create_dataset(name='duration', data=1.0, maxshape=None) +root['/entry/DASlogs/log/duration'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/duration'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log'].create_dataset(name='maximum_value', data=1.0, maxshape=None) +root['/entry/DASlogs/log/maximum_value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/maximum_value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log'].create_dataset(name='minimum_value', data=1.0, maxshape=None) +root['/entry/DASlogs/log/minimum_value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/minimum_value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log'].create_dataset(name='time', data=1.0, maxshape=None) +root['/entry/DASlogs/log/time'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/time'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log'].create_dataset(name='value', data=1.0, maxshape=None) +root['/entry/DASlogs/log/value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner'].create_dataset(name='average_value', data=1.0, maxshape=None) +root['/entry/DASlogs/positioner/average_value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/average_value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner'].create_dataset(name='average_value_error', data=1.0, maxshape=None) +root['/entry/DASlogs/positioner/average_value_error'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/average_value_error'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner'].create_dataset(name='average_value_errors', data=1.0, maxshape=None) +root['/entry/DASlogs/positioner/average_value_errors'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/average_value_errors'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner'].create_dataset(name='description', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/DASlogs/positioner/description'].attrs['type'] = 'NX_CHAR' +root['/entry/DASlogs/positioner/description'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner'].create_dataset(name='duration', data=1.0, maxshape=None) +root['/entry/DASlogs/positioner/duration'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/duration'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner'].create_dataset(name='maximum_value', data=1.0, maxshape=None) +root['/entry/DASlogs/positioner/maximum_value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/maximum_value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner'].create_dataset(name='minimum_value', data=1.0, maxshape=None) +root['/entry/DASlogs/positioner/minimum_value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/minimum_value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner'].create_dataset(name='time', data=1.0, maxshape=None) +root['/entry/DASlogs/positioner/time'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/time'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner'].create_dataset(name='value', data=1.0, maxshape=None) +root['/entry/DASlogs/positioner/value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/value'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool'].create_dataset(name='SNSbanking_file_name', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/SNSHistoTool/SNSbanking_file_name'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/SNSbanking_file_name'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool'].create_dataset(name='SNSmapping_file_name', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/SNSHistoTool/SNSmapping_file_name'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/SNSmapping_file_name'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool'].create_dataset(name='author', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/SNSHistoTool/author'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/author'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool'].create_dataset(name='command1', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/SNSHistoTool/command1'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/command1'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool'].create_dataset(name='date', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/SNSHistoTool/date'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/date'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool'].create_dataset(name='description', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/SNSHistoTool/description'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/description'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool'].create_dataset(name='version', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/SNSHistoTool/version'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/version'].attrs['EX_required'] = 'false' + +root['/entry'].create_dataset(name='collection_identifier', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/collection_identifier'].attrs['type'] = 'NX_CHAR' +root['/entry/collection_identifier'].attrs['EX_required'] = 'false' + +root['/entry'].create_dataset(name='collection_title', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/collection_title'].attrs['type'] = 'NX_CHAR' +root['/entry/collection_title'].attrs['EX_required'] = 'false' + +# Valid enumeration values for root['/entry']['definition'] are: +# NXsnshisto + +root['/entry'].create_dataset(name='definition', data='NXsnshisto', maxshape=None) +root['/entry/definition'].attrs['type'] = 'NX_CHAR' +root['/entry/definition'].attrs['EX_required'] = 'false' + +root['/entry'].create_dataset(name='duration', data=1.0, maxshape=None) +root['/entry/duration'].attrs['type'] = 'NX_FLOAT' +root['/entry/duration'].attrs['EX_required'] = 'false' +root['/entry/duration'].attrs['units'] = 'NX_TIME' + +root['/entry'].create_dataset(name='end_time', data='2022-03-04T14:56:25.264424', maxshape=None) +root['/entry/end_time'].attrs['type'] = 'NX_DATE_TIME' +root['/entry/end_time'].attrs['EX_required'] = 'false' + +root['/entry'].create_dataset(name='entry_identifier', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/entry_identifier'].attrs['type'] = 'NX_CHAR' +root['/entry/entry_identifier'].attrs['EX_required'] = 'false' + +root['/entry'].create_dataset(name='experiment_identifier', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/experiment_identifier'].attrs['type'] = 'NX_CHAR' +root['/entry/experiment_identifier'].attrs['EX_required'] = 'false' + +root['/entry/instrument/SNS'].create_dataset(name='frequency', data=1.0, maxshape=None) +root['/entry/instrument/SNS/frequency'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/SNS/frequency'].attrs['EX_required'] = 'false' +root['/entry/instrument/SNS/frequency'].attrs['units'] = 'NX_FREQUENCY' + +root['/entry/instrument/SNS'].create_dataset(name='name', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/SNS/name'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/SNS/name'].attrs['EX_required'] = 'false' + +root['/entry/instrument/SNS'].create_dataset(name='probe', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/SNS/probe'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/SNS/probe'].attrs['EX_required'] = 'false' + +root['/entry/instrument/SNS'].create_dataset(name='type', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/SNS/type'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/SNS/type'].attrs['EX_required'] = 'false' + +root['/entry/instrument'].create_dataset(name='SNSdetector_calibration_id', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/SNSdetector_calibration_id'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/SNSdetector_calibration_id'].attrs['EX_required'] = 'false' + +root['/entry/instrument'].create_dataset(name='SNSgeometry_file_name', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/SNSgeometry_file_name'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/SNSgeometry_file_name'].attrs['EX_required'] = 'false' + +root['/entry/instrument'].create_dataset(name='SNStranslation_service', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/SNStranslation_service'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/SNStranslation_service'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector'].create_dataset(name='azimuthal_angle', data=1.0, maxshape=None) +root['/entry/instrument/detector/azimuthal_angle'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/azimuthal_angle'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/azimuthal_angle'].attrs['units'] = 'NX_ANGLE' + +root['/entry/instrument/detector'].create_dataset(name='data', data=np.ushort(1), maxshape=None) +root['/entry/instrument/detector/data'].attrs['type'] = 'NX_UINT' +root['/entry/instrument/detector/data'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/data'].attrs['axes'] = 'x_pixel_offset,y_pixel_offset,time_of_flight' +root['/entry/instrument/detector/data'].attrs['signal'] = '1' + +root['/entry/instrument/detector'].create_dataset(name='data_x_time_of_flight', data=np.ushort(1), maxshape=None) +root['/entry/instrument/detector/data_x_time_of_flight'].attrs['type'] = 'NX_UINT' +root['/entry/instrument/detector/data_x_time_of_flight'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/data_x_time_of_flight'].attrs['axes'] = 'x_pixel_offset,time_of_flight' +root['/entry/instrument/detector/data_x_time_of_flight'].attrs['signal'] = '3' + +root['/entry/instrument/detector'].create_dataset(name='data_x_y', data=np.ushort(1), maxshape=None) +root['/entry/instrument/detector/data_x_y'].attrs['type'] = 'NX_UINT' +root['/entry/instrument/detector/data_x_y'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/data_x_y'].attrs['axes'] = 'x_pixel_offset,y_pixel_offset' +root['/entry/instrument/detector/data_x_y'].attrs['signal'] = '2' + +root['/entry/instrument/detector'].create_dataset(name='data_y_time_of_flight', data=np.ushort(1), maxshape=None) +root['/entry/instrument/detector/data_y_time_of_flight'].attrs['type'] = 'NX_UINT' +root['/entry/instrument/detector/data_y_time_of_flight'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/data_y_time_of_flight'].attrs['axes'] = 'y_pixel_offset,time_of_flight' +root['/entry/instrument/detector/data_y_time_of_flight'].attrs['signal'] = '4' + +root['/entry/instrument/detector'].create_dataset(name='distance', data=1.0, maxshape=None) +root['/entry/instrument/detector/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/detector/origin/orientation'].create_dataset(name='value', data=1.0, maxshape=None) +root['/entry/instrument/detector/origin/orientation/value'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/origin/orientation/value'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector/origin/shape'].create_dataset(name='description', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/detector/origin/shape/description'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/detector/origin/shape/description'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector/origin/shape'].create_dataset(name='shape', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/detector/origin/shape/shape'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/detector/origin/shape/shape'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector/origin/shape'].create_dataset(name='size', data=1.0, maxshape=None) +root['/entry/instrument/detector/origin/shape/size'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/origin/shape/size'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/origin/shape/size'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/detector/origin/translation'].create_dataset(name='distance', data=1.0, maxshape=None) +root['/entry/instrument/detector/origin/translation/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/origin/translation/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/origin/translation/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/detector'].create_dataset(name='pixel_id', data=np.ushort(1), maxshape=None) +root['/entry/instrument/detector/pixel_id'].attrs['type'] = 'NX_UINT' +root['/entry/instrument/detector/pixel_id'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector'].create_dataset(name='polar_angle', data=1.0, maxshape=None) +root['/entry/instrument/detector/polar_angle'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/polar_angle'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/polar_angle'].attrs['units'] = 'NX_ANGLE' + +root['/entry/instrument/detector'].create_dataset(name='time_of_flight', data=1.0, maxshape=None) +root['/entry/instrument/detector/time_of_flight'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/time_of_flight'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/time_of_flight'].attrs['axis'] = '3' +root['/entry/instrument/detector/time_of_flight'].attrs['primary'] = '1' +root['/entry/instrument/detector/time_of_flight'].attrs['units'] = 'NX_TIME_OF_FLIGHT' + +root['/entry/instrument/detector'].create_dataset(name='total_counts', data=np.ushort(1), maxshape=None) +root['/entry/instrument/detector/total_counts'].attrs['type'] = 'NX_UINT' +root['/entry/instrument/detector/total_counts'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector'].create_dataset(name='x_pixel_offset', data=1.0, maxshape=None) +root['/entry/instrument/detector/x_pixel_offset'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/x_pixel_offset'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/x_pixel_offset'].attrs['axis'] = '1' +root['/entry/instrument/detector/x_pixel_offset'].attrs['primary'] = '1' +root['/entry/instrument/detector/x_pixel_offset'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/detector'].create_dataset(name='y_pixel_offset', data=1.0, maxshape=None) +root['/entry/instrument/detector/y_pixel_offset'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/y_pixel_offset'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/y_pixel_offset'].attrs['axis'] = '2' +root['/entry/instrument/detector/y_pixel_offset'].attrs['primary'] = '1' +root['/entry/instrument/detector/y_pixel_offset'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument'].create_dataset(name='beamline', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/beamline'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/beamline'].attrs['EX_required'] = 'false' + +root['/entry/instrument/NXdisk_chopper'].create_dataset(name='distance', data=1.0, maxshape=None) +root['/entry/instrument/NXdisk_chopper/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/NXdisk_chopper/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/NXdisk_chopper/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/NXfermi_chopper'].create_dataset(name='distance', data=1.0, maxshape=None) +root['/entry/instrument/NXfermi_chopper/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/NXfermi_chopper/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/NXfermi_chopper/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/moderator'].create_dataset(name='coupling_material', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/moderator/coupling_material'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/moderator/coupling_material'].attrs['EX_required'] = 'false' + +root['/entry/instrument/moderator'].create_dataset(name='distance', data=1.0, maxshape=None) +root['/entry/instrument/moderator/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/moderator/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/moderator/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/moderator'].create_dataset(name='temperature', data=1.0, maxshape=None) +root['/entry/instrument/moderator/temperature'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/moderator/temperature'].attrs['EX_required'] = 'false' +root['/entry/instrument/moderator/temperature'].attrs['units'] = 'NX_TEMPERATURE' + +root['/entry/instrument/moderator'].create_dataset(name='type', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/moderator/type'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/moderator/type'].attrs['EX_required'] = 'false' + +root['/entry/instrument'].create_dataset(name='name', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/name'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/name'].attrs['EX_required'] = 'false' + +root['/entry/instrument/aperture/origin/orientation'].create_dataset(name='value', data=1.0, maxshape=None) +root['/entry/instrument/aperture/origin/orientation/value'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/aperture/origin/orientation/value'].attrs['EX_required'] = 'false' + +root['/entry/instrument/aperture/origin/shape'].create_dataset(name='description', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/aperture/origin/shape/description'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/aperture/origin/shape/description'].attrs['EX_required'] = 'false' + +root['/entry/instrument/aperture/origin/shape'].create_dataset(name='shape', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/aperture/origin/shape/shape'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/aperture/origin/shape/shape'].attrs['EX_required'] = 'false' + +root['/entry/instrument/aperture/origin/shape'].create_dataset(name='size', data=1.0, maxshape=None) +root['/entry/instrument/aperture/origin/shape/size'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/aperture/origin/shape/size'].attrs['EX_required'] = 'false' +root['/entry/instrument/aperture/origin/shape/size'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/aperture/origin/translation'].create_dataset(name='distance', data=1.0, maxshape=None) +root['/entry/instrument/aperture/origin/translation/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/aperture/origin/translation/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/aperture/origin/translation/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/aperture'].create_dataset(name='x_pixel_offset', data=1.0, maxshape=None) +root['/entry/instrument/aperture/x_pixel_offset'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/aperture/x_pixel_offset'].attrs['EX_required'] = 'false' +root['/entry/instrument/aperture/x_pixel_offset'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/attenuator'].create_dataset(name='distance', data=1.0, maxshape=None) +root['/entry/instrument/attenuator/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/attenuator/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/attenuator/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/crystal/origin'].create_dataset(name='description', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/crystal/origin/description'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/crystal/origin/description'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal/origin/orientation'].create_dataset(name='value', data=1.0, maxshape=None) +root['/entry/instrument/crystal/origin/orientation/value'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/crystal/origin/orientation/value'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal/origin/shape'].create_dataset(name='description', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/crystal/origin/shape/description'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/crystal/origin/shape/description'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal/origin/shape'].create_dataset(name='shape', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/crystal/origin/shape/shape'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/crystal/origin/shape/shape'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal/origin/shape'].create_dataset(name='size', data=1.0, maxshape=None) +root['/entry/instrument/crystal/origin/shape/size'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/crystal/origin/shape/size'].attrs['EX_required'] = 'false' +root['/entry/instrument/crystal/origin/shape/size'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/crystal/origin/translation'].create_dataset(name='distance', data=1.0, maxshape=None) +root['/entry/instrument/crystal/origin/translation/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/crystal/origin/translation/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/crystal/origin/translation/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/crystal'].create_dataset(name='type', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/instrument/crystal/type'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/crystal/type'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal'].create_dataset(name='wavelength', data=1.0, maxshape=None) +root['/entry/instrument/crystal/wavelength'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/crystal/wavelength'].attrs['EX_required'] = 'false' +root['/entry/instrument/crystal/wavelength'].attrs['units'] = 'NX_WAVELENGTH' + +root['/entry/monitor'].create_dataset(name='data', data=np.ushort(1), maxshape=None) +root['/entry/monitor/data'].attrs['type'] = 'NX_UINT' +root['/entry/monitor/data'].attrs['EX_required'] = 'false' +root['/entry/monitor/data'].attrs['axes'] = 'time_of_flight' +root['/entry/monitor/data'].attrs['signal'] = '1' + +root['/entry/monitor'].create_dataset(name='distance', data=1.0, maxshape=None) +root['/entry/monitor/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/monitor/distance'].attrs['EX_required'] = 'false' +root['/entry/monitor/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/monitor'].create_dataset(name='mode', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/monitor/mode'].attrs['type'] = 'NX_CHAR' +root['/entry/monitor/mode'].attrs['EX_required'] = 'false' + +root['/entry/monitor'].create_dataset(name='time_of_flight', data=1.0, maxshape=None) +root['/entry/monitor/time_of_flight'].attrs['type'] = 'NX_FLOAT' +root['/entry/monitor/time_of_flight'].attrs['EX_required'] = 'false' +root['/entry/monitor/time_of_flight'].attrs['units'] = 'NX_TIME' + +root['/entry'].create_dataset(name='notes', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/notes'].attrs['type'] = 'NX_CHAR' +root['/entry/notes'].attrs['EX_required'] = 'false' + +root['/entry'].create_dataset(name='proton_charge', data=1.0, maxshape=None) +root['/entry/proton_charge'].attrs['type'] = 'NX_FLOAT' +root['/entry/proton_charge'].attrs['EX_required'] = 'false' +root['/entry/proton_charge'].attrs['units'] = 'NX_CHARGE' + +root['/entry'].create_dataset(name='raw_frames', data=1, maxshape=None) +root['/entry/raw_frames'].attrs['type'] = 'NX_INT' +root['/entry/raw_frames'].attrs['EX_required'] = 'false' + +root['/entry'].create_dataset(name='run_number', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/run_number'].attrs['type'] = 'NX_CHAR' +root['/entry/run_number'].attrs['EX_required'] = 'false' + +root['/entry/sample'].create_dataset(name='changer_position', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/sample/changer_position'].attrs['type'] = 'NX_CHAR' +root['/entry/sample/changer_position'].attrs['EX_required'] = 'false' + +root['/entry/sample'].create_dataset(name='holder', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/sample/holder'].attrs['type'] = 'NX_CHAR' +root['/entry/sample/holder'].attrs['EX_required'] = 'false' + +root['/entry/sample'].create_dataset(name='identifier', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/sample/identifier'].attrs['type'] = 'NX_CHAR' +root['/entry/sample/identifier'].attrs['EX_required'] = 'false' + +root['/entry/sample'].create_dataset(name='name', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/sample/name'].attrs['type'] = 'NX_CHAR' +root['/entry/sample/name'].attrs['EX_required'] = 'false' + +root['/entry/sample'].create_dataset(name='nature', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/sample/nature'].attrs['type'] = 'NX_CHAR' +root['/entry/sample/nature'].attrs['EX_required'] = 'false' + +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:25.358149', maxshape=None) +root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' +root['/entry/start_time'].attrs['EX_required'] = 'false' + +root['/entry'].create_dataset(name='title', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/title'].attrs['type'] = 'NX_CHAR' +root['/entry/title'].attrs['EX_required'] = 'false' + +root['/entry'].create_dataset(name='total_counts', data=np.ushort(1), maxshape=None) +root['/entry/total_counts'].attrs['type'] = 'NX_UINT' +root['/entry/total_counts'].attrs['EX_required'] = 'false' +root['/entry/total_counts'].attrs['units'] = 'NX_UNITLESS' + +root['/entry'].create_dataset(name='total_uncounted_counts', data=np.ushort(1), maxshape=None) +root['/entry/total_uncounted_counts'].attrs['type'] = 'NX_UINT' +root['/entry/total_uncounted_counts'].attrs['EX_required'] = 'false' +root['/entry/total_uncounted_counts'].attrs['units'] = 'NX_UNITLESS' + +root['/entry/user'].create_dataset(name='facility_user_id', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/user/facility_user_id'].attrs['type'] = 'NX_CHAR' +root['/entry/user/facility_user_id'].attrs['EX_required'] = 'false' + +root['/entry/user'].create_dataset(name='name', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/user/name'].attrs['type'] = 'NX_CHAR' +root['/entry/user/name'].attrs['EX_required'] = 'false' + +root['/entry/user'].create_dataset(name='role', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/user/role'].attrs['type'] = 'NX_CHAR' +root['/entry/user/role'].attrs['EX_required'] = 'false' + +# Create the LINKS +root['/entry/data/data'] = h5py.SoftLink('/entry/instrument/detector/data') +root['/entry/data/data/'].attrs['target'] = '/entry/instrument/detector/data' + +# Create the LINKS +root['/entry/data/data_x_time_of_flight'] = h5py.SoftLink('/entry/instrument/detector/data_x_time_of_flight') +root['/entry/data/data_x_time_of_flight/'].attrs['target'] = '/entry/instrument/detector/data_x_time_of_flight' + +# Create the LINKS +root['/entry/data/data_x_y'] = h5py.SoftLink('/entry/instrument/detector/data_x_y') +root['/entry/data/data_x_y/'].attrs['target'] = '/entry/instrument/detector/data_x_y' + +# Create the LINKS +root['/entry/data/data_y_time_of_flight'] = h5py.SoftLink('/entry/instrument/detector/data_y_time_of_flight') +root['/entry/data/data_y_time_of_flight/'].attrs['target'] = '/entry/instrument/detector/data_y_time_of_flight' + +# Create the LINKS +root['/entry/data/pixel_id'] = h5py.SoftLink('/entry/instrument/detector/pixel_id') +root['/entry/data/pixel_id/'].attrs['target'] = '/entry/instrument/detector/pixel_id' + +# Create the LINKS +root['/entry/data/time_of_flight'] = h5py.SoftLink('/entry/instrument/detector/time_of_flight') +root['/entry/data/time_of_flight/'].attrs['target'] = '/entry/instrument/detector/time_of_flight' + +# Create the LINKS +root['/entry/data/total_counts'] = h5py.SoftLink('/entry/instrument/detector/total_counts') +root['/entry/data/total_counts/'].attrs['target'] = '/entry/instrument/detector/total_counts' + +# Create the LINKS +root['/entry/data/x_pixel_offset'] = h5py.SoftLink('/entry/instrument/detector/x_pixel_offset') +root['/entry/data/x_pixel_offset/'].attrs['target'] = '/entry/instrument/detector/x_pixel_offset' + +# Create the LINKS +root['/entry/data/y_pixel_offset'] = h5py.SoftLink('/entry/instrument/detector/y_pixel_offset') +root['/entry/data/y_pixel_offset/'].attrs['target'] = '/entry/instrument/detector/y_pixel_offset' + +# Create the DOC strings +root['/entry/DASlogs'].attrs['EX_doc'] = 'Details of all logs, both from cvinfo file and from HistoTool (frequency and proton_charge). ' +root['/entry/DASlogs/positioner'].attrs['EX_doc'] = 'Motor logs from cvinfo file. ' +root['/entry/SNSHistoTool/command1'].attrs['EX_doc'] = 'Command string for event2histo_nxl. ' +root['/entry/definition'].attrs['EX_doc'] = 'Official NXDL schema after this file goes to applications. ' +root['/entry/instrument/SNSdetector_calibration_id'].attrs['EX_doc'] = 'Detector calibration id from DAS. ' +root['/entry/instrument/detector/origin/orientation/value'].attrs['EX_doc'] = 'Six out of nine rotation parameters. ' +root['/entry/instrument/NXdisk_chopper'].attrs['EX_doc'] = 'Original specification called for NXchopper, which is not a valid NeXus base class. Select either NXdisk_chopper or NXfermi_chopper, as appropriate. ' +root['/entry/instrument/NXfermi_chopper'].attrs['EX_doc'] = 'Original specification called for NXchopper, which is not a valid NeXus base class. Select either NXdisk_chopper or NXfermi_chopper, as appropriate. ' +root['/entry/instrument/aperture/origin/orientation/value'].attrs['EX_doc'] = 'Six out of nine rotation parameters. ' +root['/entry/instrument/crystal/origin/orientation/value'].attrs['EX_doc'] = 'Six out of nine rotation parameters. ' +root['/entry/sample/name'].attrs['EX_doc'] = 'Descriptive name of sample ' + + +# Create the ATTRIBUTES +root['/'].attrs['default'] = 'entry' +root['/entry'].attrs['default'] = 'data' +root['/entry/data'].attrs['signal'] = 'data' +root['/entry/data/data'].attrs['signal'] = '1' +root.attrs['file_name'] = os.path.abspath('NXsnshisto') +root.attrs['file_time'] = datetime.datetime.now().isoformat() +root.attrs['h5py_version'] = h5py.version.version +root.attrs['HDF5_Version'] = h5py.version.hdf5_version + +# Close the file +root.close() + + diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXspe.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXspe.py index 2ad5fb4..ab194a4 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXspe.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXspe.py @@ -126,7 +126,7 @@ # Create the DOC strings root['/entry/definition'].attrs['EX_doc'] = 'Official NeXus NXDL schema to which this file conforms. ' root['/entry/NXSPE_info/fixed_energy'].attrs['EX_doc'] = 'The fixed energy used for this file. ' -root['/entry/NXSPE_info/ki_over_kf_scaling'].attrs['EX_doc'] = 'Indicates whether ki/kf scaling has been applied or not. ' +root['/entry/NXSPE_info/ki_over_kf_scaling'].attrs['EX_doc'] = 'kf scaling has been applied or not. ' root['/entry/NXSPE_info/psi'].attrs['EX_doc'] = 'Orientation angle as expected in DCS-MSlice ' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXspecdata.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXspecdata.py new file mode 100644 index 0000000..9fdbea7 --- /dev/null +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXspecdata.py @@ -0,0 +1,304 @@ + +import numpy as np +import datetime +import h5py +import os + +# Note this example script was generated by nxdl_to_hdf5.py using the current +# installed version of the NEXUS definitions ver[v2020.10] + +root = h5py.File('NXspecdata.h5', 'w') + +# Create the GROUPS + +root.create_group('entry') +root['/entry'].attrs['NX_class'] = 'NXentry' +root['/entry'].attrs['EX_required'] = 'false' + +root['/entry/'].create_group('monitor') +root['/entry/monitor'].attrs['NX_class'] = 'NXmonitor' +root['/entry/monitor'].attrs['EX_required'] = 'false' + +root['/entry/'].create_group('data') +root['/entry/data'].attrs['NX_class'] = 'NXdata' +root['/entry/data'].attrs['EX_required'] = 'false' + +root['/entry/'].create_group('counter_cross_reference') +root['/entry/counter_cross_reference'].attrs['NX_class'] = 'NXnote' +root['/entry/counter_cross_reference'].attrs['EX_required'] = 'false' + +root['/entry/'].create_group('positioner_cross_reference') +root['/entry/positioner_cross_reference'].attrs['NX_class'] = 'NXnote' +root['/entry/positioner_cross_reference'].attrs['EX_required'] = 'false' + +root['/entry/'].create_group('spec') +root['/entry/spec'].attrs['NX_class'] = 'NXinstrument' +root['/entry/spec'].attrs['EX_required'] = 'false' + +root['/entry/spec/'].create_group('UB') +root['/entry/spec/UB'].attrs['NX_class'] = 'NXcrystal' +root['/entry/spec/UB'].attrs['EX_required'] = 'false' + +root['/entry/'].create_group('G') +root['/entry/G'].attrs['NX_class'] = 'NXnote' +root['/entry/G'].attrs['EX_required'] = 'false' + +root['/entry/'].create_group('positioners') +root['/entry/positioners'].attrs['NX_class'] = 'NXnote' +root['/entry/positioners'].attrs['EX_required'] = 'false' + +root['/entry/'].create_group('MCA') +root['/entry/MCA'].attrs['NX_class'] = 'NXnote' +root['/entry/MCA'].attrs['EX_required'] = 'false' + +root['/entry/MCA/'].create_group('ROI') +root['/entry/MCA/ROI'].attrs['NX_class'] = 'NXnote' +root['/entry/MCA/ROI'].attrs['EX_required'] = 'false' + +root['/entry/'].create_group('metadata') +root['/entry/metadata'].attrs['NX_class'] = 'NXnote' +root['/entry/metadata'].attrs['EX_required'] = 'false' + +root['/entry/'].create_group('SPEC_user') +root['/entry/SPEC_user'].attrs['NX_class'] = 'NXuser' +root['/entry/SPEC_user'].attrs['EX_required'] = 'false' + +root['/entry/'].create_group('_unrecognized') +root['/entry/_unrecognized'].attrs['NX_class'] = 'NXnote' +root['/entry/_unrecognized'].attrs['EX_required'] = 'false' + +# Create the FIELDS + +# Valid enumeration values for root['/entry']['definition'] are: +# NXspecdata + +root['/entry'].create_dataset(name='definition', data='NXspecdata', maxshape=None) +root['/entry/definition'].attrs['type'] = 'NX_CHAR' +root['/entry/definition'].attrs['EX_required'] = 'false' + +root['/entry'].create_dataset(name='scan_number', data=1.0, maxshape=None) +root['/entry/scan_number'].attrs['type'] = 'NX_NUMBER' +root['/entry/scan_number'].attrs['EX_required'] = 'false' + +root['/entry'].create_dataset(name='title', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/title'].attrs['type'] = 'NX_CHAR' +root['/entry/title'].attrs['EX_required'] = 'false' + +root['/entry'].create_dataset(name='command', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/command'].attrs['type'] = 'NX_CHAR' +root['/entry/command'].attrs['EX_required'] = 'false' + +root['/entry'].create_dataset(name='date', data='2022-03-04T14:56:25.717441', maxshape=None) +root['/entry/date'].attrs['type'] = 'NX_DATE_TIME' +root['/entry/date'].attrs['EX_required'] = 'false' + +# Valid enumeration values for root['/entry/monitor']['mode'] are: +# monitor +# timer + +root['/entry/monitor'].create_dataset(name='mode', data='monitor', maxshape=None) +root['/entry/monitor/mode'].attrs['type'] = 'NX_CHAR' +root['/entry/monitor/mode'].attrs['EX_required'] = 'false' + +root['/entry/monitor'].create_dataset(name='preset', data=1.0, maxshape=None) +root['/entry/monitor/preset'].attrs['type'] = 'NX_NUMBER' +root['/entry/monitor/preset'].attrs['EX_required'] = 'false' + +root['/entry/monitor'].create_dataset(name='data', data=1.0, maxshape=None) +root['/entry/monitor/data'].attrs['type'] = 'NX_NUMBER' +root['/entry/monitor/data'].attrs['EX_required'] = 'false' +root['/entry/monitor/data'].attrs['nameType'] = 'any' + +root['/entry/monitor'].create_dataset(name='count_time', data=1.0, maxshape=None) +root['/entry/monitor/count_time'].attrs['type'] = 'NX_NUMBER' +root['/entry/monitor/count_time'].attrs['EX_required'] = 'false' +root['/entry/monitor/count_time'].attrs['nameType'] = 'any' + +root['/entry'].create_dataset(name='comments', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/comments'].attrs['type'] = 'NX_CHAR' +root['/entry/comments'].attrs['EX_required'] = 'false' + +root['/entry'].create_dataset(name='Q', data=1.0, maxshape=None) +root['/entry/Q'].attrs['type'] = 'NX_NUMBER' +root['/entry/Q'].attrs['EX_required'] = 'false' + +root['/entry'].create_dataset(name='TEMP_SP', data=1.0, maxshape=None) +root['/entry/TEMP_SP'].attrs['type'] = 'NX_NUMBER' +root['/entry/TEMP_SP'].attrs['EX_required'] = 'false' + +root['/entry'].create_dataset(name='DEGC_SP', data=1.0, maxshape=None) +root['/entry/DEGC_SP'].attrs['type'] = 'NX_NUMBER' +root['/entry/DEGC_SP'].attrs['EX_required'] = 'false' + +root['/entry/data'].create_dataset(name='data', data=1.0, maxshape=None) +root['/entry/data/data'].attrs['type'] = 'NX_NUMBER' +root['/entry/data/data'].attrs['EX_required'] = 'false' +root['/entry/data/data'].attrs['nameType'] = 'any' + +root['/entry/data'].create_dataset(name='intensity_factor', data=1.0, maxshape=None) +root['/entry/data/intensity_factor'].attrs['type'] = 'NX_NUMBER' +root['/entry/data/intensity_factor'].attrs['EX_required'] = 'false' + +root['/entry/data'].create_dataset(name='_mca_', data=1.0, maxshape=None) +root['/entry/data/_mca_'].attrs['type'] = 'NX_NUMBER' +root['/entry/data/_mca_'].attrs['EX_required'] = 'false' + +root['/entry/data'].create_dataset(name='_mca_channel_', data=1.0, maxshape=None) +root['/entry/data/_mca_channel_'].attrs['type'] = 'NX_NUMBER' +root['/entry/data/_mca_channel_'].attrs['EX_required'] = 'false' + +root['/entry/data'].create_dataset(name='_mca1_', data=1.0, maxshape=None) +root['/entry/data/_mca1_'].attrs['type'] = 'NX_NUMBER' +root['/entry/data/_mca1_'].attrs['EX_required'] = 'false' + +root['/entry/data'].create_dataset(name='_mca1_channel_', data=1.0, maxshape=None) +root['/entry/data/_mca1_channel_'].attrs['type'] = 'NX_NUMBER' +root['/entry/data/_mca1_channel_'].attrs['EX_required'] = 'false' + +root['/entry/spec/UB'].create_dataset(name='orientation_matrix', data=1.0, maxshape=None) +root['/entry/spec/UB/orientation_matrix'].attrs['type'] = 'NX_FLOAT' +root['/entry/spec/UB/orientation_matrix'].attrs['EX_required'] = 'false' + +root['/entry/G'].create_dataset(name='G0', data=1.0, maxshape=None) +root['/entry/G/G0'].attrs['type'] = 'NX_NUMBER' +root['/entry/G/G0'].attrs['EX_required'] = 'false' + +root['/entry/G'].create_dataset(name='G1', data=1.0, maxshape=None) +root['/entry/G/G1'].attrs['type'] = 'NX_NUMBER' +root['/entry/G/G1'].attrs['EX_required'] = 'false' + +root['/entry/G'].create_dataset(name='G2', data=1.0, maxshape=None) +root['/entry/G/G2'].attrs['type'] = 'NX_NUMBER' +root['/entry/G/G2'].attrs['EX_required'] = 'false' + +root['/entry/G'].create_dataset(name='G4', data=1.0, maxshape=None) +root['/entry/G/G4'].attrs['type'] = 'NX_NUMBER' +root['/entry/G/G4'].attrs['EX_required'] = 'false' + +root['/entry/positioners'].create_dataset(name='positioner', data=1.0, maxshape=None) +root['/entry/positioners/positioner'].attrs['type'] = 'NX_NUMBER' +root['/entry/positioners/positioner'].attrs['EX_required'] = 'false' +root['/entry/positioners/positioner'].attrs['nameType'] = 'any' + +root['/entry/MCA'].create_dataset(name='preset_time', data=1.0, maxshape=None) +root['/entry/MCA/preset_time'].attrs['type'] = 'NX_NUMBER' +root['/entry/MCA/preset_time'].attrs['EX_required'] = 'false' + +root['/entry/MCA'].create_dataset(name='elapsed_live_time', data=1.0, maxshape=None) +root['/entry/MCA/elapsed_live_time'].attrs['type'] = 'NX_NUMBER' +root['/entry/MCA/elapsed_live_time'].attrs['EX_required'] = 'false' + +root['/entry/MCA'].create_dataset(name='elapsed_real_time', data=1.0, maxshape=None) +root['/entry/MCA/elapsed_real_time'].attrs['type'] = 'NX_NUMBER' +root['/entry/MCA/elapsed_real_time'].attrs['EX_required'] = 'false' + +root['/entry/MCA'].create_dataset(name='number_saved', data=1.0, maxshape=None) +root['/entry/MCA/number_saved'].attrs['type'] = 'NX_NUMBER' +root['/entry/MCA/number_saved'].attrs['EX_required'] = 'false' + +root['/entry/MCA'].create_dataset(name='first_saved', data=1, maxshape=None) +root['/entry/MCA/first_saved'].attrs['type'] = 'NX_INT' +root['/entry/MCA/first_saved'].attrs['EX_required'] = 'false' + +root['/entry/MCA'].create_dataset(name='last_saved', data=1, maxshape=None) +root['/entry/MCA/last_saved'].attrs['type'] = 'NX_INT' +root['/entry/MCA/last_saved'].attrs['EX_required'] = 'false' + +root['/entry/MCA'].create_dataset(name='reduction_coef', data=1.0, maxshape=None) +root['/entry/MCA/reduction_coef'].attrs['type'] = 'NX_NUMBER' +root['/entry/MCA/reduction_coef'].attrs['EX_required'] = 'false' + +root['/entry/MCA'].create_dataset(name='calib_a', data=1.0, maxshape=None) +root['/entry/MCA/calib_a'].attrs['type'] = 'NX_NUMBER' +root['/entry/MCA/calib_a'].attrs['EX_required'] = 'false' + +root['/entry/MCA'].create_dataset(name='calib_b', data=1.0, maxshape=None) +root['/entry/MCA/calib_b'].attrs['type'] = 'NX_NUMBER' +root['/entry/MCA/calib_b'].attrs['EX_required'] = 'false' + +root['/entry/MCA'].create_dataset(name='calib_c', data=1.0, maxshape=None) +root['/entry/MCA/calib_c'].attrs['type'] = 'NX_NUMBER' +root['/entry/MCA/calib_c'].attrs['EX_required'] = 'false' + +root['/entry/MCA/ROI'].create_dataset(name='roiN', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/MCA/ROI/roiN'].attrs['type'] = 'NX_CHAR' +root['/entry/MCA/ROI/roiN'].attrs['EX_required'] = 'false' + +root['/entry/SPEC_user'].create_dataset(name='SPEC_user', data='SAMPLE-CHAR-DATA', maxshape=None) +root['/entry/SPEC_user/SPEC_user'].attrs['type'] = 'NX_CHAR' +root['/entry/SPEC_user/SPEC_user'].attrs['EX_required'] = 'false' + +# Create the DOC strings +root['/entry'].attrs['EX_doc'] = 'one scan from a SPEC data file, starts with a **#S** line ' +root['/entry/definition'].attrs['EX_doc'] = 'Official NeXus NXDL schema to which this subentry conforms. ' +root['/entry/scan_number'].attrs['EX_doc'] = 'SPEC scan number ' +root['/entry/title'].attrs['EX_doc'] = 'SPEC scan number and command, from **#S** line SPEC data file line:: #S 1 cscan en 690 750 60 0 *title*:: 1 cscan en 690 750 60 0 ' +root['/entry/command'].attrs['EX_doc'] = 'SPEC scan command, from **#S** line, after the scan number. :SPEC data file line: ``#S 1 cscan en 690 750 60 0`` :command*: ``cscan en 690 750 60 0`` ' +root['/entry/date'].attrs['EX_doc'] = 'date from **#D** line in scan header, in ISO8601 format ' +root['/entry/monitor/mode'].attrs['EX_doc'] = 'Count to a preset value based on either clock time (timer) or received monitor counts (monitor). ' +root['/entry/monitor/preset'].attrs['EX_doc'] = 'preset value for time or monitor * **#M** -- counting against this constant monitor count (see #T) * **#T** -- counting against this constant number of seconds (see #M) ' +root['/entry/monitor/data'].attrs['EX_doc'] = 'array(s) of monitor data ' +root['/entry/monitor/count_time'].attrs['EX_doc'] = 'array(s) of monitor data ' +root['/entry/comments'].attrs['EX_doc'] = 'Any **#C** lines in this scan, stored as one string with newlines between comments ' +root['/entry/Q'].attrs['EX_doc'] = '**#Q** -- :math:`Q` (:math:`hkl`) at start of scan array of [:math:`h` :math:`k` :math:`l`] ' +root['/entry/TEMP_SP'].attrs['EX_doc'] = '**#X** -- temperature set point ' +root['/entry/DEGC_SP'].attrs['EX_doc'] = '**#X** -- temperature set point (C) ' +root['/entry/data'].attrs['EX_doc'] = 'detector (and MCA) data from this scan ' +root['/entry/data/data'].attrs['EX_doc'] = 'one column of data from the scan HDF5 requires that each member of a group must have a unique name. Pick the name of column from **#L** but make it unique which means if the same name is used in more than one column, append a number to the extra instances to make them unique yet preserve their content, just in case they might be different. Example: ``seconds seconds`` becomes ``seconds`` and ``seconda_1``. ' +root['/entry/data/intensity_factor'].attrs['EX_doc'] = '**#I** -- intensity normalizing factor ' +root['/entry/counter_cross_reference'].attrs['EX_doc'] = 'associates values declared in **#J** and **#j** scan header lines ' +root['/entry/positioner_cross_reference'].attrs['EX_doc'] = 'associates values declared in **#O** and **#o** scan header lines ' +root['/entry/spec'].attrs['EX_doc'] = 'various metadata from the SPEC scan header that have well-known NeXus base clases ' +root['/entry/spec/UB'].attrs['EX_doc'] = 'Orientation matrix of single crystal sample using Busing-Levy convention ' +root['/entry/spec/UB/orientation_matrix'].attrs['EX_doc'] = '**#G3** line in scan header ' +root['/entry/G'].attrs['EX_doc'] = 'SPEC geometry variables for this diffractometer geometry (instrument specific) TODO: give interpreted name for each array value (need to figure out how to get the names) ' +root['/entry/G/G0'].attrs['EX_doc'] = 'geometry parameters from G[] array (geo mode, sector, etc) ' +root['/entry/G/G1'].attrs['EX_doc'] = 'geometry parameters from U[] array (lattice constants, orientation reflections) ' +root['/entry/G/G2'].attrs['EX_doc'] = 'not used, although some files has a single zero value ' +root['/entry/G/G4'].attrs['EX_doc'] = 'geometry parameters from Q[] array (lambda, frozen angles, cut points, etc) ' +root['/entry/positioners'].attrs['EX_doc'] = 'names and values of all positioners (**#O** and **#P** lines) in scan header ' +root['/entry/positioners/positioner'].attrs['EX_doc'] = 'one positioner from the scan header HDF5 requires that each member of a group must have a unique name. SPEC assigns a unique name to each positioner, no extra work is neccesary to comply with the HDF5 rule for unique names in a group. ' +root['/entry/MCA'].attrs['EX_doc'] = '**#@CALIB** -- coefficients to compute a scale based on the MCA channel number ' +root['/entry/MCA/ROI/roiN'].attrs['EX_doc'] = 'numbered regions of interest, use an index number as part of the name ' +root['/entry/metadata'].attrs['EX_doc'] = 'SPEC metadata (UNICAT-style #H and #V lines) This is a block that may be unique to SPEC files acquired at certain APS beam lines. Other facilities or instruments may use this block for storing key:value pairs of data where the values have suitable attributes (such as units). ' +root['/entry/SPEC_user/SPEC_user'].attrs['EX_doc'] = 'user name from first **#C** line in file header ' +root['/entry/_unrecognized'].attrs['EX_doc'] = 'Fallback for any SPEC data file control lines not otherwise placed into groups or fields elsewhere in this specification. ' + + +# Create the ATTRIBUTES +root['/entry'].attrs['default'] = 'SAMPLE-CHAR-DATA' +root['/entry/monitor'].attrs['description'] = 'SAMPLE-CHAR-DATA' +root['/entry/monitor/preset'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root['/entry/data'].attrs['description'] = 'SAMPLE-CHAR-DATA' +root['/entry/data'].attrs['signal'] = 'SAMPLE-CHAR-DATA' +root['/entry/data'].attrs['axes'] = 'SAMPLE-CHAR-DATA' +root['/entry/data'].attrs['AXISNAME_indices'] = 'SAMPLE-CHAR-DATA' +root['/entry/data/data'].attrs['spec_name'] = 'SAMPLE-CHAR-DATA' +root['/entry/data/data'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root['/entry/counter_cross_reference'].attrs['comment'] = 'SAMPLE-CHAR-DATA' +root['/entry/counter_cross_reference'].attrs['description'] = 'SAMPLE-CHAR-DATA' +root['/entry/positioner_cross_reference'].attrs['comment'] = 'SAMPLE-CHAR-DATA' +root['/entry/positioner_cross_reference'].attrs['description'] = 'SAMPLE-CHAR-DATA' +root['/entry/G'].attrs['comment'] = 'SAMPLE-CHAR-DATA' +root['/entry/G'].attrs['description'] = 'SAMPLE-CHAR-DATA' +root['/entry/positioners'].attrs['description'] = 'SAMPLE-CHAR-DATA' +root['/entry/MCA'].attrs['description'] = 'SAMPLE-CHAR-DATA' +root['/entry/MCA/ROI/roiN'].attrs['description'] = 'SAMPLE-CHAR-DATA' +root['/entry/MCA/ROI/roiN'].attrs['first_channel'] = 'SAMPLE-CHAR-DATA' +root['/entry/MCA/ROI/roiN'].attrs['last_channel'] = 'SAMPLE-CHAR-DATA' +root['/entry/metadata'].attrs['description'] = 'SAMPLE-CHAR-DATA' +root['/entry/_unrecognized'].attrs['comment'] = 'SAMPLE-CHAR-DATA' +root['/entry/_unrecognized'].attrs['description'] = 'SAMPLE-CHAR-DATA' +root['/'].attrs['default'] = 'entry' +root['/entry'].attrs['default'] = 'data' +root['/entry/data'].attrs['signal'] = 'data' +root['/entry/data/data'].attrs['signal'] = '1' +root.attrs['file_name'] = os.path.abspath('NXspecdata') +root.attrs['file_time'] = datetime.datetime.now().isoformat() +root.attrs['h5py_version'] = h5py.version.version +root.attrs['HDF5_Version'] = h5py.version.hdf5_version + +# Close the file +root.close() + + diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXstxm.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXstxm.py index 4603950..7ed0283 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXstxm.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXstxm.py @@ -61,11 +61,11 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='start_time', data='2021-03-29T15:51:42.787454', maxshape=None) +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:36.688437', maxshape=None) root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='end_time', data='2021-03-29T15:51:42.790449', maxshape=None) +root['/entry'].create_dataset(name='end_time', data='2022-03-04T14:56:36.688437', maxshape=None) root['/entry/end_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/end_time'].attrs['EX_required'] = 'true' @@ -154,7 +154,7 @@ root['/entry/instrument/sample_x'].attrs['EX_doc'] = 'Measurements of the sample position from the x-axis interferometer. ' root['/entry/instrument/sample_y'].attrs['EX_doc'] = 'Measurements of the sample position from the y-axis interferometer. ' root['/entry/instrument/sample_z'].attrs['EX_doc'] = 'Measurements of the sample position from the z-axis interferometer. ' -root['/entry/data/stxm_scan_type'].attrs['EX_doc'] = 'Label for typical scan types as a convenience for humans. Each label corresponds to a specific set of axes being scanned to produce a data array of shape: * sample point spectrum: (photon_energy,) * sample line spectrum: (photon_energy, sample_y/sample_x) * sample image: (sample_y, sample_x) * sample image stack: (photon_energy, sample_y, sample_x) * sample focus: (zoneplate_z, sample_y/sample_x) * osa image: (osa_y, osa_x) * osa focus: (zoneplate_z, osa_y/osa_x) * detector image: (detector_y, detector_x) The "generic scan" string is to be used when none of the other choices are appropriate. ' +root['/entry/data/stxm_scan_type'].attrs['EX_doc'] = 'osa_x) * detector image: (detector_y, detector_x) The "generic scan" string is to be used when none of the other choices are appropriate. ' root['/entry/data/data'].attrs['EX_doc'] = 'Detectors that provide more than one value per scan point should be summarised to a single value per scan point for this array in order to simplify plotting. Note that "Line scans" and focus type scans measure along one spatial dimension but are not restricted to being parallel to the X or Y axes. Such scans should therefore use a single dimension for the positions along the spatial line. The "sample_x" and "sample_y" fields should then contain lists of the x- and y-positions and should both have the "axis" attribute pointing to the same dimension. ' root['/entry/data/energy'].attrs['EX_doc'] = 'List of photon energies of the X-ray beam. If scanned through multiple values, then an "axis" attribute will be required to link the field to the appropriate data array dimension. ' root['/entry/data/sample_y'].attrs['EX_doc'] = 'List of Y positions on the sample. If scanned through multiple values, then an "axis" attribute will be required to link the field to the appropriate data array dimension. ' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtas.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtas.py index ba0d469..221d485 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtas.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtas.py @@ -53,7 +53,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='start_time', data='2021-03-29T15:51:43.263179', maxshape=None) +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:36.922755', maxshape=None) root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtofnpd.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtofnpd.py index 049863b..8b72781 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtofnpd.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtofnpd.py @@ -45,7 +45,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='start_time', data='2021-03-29T15:51:43.606595', maxshape=None) +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:37.078968', maxshape=None) root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtofraw.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtofraw.py index 55e6a55..dd9bd59 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtofraw.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtofraw.py @@ -45,7 +45,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='start_time', data='2021-03-29T15:51:43.959055', maxshape=None) +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:37.266424', maxshape=None) root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtofsingle.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtofsingle.py index f5ef2ff..cf37ed3 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtofsingle.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtofsingle.py @@ -45,7 +45,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='start_time', data='2021-03-29T15:51:44.287685', maxshape=None) +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:37.453880', maxshape=None) root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtomo.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtomo.py index 5505008..d8f577e 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtomo.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtomo.py @@ -45,11 +45,11 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'false' -root['/entry'].create_dataset(name='start_time', data='2021-03-29T15:51:44.650319', maxshape=None) +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:37.625713', maxshape=None) root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'false' -root['/entry'].create_dataset(name='end_time', data='2021-03-29T15:51:44.652319', maxshape=None) +root['/entry'].create_dataset(name='end_time', data='2022-03-04T14:56:37.625713', maxshape=None) root['/entry/end_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/end_time'].attrs['EX_required'] = 'false' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtomophase.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtomophase.py index 27ca6cc..e40451a 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtomophase.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtomophase.py @@ -53,11 +53,11 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='start_time', data='2021-03-29T15:51:45.057350', maxshape=None) +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:37.860033', maxshape=None) root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='end_time', data='2021-03-29T15:51:45.060350', maxshape=None) +root['/entry'].create_dataset(name='end_time', data='2022-03-04T14:56:37.860033', maxshape=None) root['/entry/end_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/end_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtomoproc.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtomoproc.py index 8dd1170..60a3398 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtomoproc.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXtomoproc.py @@ -81,7 +81,7 @@ root['/entry/reconstruction/version'].attrs['type'] = 'NX_CHAR' root['/entry/reconstruction/version'].attrs['EX_required'] = 'true' -root['/entry/reconstruction'].create_dataset(name='date', data='2021-03-29T15:51:45.375352', maxshape=None) +root['/entry/reconstruction'].create_dataset(name='date', data='2022-03-04T14:56:38.000624', maxshape=None) root['/entry/reconstruction/date'].attrs['type'] = 'NX_DATE_TIME' root['/entry/reconstruction/date'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxas.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxas.py index fbf7085..07a199a 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxas.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxas.py @@ -53,7 +53,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='start_time', data='2021-03-29T15:51:45.626352', maxshape=None) +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:38.109973', maxshape=None) root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxasproc.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxasproc.py index 4ceee47..5381056 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxasproc.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxasproc.py @@ -56,7 +56,7 @@ root['/entry/XAS_data_reduction/version'].attrs['type'] = 'NX_CHAR' root['/entry/XAS_data_reduction/version'].attrs['EX_required'] = 'true' -root['/entry/XAS_data_reduction'].create_dataset(name='date', data='2021-03-29T15:51:45.804350', maxshape=None) +root['/entry/XAS_data_reduction'].create_dataset(name='date', data='2022-03-04T14:56:38.234943', maxshape=None) root['/entry/XAS_data_reduction/date'].attrs['type'] = 'NX_DATE_TIME' root['/entry/XAS_data_reduction/date'].attrs['EX_required'] = 'true' @@ -80,7 +80,7 @@ root['/entry/XAS_data_reduction/version'].attrs['EX_doc'] = 'Version of the program used ' root['/entry/XAS_data_reduction/date'].attrs['EX_doc'] = 'Date and time of reconstruction processing. ' root['/entry/XAS_data_reduction/parameters/raw_file'].attrs['EX_doc'] = 'Original raw data file this data was derived from ' -root['/entry/data/data'].attrs['EX_doc'] = 'This is corrected and calibrated I(incoming)/I(absorbed). So it is the absorption. Expect attribute ``signal=1`` ' +root['/entry/data/data'].attrs['EX_doc'] = 'I(absorbed). So it is the absorption. Expect attribute ``signal=1`` ' # Create the ATTRIBUTES diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxbase.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxbase.py index 83c05f9..6579f2d 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxbase.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxbase.py @@ -49,7 +49,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='start_time', data='2021-03-29T15:51:46.136351', maxshape=None) +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:38.406783', maxshape=None) root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' @@ -177,6 +177,9 @@ # Create the ATTRIBUTES + +# Valid enumeration values for root['/entry/instrument/detector/data']['signal'] are: +# 1 root['/entry/instrument/detector/data'].attrs['signal'] = '1' root['/'].attrs['default'] = 'entry' root['/entry'].attrs['default'] = 'data' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxeuler.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxeuler.py index 7cda8f4..bf340af 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxeuler.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxeuler.py @@ -53,7 +53,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='start_time', data='2021-03-29T15:51:46.670755', maxshape=None) +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:38.687998', maxshape=None) root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' @@ -231,6 +231,9 @@ # Create the ATTRIBUTES + +# Valid enumeration values for root['/entry/instrument/detector/data']['signal'] are: +# 1 root['/entry/instrument/detector/data'].attrs['signal'] = '1' root['/'].attrs['default'] = 'entry' root['/entry'].attrs['default'] = 'data' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxkappa.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxkappa.py index 3515725..52ae493 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxkappa.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxkappa.py @@ -53,7 +53,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='start_time', data='2021-03-29T15:51:47.246390', maxshape=None) +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:38.984766', maxshape=None) root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' @@ -236,6 +236,9 @@ # Create the ATTRIBUTES + +# Valid enumeration values for root['/entry/instrument/detector/data']['signal'] are: +# 1 root['/entry/instrument/detector/data'].attrs['signal'] = '1' root['/'].attrs['default'] = 'entry' root['/entry'].attrs['default'] = 'data' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxlaue.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxlaue.py index 2d97a5e..2e914a5 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxlaue.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxlaue.py @@ -61,7 +61,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='start_time', data='2021-03-29T15:51:47.928648', maxshape=None) +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:39.312812', maxshape=None) root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' @@ -247,6 +247,9 @@ # Create the ATTRIBUTES + +# Valid enumeration values for root['/entry/instrument/detector/data']['signal'] are: +# 1 root['/entry/instrument/detector/data'].attrs['signal'] = '1' root['/'].attrs['default'] = 'entry' root['/entry'].attrs['default'] = 'data' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxlaueplate.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxlaueplate.py index 98b6ee6..8803eeb 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxlaueplate.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxlaueplate.py @@ -61,7 +61,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='start_time', data='2021-03-29T15:51:48.694143', maxshape=None) +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:39.640859', maxshape=None) root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' @@ -253,6 +253,9 @@ # Create the ATTRIBUTES + +# Valid enumeration values for root['/entry/instrument/detector/data']['signal'] are: +# 1 root['/entry/instrument/detector/data'].attrs['signal'] = '1' root['/'].attrs['default'] = 'entry' root['/entry'].attrs['default'] = 'data' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxnb.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxnb.py index da7d9ff..bc37c78 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxnb.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxnb.py @@ -53,7 +53,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='start_time', data='2021-03-29T15:51:49.239441', maxshape=None) +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:39.937663', maxshape=None) root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' @@ -221,6 +221,9 @@ # Create the ATTRIBUTES + +# Valid enumeration values for root['/entry/instrument/detector/data']['signal'] are: +# 1 root['/entry/instrument/detector/data'].attrs['signal'] = '1' root['/'].attrs['default'] = 'entry' root['/entry'].attrs['default'] = 'data' diff --git a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxrot.py b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxrot.py index fdc00f7..7ecc88c 100644 --- a/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxrot.py +++ b/autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXxrot.py @@ -57,7 +57,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry'].create_dataset(name='start_time', data='2021-03-29T15:51:49.861951', maxshape=None) +root['/entry'].create_dataset(name='start_time', data='2022-03-04T14:56:40.218872', maxshape=None) root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' @@ -232,6 +232,9 @@ # Create the ATTRIBUTES + +# Valid enumeration values for root['/entry/instrument/detector/data']['signal'] are: +# 1 root['/entry/instrument/detector/data'].attrs['signal'] = '1' root['/'].attrs['default'] = 'entry' root['/entry'].attrs['default'] = 'data' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXarchive.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXarchive.py index b9fce1a..28bf205 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXarchive.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXarchive.py @@ -45,11 +45,11 @@ root['/entry/entry_identifier'].attrs['type'] = 'NX_CHAR' root['/entry/entry_identifier'].attrs['EX_required'] = 'true' -root['/entry/start_time'] = NXfield('2021-03-29T15:51:33.227367') +root['/entry/start_time'] = NXfield('2022-03-04T14:56:32.205127') root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' -root['/entry/end_time'] = NXfield('2021-03-29T15:51:33.233370') +root['/entry/end_time'] = NXfield('2022-03-04T14:56:32.220782') root['/entry/end_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/end_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXarpes.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXarpes.py index 0fac76a..92cc450 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXarpes.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXarpes.py @@ -29,7 +29,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry/start_time'] = NXfield('2021-03-29T15:51:33.838489') +root['/entry/start_time'] = NXfield('2022-03-04T14:56:32.376970') root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXcanSAS.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXcanSAS.py index 48bbeb8..a29aa90 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXcanSAS.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXcanSAS.py @@ -287,7 +287,7 @@ root['/entry/process/name'].attrs['type'] = 'NX_CHAR' root['/entry/process/name'].attrs['EX_required'] = 'false' -root['/entry/process/date'] = NXfield('2021-03-29T15:51:36.547895') +root['/entry/process/date'] = NXfield('2022-03-04T14:56:33.595457') root['/entry/process/date'].attrs['type'] = 'NX_DATE_TIME' root['/entry/process/date'].attrs['EX_required'] = 'false' @@ -387,41 +387,129 @@ # Create the ATTRIBUTES root['/entry/SAMPLE-CHAR-DATA'] = NXdata() root['/entry/SAMPLE-CHAR-DATA'].set_default() -root['/entry'].attrs['canSAS_class'] = 'SAMPLE-CHAR-DATA' -root['/entry'].attrs['version'] = 'SAMPLE-CHAR-DATA' -root['/entry/data'].attrs['canSAS_class'] = 'SAMPLE-CHAR-DATA' -root['/entry/data'].attrs['signal'] = 'SAMPLE-CHAR-DATA' + +# Valid enumeration values for root['/entry']['canSAS_class'] are: +# SASentry +root['/entry'].attrs['canSAS_class'] = 'SASentry' + +# Valid enumeration values for root['/entry']['version'] are: +# 1.1 +root['/entry'].attrs['version'] = '1.1' + +# Valid enumeration values for root['/entry/data']['canSAS_class'] are: +# SASdata +root['/entry/data'].attrs['canSAS_class'] = 'SASdata' + +# Valid enumeration values for root['/entry/data']['signal'] are: +# I +root['/entry/data'].attrs['signal'] = 'I' root['/entry/data'].attrs['I_axes'] = 'SAMPLE-CHAR-DATA' +root['/entry/data'].attrs['Q_indices'] = 'SAMPLE-CHAR-DATA' root['/entry/data'].attrs['mask'] = 'SAMPLE-CHAR-DATA' root['/entry/data'].attrs['Mask_indices'] = 'SAMPLE-CHAR-DATA' -root['/entry/data'].attrs['timestamp'] = '2021-03-29T15:51:36.601894' -root['/entry/data/Q'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root['/entry/data'].attrs['timestamp'] = 'SAMPLE-CHAR-DATA' + +# Valid enumeration values for root['/entry/data/Q']['units'] are: +# 1/m +# 1/nm +# 1/angstrom +root['/entry/data/Q'].attrs['units'] = '1/m' root['/entry/data/Q'].attrs['uncertainties'] = 'SAMPLE-CHAR-DATA' root['/entry/data/Q'].attrs['resolutions'] = 'SAMPLE-CHAR-DATA' root['/entry/data/Q'].attrs['resolutions_description'] = 'SAMPLE-CHAR-DATA' -root['/entry/data/I'].attrs['units'] = 'SAMPLE-CHAR-DATA' + +# Valid enumeration values for root['/entry/data/I']['units'] are: +# 1/m +# 1/cm +# m2/g +# cm2/g +# arbitrary +root['/entry/data/I'].attrs['units'] = '1/m' root['/entry/data/I'].attrs['uncertainties'] = 'SAMPLE-CHAR-DATA' root['/entry/data/I'].attrs['scaling_factor'] = 'SAMPLE-CHAR-DATA' -root['/entry/data/Idev'].attrs['units'] = 'SAMPLE-CHAR-DATA' -root['/entry/data/Qdev'].attrs['units'] = 'SAMPLE-CHAR-DATA' -root['/entry/data/dQw'].attrs['units'] = 'SAMPLE-CHAR-DATA' -root['/entry/data/dQl'].attrs['units'] = 'SAMPLE-CHAR-DATA' -root['/entry/data/Qmean'].attrs['units'] = 'SAMPLE-CHAR-DATA' + +# Valid enumeration values for root['/entry/data/Idev']['units'] are: +# 1/m +# 1/cm +# m2/g +# cm2/g +# arbitrary +root['/entry/data/Idev'].attrs['units'] = '1/m' + +# Valid enumeration values for root['/entry/data/Qdev']['units'] are: +# 1/m +# 1/nm +# 1/angstrom +root['/entry/data/Qdev'].attrs['units'] = '1/m' + +# Valid enumeration values for root['/entry/data/dQw']['units'] are: +# 1/m +# 1/nm +# 1/angstrom +root['/entry/data/dQw'].attrs['units'] = '1/m' + +# Valid enumeration values for root['/entry/data/dQl']['units'] are: +# 1/m +# 1/nm +# 1/angstrom +root['/entry/data/dQl'].attrs['units'] = '1/m' + +# Valid enumeration values for root['/entry/data/Qmean']['units'] are: +# 1/m +# 1/nm +# 1/angstrom +root['/entry/data/Qmean'].attrs['units'] = '1/m' root['/entry/run'].attrs['name'] = 'SAMPLE-CHAR-DATA' -root['/entry/instrument'].attrs['canSAS_class'] = 'SAMPLE-CHAR-DATA' -root['/entry/instrument/aperture'].attrs['canSAS_class'] = 'SAMPLE-CHAR-DATA' -root['/entry/instrument/collimator'].attrs['canSAS_class'] = 'SAMPLE-CHAR-DATA' -root['/entry/instrument/detector'].attrs['canSAS_class'] = 'SAMPLE-CHAR-DATA' -root['/entry/instrument/source'].attrs['canSAS_class'] = 'SAMPLE-CHAR-DATA' -root['/entry/sample'].attrs['canSAS_class'] = 'SAMPLE-CHAR-DATA' -root['/entry/process'].attrs['canSAS_class'] = 'SAMPLE-CHAR-DATA' -root['/entry/process/collection'].attrs['canSAS_class'] = 'SAMPLE-CHAR-DATA' -root['/entry/collection'].attrs['canSAS_class'] = 'SAMPLE-CHAR-DATA' -root['/entry/TRANSMISSION_SPECTRUM'].attrs['canSAS_class'] = 'SAMPLE-CHAR-DATA' -root['/entry/TRANSMISSION_SPECTRUM'].attrs['signal'] = 'SAMPLE-CHAR-DATA' -root['/entry/TRANSMISSION_SPECTRUM'].attrs['T_axes'] = 'SAMPLE-CHAR-DATA' + +# Valid enumeration values for root['/entry/instrument']['canSAS_class'] are: +# SASinstrument +root['/entry/instrument'].attrs['canSAS_class'] = 'SASinstrument' + +# Valid enumeration values for root['/entry/instrument/aperture']['canSAS_class'] are: +# SASaperture +root['/entry/instrument/aperture'].attrs['canSAS_class'] = 'SASaperture' + +# Valid enumeration values for root['/entry/instrument/collimator']['canSAS_class'] are: +# SAScollimation +root['/entry/instrument/collimator'].attrs['canSAS_class'] = 'SAScollimation' + +# Valid enumeration values for root['/entry/instrument/detector']['canSAS_class'] are: +# SASdetector +root['/entry/instrument/detector'].attrs['canSAS_class'] = 'SASdetector' + +# Valid enumeration values for root['/entry/instrument/source']['canSAS_class'] are: +# SASsource +root['/entry/instrument/source'].attrs['canSAS_class'] = 'SASsource' + +# Valid enumeration values for root['/entry/sample']['canSAS_class'] are: +# SASsample +root['/entry/sample'].attrs['canSAS_class'] = 'SASsample' + +# Valid enumeration values for root['/entry/process']['canSAS_class'] are: +# SASprocess +root['/entry/process'].attrs['canSAS_class'] = 'SASprocess' + +# Valid enumeration values for root['/entry/process/collection']['canSAS_class'] are: +# SASprocessnote +root['/entry/process/collection'].attrs['canSAS_class'] = 'SASprocessnote' + +# Valid enumeration values for root['/entry/collection']['canSAS_class'] are: +# SASnote +root['/entry/collection'].attrs['canSAS_class'] = 'SASnote' + +# Valid enumeration values for root['/entry/TRANSMISSION_SPECTRUM']['canSAS_class'] are: +# SAStransmission_spectrum +root['/entry/TRANSMISSION_SPECTRUM'].attrs['canSAS_class'] = 'SAStransmission_spectrum' + +# Valid enumeration values for root['/entry/TRANSMISSION_SPECTRUM']['signal'] are: +# T +root['/entry/TRANSMISSION_SPECTRUM'].attrs['signal'] = 'T' + +# Valid enumeration values for root['/entry/TRANSMISSION_SPECTRUM']['T_axes'] are: +# T +root['/entry/TRANSMISSION_SPECTRUM'].attrs['T_axes'] = 'T' root['/entry/TRANSMISSION_SPECTRUM'].attrs['name'] = 'SAMPLE-CHAR-DATA' -root['/entry/TRANSMISSION_SPECTRUM'].attrs['timestamp'] = '2021-03-29T15:51:36.609872' +root['/entry/TRANSMISSION_SPECTRUM'].attrs['timestamp'] = 'SAMPLE-CHAR-DATA' root['/entry/TRANSMISSION_SPECTRUM/T'].attrs['uncertainties'] = 'SAMPLE-CHAR-DATA' root.attrs['default'] = 'entry' root['/entry/TRANSMISSION_SPECTRUM'].set_default() diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXcxi_ptycho.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXcxi_ptycho.py new file mode 100644 index 0000000..b333a2c --- /dev/null +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXcxi_ptycho.py @@ -0,0 +1,158 @@ + +import numpy as np +from nexusformat.nexus import * + +# Note this example script was generated by nxdl_to_hdf5.py using the current +# installed version of the NEXUS definitions ver[v2020.10] + +root = NXroot() + +# Create the GROUPS +root['/entry_1'] = NXentry() +root['/entry_1'].attrs['EX_required'] = 'false' +root['/entry_1/instrument_1'] = NXinstrument() +root['/entry_1/instrument_1'].attrs['EX_required'] = 'true' +root['/entry_1/instrument_1/source_1'] = NXsource() +root['/entry_1/instrument_1/source_1'].attrs['EX_required'] = 'true' +root['/entry_1/instrument_1/beam_1'] = NXbeam() +root['/entry_1/instrument_1/beam_1'].attrs['EX_required'] = 'true' +root['/entry_1/instrument_1/detector_1'] = NXdetector() +root['/entry_1/instrument_1/detector_1'].attrs['EX_required'] = 'true' +root['/entry_1/instrument_1/detector_1/transformations'] = NXtransformations() +root['/entry_1/instrument_1/detector_1/transformations'].attrs['EX_required'] = 'false' +root['/entry_1/instrument_1/monitor'] = NXmonitor() +root['/entry_1/instrument_1/monitor'].attrs['EX_required'] = 'false' + +# Create the FIELDS + +root['/entry_1/title'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry_1/title'].attrs['type'] = 'NX_CHAR' +root['/entry_1/title'].attrs['EX_required'] = 'false' + +root['/entry_1/start_time'] = NXfield('2022-03-04T14:56:23.795988') +root['/entry_1/start_time'].attrs['type'] = 'NX_DATE_TIME' +root['/entry_1/start_time'].attrs['EX_required'] = 'false' + +root['/entry_1/end_time'] = NXfield('2022-03-04T14:56:23.795988') +root['/entry_1/end_time'].attrs['type'] = 'NX_DATE_TIME' +root['/entry_1/end_time'].attrs['EX_required'] = 'false' + +# Valid enumeration values for root['/entry_1']['definition'] are: +# NXcxi_ptycho + +root['/entry_1/definition'] = NXfield('NXcxi_ptycho') +root['/entry_1/definition'].attrs['type'] = 'NX_CHAR' +root['/entry_1/definition'].attrs['EX_required'] = 'true' + +root['/entry_1/instrument_1/source_1/name'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry_1/instrument_1/source_1/name'].attrs['type'] = 'NX_CHAR' +root['/entry_1/instrument_1/source_1/name'].attrs['EX_required'] = 'true' + +root['/entry_1/instrument_1/source_1/energy'] = NXfield(1.0) +root['/entry_1/instrument_1/source_1/energy'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/source_1/energy'].attrs['EX_required'] = 'true' + +root['/entry_1/instrument_1/source_1/probe'] = NXfield(1.0) +root['/entry_1/instrument_1/source_1/probe'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/source_1/probe'].attrs['EX_required'] = 'true' + +root['/entry_1/instrument_1/source_1/type'] = NXfield(1.0) +root['/entry_1/instrument_1/source_1/type'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/source_1/type'].attrs['EX_required'] = 'true' + +root['/entry_1/instrument_1/beam_1/energy'] = NXfield(1.0) +root['/entry_1/instrument_1/beam_1/energy'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/beam_1/energy'].attrs['EX_required'] = 'true' + +root['/entry_1/instrument_1/beam_1/extent'] = NXfield(1.0) +root['/entry_1/instrument_1/beam_1/extent'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/beam_1/extent'].attrs['EX_required'] = 'false' + +root['/entry_1/instrument_1/beam_1/incident_beam_divergence'] = NXfield(1.0) +root['/entry_1/instrument_1/beam_1/incident_beam_divergence'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/beam_1/incident_beam_divergence'].attrs['EX_required'] = 'false' + +root['/entry_1/instrument_1/beam_1/incident_beam_energy'] = NXfield(1.0) +root['/entry_1/instrument_1/beam_1/incident_beam_energy'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/beam_1/incident_beam_energy'].attrs['EX_required'] = 'true' + +root['/entry_1/instrument_1/beam_1/incident_energy_spread'] = NXfield(1.0) +root['/entry_1/instrument_1/beam_1/incident_energy_spread'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/beam_1/incident_energy_spread'].attrs['EX_required'] = 'true' + +root['/entry_1/instrument_1/detector_1/transformations/vector'] = NXfield(1.0) +root['/entry_1/instrument_1/detector_1/transformations/vector'].attrs['type'] = 'NX_NUMBER' +root['/entry_1/instrument_1/detector_1/transformations/vector'].attrs['EX_required'] = 'true' + +root['/entry_1/instrument_1/detector_1/translation'] = NXfield(1.0) +root['/entry_1/instrument_1/detector_1/translation'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/detector_1/translation'].attrs['EX_required'] = 'true' +root['/entry_1/instrument_1/detector_1/translation'].attrs['units'] = 'NX_LENGTH' + +root['/entry_1/instrument_1/detector_1/data'] = NXfield(1) +root['/entry_1/instrument_1/detector_1/data'].attrs['type'] = 'NX_INT' +root['/entry_1/instrument_1/detector_1/data'].attrs['EX_required'] = 'true' +root['/entry_1/instrument_1/detector_1/data'].attrs['signal'] = '1' + +root['/entry_1/instrument_1/detector_1/x_pixel_size'] = NXfield(1.0) +root['/entry_1/instrument_1/detector_1/x_pixel_size'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/detector_1/x_pixel_size'].attrs['EX_required'] = 'true' +root['/entry_1/instrument_1/detector_1/x_pixel_size'].attrs['units'] = 'NX_LENGTH' + +root['/entry_1/instrument_1/detector_1/y_pixel_size'] = NXfield(1.0) +root['/entry_1/instrument_1/detector_1/y_pixel_size'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/detector_1/y_pixel_size'].attrs['EX_required'] = 'true' +root['/entry_1/instrument_1/detector_1/y_pixel_size'].attrs['units'] = 'NX_LENGTH' + +root['/entry_1/instrument_1/detector_1/distance'] = NXfield(1.0) +root['/entry_1/instrument_1/detector_1/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/detector_1/distance'].attrs['EX_required'] = 'true' +root['/entry_1/instrument_1/detector_1/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry_1/instrument_1/detector_1/beam_center_x'] = NXfield(1.0) +root['/entry_1/instrument_1/detector_1/beam_center_x'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/detector_1/beam_center_x'].attrs['EX_required'] = 'false' +root['/entry_1/instrument_1/detector_1/beam_center_x'].attrs['units'] = 'NX_LENGTH' + +root['/entry_1/instrument_1/detector_1/beam_center_y'] = NXfield(1.0) +root['/entry_1/instrument_1/detector_1/beam_center_y'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/detector_1/beam_center_y'].attrs['EX_required'] = 'false' +root['/entry_1/instrument_1/detector_1/beam_center_y'].attrs['units'] = 'NX_LENGTH' + +root['/entry_1/instrument_1/monitor/data'] = NXfield(1.0) +root['/entry_1/instrument_1/monitor/data'].attrs['type'] = 'NX_FLOAT' +root['/entry_1/instrument_1/monitor/data'].attrs['EX_required'] = 'false' + +# Create the LINKS +root['/entry_1/instrument_1/detector_1/data_1'] = NXlink(target='/entry_1/title') + +# Create the DOC strings +root['/entry_1/definition'].attrs['EX_doc'] = 'Official NeXus NXDL schema to which this file conforms ' +root['/entry_1/instrument_1/source_1/energy'].attrs['EX_doc'] = 'This is the energy of the machine, not the beamline. ' +root['/entry_1/instrument_1/detector_1/translation'].attrs['EX_doc'] = 'This is an array of shape (npts_x*npts_y, 3) and can be a Virtual Dataset of x and y ' +root['/entry_1/instrument_1/detector_1/data_1'].attrs['EX_doc'] = 'This data must always have shape (npts_x*npts_y, frame_size_x, frame_size_y) regardless of the scan pattern. Use hdf5 virtual dataset to achieve this. ' +root['/entry_1/instrument_1/detector_1/distance'].attrs['EX_doc'] = 'The distance between the detector and the sample ' + + +# Create the ATTRIBUTES +root['/entry_1/instrument_1/beam_1/energy'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/beam_1/extent'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/beam_1/incident_beam_divergence'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/beam_1/incident_beam_energy'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/beam_1/incident_energy_spread'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/detector_1'].attrs['axes'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/detector_1'].attrs['signal'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/detector_1/translation'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/detector_1/translation'].attrs['axes'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/detector_1/translation'].attrs['interpretation'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/detector_1/x_pixel_size'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/detector_1/y_pixel_size'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/detector_1/distance'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/detector_1/beam_center_x'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root['/entry_1/instrument_1/detector_1/beam_center_y'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root.attrs['default'] = 'entry_1' + +# Save the file +root.save('NXcxi_ptycho.nxs', 'w') + + diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXdirecttof.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXdirecttof.py index 8c13b7f..4326ba8 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXdirecttof.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXdirecttof.py @@ -33,7 +33,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry/start_time'] = NXfield('2021-03-29T15:51:37.033456') +root['/entry/start_time'] = NXfield('2022-03-04T14:56:33.860983') root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXfluo.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXfluo.py index 2756eef..971b428 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXfluo.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXfluo.py @@ -31,7 +31,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry/start_time'] = NXfield('2021-03-29T15:51:37.263456') +root['/entry/start_time'] = NXfield('2022-03-04T14:56:33.985974') root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXindirecttof.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXindirecttof.py index e248c3a..d2309ce 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXindirecttof.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXindirecttof.py @@ -31,7 +31,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry/start_time'] = NXfield('2021-03-29T15:51:37.731456') +root['/entry/start_time'] = NXfield('2022-03-04T14:56:34.220274') root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXlauetof.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXlauetof.py index f6cee4c..f4520f6 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXlauetof.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXlauetof.py @@ -118,6 +118,10 @@ # Create the ATTRIBUTES + +# Valid enumeration values for root['/entry/instrument/detector/data']['signal'] are: +# 1 +root['/entry/instrument/detector/data'].attrs['signal'] = '1' root.attrs['default'] = 'entry' root['/entry/name'].set_default() root['/entry/name'].attrs['signal'] = 'data' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXmonopd.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXmonopd.py index 027f901..be35713 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXmonopd.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXmonopd.py @@ -31,7 +31,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry/start_time'] = NXfield('2021-03-29T15:51:38.596455') +root['/entry/start_time'] = NXfield('2022-03-04T14:56:34.657669') root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXmx.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXmx.py index 94a77a0..34b5149 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXmx.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXmx.py @@ -43,15 +43,15 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'false' -root['/entry/start_time'] = NXfield('2021-03-29T15:51:40.027458') +root['/entry/start_time'] = NXfield('2022-03-04T14:56:35.329416') root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' -root['/entry/end_time'] = NXfield('2021-03-29T15:51:40.030457') +root['/entry/end_time'] = NXfield('2022-03-04T14:56:35.329416') root['/entry/end_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/end_time'].attrs['EX_required'] = 'false' -root['/entry/end_time_estimated'] = NXfield('2021-03-29T15:51:40.039474') +root['/entry/end_time_estimated'] = NXfield('2022-03-04T14:56:35.345038') root['/entry/end_time_estimated'].attrs['type'] = 'NX_DATE_TIME' root['/entry/end_time_estimated'].attrs['EX_required'] = 'true' @@ -83,7 +83,7 @@ root['/entry/instrument/name'].attrs['type'] = 'NX_CHAR' root['/entry/instrument/name'].attrs['EX_required'] = 'true' -root['/entry/instrument/time_zone'] = NXfield('2021-03-29T15:51:40.065477') +root['/entry/instrument/time_zone'] = NXfield('2022-03-04T14:56:35.345038') root['/entry/instrument/time_zone'].attrs['type'] = 'NX_DATE_TIME' root['/entry/instrument/time_zone'].attrs['EX_required'] = 'true' @@ -381,13 +381,31 @@ # Create the ATTRIBUTES -root['/entry'].attrs['version'] = 'SAMPLE-CHAR-DATA' + +# Valid enumeration values for root['/entry']['version'] are: +# 1.0 +root['/entry'].attrs['version'] = '1.0' root['/entry/instrument/name'].attrs['short_name'] = 'SAMPLE-CHAR-DATA' -root['/entry/instrument/detector/NXdetector_module/module_offset'].attrs['transformation_type'] = 'SAMPLE-CHAR-DATA' + +# Valid enumeration values for root['/entry/instrument/detector/NXdetector_module/module_offset']['transformation_type'] are: +# translation +root['/entry/instrument/detector/NXdetector_module/module_offset'].attrs['transformation_type'] = 'translation' +root['/entry/instrument/detector/NXdetector_module/module_offset'].attrs['vector'] = 'SAMPLE-CHAR-DATA' +root['/entry/instrument/detector/NXdetector_module/module_offset'].attrs['offset'] = 'SAMPLE-CHAR-DATA' root['/entry/instrument/detector/NXdetector_module/module_offset'].attrs['depends_on'] = 'SAMPLE-CHAR-DATA' -root['/entry/instrument/detector/NXdetector_module/fast_pixel_direction'].attrs['transformation_type'] = 'SAMPLE-CHAR-DATA' + +# Valid enumeration values for root['/entry/instrument/detector/NXdetector_module/fast_pixel_direction']['transformation_type'] are: +# translation +root['/entry/instrument/detector/NXdetector_module/fast_pixel_direction'].attrs['transformation_type'] = 'translation' +root['/entry/instrument/detector/NXdetector_module/fast_pixel_direction'].attrs['vector'] = 'SAMPLE-CHAR-DATA' +root['/entry/instrument/detector/NXdetector_module/fast_pixel_direction'].attrs['offset'] = 'SAMPLE-CHAR-DATA' root['/entry/instrument/detector/NXdetector_module/fast_pixel_direction'].attrs['depends_on'] = 'SAMPLE-CHAR-DATA' -root['/entry/instrument/detector/NXdetector_module/slow_pixel_direction'].attrs['transformation_type'] = 'SAMPLE-CHAR-DATA' + +# Valid enumeration values for root['/entry/instrument/detector/NXdetector_module/slow_pixel_direction']['transformation_type'] are: +# translation +root['/entry/instrument/detector/NXdetector_module/slow_pixel_direction'].attrs['transformation_type'] = 'translation' +root['/entry/instrument/detector/NXdetector_module/slow_pixel_direction'].attrs['vector'] = 'SAMPLE-CHAR-DATA' +root['/entry/instrument/detector/NXdetector_module/slow_pixel_direction'].attrs['offset'] = 'SAMPLE-CHAR-DATA' root['/entry/instrument/detector/NXdetector_module/slow_pixel_direction'].attrs['depends_on'] = 'SAMPLE-CHAR-DATA' root['/entry/source/name'].attrs['short_name'] = 'SAMPLE-CHAR-DATA' root.attrs['default'] = 'entry' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXrefscan.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXrefscan.py index 58f53c9..3110ff6 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXrefscan.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXrefscan.py @@ -31,11 +31,11 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry/start_time'] = NXfield('2021-03-29T15:51:40.531791') +root['/entry/start_time'] = NXfield('2022-03-04T14:56:35.594947') root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' -root['/entry/end_time'] = NXfield('2021-03-29T15:51:40.534797') +root['/entry/end_time'] = NXfield('2022-03-04T14:56:35.594947') root['/entry/end_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/end_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXreftof.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXreftof.py index f9b10b4..ee3cc07 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXreftof.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXreftof.py @@ -29,11 +29,11 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry/start_time'] = NXfield('2021-03-29T15:51:40.907789') +root['/entry/start_time'] = NXfield('2022-03-04T14:56:35.735539') root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' -root['/entry/end_time'] = NXfield('2021-03-29T15:51:40.911793') +root['/entry/end_time'] = NXfield('2022-03-04T14:56:35.735539') root['/entry/end_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/end_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXsas.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXsas.py index 2b52279..4301d9c 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXsas.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXsas.py @@ -37,11 +37,11 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry/start_time'] = NXfield('2021-03-29T15:51:41.340791') +root['/entry/start_time'] = NXfield('2022-03-04T14:56:35.922993') root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' -root['/entry/end_time'] = NXfield('2021-03-29T15:51:41.343788') +root['/entry/end_time'] = NXfield('2022-03-04T14:56:35.938622') root['/entry/end_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/end_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXsastof.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXsastof.py index 45d96ca..2aaa589 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXsastof.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXsastof.py @@ -35,7 +35,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry/start_time'] = NXfield('2021-03-29T15:51:41.758791') +root['/entry/start_time'] = NXfield('2022-03-04T14:56:36.157313') root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXscan.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXscan.py index 88bcf7b..c7fed12 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXscan.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXscan.py @@ -27,11 +27,11 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry/start_time'] = NXfield('2021-03-29T15:51:41.971096') +root['/entry/start_time'] = NXfield('2022-03-04T14:56:36.266661') root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' -root['/entry/end_time'] = NXfield('2021-03-29T15:51:41.974077') +root['/entry/end_time'] = NXfield('2022-03-04T14:56:36.266661') root['/entry/end_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/end_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXsnsevent.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXsnsevent.py new file mode 100644 index 0000000..174598b --- /dev/null +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXsnsevent.py @@ -0,0 +1,545 @@ + +import numpy as np +from nexusformat.nexus import * + +# Note this example script was generated by nxdl_to_hdf5.py using the current +# installed version of the NEXUS definitions ver[v2020.10] + +root = NXroot() + +# Create the GROUPS +root['/entry'] = NXentry() +root['/entry'].attrs['EX_required'] = 'true' +root['/entry/DASlogs'] = NXcollection() +root['/entry/DASlogs'].attrs['EX_required'] = 'false' +root['/entry/DASlogs/log'] = NXlog() +root['/entry/DASlogs/log'].attrs['EX_required'] = 'true' +root['/entry/DASlogs/positioner'] = NXpositioner() +root['/entry/DASlogs/positioner'].attrs['EX_required'] = 'false' +root['/entry/SNSHistoTool'] = NXnote() +root['/entry/SNSHistoTool'].attrs['EX_required'] = 'false' +root['/entry/data'] = NXdata() +root['/entry/data'].attrs['EX_required'] = 'true' +root['/entry/NXevent_data'] = NXevent_data() +root['/entry/NXevent_data'].attrs['EX_required'] = 'true' +root['/entry/instrument'] = NXinstrument() +root['/entry/instrument'].attrs['EX_required'] = 'false' +root['/entry/instrument/SNS'] = NXsource() +root['/entry/instrument/SNS'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector'] = NXdetector() +root['/entry/instrument/detector'].attrs['EX_required'] = 'true' +root['/entry/instrument/detector/origin'] = NXgeometry() +root['/entry/instrument/detector/origin'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/origin/orientation'] = NXorientation() +root['/entry/instrument/detector/origin/orientation'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/origin/shape'] = NXshape() +root['/entry/instrument/detector/origin/shape'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/origin/translation'] = NXtranslation() +root['/entry/instrument/detector/origin/translation'].attrs['EX_required'] = 'false' +root['/entry/instrument/NXdisk_chopper'] = NXdisk_chopper() +root['/entry/instrument/NXdisk_chopper'].attrs['EX_required'] = 'false' +root['/entry/instrument/moderator'] = NXmoderator() +root['/entry/instrument/moderator'].attrs['EX_required'] = 'false' +root['/entry/instrument/aperture'] = NXaperture() +root['/entry/instrument/aperture'].attrs['EX_required'] = 'false' +root['/entry/instrument/aperture/origin'] = NXgeometry() +root['/entry/instrument/aperture/origin'].attrs['EX_required'] = 'false' +root['/entry/instrument/aperture/origin/orientation'] = NXorientation() +root['/entry/instrument/aperture/origin/orientation'].attrs['EX_required'] = 'false' +root['/entry/instrument/aperture/origin/shape'] = NXshape() +root['/entry/instrument/aperture/origin/shape'].attrs['EX_required'] = 'false' +root['/entry/instrument/aperture/origin/translation'] = NXtranslation() +root['/entry/instrument/aperture/origin/translation'].attrs['EX_required'] = 'false' +root['/entry/instrument/attenuator'] = NXattenuator() +root['/entry/instrument/attenuator'].attrs['EX_required'] = 'false' +root['/entry/instrument/polarizer'] = NXpolarizer() +root['/entry/instrument/polarizer'].attrs['EX_required'] = 'false' +root['/entry/instrument/crystal'] = NXcrystal() +root['/entry/instrument/crystal'].attrs['EX_required'] = 'false' +root['/entry/instrument/crystal/origin'] = NXgeometry() +root['/entry/instrument/crystal/origin'].attrs['EX_required'] = 'false' +root['/entry/instrument/crystal/origin/orientation'] = NXorientation() +root['/entry/instrument/crystal/origin/orientation'].attrs['EX_required'] = 'false' +root['/entry/instrument/crystal/origin/shape'] = NXshape() +root['/entry/instrument/crystal/origin/shape'].attrs['EX_required'] = 'false' +root['/entry/instrument/crystal/origin/translation'] = NXtranslation() +root['/entry/instrument/crystal/origin/translation'].attrs['EX_required'] = 'false' +root['/entry/monitor'] = NXmonitor() +root['/entry/monitor'].attrs['EX_required'] = 'false' +root['/entry/sample'] = NXsample() +root['/entry/sample'].attrs['EX_required'] = 'false' +root['/entry/user'] = NXuser() +root['/entry/user'].attrs['EX_required'] = 'true' + +# Create the FIELDS + +root['/entry/DASlogs/log/average_value'] = NXfield(1.0) +root['/entry/DASlogs/log/average_value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/average_value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log/average_value_error'] = NXfield(1.0) +root['/entry/DASlogs/log/average_value_error'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/average_value_error'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log/average_value_errors'] = NXfield(1.0) +root['/entry/DASlogs/log/average_value_errors'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/average_value_errors'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log/description'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/DASlogs/log/description'].attrs['type'] = 'NX_CHAR' +root['/entry/DASlogs/log/description'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log/duration'] = NXfield(1.0) +root['/entry/DASlogs/log/duration'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/duration'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log/maximum_value'] = NXfield(1.0) +root['/entry/DASlogs/log/maximum_value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/maximum_value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log/minimum_value'] = NXfield(1.0) +root['/entry/DASlogs/log/minimum_value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/minimum_value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log/time'] = NXfield(1.0) +root['/entry/DASlogs/log/time'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/time'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log/value'] = NXfield(1.0) +root['/entry/DASlogs/log/value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner/average_value'] = NXfield(1.0) +root['/entry/DASlogs/positioner/average_value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/average_value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner/average_value_error'] = NXfield(1.0) +root['/entry/DASlogs/positioner/average_value_error'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/average_value_error'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner/average_value_errors'] = NXfield(1.0) +root['/entry/DASlogs/positioner/average_value_errors'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/average_value_errors'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner/description'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/DASlogs/positioner/description'].attrs['type'] = 'NX_CHAR' +root['/entry/DASlogs/positioner/description'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner/duration'] = NXfield(1.0) +root['/entry/DASlogs/positioner/duration'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/duration'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner/maximum_value'] = NXfield(1.0) +root['/entry/DASlogs/positioner/maximum_value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/maximum_value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner/minimum_value'] = NXfield(1.0) +root['/entry/DASlogs/positioner/minimum_value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/minimum_value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner/time'] = NXfield(1.0) +root['/entry/DASlogs/positioner/time'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/time'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner/value'] = NXfield(1.0) +root['/entry/DASlogs/positioner/value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/value'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool/SNSbanking_file_name'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/SNSHistoTool/SNSbanking_file_name'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/SNSbanking_file_name'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool/SNSmapping_file_name'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/SNSHistoTool/SNSmapping_file_name'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/SNSmapping_file_name'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool/author'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/SNSHistoTool/author'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/author'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool/command1'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/SNSHistoTool/command1'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/command1'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool/date'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/SNSHistoTool/date'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/date'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool/description'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/SNSHistoTool/description'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/description'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool/version'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/SNSHistoTool/version'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/version'].attrs['EX_required'] = 'false' + +root['/entry/collection_identifier'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/collection_identifier'].attrs['type'] = 'NX_CHAR' +root['/entry/collection_identifier'].attrs['EX_required'] = 'false' + +root['/entry/collection_title'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/collection_title'].attrs['type'] = 'NX_CHAR' +root['/entry/collection_title'].attrs['EX_required'] = 'false' + +# Valid enumeration values for root['/entry']['definition'] are: +# NXsnsevent + +root['/entry/definition'] = NXfield('NXsnsevent') +root['/entry/definition'].attrs['type'] = 'NX_CHAR' +root['/entry/definition'].attrs['EX_required'] = 'false' + +root['/entry/duration'] = NXfield(1.0) +root['/entry/duration'].attrs['type'] = 'NX_FLOAT' +root['/entry/duration'].attrs['EX_required'] = 'false' +root['/entry/duration'].attrs['units'] = 'NX_TIME' + +root['/entry/end_time'] = NXfield('2022-03-04T14:56:24.498980') +root['/entry/end_time'].attrs['type'] = 'NX_DATE_TIME' +root['/entry/end_time'].attrs['EX_required'] = 'false' + +root['/entry/entry_identifier'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/entry_identifier'].attrs['type'] = 'NX_CHAR' +root['/entry/entry_identifier'].attrs['EX_required'] = 'false' + +root['/entry/experiment_identifier'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/experiment_identifier'].attrs['type'] = 'NX_CHAR' +root['/entry/experiment_identifier'].attrs['EX_required'] = 'false' + +root['/entry/instrument/SNS/frequency'] = NXfield(1.0) +root['/entry/instrument/SNS/frequency'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/SNS/frequency'].attrs['EX_required'] = 'false' +root['/entry/instrument/SNS/frequency'].attrs['units'] = 'NX_FREQUENCY' + +root['/entry/instrument/SNS/name'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/SNS/name'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/SNS/name'].attrs['EX_required'] = 'false' + +root['/entry/instrument/SNS/probe'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/SNS/probe'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/SNS/probe'].attrs['EX_required'] = 'false' + +root['/entry/instrument/SNS/type'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/SNS/type'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/SNS/type'].attrs['EX_required'] = 'false' + +root['/entry/instrument/SNSdetector_calibration_id'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/SNSdetector_calibration_id'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/SNSdetector_calibration_id'].attrs['EX_required'] = 'false' + +root['/entry/instrument/SNSgeometry_file_name'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/SNSgeometry_file_name'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/SNSgeometry_file_name'].attrs['EX_required'] = 'false' + +root['/entry/instrument/SNStranslation_service'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/SNStranslation_service'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/SNStranslation_service'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector/azimuthal_angle'] = NXfield(1.0) +root['/entry/instrument/detector/azimuthal_angle'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/azimuthal_angle'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/azimuthal_angle'].attrs['units'] = 'NX_ANGLE' + +root['/entry/instrument/detector/data_x_y'] = NXfield(1) +root['/entry/instrument/detector/data_x_y'].attrs['type'] = 'NX_UINT' +root['/entry/instrument/detector/data_x_y'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector/distance'] = NXfield(1.0) +root['/entry/instrument/detector/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/detector/event_index'] = NXfield(1) +root['/entry/instrument/detector/event_index'].attrs['type'] = 'NX_UINT' +root['/entry/instrument/detector/event_index'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector/event_pixel_id'] = NXfield(1) +root['/entry/instrument/detector/event_pixel_id'].attrs['type'] = 'NX_UINT' +root['/entry/instrument/detector/event_pixel_id'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector/event_time_of_flight'] = NXfield(1.0) +root['/entry/instrument/detector/event_time_of_flight'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/event_time_of_flight'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/event_time_of_flight'].attrs['units'] = 'NX_TIME_OF_FLIGHT' + +root['/entry/instrument/detector/origin/orientation/value'] = NXfield(1.0) +root['/entry/instrument/detector/origin/orientation/value'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/origin/orientation/value'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector/origin/shape/description'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/detector/origin/shape/description'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/detector/origin/shape/description'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector/origin/shape/shape'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/detector/origin/shape/shape'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/detector/origin/shape/shape'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector/origin/shape/size'] = NXfield(1.0) +root['/entry/instrument/detector/origin/shape/size'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/origin/shape/size'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/origin/shape/size'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/detector/origin/translation/distance'] = NXfield(1.0) +root['/entry/instrument/detector/origin/translation/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/origin/translation/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/origin/translation/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/detector/pixel_id'] = NXfield(1) +root['/entry/instrument/detector/pixel_id'].attrs['type'] = 'NX_UINT' +root['/entry/instrument/detector/pixel_id'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector/polar_angle'] = NXfield(1.0) +root['/entry/instrument/detector/polar_angle'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/polar_angle'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/polar_angle'].attrs['units'] = 'NX_ANGLE' + +root['/entry/instrument/detector/pulse_time'] = NXfield(1.0) +root['/entry/instrument/detector/pulse_time'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/pulse_time'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/pulse_time'].attrs['units'] = 'NX_TIME' + +root['/entry/instrument/detector/total_counts'] = NXfield(1) +root['/entry/instrument/detector/total_counts'].attrs['type'] = 'NX_UINT' +root['/entry/instrument/detector/total_counts'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector/x_pixel_offset'] = NXfield(1.0) +root['/entry/instrument/detector/x_pixel_offset'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/x_pixel_offset'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/x_pixel_offset'].attrs['axis'] = '1' +root['/entry/instrument/detector/x_pixel_offset'].attrs['primary'] = '1' +root['/entry/instrument/detector/x_pixel_offset'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/detector/y_pixel_offset'] = NXfield(1.0) +root['/entry/instrument/detector/y_pixel_offset'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/y_pixel_offset'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/y_pixel_offset'].attrs['axis'] = '2' +root['/entry/instrument/detector/y_pixel_offset'].attrs['primary'] = '1' +root['/entry/instrument/detector/y_pixel_offset'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/beamline'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/beamline'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/beamline'].attrs['EX_required'] = 'false' + +root['/entry/instrument/NXdisk_chopper/distance'] = NXfield(1.0) +root['/entry/instrument/NXdisk_chopper/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/NXdisk_chopper/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/NXdisk_chopper/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/moderator/coupling_material'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/moderator/coupling_material'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/moderator/coupling_material'].attrs['EX_required'] = 'false' + +root['/entry/instrument/moderator/distance'] = NXfield(1.0) +root['/entry/instrument/moderator/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/moderator/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/moderator/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/moderator/temperature'] = NXfield(1.0) +root['/entry/instrument/moderator/temperature'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/moderator/temperature'].attrs['EX_required'] = 'false' +root['/entry/instrument/moderator/temperature'].attrs['units'] = 'NX_TEMPERATURE' + +root['/entry/instrument/moderator/type'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/moderator/type'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/moderator/type'].attrs['EX_required'] = 'false' + +root['/entry/instrument/name'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/name'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/name'].attrs['EX_required'] = 'false' + +root['/entry/instrument/aperture/origin/orientation/value'] = NXfield(1.0) +root['/entry/instrument/aperture/origin/orientation/value'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/aperture/origin/orientation/value'].attrs['EX_required'] = 'false' + +root['/entry/instrument/aperture/origin/shape/description'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/aperture/origin/shape/description'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/aperture/origin/shape/description'].attrs['EX_required'] = 'false' + +root['/entry/instrument/aperture/origin/shape/shape'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/aperture/origin/shape/shape'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/aperture/origin/shape/shape'].attrs['EX_required'] = 'false' + +root['/entry/instrument/aperture/origin/shape/size'] = NXfield(1.0) +root['/entry/instrument/aperture/origin/shape/size'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/aperture/origin/shape/size'].attrs['EX_required'] = 'false' +root['/entry/instrument/aperture/origin/shape/size'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/aperture/origin/translation/distance'] = NXfield(1.0) +root['/entry/instrument/aperture/origin/translation/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/aperture/origin/translation/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/aperture/origin/translation/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/aperture/x_pixel_offset'] = NXfield(1.0) +root['/entry/instrument/aperture/x_pixel_offset'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/aperture/x_pixel_offset'].attrs['EX_required'] = 'false' +root['/entry/instrument/aperture/x_pixel_offset'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/attenuator/distance'] = NXfield(1.0) +root['/entry/instrument/attenuator/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/attenuator/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/attenuator/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/crystal/origin/description'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/crystal/origin/description'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/crystal/origin/description'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal/origin/orientation/value'] = NXfield(1.0) +root['/entry/instrument/crystal/origin/orientation/value'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/crystal/origin/orientation/value'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal/origin/shape/description'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/crystal/origin/shape/description'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/crystal/origin/shape/description'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal/origin/shape/shape'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/crystal/origin/shape/shape'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/crystal/origin/shape/shape'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal/origin/shape/size'] = NXfield(1.0) +root['/entry/instrument/crystal/origin/shape/size'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/crystal/origin/shape/size'].attrs['EX_required'] = 'false' +root['/entry/instrument/crystal/origin/shape/size'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/crystal/origin/translation/distance'] = NXfield(1.0) +root['/entry/instrument/crystal/origin/translation/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/crystal/origin/translation/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/crystal/origin/translation/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/crystal/type'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/crystal/type'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/crystal/type'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal/wavelength'] = NXfield(1.0) +root['/entry/instrument/crystal/wavelength'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/crystal/wavelength'].attrs['EX_required'] = 'false' +root['/entry/instrument/crystal/wavelength'].attrs['units'] = 'NX_WAVELENGTH' + +root['/entry/monitor/data'] = NXfield(1) +root['/entry/monitor/data'].attrs['type'] = 'NX_UINT' +root['/entry/monitor/data'].attrs['EX_required'] = 'false' + +root['/entry/monitor/distance'] = NXfield(1.0) +root['/entry/monitor/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/monitor/distance'].attrs['EX_required'] = 'false' +root['/entry/monitor/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/monitor/mode'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/monitor/mode'].attrs['type'] = 'NX_CHAR' +root['/entry/monitor/mode'].attrs['EX_required'] = 'false' + +root['/entry/monitor/time_of_flight'] = NXfield(1.0) +root['/entry/monitor/time_of_flight'].attrs['type'] = 'NX_FLOAT' +root['/entry/monitor/time_of_flight'].attrs['EX_required'] = 'false' +root['/entry/monitor/time_of_flight'].attrs['units'] = 'NX_TIME' + +root['/entry/notes'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/notes'].attrs['type'] = 'NX_CHAR' +root['/entry/notes'].attrs['EX_required'] = 'false' + +root['/entry/proton_charge'] = NXfield(1.0) +root['/entry/proton_charge'].attrs['type'] = 'NX_FLOAT' +root['/entry/proton_charge'].attrs['EX_required'] = 'false' +root['/entry/proton_charge'].attrs['units'] = 'NX_CHARGE' + +root['/entry/raw_frames'] = NXfield(1) +root['/entry/raw_frames'].attrs['type'] = 'NX_INT' +root['/entry/raw_frames'].attrs['EX_required'] = 'false' + +root['/entry/run_number'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/run_number'].attrs['type'] = 'NX_CHAR' +root['/entry/run_number'].attrs['EX_required'] = 'false' + +root['/entry/sample/changer_position'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/sample/changer_position'].attrs['type'] = 'NX_CHAR' +root['/entry/sample/changer_position'].attrs['EX_required'] = 'false' + +root['/entry/sample/holder'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/sample/holder'].attrs['type'] = 'NX_CHAR' +root['/entry/sample/holder'].attrs['EX_required'] = 'false' + +root['/entry/sample/identifier'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/sample/identifier'].attrs['type'] = 'NX_CHAR' +root['/entry/sample/identifier'].attrs['EX_required'] = 'false' + +root['/entry/sample/name'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/sample/name'].attrs['type'] = 'NX_CHAR' +root['/entry/sample/name'].attrs['EX_required'] = 'false' + +root['/entry/sample/nature'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/sample/nature'].attrs['type'] = 'NX_CHAR' +root['/entry/sample/nature'].attrs['EX_required'] = 'false' + +root['/entry/start_time'] = NXfield('2022-03-04T14:56:24.592709') +root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' +root['/entry/start_time'].attrs['EX_required'] = 'false' + +root['/entry/title'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/title'].attrs['type'] = 'NX_CHAR' +root['/entry/title'].attrs['EX_required'] = 'false' + +root['/entry/total_counts'] = NXfield(1) +root['/entry/total_counts'].attrs['type'] = 'NX_UINT' +root['/entry/total_counts'].attrs['EX_required'] = 'false' +root['/entry/total_counts'].attrs['units'] = 'NX_UNITLESS' + +root['/entry/total_uncounted_counts'] = NXfield(1) +root['/entry/total_uncounted_counts'].attrs['type'] = 'NX_UINT' +root['/entry/total_uncounted_counts'].attrs['EX_required'] = 'false' +root['/entry/total_uncounted_counts'].attrs['units'] = 'NX_UNITLESS' + +root['/entry/user/facility_user_id'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/user/facility_user_id'].attrs['type'] = 'NX_CHAR' +root['/entry/user/facility_user_id'].attrs['EX_required'] = 'false' + +root['/entry/user/name'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/user/name'].attrs['type'] = 'NX_CHAR' +root['/entry/user/name'].attrs['EX_required'] = 'false' + +root['/entry/user/role'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/user/role'].attrs['type'] = 'NX_CHAR' +root['/entry/user/role'].attrs['EX_required'] = 'false' + +# Create the LINKS +root['/entry/data/data_x_y'] = NXlink(target='/entry/instrument/detector/data_x_y') + +# Create the LINKS +root['/entry/data/x_pixel_offset'] = NXlink(target='/entry/instrument/detector/x_pixel_offset') + +# Create the LINKS +root['/entry/data/y_pixel_offset'] = NXlink(target='/entry/instrument/detector/y_pixel_offset') + +# Create the LINKS +root['/entry/NXevent_data/event_index'] = NXlink(target='/entry/instrument/detector/event_index') + +# Create the LINKS +root['/entry/NXevent_data/event_pixel_id'] = NXlink(target='/entry/instrument/detector/event_pixel_id') + +# Create the LINKS +root['/entry/NXevent_data/event_time_of_flight'] = NXlink(target='/entry/instrument/detector/event_time_of_flight') + +# Create the LINKS +root['/entry/NXevent_data/pulse_time'] = NXlink(target='/entry/instrument/detector/pulse_time') + +# Create the DOC strings +root['/entry/DASlogs'].attrs['EX_doc'] = 'Details of all logs, both from cvinfo file and from HistoTool (frequency and proton_charge). ' +root['/entry/DASlogs/positioner'].attrs['EX_doc'] = 'Motor logs from cvinfo file. ' +root['/entry/SNSHistoTool/command1'].attrs['EX_doc'] = 'Command string for event2nxl. ' +root['/entry/definition'].attrs['EX_doc'] = 'Official NXDL schema after this file goes to applications. ' +root['/entry/instrument/SNSdetector_calibration_id'].attrs['EX_doc'] = 'Detector calibration id from DAS. ' +root['/entry/instrument/detector/data_x_y'].attrs['EX_doc'] = 'expect ``signal=2 axes="x_pixel_offset,y_pixel_offset``" ' +root['/entry/instrument/detector/origin/orientation/value'].attrs['EX_doc'] = 'Six out of nine rotation parameters. ' +root['/entry/instrument/aperture/origin/orientation/value'].attrs['EX_doc'] = 'Six out of nine rotation parameters. ' +root['/entry/instrument/crystal/origin/orientation/value'].attrs['EX_doc'] = 'Six out of nine rotation parameters. ' +root['/entry/monitor/data'].attrs['EX_doc'] = 'expect ``signal=1 axes="time_of_flight"`` ' +root['/entry/sample/name'].attrs['EX_doc'] = 'Descriptive name of sample ' + + +# Create the ATTRIBUTES +root.attrs['default'] = 'entry' +root['/entry/data'].set_default() +root['/entry/data'].attrs['signal'] = 'data_x_y' +root['/entry/data/data_x_y'].attrs['signal'] = '1' + +# Save the file +root.save('NXsnsevent.nxs', 'w') + + diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXsnshisto.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXsnshisto.py new file mode 100644 index 0000000..b46c705 --- /dev/null +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXsnshisto.py @@ -0,0 +1,567 @@ + +import numpy as np +from nexusformat.nexus import * + +# Note this example script was generated by nxdl_to_hdf5.py using the current +# installed version of the NEXUS definitions ver[v2020.10] + +root = NXroot() + +# Create the GROUPS +root['/entry'] = NXentry() +root['/entry'].attrs['EX_required'] = 'true' +root['/entry/DASlogs'] = NXcollection() +root['/entry/DASlogs'].attrs['EX_required'] = 'false' +root['/entry/DASlogs/log'] = NXlog() +root['/entry/DASlogs/log'].attrs['EX_required'] = 'true' +root['/entry/DASlogs/positioner'] = NXpositioner() +root['/entry/DASlogs/positioner'].attrs['EX_required'] = 'false' +root['/entry/SNSHistoTool'] = NXnote() +root['/entry/SNSHistoTool'].attrs['EX_required'] = 'false' +root['/entry/data'] = NXdata() +root['/entry/data'].attrs['EX_required'] = 'true' +root['/entry/instrument'] = NXinstrument() +root['/entry/instrument'].attrs['EX_required'] = 'false' +root['/entry/instrument/SNS'] = NXsource() +root['/entry/instrument/SNS'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector'] = NXdetector() +root['/entry/instrument/detector'].attrs['EX_required'] = 'true' +root['/entry/instrument/detector/origin'] = NXgeometry() +root['/entry/instrument/detector/origin'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/origin/orientation'] = NXorientation() +root['/entry/instrument/detector/origin/orientation'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/origin/shape'] = NXshape() +root['/entry/instrument/detector/origin/shape'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/origin/translation'] = NXtranslation() +root['/entry/instrument/detector/origin/translation'].attrs['EX_required'] = 'false' +root['/entry/instrument/NXdisk_chopper'] = NXdisk_chopper() +root['/entry/instrument/NXdisk_chopper'].attrs['EX_required'] = 'false' +root['/entry/instrument/NXfermi_chopper'] = NXfermi_chopper() +root['/entry/instrument/NXfermi_chopper'].attrs['EX_required'] = 'false' +root['/entry/instrument/moderator'] = NXmoderator() +root['/entry/instrument/moderator'].attrs['EX_required'] = 'false' +root['/entry/instrument/aperture'] = NXaperture() +root['/entry/instrument/aperture'].attrs['EX_required'] = 'false' +root['/entry/instrument/aperture/origin'] = NXgeometry() +root['/entry/instrument/aperture/origin'].attrs['EX_required'] = 'false' +root['/entry/instrument/aperture/origin/orientation'] = NXorientation() +root['/entry/instrument/aperture/origin/orientation'].attrs['EX_required'] = 'false' +root['/entry/instrument/aperture/origin/shape'] = NXshape() +root['/entry/instrument/aperture/origin/shape'].attrs['EX_required'] = 'false' +root['/entry/instrument/aperture/origin/translation'] = NXtranslation() +root['/entry/instrument/aperture/origin/translation'].attrs['EX_required'] = 'false' +root['/entry/instrument/attenuator'] = NXattenuator() +root['/entry/instrument/attenuator'].attrs['EX_required'] = 'false' +root['/entry/instrument/polarizer'] = NXpolarizer() +root['/entry/instrument/polarizer'].attrs['EX_required'] = 'false' +root['/entry/instrument/crystal'] = NXcrystal() +root['/entry/instrument/crystal'].attrs['EX_required'] = 'false' +root['/entry/instrument/crystal/origin'] = NXgeometry() +root['/entry/instrument/crystal/origin'].attrs['EX_required'] = 'false' +root['/entry/instrument/crystal/origin/orientation'] = NXorientation() +root['/entry/instrument/crystal/origin/orientation'].attrs['EX_required'] = 'false' +root['/entry/instrument/crystal/origin/shape'] = NXshape() +root['/entry/instrument/crystal/origin/shape'].attrs['EX_required'] = 'false' +root['/entry/instrument/crystal/origin/translation'] = NXtranslation() +root['/entry/instrument/crystal/origin/translation'].attrs['EX_required'] = 'false' +root['/entry/monitor'] = NXmonitor() +root['/entry/monitor'].attrs['EX_required'] = 'false' +root['/entry/sample'] = NXsample() +root['/entry/sample'].attrs['EX_required'] = 'false' +root['/entry/user'] = NXuser() +root['/entry/user'].attrs['EX_required'] = 'true' + +# Create the FIELDS + +root['/entry/DASlogs/log/average_value'] = NXfield(1.0) +root['/entry/DASlogs/log/average_value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/average_value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log/average_value_error'] = NXfield(1.0) +root['/entry/DASlogs/log/average_value_error'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/average_value_error'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log/average_value_errors'] = NXfield(1.0) +root['/entry/DASlogs/log/average_value_errors'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/average_value_errors'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log/description'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/DASlogs/log/description'].attrs['type'] = 'NX_CHAR' +root['/entry/DASlogs/log/description'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log/duration'] = NXfield(1.0) +root['/entry/DASlogs/log/duration'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/duration'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log/maximum_value'] = NXfield(1.0) +root['/entry/DASlogs/log/maximum_value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/maximum_value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log/minimum_value'] = NXfield(1.0) +root['/entry/DASlogs/log/minimum_value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/minimum_value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log/time'] = NXfield(1.0) +root['/entry/DASlogs/log/time'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/time'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/log/value'] = NXfield(1.0) +root['/entry/DASlogs/log/value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/log/value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner/average_value'] = NXfield(1.0) +root['/entry/DASlogs/positioner/average_value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/average_value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner/average_value_error'] = NXfield(1.0) +root['/entry/DASlogs/positioner/average_value_error'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/average_value_error'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner/average_value_errors'] = NXfield(1.0) +root['/entry/DASlogs/positioner/average_value_errors'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/average_value_errors'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner/description'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/DASlogs/positioner/description'].attrs['type'] = 'NX_CHAR' +root['/entry/DASlogs/positioner/description'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner/duration'] = NXfield(1.0) +root['/entry/DASlogs/positioner/duration'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/duration'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner/maximum_value'] = NXfield(1.0) +root['/entry/DASlogs/positioner/maximum_value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/maximum_value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner/minimum_value'] = NXfield(1.0) +root['/entry/DASlogs/positioner/minimum_value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/minimum_value'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner/time'] = NXfield(1.0) +root['/entry/DASlogs/positioner/time'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/time'].attrs['EX_required'] = 'false' + +root['/entry/DASlogs/positioner/value'] = NXfield(1.0) +root['/entry/DASlogs/positioner/value'].attrs['type'] = 'NX_FLOAT' +root['/entry/DASlogs/positioner/value'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool/SNSbanking_file_name'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/SNSHistoTool/SNSbanking_file_name'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/SNSbanking_file_name'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool/SNSmapping_file_name'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/SNSHistoTool/SNSmapping_file_name'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/SNSmapping_file_name'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool/author'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/SNSHistoTool/author'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/author'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool/command1'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/SNSHistoTool/command1'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/command1'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool/date'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/SNSHistoTool/date'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/date'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool/description'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/SNSHistoTool/description'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/description'].attrs['EX_required'] = 'false' + +root['/entry/SNSHistoTool/version'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/SNSHistoTool/version'].attrs['type'] = 'NX_CHAR' +root['/entry/SNSHistoTool/version'].attrs['EX_required'] = 'false' + +root['/entry/collection_identifier'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/collection_identifier'].attrs['type'] = 'NX_CHAR' +root['/entry/collection_identifier'].attrs['EX_required'] = 'false' + +root['/entry/collection_title'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/collection_title'].attrs['type'] = 'NX_CHAR' +root['/entry/collection_title'].attrs['EX_required'] = 'false' + +# Valid enumeration values for root['/entry']['definition'] are: +# NXsnshisto + +root['/entry/definition'] = NXfield('NXsnshisto') +root['/entry/definition'].attrs['type'] = 'NX_CHAR' +root['/entry/definition'].attrs['EX_required'] = 'false' + +root['/entry/duration'] = NXfield(1.0) +root['/entry/duration'].attrs['type'] = 'NX_FLOAT' +root['/entry/duration'].attrs['EX_required'] = 'false' +root['/entry/duration'].attrs['units'] = 'NX_TIME' + +root['/entry/end_time'] = NXfield('2022-03-04T14:56:25.264424') +root['/entry/end_time'].attrs['type'] = 'NX_DATE_TIME' +root['/entry/end_time'].attrs['EX_required'] = 'false' + +root['/entry/entry_identifier'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/entry_identifier'].attrs['type'] = 'NX_CHAR' +root['/entry/entry_identifier'].attrs['EX_required'] = 'false' + +root['/entry/experiment_identifier'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/experiment_identifier'].attrs['type'] = 'NX_CHAR' +root['/entry/experiment_identifier'].attrs['EX_required'] = 'false' + +root['/entry/instrument/SNS/frequency'] = NXfield(1.0) +root['/entry/instrument/SNS/frequency'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/SNS/frequency'].attrs['EX_required'] = 'false' +root['/entry/instrument/SNS/frequency'].attrs['units'] = 'NX_FREQUENCY' + +root['/entry/instrument/SNS/name'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/SNS/name'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/SNS/name'].attrs['EX_required'] = 'false' + +root['/entry/instrument/SNS/probe'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/SNS/probe'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/SNS/probe'].attrs['EX_required'] = 'false' + +root['/entry/instrument/SNS/type'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/SNS/type'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/SNS/type'].attrs['EX_required'] = 'false' + +root['/entry/instrument/SNSdetector_calibration_id'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/SNSdetector_calibration_id'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/SNSdetector_calibration_id'].attrs['EX_required'] = 'false' + +root['/entry/instrument/SNSgeometry_file_name'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/SNSgeometry_file_name'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/SNSgeometry_file_name'].attrs['EX_required'] = 'false' + +root['/entry/instrument/SNStranslation_service'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/SNStranslation_service'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/SNStranslation_service'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector/azimuthal_angle'] = NXfield(1.0) +root['/entry/instrument/detector/azimuthal_angle'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/azimuthal_angle'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/azimuthal_angle'].attrs['units'] = 'NX_ANGLE' + +root['/entry/instrument/detector/data'] = NXfield(1) +root['/entry/instrument/detector/data'].attrs['type'] = 'NX_UINT' +root['/entry/instrument/detector/data'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/data'].attrs['axes'] = 'x_pixel_offset,y_pixel_offset,time_of_flight' +root['/entry/instrument/detector/data'].attrs['signal'] = '1' + +root['/entry/instrument/detector/data_x_time_of_flight'] = NXfield(1) +root['/entry/instrument/detector/data_x_time_of_flight'].attrs['type'] = 'NX_UINT' +root['/entry/instrument/detector/data_x_time_of_flight'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/data_x_time_of_flight'].attrs['axes'] = 'x_pixel_offset,time_of_flight' +root['/entry/instrument/detector/data_x_time_of_flight'].attrs['signal'] = '3' + +root['/entry/instrument/detector/data_x_y'] = NXfield(1) +root['/entry/instrument/detector/data_x_y'].attrs['type'] = 'NX_UINT' +root['/entry/instrument/detector/data_x_y'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/data_x_y'].attrs['axes'] = 'x_pixel_offset,y_pixel_offset' +root['/entry/instrument/detector/data_x_y'].attrs['signal'] = '2' + +root['/entry/instrument/detector/data_y_time_of_flight'] = NXfield(1) +root['/entry/instrument/detector/data_y_time_of_flight'].attrs['type'] = 'NX_UINT' +root['/entry/instrument/detector/data_y_time_of_flight'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/data_y_time_of_flight'].attrs['axes'] = 'y_pixel_offset,time_of_flight' +root['/entry/instrument/detector/data_y_time_of_flight'].attrs['signal'] = '4' + +root['/entry/instrument/detector/distance'] = NXfield(1.0) +root['/entry/instrument/detector/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/detector/origin/orientation/value'] = NXfield(1.0) +root['/entry/instrument/detector/origin/orientation/value'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/origin/orientation/value'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector/origin/shape/description'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/detector/origin/shape/description'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/detector/origin/shape/description'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector/origin/shape/shape'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/detector/origin/shape/shape'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/detector/origin/shape/shape'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector/origin/shape/size'] = NXfield(1.0) +root['/entry/instrument/detector/origin/shape/size'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/origin/shape/size'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/origin/shape/size'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/detector/origin/translation/distance'] = NXfield(1.0) +root['/entry/instrument/detector/origin/translation/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/origin/translation/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/origin/translation/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/detector/pixel_id'] = NXfield(1) +root['/entry/instrument/detector/pixel_id'].attrs['type'] = 'NX_UINT' +root['/entry/instrument/detector/pixel_id'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector/polar_angle'] = NXfield(1.0) +root['/entry/instrument/detector/polar_angle'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/polar_angle'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/polar_angle'].attrs['units'] = 'NX_ANGLE' + +root['/entry/instrument/detector/time_of_flight'] = NXfield(1.0) +root['/entry/instrument/detector/time_of_flight'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/time_of_flight'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/time_of_flight'].attrs['axis'] = '3' +root['/entry/instrument/detector/time_of_flight'].attrs['primary'] = '1' +root['/entry/instrument/detector/time_of_flight'].attrs['units'] = 'NX_TIME_OF_FLIGHT' + +root['/entry/instrument/detector/total_counts'] = NXfield(1) +root['/entry/instrument/detector/total_counts'].attrs['type'] = 'NX_UINT' +root['/entry/instrument/detector/total_counts'].attrs['EX_required'] = 'false' + +root['/entry/instrument/detector/x_pixel_offset'] = NXfield(1.0) +root['/entry/instrument/detector/x_pixel_offset'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/x_pixel_offset'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/x_pixel_offset'].attrs['axis'] = '1' +root['/entry/instrument/detector/x_pixel_offset'].attrs['primary'] = '1' +root['/entry/instrument/detector/x_pixel_offset'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/detector/y_pixel_offset'] = NXfield(1.0) +root['/entry/instrument/detector/y_pixel_offset'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/detector/y_pixel_offset'].attrs['EX_required'] = 'false' +root['/entry/instrument/detector/y_pixel_offset'].attrs['axis'] = '2' +root['/entry/instrument/detector/y_pixel_offset'].attrs['primary'] = '1' +root['/entry/instrument/detector/y_pixel_offset'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/beamline'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/beamline'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/beamline'].attrs['EX_required'] = 'false' + +root['/entry/instrument/NXdisk_chopper/distance'] = NXfield(1.0) +root['/entry/instrument/NXdisk_chopper/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/NXdisk_chopper/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/NXdisk_chopper/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/NXfermi_chopper/distance'] = NXfield(1.0) +root['/entry/instrument/NXfermi_chopper/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/NXfermi_chopper/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/NXfermi_chopper/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/moderator/coupling_material'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/moderator/coupling_material'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/moderator/coupling_material'].attrs['EX_required'] = 'false' + +root['/entry/instrument/moderator/distance'] = NXfield(1.0) +root['/entry/instrument/moderator/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/moderator/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/moderator/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/moderator/temperature'] = NXfield(1.0) +root['/entry/instrument/moderator/temperature'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/moderator/temperature'].attrs['EX_required'] = 'false' +root['/entry/instrument/moderator/temperature'].attrs['units'] = 'NX_TEMPERATURE' + +root['/entry/instrument/moderator/type'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/moderator/type'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/moderator/type'].attrs['EX_required'] = 'false' + +root['/entry/instrument/name'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/name'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/name'].attrs['EX_required'] = 'false' + +root['/entry/instrument/aperture/origin/orientation/value'] = NXfield(1.0) +root['/entry/instrument/aperture/origin/orientation/value'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/aperture/origin/orientation/value'].attrs['EX_required'] = 'false' + +root['/entry/instrument/aperture/origin/shape/description'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/aperture/origin/shape/description'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/aperture/origin/shape/description'].attrs['EX_required'] = 'false' + +root['/entry/instrument/aperture/origin/shape/shape'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/aperture/origin/shape/shape'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/aperture/origin/shape/shape'].attrs['EX_required'] = 'false' + +root['/entry/instrument/aperture/origin/shape/size'] = NXfield(1.0) +root['/entry/instrument/aperture/origin/shape/size'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/aperture/origin/shape/size'].attrs['EX_required'] = 'false' +root['/entry/instrument/aperture/origin/shape/size'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/aperture/origin/translation/distance'] = NXfield(1.0) +root['/entry/instrument/aperture/origin/translation/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/aperture/origin/translation/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/aperture/origin/translation/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/aperture/x_pixel_offset'] = NXfield(1.0) +root['/entry/instrument/aperture/x_pixel_offset'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/aperture/x_pixel_offset'].attrs['EX_required'] = 'false' +root['/entry/instrument/aperture/x_pixel_offset'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/attenuator/distance'] = NXfield(1.0) +root['/entry/instrument/attenuator/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/attenuator/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/attenuator/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/crystal/origin/description'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/crystal/origin/description'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/crystal/origin/description'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal/origin/orientation/value'] = NXfield(1.0) +root['/entry/instrument/crystal/origin/orientation/value'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/crystal/origin/orientation/value'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal/origin/shape/description'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/crystal/origin/shape/description'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/crystal/origin/shape/description'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal/origin/shape/shape'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/crystal/origin/shape/shape'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/crystal/origin/shape/shape'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal/origin/shape/size'] = NXfield(1.0) +root['/entry/instrument/crystal/origin/shape/size'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/crystal/origin/shape/size'].attrs['EX_required'] = 'false' +root['/entry/instrument/crystal/origin/shape/size'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/crystal/origin/translation/distance'] = NXfield(1.0) +root['/entry/instrument/crystal/origin/translation/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/crystal/origin/translation/distance'].attrs['EX_required'] = 'false' +root['/entry/instrument/crystal/origin/translation/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/instrument/crystal/type'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/instrument/crystal/type'].attrs['type'] = 'NX_CHAR' +root['/entry/instrument/crystal/type'].attrs['EX_required'] = 'false' + +root['/entry/instrument/crystal/wavelength'] = NXfield(1.0) +root['/entry/instrument/crystal/wavelength'].attrs['type'] = 'NX_FLOAT' +root['/entry/instrument/crystal/wavelength'].attrs['EX_required'] = 'false' +root['/entry/instrument/crystal/wavelength'].attrs['units'] = 'NX_WAVELENGTH' + +root['/entry/monitor/data'] = NXfield(1) +root['/entry/monitor/data'].attrs['type'] = 'NX_UINT' +root['/entry/monitor/data'].attrs['EX_required'] = 'false' +root['/entry/monitor/data'].attrs['axes'] = 'time_of_flight' +root['/entry/monitor/data'].attrs['signal'] = '1' + +root['/entry/monitor/distance'] = NXfield(1.0) +root['/entry/monitor/distance'].attrs['type'] = 'NX_FLOAT' +root['/entry/monitor/distance'].attrs['EX_required'] = 'false' +root['/entry/monitor/distance'].attrs['units'] = 'NX_LENGTH' + +root['/entry/monitor/mode'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/monitor/mode'].attrs['type'] = 'NX_CHAR' +root['/entry/monitor/mode'].attrs['EX_required'] = 'false' + +root['/entry/monitor/time_of_flight'] = NXfield(1.0) +root['/entry/monitor/time_of_flight'].attrs['type'] = 'NX_FLOAT' +root['/entry/monitor/time_of_flight'].attrs['EX_required'] = 'false' +root['/entry/monitor/time_of_flight'].attrs['units'] = 'NX_TIME' + +root['/entry/notes'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/notes'].attrs['type'] = 'NX_CHAR' +root['/entry/notes'].attrs['EX_required'] = 'false' + +root['/entry/proton_charge'] = NXfield(1.0) +root['/entry/proton_charge'].attrs['type'] = 'NX_FLOAT' +root['/entry/proton_charge'].attrs['EX_required'] = 'false' +root['/entry/proton_charge'].attrs['units'] = 'NX_CHARGE' + +root['/entry/raw_frames'] = NXfield(1) +root['/entry/raw_frames'].attrs['type'] = 'NX_INT' +root['/entry/raw_frames'].attrs['EX_required'] = 'false' + +root['/entry/run_number'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/run_number'].attrs['type'] = 'NX_CHAR' +root['/entry/run_number'].attrs['EX_required'] = 'false' + +root['/entry/sample/changer_position'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/sample/changer_position'].attrs['type'] = 'NX_CHAR' +root['/entry/sample/changer_position'].attrs['EX_required'] = 'false' + +root['/entry/sample/holder'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/sample/holder'].attrs['type'] = 'NX_CHAR' +root['/entry/sample/holder'].attrs['EX_required'] = 'false' + +root['/entry/sample/identifier'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/sample/identifier'].attrs['type'] = 'NX_CHAR' +root['/entry/sample/identifier'].attrs['EX_required'] = 'false' + +root['/entry/sample/name'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/sample/name'].attrs['type'] = 'NX_CHAR' +root['/entry/sample/name'].attrs['EX_required'] = 'false' + +root['/entry/sample/nature'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/sample/nature'].attrs['type'] = 'NX_CHAR' +root['/entry/sample/nature'].attrs['EX_required'] = 'false' + +root['/entry/start_time'] = NXfield('2022-03-04T14:56:25.358149') +root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' +root['/entry/start_time'].attrs['EX_required'] = 'false' + +root['/entry/title'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/title'].attrs['type'] = 'NX_CHAR' +root['/entry/title'].attrs['EX_required'] = 'false' + +root['/entry/total_counts'] = NXfield(1) +root['/entry/total_counts'].attrs['type'] = 'NX_UINT' +root['/entry/total_counts'].attrs['EX_required'] = 'false' +root['/entry/total_counts'].attrs['units'] = 'NX_UNITLESS' + +root['/entry/total_uncounted_counts'] = NXfield(1) +root['/entry/total_uncounted_counts'].attrs['type'] = 'NX_UINT' +root['/entry/total_uncounted_counts'].attrs['EX_required'] = 'false' +root['/entry/total_uncounted_counts'].attrs['units'] = 'NX_UNITLESS' + +root['/entry/user/facility_user_id'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/user/facility_user_id'].attrs['type'] = 'NX_CHAR' +root['/entry/user/facility_user_id'].attrs['EX_required'] = 'false' + +root['/entry/user/name'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/user/name'].attrs['type'] = 'NX_CHAR' +root['/entry/user/name'].attrs['EX_required'] = 'false' + +root['/entry/user/role'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/user/role'].attrs['type'] = 'NX_CHAR' +root['/entry/user/role'].attrs['EX_required'] = 'false' + +# Create the LINKS +root['/entry/data/data'] = NXlink(target='/entry/instrument/detector/data') + +# Create the LINKS +root['/entry/data/data_x_time_of_flight'] = NXlink(target='/entry/instrument/detector/data_x_time_of_flight') + +# Create the LINKS +root['/entry/data/data_x_y'] = NXlink(target='/entry/instrument/detector/data_x_y') + +# Create the LINKS +root['/entry/data/data_y_time_of_flight'] = NXlink(target='/entry/instrument/detector/data_y_time_of_flight') + +# Create the LINKS +root['/entry/data/pixel_id'] = NXlink(target='/entry/instrument/detector/pixel_id') + +# Create the LINKS +root['/entry/data/time_of_flight'] = NXlink(target='/entry/instrument/detector/time_of_flight') + +# Create the LINKS +root['/entry/data/total_counts'] = NXlink(target='/entry/instrument/detector/total_counts') + +# Create the LINKS +root['/entry/data/x_pixel_offset'] = NXlink(target='/entry/instrument/detector/x_pixel_offset') + +# Create the LINKS +root['/entry/data/y_pixel_offset'] = NXlink(target='/entry/instrument/detector/y_pixel_offset') + +# Create the DOC strings +root['/entry/DASlogs'].attrs['EX_doc'] = 'Details of all logs, both from cvinfo file and from HistoTool (frequency and proton_charge). ' +root['/entry/DASlogs/positioner'].attrs['EX_doc'] = 'Motor logs from cvinfo file. ' +root['/entry/SNSHistoTool/command1'].attrs['EX_doc'] = 'Command string for event2histo_nxl. ' +root['/entry/definition'].attrs['EX_doc'] = 'Official NXDL schema after this file goes to applications. ' +root['/entry/instrument/SNSdetector_calibration_id'].attrs['EX_doc'] = 'Detector calibration id from DAS. ' +root['/entry/instrument/detector/origin/orientation/value'].attrs['EX_doc'] = 'Six out of nine rotation parameters. ' +root['/entry/instrument/NXdisk_chopper'].attrs['EX_doc'] = 'Original specification called for NXchopper, which is not a valid NeXus base class. Select either NXdisk_chopper or NXfermi_chopper, as appropriate. ' +root['/entry/instrument/NXfermi_chopper'].attrs['EX_doc'] = 'Original specification called for NXchopper, which is not a valid NeXus base class. Select either NXdisk_chopper or NXfermi_chopper, as appropriate. ' +root['/entry/instrument/aperture/origin/orientation/value'].attrs['EX_doc'] = 'Six out of nine rotation parameters. ' +root['/entry/instrument/crystal/origin/orientation/value'].attrs['EX_doc'] = 'Six out of nine rotation parameters. ' +root['/entry/sample/name'].attrs['EX_doc'] = 'Descriptive name of sample ' + + +# Create the ATTRIBUTES +root.attrs['default'] = 'entry' +root['/entry/data'].set_default() +root['/entry/data'].attrs['signal'] = 'data' +root['/entry/data/data'].attrs['signal'] = '1' + +# Save the file +root.save('NXsnshisto.nxs', 'w') + + diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXspecdata.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXspecdata.py new file mode 100644 index 0000000..ee2ac20 --- /dev/null +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXspecdata.py @@ -0,0 +1,271 @@ + +import numpy as np +from nexusformat.nexus import * + +# Note this example script was generated by nxdl_to_hdf5.py using the current +# installed version of the NEXUS definitions ver[v2020.10] + +root = NXroot() + +# Create the GROUPS +root['/entry'] = NXentry() +root['/entry'].attrs['EX_required'] = 'false' +root['/entry/monitor'] = NXmonitor() +root['/entry/monitor'].attrs['EX_required'] = 'false' +root['/entry/data'] = NXdata() +root['/entry/data'].attrs['EX_required'] = 'false' +root['/entry/counter_cross_reference'] = NXnote() +root['/entry/counter_cross_reference'].attrs['EX_required'] = 'false' +root['/entry/positioner_cross_reference'] = NXnote() +root['/entry/positioner_cross_reference'].attrs['EX_required'] = 'false' +root['/entry/spec'] = NXinstrument() +root['/entry/spec'].attrs['EX_required'] = 'false' +root['/entry/spec/UB'] = NXcrystal() +root['/entry/spec/UB'].attrs['EX_required'] = 'false' +root['/entry/G'] = NXnote() +root['/entry/G'].attrs['EX_required'] = 'false' +root['/entry/positioners'] = NXnote() +root['/entry/positioners'].attrs['EX_required'] = 'false' +root['/entry/MCA'] = NXnote() +root['/entry/MCA'].attrs['EX_required'] = 'false' +root['/entry/MCA/ROI'] = NXnote() +root['/entry/MCA/ROI'].attrs['EX_required'] = 'false' +root['/entry/metadata'] = NXnote() +root['/entry/metadata'].attrs['EX_required'] = 'false' +root['/entry/SPEC_user'] = NXuser() +root['/entry/SPEC_user'].attrs['EX_required'] = 'false' +root['/entry/_unrecognized'] = NXnote() +root['/entry/_unrecognized'].attrs['EX_required'] = 'false' + +# Create the FIELDS + +# Valid enumeration values for root['/entry']['definition'] are: +# NXspecdata + +root['/entry/definition'] = NXfield('NXspecdata') +root['/entry/definition'].attrs['type'] = 'NX_CHAR' +root['/entry/definition'].attrs['EX_required'] = 'false' + +root['/entry/scan_number'] = NXfield(1.0) +root['/entry/scan_number'].attrs['type'] = 'NX_NUMBER' +root['/entry/scan_number'].attrs['EX_required'] = 'false' + +root['/entry/title'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/title'].attrs['type'] = 'NX_CHAR' +root['/entry/title'].attrs['EX_required'] = 'false' + +root['/entry/command'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/command'].attrs['type'] = 'NX_CHAR' +root['/entry/command'].attrs['EX_required'] = 'false' + +root['/entry/date'] = NXfield('2022-03-04T14:56:25.717441') +root['/entry/date'].attrs['type'] = 'NX_DATE_TIME' +root['/entry/date'].attrs['EX_required'] = 'false' + +# Valid enumeration values for root['/entry/monitor']['mode'] are: +# monitor +# timer + +root['/entry/monitor/mode'] = NXfield('monitor') +root['/entry/monitor/mode'].attrs['type'] = 'NX_CHAR' +root['/entry/monitor/mode'].attrs['EX_required'] = 'false' + +root['/entry/monitor/preset'] = NXfield(1.0) +root['/entry/monitor/preset'].attrs['type'] = 'NX_NUMBER' +root['/entry/monitor/preset'].attrs['EX_required'] = 'false' + +root['/entry/monitor/data'] = NXfield(1.0) +root['/entry/monitor/data'].attrs['type'] = 'NX_NUMBER' +root['/entry/monitor/data'].attrs['EX_required'] = 'false' +root['/entry/monitor/data'].attrs['nameType'] = 'any' + +root['/entry/monitor/count_time'] = NXfield(1.0) +root['/entry/monitor/count_time'].attrs['type'] = 'NX_NUMBER' +root['/entry/monitor/count_time'].attrs['EX_required'] = 'false' +root['/entry/monitor/count_time'].attrs['nameType'] = 'any' + +root['/entry/comments'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/comments'].attrs['type'] = 'NX_CHAR' +root['/entry/comments'].attrs['EX_required'] = 'false' + +root['/entry/Q'] = NXfield(1.0) +root['/entry/Q'].attrs['type'] = 'NX_NUMBER' +root['/entry/Q'].attrs['EX_required'] = 'false' + +root['/entry/TEMP_SP'] = NXfield(1.0) +root['/entry/TEMP_SP'].attrs['type'] = 'NX_NUMBER' +root['/entry/TEMP_SP'].attrs['EX_required'] = 'false' + +root['/entry/DEGC_SP'] = NXfield(1.0) +root['/entry/DEGC_SP'].attrs['type'] = 'NX_NUMBER' +root['/entry/DEGC_SP'].attrs['EX_required'] = 'false' + +root['/entry/data/data'] = NXfield(1.0) +root['/entry/data/data'].attrs['type'] = 'NX_NUMBER' +root['/entry/data/data'].attrs['EX_required'] = 'false' +root['/entry/data/data'].attrs['nameType'] = 'any' + +root['/entry/data/intensity_factor'] = NXfield(1.0) +root['/entry/data/intensity_factor'].attrs['type'] = 'NX_NUMBER' +root['/entry/data/intensity_factor'].attrs['EX_required'] = 'false' + +root['/entry/data/_mca_'] = NXfield(1.0) +root['/entry/data/_mca_'].attrs['type'] = 'NX_NUMBER' +root['/entry/data/_mca_'].attrs['EX_required'] = 'false' + +root['/entry/data/_mca_channel_'] = NXfield(1.0) +root['/entry/data/_mca_channel_'].attrs['type'] = 'NX_NUMBER' +root['/entry/data/_mca_channel_'].attrs['EX_required'] = 'false' + +root['/entry/data/_mca1_'] = NXfield(1.0) +root['/entry/data/_mca1_'].attrs['type'] = 'NX_NUMBER' +root['/entry/data/_mca1_'].attrs['EX_required'] = 'false' + +root['/entry/data/_mca1_channel_'] = NXfield(1.0) +root['/entry/data/_mca1_channel_'].attrs['type'] = 'NX_NUMBER' +root['/entry/data/_mca1_channel_'].attrs['EX_required'] = 'false' + +root['/entry/spec/UB/orientation_matrix'] = NXfield(1.0) +root['/entry/spec/UB/orientation_matrix'].attrs['type'] = 'NX_FLOAT' +root['/entry/spec/UB/orientation_matrix'].attrs['EX_required'] = 'false' + +root['/entry/G/G0'] = NXfield(1.0) +root['/entry/G/G0'].attrs['type'] = 'NX_NUMBER' +root['/entry/G/G0'].attrs['EX_required'] = 'false' + +root['/entry/G/G1'] = NXfield(1.0) +root['/entry/G/G1'].attrs['type'] = 'NX_NUMBER' +root['/entry/G/G1'].attrs['EX_required'] = 'false' + +root['/entry/G/G2'] = NXfield(1.0) +root['/entry/G/G2'].attrs['type'] = 'NX_NUMBER' +root['/entry/G/G2'].attrs['EX_required'] = 'false' + +root['/entry/G/G4'] = NXfield(1.0) +root['/entry/G/G4'].attrs['type'] = 'NX_NUMBER' +root['/entry/G/G4'].attrs['EX_required'] = 'false' + +root['/entry/positioners/positioner'] = NXfield(1.0) +root['/entry/positioners/positioner'].attrs['type'] = 'NX_NUMBER' +root['/entry/positioners/positioner'].attrs['EX_required'] = 'false' +root['/entry/positioners/positioner'].attrs['nameType'] = 'any' + +root['/entry/MCA/preset_time'] = NXfield(1.0) +root['/entry/MCA/preset_time'].attrs['type'] = 'NX_NUMBER' +root['/entry/MCA/preset_time'].attrs['EX_required'] = 'false' + +root['/entry/MCA/elapsed_live_time'] = NXfield(1.0) +root['/entry/MCA/elapsed_live_time'].attrs['type'] = 'NX_NUMBER' +root['/entry/MCA/elapsed_live_time'].attrs['EX_required'] = 'false' + +root['/entry/MCA/elapsed_real_time'] = NXfield(1.0) +root['/entry/MCA/elapsed_real_time'].attrs['type'] = 'NX_NUMBER' +root['/entry/MCA/elapsed_real_time'].attrs['EX_required'] = 'false' + +root['/entry/MCA/number_saved'] = NXfield(1.0) +root['/entry/MCA/number_saved'].attrs['type'] = 'NX_NUMBER' +root['/entry/MCA/number_saved'].attrs['EX_required'] = 'false' + +root['/entry/MCA/first_saved'] = NXfield(1) +root['/entry/MCA/first_saved'].attrs['type'] = 'NX_INT' +root['/entry/MCA/first_saved'].attrs['EX_required'] = 'false' + +root['/entry/MCA/last_saved'] = NXfield(1) +root['/entry/MCA/last_saved'].attrs['type'] = 'NX_INT' +root['/entry/MCA/last_saved'].attrs['EX_required'] = 'false' + +root['/entry/MCA/reduction_coef'] = NXfield(1.0) +root['/entry/MCA/reduction_coef'].attrs['type'] = 'NX_NUMBER' +root['/entry/MCA/reduction_coef'].attrs['EX_required'] = 'false' + +root['/entry/MCA/calib_a'] = NXfield(1.0) +root['/entry/MCA/calib_a'].attrs['type'] = 'NX_NUMBER' +root['/entry/MCA/calib_a'].attrs['EX_required'] = 'false' + +root['/entry/MCA/calib_b'] = NXfield(1.0) +root['/entry/MCA/calib_b'].attrs['type'] = 'NX_NUMBER' +root['/entry/MCA/calib_b'].attrs['EX_required'] = 'false' + +root['/entry/MCA/calib_c'] = NXfield(1.0) +root['/entry/MCA/calib_c'].attrs['type'] = 'NX_NUMBER' +root['/entry/MCA/calib_c'].attrs['EX_required'] = 'false' + +root['/entry/MCA/ROI/roiN'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/MCA/ROI/roiN'].attrs['type'] = 'NX_CHAR' +root['/entry/MCA/ROI/roiN'].attrs['EX_required'] = 'false' + +root['/entry/SPEC_user/SPEC_user'] = NXfield('SAMPLE-CHAR-DATA') +root['/entry/SPEC_user/SPEC_user'].attrs['type'] = 'NX_CHAR' +root['/entry/SPEC_user/SPEC_user'].attrs['EX_required'] = 'false' + +# Create the DOC strings +root['/entry'].attrs['EX_doc'] = 'one scan from a SPEC data file, starts with a **#S** line ' +root['/entry/definition'].attrs['EX_doc'] = 'Official NeXus NXDL schema to which this subentry conforms. ' +root['/entry/scan_number'].attrs['EX_doc'] = 'SPEC scan number ' +root['/entry/title'].attrs['EX_doc'] = 'SPEC scan number and command, from **#S** line SPEC data file line:: #S 1 cscan en 690 750 60 0 *title*:: 1 cscan en 690 750 60 0 ' +root['/entry/command'].attrs['EX_doc'] = 'SPEC scan command, from **#S** line, after the scan number. :SPEC data file line: ``#S 1 cscan en 690 750 60 0`` :command*: ``cscan en 690 750 60 0`` ' +root['/entry/date'].attrs['EX_doc'] = 'date from **#D** line in scan header, in ISO8601 format ' +root['/entry/monitor/mode'].attrs['EX_doc'] = 'Count to a preset value based on either clock time (timer) or received monitor counts (monitor). ' +root['/entry/monitor/preset'].attrs['EX_doc'] = 'preset value for time or monitor * **#M** -- counting against this constant monitor count (see #T) * **#T** -- counting against this constant number of seconds (see #M) ' +root['/entry/monitor/data'].attrs['EX_doc'] = 'array(s) of monitor data ' +root['/entry/monitor/count_time'].attrs['EX_doc'] = 'array(s) of monitor data ' +root['/entry/comments'].attrs['EX_doc'] = 'Any **#C** lines in this scan, stored as one string with newlines between comments ' +root['/entry/Q'].attrs['EX_doc'] = '**#Q** -- :math:`Q` (:math:`hkl`) at start of scan array of [:math:`h` :math:`k` :math:`l`] ' +root['/entry/TEMP_SP'].attrs['EX_doc'] = '**#X** -- temperature set point ' +root['/entry/DEGC_SP'].attrs['EX_doc'] = '**#X** -- temperature set point (C) ' +root['/entry/data'].attrs['EX_doc'] = 'detector (and MCA) data from this scan ' +root['/entry/data/data'].attrs['EX_doc'] = 'one column of data from the scan HDF5 requires that each member of a group must have a unique name. Pick the name of column from **#L** but make it unique which means if the same name is used in more than one column, append a number to the extra instances to make them unique yet preserve their content, just in case they might be different. Example: ``seconds seconds`` becomes ``seconds`` and ``seconda_1``. ' +root['/entry/data/intensity_factor'].attrs['EX_doc'] = '**#I** -- intensity normalizing factor ' +root['/entry/counter_cross_reference'].attrs['EX_doc'] = 'associates values declared in **#J** and **#j** scan header lines ' +root['/entry/positioner_cross_reference'].attrs['EX_doc'] = 'associates values declared in **#O** and **#o** scan header lines ' +root['/entry/spec'].attrs['EX_doc'] = 'various metadata from the SPEC scan header that have well-known NeXus base clases ' +root['/entry/spec/UB'].attrs['EX_doc'] = 'Orientation matrix of single crystal sample using Busing-Levy convention ' +root['/entry/spec/UB/orientation_matrix'].attrs['EX_doc'] = '**#G3** line in scan header ' +root['/entry/G'].attrs['EX_doc'] = 'SPEC geometry variables for this diffractometer geometry (instrument specific) TODO: give interpreted name for each array value (need to figure out how to get the names) ' +root['/entry/G/G0'].attrs['EX_doc'] = 'geometry parameters from G[] array (geo mode, sector, etc) ' +root['/entry/G/G1'].attrs['EX_doc'] = 'geometry parameters from U[] array (lattice constants, orientation reflections) ' +root['/entry/G/G2'].attrs['EX_doc'] = 'not used, although some files has a single zero value ' +root['/entry/G/G4'].attrs['EX_doc'] = 'geometry parameters from Q[] array (lambda, frozen angles, cut points, etc) ' +root['/entry/positioners'].attrs['EX_doc'] = 'names and values of all positioners (**#O** and **#P** lines) in scan header ' +root['/entry/positioners/positioner'].attrs['EX_doc'] = 'one positioner from the scan header HDF5 requires that each member of a group must have a unique name. SPEC assigns a unique name to each positioner, no extra work is neccesary to comply with the HDF5 rule for unique names in a group. ' +root['/entry/MCA'].attrs['EX_doc'] = '**#@CALIB** -- coefficients to compute a scale based on the MCA channel number ' +root['/entry/MCA/ROI/roiN'].attrs['EX_doc'] = 'numbered regions of interest, use an index number as part of the name ' +root['/entry/metadata'].attrs['EX_doc'] = 'SPEC metadata (UNICAT-style #H and #V lines) This is a block that may be unique to SPEC files acquired at certain APS beam lines. Other facilities or instruments may use this block for storing key:value pairs of data where the values have suitable attributes (such as units). ' +root['/entry/SPEC_user/SPEC_user'].attrs['EX_doc'] = 'user name from first **#C** line in file header ' +root['/entry/_unrecognized'].attrs['EX_doc'] = 'Fallback for any SPEC data file control lines not otherwise placed into groups or fields elsewhere in this specification. ' + + +# Create the ATTRIBUTES +root['/entry/SAMPLE-CHAR-DATA'] = NXdata() +root['/entry/SAMPLE-CHAR-DATA'].set_default() +root['/entry/monitor'].attrs['description'] = 'SAMPLE-CHAR-DATA' +root['/entry/monitor/preset'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root['/entry/data'].attrs['description'] = 'SAMPLE-CHAR-DATA' +root['/entry/data'].attrs['signal'] = 'SAMPLE-CHAR-DATA' +root['/entry/data'].attrs['axes'] = 'SAMPLE-CHAR-DATA' +root['/entry/data'].attrs['AXISNAME_indices'] = 'SAMPLE-CHAR-DATA' +root['/entry/data/data'].attrs['spec_name'] = 'SAMPLE-CHAR-DATA' +root['/entry/data/data'].attrs['units'] = 'SAMPLE-CHAR-DATA' +root['/entry/counter_cross_reference'].attrs['comment'] = 'SAMPLE-CHAR-DATA' +root['/entry/counter_cross_reference'].attrs['description'] = 'SAMPLE-CHAR-DATA' +root['/entry/positioner_cross_reference'].attrs['comment'] = 'SAMPLE-CHAR-DATA' +root['/entry/positioner_cross_reference'].attrs['description'] = 'SAMPLE-CHAR-DATA' +root['/entry/G'].attrs['comment'] = 'SAMPLE-CHAR-DATA' +root['/entry/G'].attrs['description'] = 'SAMPLE-CHAR-DATA' +root['/entry/positioners'].attrs['description'] = 'SAMPLE-CHAR-DATA' +root['/entry/MCA'].attrs['description'] = 'SAMPLE-CHAR-DATA' +root['/entry/MCA/ROI/roiN'].attrs['description'] = 'SAMPLE-CHAR-DATA' +root['/entry/MCA/ROI/roiN'].attrs['first_channel'] = 'SAMPLE-CHAR-DATA' +root['/entry/MCA/ROI/roiN'].attrs['last_channel'] = 'SAMPLE-CHAR-DATA' +root['/entry/metadata'].attrs['description'] = 'SAMPLE-CHAR-DATA' +root['/entry/_unrecognized'].attrs['comment'] = 'SAMPLE-CHAR-DATA' +root['/entry/_unrecognized'].attrs['description'] = 'SAMPLE-CHAR-DATA' +root.attrs['default'] = 'entry' +root['/entry/data'].set_default() +root['/entry/data'].attrs['signal'] = 'data' +root['/entry/data/data'].attrs['signal'] = '1' + +# Save the file +root.save('NXspecdata.nxs', 'w') + + diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXstxm.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXstxm.py index 6a23090..a93aa61 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXstxm.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXstxm.py @@ -37,11 +37,11 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry/start_time'] = NXfield('2021-03-29T15:51:42.787454') +root['/entry/start_time'] = NXfield('2022-03-04T14:56:36.688437') root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' -root['/entry/end_time'] = NXfield('2021-03-29T15:51:42.790449') +root['/entry/end_time'] = NXfield('2022-03-04T14:56:36.688437') root['/entry/end_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/end_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtas.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtas.py index 2e24fa9..67d91db 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtas.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtas.py @@ -33,7 +33,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry/start_time'] = NXfield('2021-03-29T15:51:43.263179') +root['/entry/start_time'] = NXfield('2022-03-04T14:56:36.922755') root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtofnpd.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtofnpd.py index e3735c2..349645b 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtofnpd.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtofnpd.py @@ -29,7 +29,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry/start_time'] = NXfield('2021-03-29T15:51:43.606595') +root['/entry/start_time'] = NXfield('2022-03-04T14:56:37.078968') root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtofraw.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtofraw.py index 36a1b33..df25a0f 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtofraw.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtofraw.py @@ -29,7 +29,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry/start_time'] = NXfield('2021-03-29T15:51:43.959055') +root['/entry/start_time'] = NXfield('2022-03-04T14:56:37.266424') root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtofsingle.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtofsingle.py index 97cc406..6bc9e8f 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtofsingle.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtofsingle.py @@ -29,7 +29,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry/start_time'] = NXfield('2021-03-29T15:51:44.287685') +root['/entry/start_time'] = NXfield('2022-03-04T14:56:37.453880') root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtomo.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtomo.py index 33c412d..ed2f3dc 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtomo.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtomo.py @@ -29,11 +29,11 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'false' -root['/entry/start_time'] = NXfield('2021-03-29T15:51:44.650319') +root['/entry/start_time'] = NXfield('2022-03-04T14:56:37.625713') root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'false' -root['/entry/end_time'] = NXfield('2021-03-29T15:51:44.652319') +root['/entry/end_time'] = NXfield('2022-03-04T14:56:37.625713') root['/entry/end_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/end_time'].attrs['EX_required'] = 'false' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtomophase.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtomophase.py index c746c61..e6aa89e 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtomophase.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtomophase.py @@ -33,11 +33,11 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry/start_time'] = NXfield('2021-03-29T15:51:45.057350') +root['/entry/start_time'] = NXfield('2022-03-04T14:56:37.860033') root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' -root['/entry/end_time'] = NXfield('2021-03-29T15:51:45.060350') +root['/entry/end_time'] = NXfield('2022-03-04T14:56:37.860033') root['/entry/end_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/end_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtomoproc.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtomoproc.py index d9295d7..3342a10 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtomoproc.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXtomoproc.py @@ -65,7 +65,7 @@ root['/entry/reconstruction/version'].attrs['type'] = 'NX_CHAR' root['/entry/reconstruction/version'].attrs['EX_required'] = 'true' -root['/entry/reconstruction/date'] = NXfield('2021-03-29T15:51:45.375352') +root['/entry/reconstruction/date'] = NXfield('2022-03-04T14:56:38.000624') root['/entry/reconstruction/date'].attrs['type'] = 'NX_DATE_TIME' root['/entry/reconstruction/date'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxas.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxas.py index 3ebd444..ec51856 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxas.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxas.py @@ -33,7 +33,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry/start_time'] = NXfield('2021-03-29T15:51:45.626352') +root['/entry/start_time'] = NXfield('2022-03-04T14:56:38.109973') root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxasproc.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxasproc.py index 8824288..0233812 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxasproc.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxasproc.py @@ -44,7 +44,7 @@ root['/entry/XAS_data_reduction/version'].attrs['type'] = 'NX_CHAR' root['/entry/XAS_data_reduction/version'].attrs['EX_required'] = 'true' -root['/entry/XAS_data_reduction/date'] = NXfield('2021-03-29T15:51:45.804350') +root['/entry/XAS_data_reduction/date'] = NXfield('2022-03-04T14:56:38.234943') root['/entry/XAS_data_reduction/date'].attrs['type'] = 'NX_DATE_TIME' root['/entry/XAS_data_reduction/date'].attrs['EX_required'] = 'true' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxbase.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxbase.py index 94843a0..908dd8f 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxbase.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxbase.py @@ -31,7 +31,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry/start_time'] = NXfield('2021-03-29T15:51:46.136351') +root['/entry/start_time'] = NXfield('2022-03-04T14:56:38.406783') root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' @@ -158,6 +158,10 @@ # Create the ATTRIBUTES + +# Valid enumeration values for root['/entry/instrument/detector/data']['signal'] are: +# 1 +root['/entry/instrument/detector/data'].attrs['signal'] = '1' root.attrs['default'] = 'entry' root['/entry/data'].set_default() root['/entry/data'].attrs['signal'] = 'data' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxeuler.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxeuler.py index 938b4d7..ab3940d 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxeuler.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxeuler.py @@ -33,7 +33,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry/start_time'] = NXfield('2021-03-29T15:51:46.670755') +root['/entry/start_time'] = NXfield('2022-03-04T14:56:38.687998') root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' @@ -206,6 +206,10 @@ # Create the ATTRIBUTES + +# Valid enumeration values for root['/entry/instrument/detector/data']['signal'] are: +# 1 +root['/entry/instrument/detector/data'].attrs['signal'] = '1' root.attrs['default'] = 'entry' root['/entry/data'].set_default() root['/entry/data'].attrs['signal'] = 'data' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxkappa.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxkappa.py index ce34c32..6f8f35e 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxkappa.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxkappa.py @@ -33,7 +33,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry/start_time'] = NXfield('2021-03-29T15:51:47.246390') +root['/entry/start_time'] = NXfield('2022-03-04T14:56:38.984766') root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' @@ -211,6 +211,10 @@ # Create the ATTRIBUTES + +# Valid enumeration values for root['/entry/instrument/detector/data']['signal'] are: +# 1 +root['/entry/instrument/detector/data'].attrs['signal'] = '1' root.attrs['default'] = 'entry' root['/entry/data'].set_default() root['/entry/data'].attrs['signal'] = 'data' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxlaue.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxlaue.py index 06b35d4..2f966d1 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxlaue.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxlaue.py @@ -37,7 +37,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry/start_time'] = NXfield('2021-03-29T15:51:47.928648') +root['/entry/start_time'] = NXfield('2022-03-04T14:56:39.312812') root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' @@ -221,6 +221,10 @@ # Create the ATTRIBUTES + +# Valid enumeration values for root['/entry/instrument/detector/data']['signal'] are: +# 1 +root['/entry/instrument/detector/data'].attrs['signal'] = '1' root.attrs['default'] = 'entry' root['/entry/data'].set_default() root['/entry/data'].attrs['signal'] = 'data' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxlaueplate.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxlaueplate.py index 44fe13e..b53c5dd 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxlaueplate.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxlaueplate.py @@ -37,7 +37,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry/start_time'] = NXfield('2021-03-29T15:51:48.694143') +root['/entry/start_time'] = NXfield('2022-03-04T14:56:39.640859') root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' @@ -227,6 +227,10 @@ # Create the ATTRIBUTES + +# Valid enumeration values for root['/entry/instrument/detector/data']['signal'] are: +# 1 +root['/entry/instrument/detector/data'].attrs['signal'] = '1' root.attrs['default'] = 'entry' root['/entry/data'].set_default() root['/entry/data'].attrs['signal'] = 'data' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxnb.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxnb.py index f4a69b0..a18069c 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxnb.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxnb.py @@ -33,7 +33,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry/start_time'] = NXfield('2021-03-29T15:51:49.239441') +root['/entry/start_time'] = NXfield('2022-03-04T14:56:39.937663') root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' @@ -197,6 +197,10 @@ # Create the ATTRIBUTES + +# Valid enumeration values for root['/entry/instrument/detector/data']['signal'] are: +# 1 +root['/entry/instrument/detector/data'].attrs['signal'] = '1' root.attrs['default'] = 'entry' root['/entry/data'].set_default() root['/entry/data'].attrs['signal'] = 'data' diff --git a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxrot.py b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxrot.py index 05d6274..debf095 100644 --- a/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxrot.py +++ b/autogenerated_examples/nxdl/python_scripts/nexusformat/ex_nexusformat_NXxrot.py @@ -35,7 +35,7 @@ root['/entry/title'].attrs['type'] = 'NX_CHAR' root['/entry/title'].attrs['EX_required'] = 'true' -root['/entry/start_time'] = NXfield('2021-03-29T15:51:49.861951') +root['/entry/start_time'] = NXfield('2022-03-04T14:56:40.218872') root['/entry/start_time'].attrs['type'] = 'NX_DATE_TIME' root['/entry/start_time'].attrs['EX_required'] = 'true' @@ -208,6 +208,10 @@ # Create the ATTRIBUTES + +# Valid enumeration values for root['/entry/instrument/detector/data']['signal'] are: +# 1 +root['/entry/instrument/detector/data'].attrs['signal'] = '1' root.attrs['default'] = 'entry' root['/entry/data'].set_default() root['/entry/data'].attrs['signal'] = 'data' diff --git a/nxdl/README.md b/nxdl/README.md index 2628e79..9e1e230 100644 --- a/nxdl/README.md +++ b/nxdl/README.md @@ -9,13 +9,26 @@ a master dictionary separated into the different XML tags (group, field, link, a create the file with this dict in a controlled order, this made it much easier to debug and section off where errors were during the process. -The result of executing **nxdl_to_hdf5 -d applications** is the following which is true for each application definition: +The result of executing **python nxdl_to_hdf5.py -d applications** is the following which is true for each application definition: - Hdf5 file is created in **exampledata/autogenerated_examples/nxdl/applications** - A python script to create the definition using h5py is created in **exampledata/autogenerated_examples/nxdl/h5py** - A python script to create the definition using nexusformat is created in **exampledata/autogenerated_examples/nxdl/nexusformat** -**Dependancies** +## Contributed Definition testing + +A good way to stay on track while developing a new application definition is to use ```nxdl_to_hdf5.py``` +to try and generate your definition, if there are basic errors they will be reported, and if your +definition generates an hdf5 file without errors there is a good chance that it will also pass ```cnxvalidate```. +As with any other definition, a python script using both **h5py** and **nexusformat** modules will also be created +to give you a tangible example of what is needed to create a compliant file for your definition. + +To generate your definition, save your definitions **.nxdl.xml** file to the +`nexusformat/definitions/contributed_definitions` folder, then generate the file by executing: + + `python nxdl_to_hdf5.py -d contributed_definitions` + +### **Dependancies** nxdl_to_hdf5 requires the following modules: @@ -27,7 +40,7 @@ nxdl_to_hdf5 requires the following modules: - bs4 - tinydb -**Arguments and Usage:** +### **Arguments and Usage:** ``` >python nxdl_to_hdf5.py --help usage: nxdl_to_hdf5.py [-h] [-f FILE | -d DIRECTORY] diff --git a/nxdl/db.json b/nxdl/db.json new file mode 100644 index 0000000..e69de29 diff --git a/nxdl/nxdl_to_hdf5.py b/nxdl/nxdl_to_hdf5.py old mode 100644 new mode 100755 index 744111c..1865d76 --- a/nxdl/nxdl_to_hdf5.py +++ b/nxdl/nxdl_to_hdf5.py @@ -1,4 +1,5 @@ -from pathlib import Path +#! /usr/bin/env python +import pathlib import os import pkg_resources import h5py @@ -12,10 +13,10 @@ readme_string = """ - Autogenerated using version [%s] of the NEXUS definitions. + Autogenerated using version [{}] of the NEXUS definitions. The file generated by this script is intended to give the user an example of a -file that conforms to the [%s] application definition such that it will pass +file that conforms to the [{}] application definition such that it will pass validation with cnxvalidate. There are some attributes that have been added for informational purposes to help the user know what is a required field or group, the informational only attributes have the prefix 'EX_', for example if a group @@ -45,7 +46,8 @@ def init_database(): global db, query, tables_dct - if os.path.exists('db.json'): + + if pathlib.Path('db.json').exists(): # reset database to nothing if db is not None: db.close() @@ -65,8 +67,8 @@ def init_database(): 'attribute': db.table('attribute_table'), 'link': db.table('link_table'), 'symbols': db.table('symbols_table'), - 'docs': db.table('docs_table') - } + 'docs': db.table('docs_table'), + } def _string_attr(nxgrp, name, sdata, do_print=True, skip_nxsfrmt=False): ''' @@ -81,29 +83,28 @@ def _string_attr(nxgrp, name, sdata, do_print=True, skip_nxsfrmt=False): if do_print: s_data = sdata.replace(__file__.replace('/nxdl_to_hdf5.py', ''), '') s_data = s_data.replace('/..', '..') - if sdata.find('.hdf5') > -1: + if sdata.find('.h5') > -1: #just use the file name - h5py_script_lst.append('root[\'%s\'].attrs[\'%s\'] = \'%s\'' % (nxgrp.name, name, s_data.split('/')[-1])) + h5py_script_lst.append(f"root['{nxgrp.name}'].attrs['{name}'] = '{s_data.split('/')[-1]}'") if not skip_nxsfrmt: - nxsfrmt_script_lst.append('root[\'{}\'].attrs[\'{}\'] = \'{}\''.format(nxgrp.name, name, s_data)) + nxsfrmt_script_lst.append(f"root['{nxgrp.name}'].attrs['{name}'] = '{s_data}'") else: - h5py_script_lst.append('root[\'%s\'].attrs[\'%s\'] = \'%s\'' % (nxgrp.name, name, sdata)) + h5py_script_lst.append(f"root['{nxgrp.name}'].attrs['{name}'] = '{s_data.split('/')[-1]}'") if not skip_nxsfrmt: if name.find('default') > -1: if nxgrp.name == '/': #need to set the 'default' attribute for the file to point to the default entry name - nxsfrmt_script_lst.append('root.attrs[\'default\'] = \'{}\''.format(s_data)) + nxsfrmt_script_lst.append(f"root.attrs[\'default\'] = \'{s_data}\'") else: - #nxsfrmt_script_lst.append('root[\'{}/{}\'].set_default()'.format(nxgrp.name, s_data)) if s_data == 'SAMPLE-CHAR-DATA': #this is the /entry default attribute - nxsfrmt_script_lst.append('root[\'{}/{}\'] = NXdata()'.format(nxgrp.name, s_data)) - nxsfrmt_script_lst.append('root[\'{}/{}\'].set_default()'.format(nxgrp.name, s_data)) + nxsfrmt_script_lst.append(f"root[\'{nxgrp.name}/{s_data}\'] = NXdata()") + nxsfrmt_script_lst.append(f"root[\'{nxgrp.name}/{s_data}\'].set_default()") else: - nxsfrmt_script_lst.append('root[\'{}/{}\'].set_default()'.format(nxgrp.name, s_data)) + nxsfrmt_script_lst.append(f"root[\'{nxgrp.name}/{s_data}\'].set_default()") else: - nxsfrmt_script_lst.append('root[\'{}\'].attrs[\'{}\'] = \'{}\''.format(nxgrp.name, name, s_data)) + nxsfrmt_script_lst.append(f"root[\'{nxgrp.name}\'].attrs[\'{name}\'] = \'{s_data}\'") def _num_attr(nxgrp, name, data, do_print=True): ''' @@ -114,8 +115,7 @@ def _num_attr(nxgrp, name, data, do_print=True): nxgrp.attrs[name] = data if do_print: - h5py_script_lst.append('root[\'%s\'].attrs[\'%s\'] = \'%s\'' % (nxgrp.name, name, str(data))) - #print('root[\'%s\'].attrs[\'%s\'] = \'%s\'' % (nxgrp.name, name, sdata.replace('\'', '"'))) + h5py_script_lst.append(f"root[\'{nxgrp.name}\'].attrs[\'{name}\'] = \'{str(data)}\'") def _list_attr(nxgrp, name, lstdata, do_print=True): ''' @@ -134,15 +134,13 @@ def print_list_attr(nxgrp, name, lstdata, do_print=True): if do_print: h5py_script_lst.append(' ') nxsfrmt_script_lst.append(' ') - #h5py_script_lst.append('root[\'%s\'].attrs[\'%s\'] = \'%s\'' % (nxgrp.name, name, str(lstdata))) - #h5py_script_lst.append('# the allowable values for root[\'%s\'].attrs[\'%s\'] are: \'%s\'' % (nxgrp.name, name, str(lstdata))) h5py_script_lst.append( - '# Valid enumeration values for root[\'%s\'][\'%s\'] are: ' % (nxgrp.name, name)) + f"# Valid enumeration values for root[\'{nxgrp.name}\'][\'{name}\'] are: ") nxsfrmt_script_lst.append( - '# Valid enumeration values for root[\'%s\'][\'%s\'] are: ' % (nxgrp.name, name)) + f"# Valid enumeration values for root[\'{nxgrp.name}\'][\'{name}\'] are: ") for i in lstdata: - h5py_script_lst.append('#\t %s' % i) - nxsfrmt_script_lst.append('#\t %s' % i) + h5py_script_lst.append(f"#\t {i}") + nxsfrmt_script_lst.append(f"#\t {i}") def check_for_duplicate_grp_names(nxgrp, name, nxdata_type): @@ -150,7 +148,7 @@ def check_for_duplicate_grp_names(nxgrp, name, nxdata_type): i = 1 _name = name while name in nxgrp.keys() and i < 100: - name = _name + '_%d' % i + name = _name + f"_{i}" i += 1 return(True) return(False) @@ -199,6 +197,8 @@ def _dataset(nxgrp, name, data, nxdata_type, nx_units='', dset={}, do_print=True ''' # grp = nxgrp.create_dataset(name=name, data=data, maxshape=None) #strip any units off of nxdata_type + if name.find('data_x_y') > -1: + print() _dt = nxdata_type.split('-') nxdata_type = _dt[0] @@ -210,10 +210,10 @@ def _dataset(nxgrp, name, data, nxdata_type, nx_units='', dset={}, do_print=True data = data.replace('\' ', '\' , ') data = data.encode("ascii", "ignore") h5py_script_lst.append(' ') - h5py_script_lst.append('root[\'{}\'][\'{}\'] = {}'.format(nxgrp.name, name, data)) + h5py_script_lst.append(f"root[\'{nxgrp.name}\'][\'{name}\'] = {data}") elif (type(data) == np.ndarray): - #print('creating np.ndarray dataset [%s]' % name) + #print('creating np.ndarray dataset [{}]'.format(name) grp = nxgrp.create_dataset(name=name, data=data, maxshape=None, compression="gzip") if nxdata_type == 'NX_FLOAT': @@ -222,28 +222,27 @@ def _dataset(nxgrp, name, data, nxdata_type, nx_units='', dset={}, do_print=True elif nxdata_type in ['NX_INT', 'NX_NUMBER', 'NX_POSINT', 'NX_UINT']: s = str(data.astype(int)).replace('\n', ',') else: - print('_dataset: UNSUPPORTED ndarray TYPE %s' % nxdata_type) + print(f"_dataset: UNSUPPORTED ndarray TYPE {nxdata_type}") if s.find('. ') > -1: data = s.replace('. ', '. , ').replace('\n', ',') h5py_script_lst .append(' ') - h5py_script_lst.append('root[\'%s\'].create_dataset(name=\'%s\', data=%s, maxshape=None, compression="gzip")' % (nxgrp.name, name, str(data))) - - #h5py_script_lst.append('root[\'{}\'][\'{}\'] = {}'.format(nxgrp.name, name, data)) - + #h5py_script_lst.append('root[\'{}\'].create_dataset(name=\'{}\', data={}, maxshape=None, compression="gzip")'.format(nxgrp.name, name, str(data))) + h5py_script_lst.append( + f"root[\'{nxgrp.name}\'].create_dataset(name=\'{name}\', data={str(data)}, maxshape=None, compression=""gzip") else: - #print('name[%s] data[%s]' % (name, data)) + #print('name[{}] data[{}]'.format(name, data)) if(data is None): data = '' if node_exists(nxgrp, name): # update the contents - #print('modify [%s] = %s' % (nxgrp.name + '/' + name, data)) - nxgrp['%s' % nxgrp.name + '/' + name][()] = data + #print('modify [{}] = {}'.format(nxgrp.name + '/' + name, data)) + nxgrp[f"{nxgrp.name}/{name}"][()] = data #TODO: now add this mod to h5py_script_lst return - #print('creating dataset [%s]' % name) + #print('creating dataset [{}]'.format(name) if nxdata_type == 'NX_INT': grp = nxgrp.create_dataset(name=name, data=data, dtype=np.int64, maxshape=None) else: @@ -254,14 +253,18 @@ def _dataset(nxgrp, name, data, nxdata_type, nx_units='', dset={}, do_print=True s_data = fix_non_standard_definition_name(s_data) if nxdata_type == 'NX_BOOLEAN': s_data = 'np.int8(0)' + if nxdata_type == 'NX_UINT': + #s_data = 'np.intc(1)' + s_data = 'np.ushort(1)' if type(data) is str: if do_print: h5py_script_lst.append(' ') nxsfrmt_script_lst.append(' ') - h5py_script_lst.append('root[\'%s\'].create_dataset(name=\'%s\', data=\'%s\', maxshape=None)' % (nxgrp.name, name, s_data)) + h5py_script_lst.append( + f"root[\'{nxgrp.name}\'].create_dataset(name=\'{name}\', data=\'{s_data}\', maxshape=None)") - nxsfrmt_script_lst.append('root[\'{}/{}\'] = NXfield(\'{}\')'.format(nxgrp.name, name, s_data)) + nxsfrmt_script_lst.append(f"root[\'{nxgrp.name}/{name}\'] = NXfield(\'{s_data}\')") else: if do_print: h5py_script_lst.append(' ') @@ -269,16 +272,14 @@ def _dataset(nxgrp, name, data, nxdata_type, nx_units='', dset={}, do_print=True if s_data.find('array') > -1: # make sure it reads correctly as a numpy array s_data = s_data.replace('array', 'np.array') - h5py_script_lst.append('root[\'%s\'].create_dataset(name=\'%s\', data=%s, maxshape=None)' % (nxgrp.name, name, s_data)) + h5py_script_lst.append( + f"root[\'{nxgrp.name}\'].create_dataset(name=\'{name}\', data={s_data}, maxshape=None)") # catch if it is a NX_BOOLEAN, cnxvalidate needs a specific type not just 0 for False it must be an np.int8 if nxdata_type == 'NX_BOOLEAN': - nxsfrmt_script_lst.append('root[\'{}/{}\'] = NXfield(np.int8(0))'.format(nxgrp.name, name)) + nxsfrmt_script_lst.append(f"root[\'{nxgrp.name}/{name}\'] = NXfield(np.int8(0))") else: - nxsfrmt_script_lst.append('root[\'{}/{}\'] = NXfield({})'.format(nxgrp.name, name, data)) - - # grp_name = get_last_name_from_abspath(dct['abspath']) - # print('root[\'%s\'] = h5py.create_group(\'%s\')' % (get_parent_path(dct['abspath']), grp_name)) + nxsfrmt_script_lst.append(f"root[\'{nxgrp.name}/{name}\'] = NXfield({data})") _string_attr(grp, 'type', nxdata_type, do_print) @@ -328,7 +329,7 @@ def abspath_lst_to_str(l): # print() s = '/' for n in l: - s += '%s/' % fix_nx_name(n) + s += f"{fix_nx_name(n)}/" return(s) def get_children_list_of_lists(e): @@ -385,7 +386,7 @@ def get_type(d): if 'units' in d['attrib'].keys(): #return a concatenation of the default for no specified type 'NX_CHAR' and '- - return ('NX_CHAR-%s' % d['attrib']['units']) + return (f"NX_CHAR-{d['attrib']['units']}") #return ('NX_CHAR') return ('') else: @@ -416,7 +417,7 @@ def get_min_occurs(d, category): ''' valid_categories = ['base', 'application', 'contributed'] if category not in valid_categories: - print('Error: invalid definition category [%s]' % (category)) + print(f"Error: invalid definition category [{category}]") print('\t must be one of ', valid_categories) exit() if ('minOccurs' in d['attrib'].keys()): @@ -458,20 +459,20 @@ def sanity_check_dimensions(dct, sym_dct={}, show_warnings=True): if show_warnings: print( '\t\tNote: rank designation is using an expression, expressions are currently not supported for generation, the value of 1 will be used') - print('\t\t The expression used in the definition is: [%s]' % (dct['attrib']['rank'])) + print(f"\t\t The expression used in the definition is: [{dct['attrib']['rank']}]") else: if show_warnings: print( '\t\tError: rank designation is using a symbol that has not been defined in Symbols table or it is a comment') - print('\t\t [%s]' % (dct['attrib']['rank'])) + print(f"\t\t [{dct['attrib']['rank']}]") return(False) if(rank <= len(dct['attrib']['dim'])): return(True) else: if show_warnings: - print('\t\tError: Incorrect number of dim sections for this dimensions specification, should be at least [%d] found [%d]' % (rank, len(dct['attrib']['dim']))) - print('\t\t[%s]' % dct['abspath']) + print(f"\t\tError: Incorrect number of dim sections for this dimensions specification, should be at least [{rank}] found [{len(dct['attrib']['dim'])}]") + print(f"\t\t[{dct['abspath']}]") return (False) else: #print('\t\tError: dimensions must specify a rank, this does not >', dct) @@ -505,7 +506,7 @@ def get_nx_data_by_type(nx_type, dimensions=None, sym_dct={}): if 'value' in dimensions.keys(): if not has_numbers(dimensions['value']): if dimensions['value'] not in sym_dct.keys(): - print('\t-Most likely this [%s] should be a symbol but has not been defined in the Symbols table as one' % dimensions['value']) + print(f"\t-Most likely this [{dimensions['value']}] should be a symbol but has not been defined in the Symbols table as one") rank = 1 sym_dct[dimensions['value']] = rank else: @@ -516,7 +517,7 @@ def get_nx_data_by_type(nx_type, dimensions=None, sym_dct={}): for r in range(0, rank): #verify length of dim as teh number of dim entries must equal rank size if (len(dimensions['dim']) < rank): - print('\t-Invalid NXDL file, the number of DIM entries must equal the size of specified rank [%d]' % rank) + print(f"\t-Invalid NXDL file, the number of DIM entries must equal the size of specified rank [{rank}]") errors = True return(None) # check if symbol was used in defining a dim value @@ -528,7 +529,7 @@ def get_nx_data_by_type(nx_type, dimensions=None, sym_dct={}): return (None) if not has_numbers(str(dimensions['dim'][r]['value'])): if dimensions['dim'][r]['value'] not in sym_dct.keys(): - print('\t-Most likely this [%s] should be a symbol but has not been entered in the definition as one' % dimensions['dim'][r]['value']) + print(f"\t-Most likely this [{dimensions['dim'][r]['value']}] should be a symbol but has not been entered in the definition as one") val = 1 sym_dct[dimensions['dim'][r]['value']] = val @@ -594,12 +595,20 @@ def get_nx_data_by_type(nx_type, dimensions=None, sym_dct={}): else: return (1) elif (nx_type.find('NX_UINT') > -1): + if (use_dims): + #return (data) + return(np.uintc(data)) #force a unit32 + else: + #return (1) + return(np.uintc(1)) + elif (nx_type.find('NX_DIMENSIONLESS') > -1): if (use_dims): return (data) else: return (1) + def get_units(nx_type): ''' check to see if this nx_type contains the units as well ex: NX_CHAR-NX_WAVENUMBER @@ -617,11 +626,21 @@ def make_timestamp_now(): t = datetime.datetime.now().isoformat() return (t) +def fatal_error(msg): + ''' + a fatal error has occurred, print message + ''' + print(f"\tFATAL_ERROR: {msg}") + + def get_entry(nf): ''' return the name of the entry in the file ''' keys = list(nf.keys()) + if len(keys) == 0: + #fatal_error('File does not contain NXentry group') + return(None, None) s1 = 'entry' for k in keys: if s1.casefold() == k.casefold(): @@ -716,12 +735,12 @@ def process_symbols(soup, sym_args_dct={}): if(sym_nm in sym_args_dct.keys()): #use the user passed in value for this symbol val = sym_args_dct[sym_nm] - print('\tsymbol [%s] will use the value [%s] passed in by user' % (sym_nm, str(val))) + print(f"\tsymbol [{sym_nm}] will use the value [{ str(val)}] passed in by user") else: if(sym_nm == 'dataRank'): - print('\tsymbol [%s] was not defined and passed in in the usr_args, so it will be auto calculated at every occurance' % (sym_nm)) + print(f"\tsymbol [{sym_nm}] was not defined and passed in in the usr_args, so it will be auto calculated at every occurance") else: - print('\tsymbol [%s] was not defined and passed in in the usr_args, so using default value of 1 for [%s]' % (sym_nm,sym_nm)) + print(f"\tsymbol [{sym_nm}] was not defined and passed in in the usr_args, so using default value of 1 for [{sym_nm}]") if(type(val) is dict): #if users passed in symbols from the command line these will be in a dict @@ -781,27 +800,30 @@ def process_symbols(soup, sym_args_dct={}): def get_extending_class(fname, cls_nm, sym_args_dct={}, dct={}, docs=[], report_symbols_only=False): fparts = fname.split('\\') - eclass_file = fname.replace(fparts[-1], '%s.nxdl.xml' % cls_nm) - if (not os.path.exists(eclass_file)): - print('get_extending_class: XML file [%s] does not exist' % eclass_file) + eclass_file = fname.replace(fparts[-1], f"{cls_nm}.nxdl.xml") + + if not pathlib.Path(eclass_file).exists(): + print(f"get_extending_class: XML file [{eclass_file}] does not exist") return({}, {}, {}) - print('extending with [%s]' % cls_nm) + print(f"extending with [{cls_nm}]") dct, syms, docs = get_xml_paths(eclass_file, sym_args_dct=sym_args_dct, dct=dct, docs=docs, report_symbols_only=report_symbols_only, allow_extend=True) return (dct, syms, docs) -def get_xml_root(fname): +def get_xml_root(fpath): ''' takes the path to teh nxdl.xml file and returns a dict of element category lists of the entire structure ''' - if(not fname.exists()): - print('XML file [%s] does not exist' % str(fname.absolute())) + if not fpath.exists(): + print(f"XML file [{fpath}] does not exist") return(None) - infile = open(fname, "r") - contents = infile.read() - infile.close() + #infile = open(str(fpath), "r") + #contents = infile.read() + #infile.close() + with open(str(fpath), "r") as infile: + contents = infile.read() contents = contents.replace('xmlns="http://definition.nexusformat.org/nxdl/3.1"','') contents = contents.replace('xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n', '') contents = contents.replace('xsi:schemaLocation="http://definition.nexusformat.org/nxdl/3.1 ../nxdl.xsd"', '') @@ -823,13 +845,13 @@ def walk_extends_chain(fpath, root): main_clss = main_clss.replace('.nxdl.xml','') ext_lst = [main_clss] extends_clss = root.get('extends') - fpath = Path(str(fpath.absolute()).replace(main_clss, f'{extends_clss}')) + fpath = pathlib.Path(str(fpath.absolute()).replace(main_clss, f'{extends_clss}')) while extends_clss != 'NXobject': #(dct, syms, docs) = ext_lst.append(extends_clss) _root, _soup = get_xml_root(fpath) extends_clss = _root.get('extends') - fpath = Path(str(fpath.absolute()).replace(ext_lst[-1], f'{extends_clss}')) + fpath = pathlib.Path(str(fpath.absolute()).replace(ext_lst[-1], f'{extends_clss}')) ext_lst.reverse() return(ext_lst) @@ -839,14 +861,14 @@ def get_xml_paths(fname, sym_args_dct={}, dct={}, docs=[], report_symbols_only=F ''' fname = fname.replace('\\', '/') - fpath = Path(fname) + fpath = pathlib.Path(fname) _root, _soup = get_xml_root(fpath) if _root is None: return extends_lst = walk_extends_chain(fpath, _root) def_lst = [] for ext_clss in extends_lst: - fpath = Path(str(fpath.absolute()).replace(fpath.name, f'{ext_clss}.nxdl.xml')) + fpath = pathlib.Path(str(fpath.absolute()).replace(fpath.name, f'{ext_clss}.nxdl.xml')) tables_dct['main'].insert({'filename': str(fpath.name)}) _root, _soup = get_xml_root(fpath) def_lst.append(get_definition_details(_root, _soup)) @@ -932,7 +954,7 @@ def get_parent_group(nf, ppath): pgrp = nf else: if ppath not in nf: - print('\t\tError: why doesnt [%s] exist?' % ppath) + print(f'\t\tError: why doesnt [{ppath}] exist?') else: pgrp = nf[ppath] return(pgrp) @@ -972,22 +994,20 @@ def print_script_group(dct): #grp_name = dct['abspath'].replace('/','') parent_grp = get_parent_path(dct['abspath']) grp_name = get_last_name_from_abspath(dct['abspath']) - #print('root[\'%s\'] = root.create_group(\'%s\')' % (get_parent_path(dct['abspath']), grp_name)) + #print('root[\'{}\'] = root.create_group(\'{}\')'.format(get_parent_path(dct['abspath']), grp_name)) if len(parent_grp) > 1: - #print('root[\'%s\'].create_group(\'%s\')' % (parent_grp, grp_name)) + #print('root[\'{}\'].create_group(\'{}\')'.format(parent_grp, grp_name)) h5py_script_lst.append(' ') - h5py_script_lst.append('root[\'%s\'].create_group(\'%s\')' % (parent_grp, grp_name)) + h5py_script_lst.append(f"root[\'{parent_grp}\'].create_group(\'{grp_name}\')") - nxsfrmt_script_lst.append('root[\'%s\'] = %s()' % (dct['abspath'], dct['attrib']['type'])) + nxsfrmt_script_lst.append(f"root[\'{dct['abspath']}\'] = {dct['attrib']['type']}()") else: - #print('root.create_group(\'%s\')' % (grp_name)) + #print('root.create_group(\'{}\')'.format(grp_name)) h5py_script_lst.append(' ') - h5py_script_lst.append('root.create_group(\'%s\')' % (grp_name)) - #h5py_script_lst.append('root[\'%s%s\'] = [()]' % (parent_grp, grp_name)) - + h5py_script_lst.append(f"root.create_group(\'{grp_name}\')") - nxsfrmt_script_lst.append('root[\'%s\'] = %s()' % (dct['abspath'], dct['attrib']['type'])) + nxsfrmt_script_lst.append(f"root[\'{dct['abspath']}\'] = {dct['attrib']['type']}()") def get_category(): ''' @@ -1047,7 +1067,7 @@ def create_groups(nf): doc = get_doc(d) if (doc): _string_attr(_grp, 'doc', doc) - #print('created: GROUP [%s]' % fix_nx_path(d['abspath'])) + #print('created: GROUP [{}]'.format(fix_nx_path(d['abspath'])) @@ -1109,7 +1129,7 @@ def create_fields(nf, sym_dct={}, category=''): else: data = get_nx_data_by_type(_type, use_dim_dct_lst, sym_dct) if(data is None): - print('\t\tError: There is an issue with a non standard field for fieldname [%s]' % name) + print(f"\t\tError: There is an issue with a non standard field for fieldname [{name}]: ") return(False) # if name.find('depends_on'): @@ -1117,7 +1137,7 @@ def create_fields(nf, sym_dct={}, category=''): # data = ppath _dset = _dataset(pgrp, name, data, _type, nx_units=units) - #print('created: FIELD [%s]' % fix_nx_path(d['abspath'])) + #print('created: FIELD [{}]'.format(fix_nx_path(d['abspath'])) _string_attr(_dset, 'EX_required', get_min_occurs(d, category)) doc = get_doc(d) if (doc): @@ -1164,8 +1184,8 @@ def fix_link_target(nf, trgt_dct, hdf5_path_lst): ''' ppath = get_parent_path(trgt_dct['abspath']) if ppath not in nf: - print('\t-Error: while checking the links, this parent path [%s] not exist in generated file' % ppath) - print('\t\ttarget path: [%s] ' % trgt_dct['abspath']) + print(f"\t-Error: while checking the links, this parent path [{ppath}] not exist in generated file") + print(f"\t\ttarget path: [{trgt_dct['abspath']}] ") exit() else: add_line_to_scripts('# Create the LINKS ', with_prec_newline=True) @@ -1187,8 +1207,8 @@ def fix_link_target(nf, trgt_dct, hdf5_path_lst): link_nm = get_last_name_in_path(trgt_dct['abspath']) #if(target_str not in nf): if (pstr not in nf): - #print('\t-Error: The link path [%s] specified in NXDL file for [%s] does not exist in the generated file' % (target_str, trgt_dct['abspath'])) - print('\t-Link Error: This field [%s] specifies a link target that does not exist in the generated file [%s]' % (trgt_dct['abspath'], target_str)) + #print('\t-Error: The link path [{}] specified in NXDL file for [{}] does not exist in the generated file'.format(target_str, trgt_dct['abspath'])) + print(f"\t-Link Error: This field [{trgt_dct['abspath']}] specifies a link target that does not exist in the generated file [{target_str}]") #exit() else: #force the link to be what we found in the file @@ -1196,12 +1216,12 @@ def fix_link_target(nf, trgt_dct, hdf5_path_lst): pgrp[link_nm].attrs['target'] = pstr #need to add this to the list oof script items - h5py_script_lst.append('root[\'%s%s\'] = h5py.SoftLink(\'%s\')' % (ppath, link_nm, pstr)) - h5py_script_lst.append('root[\'%s\'].attrs[\'%s\'] = \'%s\'' % (trgt_dct['abspath'], 'target', target_str)) + h5py_script_lst.append(f"root[\'{ppath}{link_nm}\'] = h5py.SoftLink(\'{pstr}\')") + h5py_script_lst.append(f"root[\'{trgt_dct['abspath']}\'].attrs[\'target\'] = \'{target_str}\'") - nxsfrmt_script_lst.append('root[\'%s%s\'] = NXlink(target=\'%s\')' % (ppath, link_nm, pstr)) + nxsfrmt_script_lst.append(f"root[\'{ppath}{link_nm}\'] = NXlink(target=\'{pstr}\')") #root['/entry/data/data'] = NXlink(target='/entry/instrument/detector/data') - #nxsfrmt_script_lst.append('root[\'%s\'].attrs[\'%s\'] = \'%s\'' % (trgt_dct['abspath'], 'target', target_str)) + #nxsfrmt_script_lst.append('root[\'{}\'].attrs[\'{}\'] = \'{}\''.format(trgt_dct['abspath'], 'target', target_str)) @@ -1215,25 +1235,41 @@ def standardize_link_target_str(trgt): def _soft_link(nxgrp, name, target): nxgrp[name] = h5py.SoftLink(target) -def create_attributes(nf):#, dct): +def create_attributes(nf, sym_dct):#, dct): ''' + pull all attributes from the database and create them ''' - #paths_lst = get_all_paths_in_hdf5(nf) add_line_to_scripts('# Create the ATTRIBUTES ', with_prec_newline=True) for d in tables_dct['attribute'].all(): #print(d) ppath = get_parent_path(d['abspath']) + # get all enumerations if any exist for this parent path + name = fix_nx_name(d['attrib']['name']) + enums = get_enums(d['abspath']) + _type = get_type(d) + if ppath not in nf: print('\t-Error: while creating Attributes, this parent path [%s] not exist in generated file' % ppath) exit() else: pgrp = nf[ppath] - if('type' in d['attrib'].keys()): - data = get_nx_data_by_type(d['attrib']['type']) + if len(enums) > 0: + #if this is an enumerated data type just use teh first enumeration as the data + data = enums[0] + # and include a comment in teh script + print_list_attr(pgrp, name, enums) else: data = get_nx_data_by_type('NX_CHAR') + # if(data is None): + # print('\t\tError: There is an issue with a non standard field for fieldname [%s]' % name) + # return(False) + # + # if('type' in d['attrib'].keys()): + # data = get_nx_data_by_type(d['attrib']['type']) + # else: + # data = get_nx_data_by_type('NX_CHAR') if type(data) is str: _string_attr(pgrp, d['attrib']['name'], data) @@ -1262,7 +1298,7 @@ def add_docs(nf, docs): # print(d) ppath = d['abspath'] if ppath not in nf: - #print('\t-Error: while adding doc strings, this parent path [%s] not exist in generated file' % ppath) + #print('\t-Error: while adding doc strings, this parent path [{}] not exist in generated file'.format(ppath) #exit() #just skip it continue @@ -1276,15 +1312,15 @@ def add_docs(nf, docs): _string_attr(pgrp, 'EX_doc', doc_str[1:]) -def print_script_start(fname): +def print_script_start(fname, rel_ver): ''' make calls to the currently supported example script modules (h5py, nexusformat) so that the proper lines can be appended to their respective string lists from which the final scripto file will be written from ''' - print_h5py_ex_start(fname) - print_nxsfrmt_ex_start(fname) + print_h5py_ex_start(fname, rel_ver) + print_nxsfrmt_ex_start(fname, rel_ver) -def print_nxsfrmt_ex_start(fname): +def print_nxsfrmt_ex_start(fname, rel_ver): ''' append the proper lines to open each example script for nexusformat ''' @@ -1294,17 +1330,18 @@ def print_nxsfrmt_ex_start(fname): nxsfrmt_script_lst.append('import numpy as np') nxsfrmt_script_lst.append('from nexusformat.nexus import *') nxsfrmt_script_lst.append(' ') - nxsfrmt_script_lst.append('# Note this example script was generated by nxdl_to_hdf5.py using the current \n# installed version of the NEXUS definitions ver[%s] ' % rel_ver) + nxsfrmt_script_lst.append(f"# Note this example script was generated by nxdl_to_hdf5.py using the current \n# installed version of the NEXUS definitions ver[{rel_ver}] ") nxsfrmt_script_lst.append(' ') nxsfrmt_script_lst.append('root = NXroot()') -def print_h5py_ex_start(fname): +def print_h5py_ex_start(fname, rel_ver): ''' append the proper lines to open each example script for h5py ''' global h5py_script_lst + h5py_script_lst = [] #fpath = __file__.replace('nxdl_to_hdf5.py','') h5py_script_lst.append(' ') @@ -1314,9 +1351,9 @@ def print_h5py_ex_start(fname): h5py_script_lst.append('import os') h5py_script_lst.append(' ') h5py_script_lst.append( - '# Note this example script was generated by nxdl_to_hdf5.py using the current \n# installed version of the NEXUS definitions ver[%s] ' % rel_ver) + f"# Note this example script was generated by nxdl_to_hdf5.py using the current \n# installed version of the NEXUS definitions ver[{rel_ver}] ") h5py_script_lst.append(' ') - h5py_script_lst.append('root = h5py.File(\'%s.h5\', \'w\')' % (fname)) + h5py_script_lst.append(f"root = h5py.File(\'{fname}.h5\', \'w\')") def print_script_close(class_nm): ''' @@ -1340,118 +1377,115 @@ def print_nxsfrmt_close(class_nm): append the proper lines to close each example script for nexusformat ''' nxsfrmt_script_lst.append('\n# Save the file') - nxsfrmt_script_lst.append('root.save(\'%s.nxs\', \'w\')\n\n' % class_nm) + nxsfrmt_script_lst.append(f"root.save(\'{class_nm}.nxs\', \'w\')\n\n") -def make_class_as_nf_file(clss_nm, dest_dir, symbol_dct={}): +def make_class_as_nf_file(class_nm, dest_dir, symbol_dct={}, rel_ver='UNKNOWN'): ''' create an hdf5 file of the application definition (class_nm) in the specified destination directory ''' - print('\texporting: [%s]' % clss_nm) + print(f"\texporting: [{class_nm}]") res = True category = def_dir = get_category() - if (not os.path.exists(dest_dir)): + if not pathlib.Path(dest_dir).exists(): os.makedirs(dest_dir) - fpath = os.path.join(dest_dir, '%s.hdf5' % clss_nm) - nf = h5py.File(fpath, 'w') + fpath = str(pathlib.PurePath(dest_dir, f'{class_nm}.h5')) + with h5py.File(fpath, 'w') as nf: - sym_dct = {} - # process SYMBOLS - for d in tables_dct['symbols'].all(): - sym_nm = d['name'] - if (True): - #sym_nm = d['name'] - val = int(d['value']) - else: - #sym_nm = d['name'] - val = default_symbol_val + sym_dct = {} + # process SYMBOLS + for d in tables_dct['symbols'].all(): + sym_nm = d['name'] + if (True): + #sym_nm = d['name'] + val = int(d['value']) + else: + #sym_nm = d['name'] + val = default_symbol_val + + sym_dct[sym_nm] = val - sym_dct[sym_nm] = val + #create the symbol string attrs in the root of the file + _string_attr(nf, sym_nm, d['doc']) - #create the symbol string attrs in the root of the file - _string_attr(nf, sym_nm, d['doc']) + for l in tables_dct['dimensions'].all(): + if 'rank' in l['attrib'].keys(): + if l['attrib']['rank'] == sym_nm: + # substitute the value + l['attrib']['rank'] = val - for l in tables_dct['dimensions'].all(): - if 'rank' in l['attrib'].keys(): - if l['attrib']['rank'] == sym_nm: - # substitute the value - l['attrib']['rank'] = val + for l in tables_dct['dim'].all(): + if 'value' in l['attrib'].keys(): + if l['attrib']['value'] == sym_nm: + #substitute the value + l['attrib']['value'] = val for l in tables_dct['dim'].all(): if 'value' in l['attrib'].keys(): - if l['attrib']['value'] == sym_nm: - #substitute the value - l['attrib']['value'] = val - - for l in tables_dct['dim'].all(): - if 'value' in l['attrib'].keys(): - val = l['attrib']['value'] - if not has_numbers(val): - # does it also contain spaces? if so then it is not a symbol - if val.find(' ') == -1: - if val not in sym_dct.keys(): - print('\t-Symbol Warning: the symbol [%s] is being used but has not been defined in the Symbols table, setting to default value of 1' % val) - sym_dct[val] = 1 - l['attrib']['value'] = 1 + val = l['attrib']['value'] + if not has_numbers(val): + # does it also contain spaces? if so then it is not a symbol + if val.find(' ') == -1: + if val not in sym_dct.keys(): + print(f"\t-Symbol Warning: the symbol [{val}] is being used but has not been defined in the Symbols table, setting to default value of 1") + sym_dct[val] = 1 + l['attrib']['value'] = 1 - print_script_start(class_nm) + print_script_start(class_nm, rel_ver) - # create GROUPs - create_groups(nf) + # create GROUPs + create_groups(nf) - # # create FIELDs - res = create_fields(nf, sym_dct, category) + # # create FIELDs + res = create_fields(nf, sym_dct, category) - # create Links - create_links(nf) + # create Links + create_links(nf) - # add the docs from fields and groups now that they exist - add_docs(nf, tables_dct['doc'].all()) + # add the docs from fields and groups now that they exist + add_docs(nf, tables_dct['doc'].all()) - h5py_script_lst.append(' ') - nxsfrmt_script_lst.append(' ') - - if(res): - # create Attributes - create_attributes(nf) - - _string_attr(nf, 'file_name', fpath.replace('\\', '/'), do_print=False) - _string_attr(nf, 'file_time', make_timestamp_now(), do_print=False) - _string_attr(nf, 'HDF5_Version', h5py.version.hdf5_version, do_print=False) - _string_attr(nf, 'h5py_version', h5py.version.version, do_print=False) - #_string_attr(nf, 'NEXUS_release_ver', rel_ver) - entry_grp, entry_nm = get_entry(nf) - #ensure the definition is correct - entry_grp['definition'][()] = get_cur_def_name() - _string_attr(nf, 'default', entry_nm) - nx_data_grp, nx_data_nm = get_NXdata_nm(nf) - if (nx_data_nm): - _string_attr(entry_grp, 'default', nx_data_nm) - dset_nm = get_NXdataset_nm(nx_data_grp) - if (dset_nm): - _string_attr(nx_data_grp, 'signal', dset_nm) - _string_attr(nx_data_grp[dset_nm], 'signal', '1') - - _dataset(nf, 'README', readme_string % (rel_ver, clss_nm), 'NX_CHAR', nx_units='NX_UNITLESS', dset={}, do_print=False) - - prune_extended_entries(nf) - - nf.close() - #print('finished exporting to [%s]' % fpath) - else: - print('Failed exporting [%s]' % fpath) - nf.close() + h5py_script_lst.append(' ') + nxsfrmt_script_lst.append(' ') + if(res): + # create Attributes + create_attributes(nf, sym_dct) + + _string_attr(nf, 'file_name', fpath.replace('\\', '/'), do_print=False) + _string_attr(nf, 'file_time', make_timestamp_now(), do_print=False) + _string_attr(nf, 'HDF5_Version', h5py.version.hdf5_version, do_print=False) + _string_attr(nf, 'h5py_version', h5py.version.version, do_print=False) + #_string_attr(nf, 'NEXUS_release_ver', rel_ver) + entry_grp, entry_nm = get_entry(nf) + if entry_grp is None: + fatal_error('File does not contain an NXentry group') + return(None) + #ensure the definition is correct + entry_grp['definition'][()] = get_cur_def_name() + _string_attr(nf, 'default', entry_nm) + nx_data_grp, nx_data_nm = get_NXdata_nm(nf) + if (nx_data_nm): + _string_attr(entry_grp, 'default', nx_data_nm) + dset_nm = get_NXdataset_nm(nx_data_grp) + if (dset_nm): + _string_attr(nx_data_grp, 'signal', dset_nm) + _string_attr(nx_data_grp[dset_nm], 'signal', '1') + + _dataset(nf, 'README', readme_string.format(rel_ver, class_nm), 'NX_CHAR', nx_units='NX_UNITLESS', dset={}, do_print=False) + + prune_extended_entries(nf) + #print('finished exporting to [{}]'.format(fpath) + else: + print(f"Failed exporting [{fpath}]") print_script_versions(class_nm) print_script_close(class_nm) - write_script_file(class_nm) - - + write_script_files(class_nm) return(res) @@ -1467,63 +1501,69 @@ def print_script_versions(fname): print_nxsfrmt_versions(fname) def print_h5py_versions(class_nm): - h5py_script_lst.append('root.attrs[\'file_name\'] = os.path.abspath(\'%s\')' % class_nm) + h5py_script_lst.append(f"root.attrs[\'file_name\'] = os.path.abspath(\'{class_nm}\')") h5py_script_lst.append('root.attrs[\'file_time\'] = datetime.datetime.now().isoformat()') h5py_script_lst.append('root.attrs[\'h5py_version\'] = h5py.version.version') h5py_script_lst.append('root.attrs[\'HDF5_Version\'] = h5py.version.hdf5_version') def print_nxsfrmt_versions(class_nm): - # nxsfrmt_script_lst.append('root.attrs[\'file_name\'] = os.path.abspath(\'%s\')' % class_nm) + # nxsfrmt_script_lst.append('root.attrs[\'file_name\'] = os.path.abspath(\'{}\')'.format(class_nm) # nxsfrmt_script_lst.append('root.attrs[\'file_time\'] = datetime.datetime.now().isoformat()') # nxsfrmt_script_lst.append('root.attrs[\'nexusformat_version\'] = nexusformat.__version__') # nxsfrmt_script_lst.append('root.attrs[\'HDF5_Version\'] = h5py.version.hdf5_version') pass -def write_script_file(class_nm): - write_h5py_script(os.path.join(os.getcwd(), '..', 'autogenerated_examples','nxdl', 'python_scripts','h5py'), class_nm, h5py_script_lst) - write_nxsfrmt_script(os.path.join(os.getcwd(), '..', 'autogenerated_examples','nxdl', 'python_scripts', 'nexusformat'), class_nm, nxsfrmt_script_lst) +def write_script_files(class_nm): + mod_name = 'h5py' + write_script(mod_name, + pathlib.PurePath(pathlib.os.getcwd(), '..', 'autogenerated_examples','nxdl', 'python_scripts', mod_name), + class_nm, + h5py_script_lst) + mod_name = 'nexusformat' + write_script(mod_name, + pathlib.PurePath(mod_name, pathlib.os.getcwd(), '..', 'autogenerated_examples','nxdl', 'python_scripts', mod_name), + class_nm, + nxsfrmt_script_lst) + +def write_script(mod_name, path, class_nm, script_lst): + ''' + Take a module name of the script type, path to output the script to, the definition class name and a list + of strings for the script and write it to disk + ''' -def write_h5py_script(path, class_nm, script_lst): - if not os.path.exists(path): - os.makedirs(path) - f = open(os.path.join(path, 'ex_h5py_%s.py' % class_nm), 'w') + if not pathlib.Path(path).exists(): + os.makedirs(path) + + with open(pathlib.PurePath(path, f"ex_{mod_name}_{pathlib.PurePath(class_nm).name}.py"), 'w') as f: for l in script_lst: f.write(l + '\n') - f.close() - -def write_nxsfrmt_script(path, class_nm, script_lst): - if not os.path.exists(path): - os.mkdir(path) - f = open(os.path.join(path, 'ex_nexusformat_%s.py' % class_nm), 'w') - for l in script_lst: - f.write(l + '\n') - f.close() def build_class_db(class_dir='base_classes', desired_class=None, defdir=None, sym_args_dct={},report_symbols_only=False): ''' build a nxdl definition into a dict - class_dir: either 'applications' or 'base_classes' - desired_class: the name of a desired class definition such as 'NXstxm', if left as None then all class definitions\ + class_dir: one of the following: ``applications``,``base_classes`` or ``contributed_definitions`` + desired_class: the name of a desired class definition such as ``NXstxm``, if left as None then all class definitions\ will be returned. defdir: if the definitions are located somewhere other than in a subdir of nexpy ''' if(defdir is None): - class_path = pkg_resources.resource_filename('nexpy', 'definitions/%s' % class_dir) + class_path = pathlib.PurePath(pkg_resources.resource_filename('nexpy', f'definitions/{class_dir}')) else: - class_path = os.path.join(defdir, class_dir) + class_path = pathlib.PurePath(defdir, class_dir) - nxdl_files = list(map(os.path.basename, glob.glob(os.path.join(class_path, '*.nxdl.xml')))) + nxdl_files = list(map(os.path.basename, glob.glob(str(pathlib.PurePath(class_path, '*.nxdl.xml'))))) dct = {} if(desired_class): - nxdl_files = [os.path.join(class_path, '%s.nxdl.xml' % desired_class)] + nxdl_files = [class_path / f"{desired_class}.nxdl.xml"] for nxdl_file in nxdl_files: + nxdl_file = str(nxdl_file) class_nm = nxdl_file.replace('.nxdl.xml', '') - if(class_nm.find(os.path.sep) > -1): - class_nm = class_nm.split(os.path.sep)[-1] - print('\nProcessing [%s]' % nxdl_file) + if(class_nm.find(pathlib.os.sep) > -1): + class_nm = class_nm.split(pathlib.os.sep)[-1] + print(f"\nProcessing [{nxdl_file.replace(pathlib.os.getcwd(),'.')}]") resp_dict, syms, docs = get_xml_paths(nxdl_file, sym_args_dct=sym_args_dct, report_symbols_only=report_symbols_only) dct[class_nm] = resp_dict return(dct, syms, docs) @@ -1536,7 +1576,23 @@ def symbol_args_to_dict(arg_lst): return(dct) -if __name__ == '__main__': +def process_nxdl(class_path, def_dir, def_subdir, sym_args_dct, rel_ver, report_symbols_only=False): + ''' + given the class name and the destination directory, parse the nxdl file and produce an hdf5 file + as well as example scripts using h5py and nexusformat + ''' + def_dir = class_path.parent.parent + if pathlib.Path(class_path).is_file(): + if class_path.name.find('.nxdl.xml') > -1: + class_nm = class_path.name.replace('.nxdl.xml', '') + build_class_db(def_subdir, desired_class=class_nm, + defdir=def_dir, sym_args_dct=sym_args_dct, + report_symbols_only=report_symbols_only) + dest_dir = pathlib.PurePath(pathlib.os.getcwd(), '..', 'autogenerated_examples', 'nxdl', def_subdir) + make_class_as_nf_file(class_nm, dest_dir, symbol_dct=sym_args_dct, rel_ver=rel_ver) + + +def main(): import argparse init_database() @@ -1560,33 +1616,44 @@ def symbol_args_to_dict(arg_lst): class_nm = None class_path = None report_symbols_only = False + if args.file: - print('\tProcess this specific definition [%s]' % args.file) + print(f"\tProcess this specific definition [{args.file}]") class_nm = args.file elif args.directory: - print('\tProcess this entire directory [%s]' % args.directory) + print(f"\tProcess this entire directory [{args.directory}]") def_subdirs = [args.directory] else: - print('\tError: neither a specific definition or directory was specified so nothing to do') - exit() + print('Processing the definitions in the following sub directories', def_subdirs) if args.symbols: - print('\tProcess using the following symbols [%s]' % args.symbols) + print(f"\tProcess using the following symbols [{args.symbols}]") sym_args_dct = symbol_args_to_dict(args.symbols) if args.nxdefdir: - print('\tUsing the following definitions base directory [%s]' % args.nxdefdir) - def_dir = args.nxdefdir + print(f"\tUsing the following definitions base directory [{args.nxdefdir}]") + def_dir = pathlib.Path(args.nxdefdir) else: - #use the definitions in the installed nexpy - def_dir = os.path.join(os.path.dirname(__file__), '..', '..', 'definitions') + #use the definitions in a neighboring directory + def_dir = pathlib.Path("This non-existing path is used for testing.") + cwd = pathlib.Path(pathlib.os.getcwd()) + for _path in ( + (cwd.parent / "definitions"), + (cwd.parent.parent / "definitions"), + ): + if _path.exists(): + def_dir = _path + break + if not def_dir.exists(): + raise FileNotFoundError("NeXus definitions not found here: " + str(def_dir)) #get the release version of the definitions - if os.path.exists(os.path.join(def_dir, 'NXDL_VERSION')): - f = open(os.path.join(def_dir, 'NXDL_VERSION'), 'r') - l = f.readlines() - f.close() - rel_ver = l[0].replace('\n','') + if (def_dir / 'NXDL_VERSION').exists(): + with open(pathlib.PurePath(def_dir, 'NXDL_VERSION'), 'r') as f: + rel_ver = f.readline().replace('\n','') + #tables_dct['config']['rel_ver'] = rel_ver + + if args.report: #just repolrt on the symbols that are defined in @@ -1597,44 +1664,31 @@ def symbol_args_to_dict(arg_lst): #only search in applications and contributed_definitions subdirectories if(class_nm): for def_subdir in def_subdirs: - class_path = os.path.join(def_dir, def_subdir, class_nm + '.nxdl.xml') - if(os.path.exists(class_path)): + class_path = pathlib.PurePath(def_dir, def_subdir, class_nm + '.nxdl.xml') + if pathlib.Path(class_path).exists(): break else: class_path = None if(class_path is None): - print('Error: the class name [%s.nxdl.xml] doesnt exist in either of the applications or contributed_definitions subdirectories' % class_nm) + raise ValueError( + f'''Error: the class name [{class_nm}.nxdl.xml] doesnt exist in ''' + '''either of the applications or contributed_definitions subdirectories''' + ) + exit() + else: + process_nxdl(class_path, def_dir, def_subdir, sym_args_dct, rel_ver, report_symbols_only=report_symbols_only) exit() files = None for def_subdir in def_subdirs: - files = sorted(os.listdir(os.path.join(def_dir, def_subdir))) - dest_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)),'..', 'autogenerated_examples', 'nxdl', def_subdir) - # FOR TESTING ##################### - #dest_dir = 'G:/github/nexusformat/exampledata/autogenerated_examples/nxdl/applications' - ################################## - if (class_nm is None): - do_exit = False - else: - do_exit = True + files = sorted((def_dir / def_subdir).iterdir()) for class_path in files: - if class_path.find('.nxdl.xml') > -1: - if class_nm is None: - class_nm = class_path.replace('.nxdl.xml','') - - # path_dct, syms, docs = build_class_db(def_subdir, desired_class=class_nm, - # defdir=def_dir, sym_args_dct=sym_args_dct, - # report_symbols_only=report_symbols_only) - build_class_db(def_subdir, desired_class=class_nm, - defdir=def_dir, sym_args_dct=sym_args_dct, - report_symbols_only=report_symbols_only) - res = make_class_as_nf_file(class_nm, dest_dir, symbol_dct=sym_args_dct) + process_nxdl(class_path, def_dir, def_subdir, sym_args_dct, rel_ver, report_symbols_only=report_symbols_only) + init_database() - init_database() - class_nm = None - if do_exit: - exit() +if __name__ == '__main__': + main()