diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e68d413..05bf6cbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,11 @@ -## 0.#.# +## 0.8.5 ### Fixed - Rotation axis vector for Electron Diffraction. +- I19 CLI arguments, added number of images, minor bug fixes. ## 0.8.4 diff --git a/docs/api_beamlines.rst b/docs/api_beamlines.rst index ec15540b..7b5fd091 100644 --- a/docs/api_beamlines.rst +++ b/docs/api_beamlines.rst @@ -40,9 +40,10 @@ Some useful type definitions to use with these methods: :members: +Collection parameters schema for I19-2 -.. autoclass:: nexgen.beamlines.I19_2_nxs.CollectionParameters - :members: +.. autopydantic_model:: nexgen.beamlines.I19_2_nxs.CollectionParams + :model-show-config-summary: False diff --git a/docs/beamlines.rst b/docs/beamlines.rst index b18c9c3c..8e324f16 100644 --- a/docs/beamlines.rst +++ b/docs/beamlines.rst @@ -211,7 +211,21 @@ Manually generate a NeXus file for a dataset collected on Eiger detector using t .. code-block:: console - I19_nexus 2 Expt1_00_meta.h5 eiger 0.02 -tr 100 + I19_nexus 2 Expt1_00_meta.h5 eiger 0.02 -tr 100 --use-meta + + +If the `--use-meta` flag is not passed, the writer will not look up the axes/beam_center/wavelength information in the meta file. +This will then need to be passed from the commang line: + +.. code-block:: console + + I19_nexus gen Expt1_00_meta.h5 eiger 0.095 -wl 0.485 -bc 989.8 1419 --det-axes det_z --det-start 140 --axes omega phi --ax-start -90 -130.5 --ax-inc 0 0.1 -tr 5 -n 75 + + +.. note:: + Only the goniometer/detector axes that have values and increments different from 0 need to be passed to the command line. + If --scan-axis is not passed, it will default to 'phi'. + If -bc (beam_center) is not passed, in the absence of a meta file it will default to (0, 0) SSX CLI diff --git a/docs/conf.py b/docs/conf.py index 9d237ce0..b1bd5071 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -38,6 +38,7 @@ "sphinx.ext.viewcode", "sphinx_rtd_theme", "sphinx.ext.napoleon", + "sphinxcontrib.autodoc_pydantic", ] # Add any paths that contain templates here, relative to this directory. @@ -103,6 +104,9 @@ # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ["_static"] +# -- Options for pydantic objects +# autodoc_pydantic_model_show_json = True +autodoc_pydantic_model_show_config_summary = True # -- Options for HTMLHelp output --------------------------------------- diff --git a/pyproject.toml b/pyproject.toml index f96eed6d..7eda74e5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,6 +39,7 @@ dev = [ "pytest-cov", "pytest-random-order", "sphinx-autobuild", + "autodoc_pydantic<2.0.0", # Needed for pydantic docs "bump2version", "pipdeptree", "ipython", diff --git a/requirements_doc.txt b/requirements_doc.txt index 009fe870..909c3ea1 100644 --- a/requirements_doc.txt +++ b/requirements_doc.txt @@ -1,5 +1,6 @@ Sphinx==7.2.6 sphinx-rtd-theme==2.0.0 +autodoc_pydantic==1.9.0 numpy==1.26.4 pint==0.23 h5py==3.10.0 diff --git a/src/nexgen/beamlines/I19_2_nxs.py b/src/nexgen/beamlines/I19_2_nxs.py index 2779d66a..31f16e1b 100644 --- a/src/nexgen/beamlines/I19_2_nxs.py +++ b/src/nexgen/beamlines/I19_2_nxs.py @@ -66,8 +66,18 @@ class ExperimentTypeError(Exception): # Useful axis definitions axes = namedtuple("axes", ("id", "start", "inc", "end"), defaults=(None, 0.0, 0.0, 0.0)) axes.__doc__ = """Goniometer axis name, start and end position, increment.""" +axes.id.__doc__ = "Axis name." +axes.start.__doc__ = "Axis start position. Defaults fo 0.0." +axes.inc.__doc__ = ( + "Axis increment value. Defaults fo 0.0. Only needed for the scan axis." +) +axes.end.__doc__ = ( + "Axis end position. Defaults fo 0.0. Only really needed for Tristan collections." +) det_axes = namedtuple("det_axes", ("id", "start"), defaults=(None, 0.0)) det_axes.__doc__ = """Detector axis name and position.""" +det_axes.id.__doc__ = "Axis name." +det_axes.start.__doc__ = "Axis position. Defaults to 0.0." def tristan_writer( diff --git a/src/nexgen/command_line/I19_2_cli.py b/src/nexgen/command_line/I19_2_cli.py index 948e13f0..888df0b3 100644 --- a/src/nexgen/command_line/I19_2_cli.py +++ b/src/nexgen/command_line/I19_2_cli.py @@ -104,14 +104,15 @@ def nexgen_writer(args): exposure_time=args.exp_time, transmission=args.transmission if args.transmission else None, wavelength=args.wavelength if args.wavelength else None, - beam_center=args.beam_center if args.beam_center else None, + beam_center=args.beam_center if args.beam_center else (0, 0), start_time=datetime.strptime(args.start, "%Y-%m-%dT%H:%M:%SZ") if args.start else None, stop_time=datetime.strptime(args.stop, "%Y-%m-%dT%H:%M:%SZ") if args.stop else None, - scan_axis=args.scan_axis if args.scan_axis else None, + n_imgs=args.num_imgs if args.num_imgs else None, + scan_axis=args.scan_axis if args.scan_axis else "phi", gonio_pos=axes_list if args.axes else None, det_pos=det_list if args.det_axes else None, outdir=args.output if args.output else None, @@ -131,7 +132,12 @@ def nexgen_writer(args): gonioAx_parser.add_argument( "--ax-end", type=float, nargs="+", help="Eventual axes ends." ) -gonioAx_parser.add_argument("--scan-axis", type=str, help="Identify scan axis.") +gonioAx_parser.add_argument( + "--scan-axis", + type=str, + default="phi", + help="Identify scan axis. If not specified, defaults to phi.", +) detAx_parser = argparse.ArgumentParser(add_help=False) detAx_parser.add_argument( @@ -205,6 +211,13 @@ def nexgen_writer(args): "detector_name", type=str, help="Detector currently in use on beamline." ) parser_nex.add_argument("exp_time", type=float, help="Exposure time, in s.") +parser_nex.add_argument( + "-n", + "--num_imgs", + type=int, + default=None, + help="Number of frames collected. Necessary for eiger if not using meta file.", +) parser_nex.add_argument( "-tr", "--transmission",