Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

29 generate contributed defs #30

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
# Microsoft VSCode
settings.json
launch.json

#pyCharm
.idea
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
167 changes: 127 additions & 40 deletions autogenerated_examples/nxdl/python_scripts/h5py/ex_h5py_NXcanSAS.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -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()


Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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
Expand Down
Loading