From 8ab069f4257d25aa8781c178c1528db45abef598 Mon Sep 17 00:00:00 2001 From: Noemi Frisina Date: Tue, 20 Feb 2024 18:04:48 +0000 Subject: [PATCH 01/13] CLI fixes for I19 --- src/nexgen/command_line/I19_2_cli.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/nexgen/command_line/I19_2_cli.py b/src/nexgen/command_line/I19_2_cli.py index 948e13f0..88ec63e1 100644 --- a/src/nexgen/command_line/I19_2_cli.py +++ b/src/nexgen/command_line/I19_2_cli.py @@ -111,6 +111,7 @@ def nexgen_writer(args): stop_time=datetime.strptime(args.stop, "%Y-%m-%dT%H:%M:%SZ") if args.stop else None, + n_imgs=args.num_imgs if args.num_imgs else None, scan_axis=args.scan_axis if args.scan_axis else None, gonio_pos=axes_list if args.axes else None, det_pos=det_list if args.det_axes else None, @@ -205,6 +206,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", From 13bbd8109756d50c947998c4c88b19b6aa20ce4c Mon Sep 17 00:00:00 2001 From: Noemi Frisina Date: Tue, 20 Feb 2024 18:07:43 +0000 Subject: [PATCH 02/13] Set default for scan axis --- src/nexgen/command_line/I19_2_cli.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/nexgen/command_line/I19_2_cli.py b/src/nexgen/command_line/I19_2_cli.py index 88ec63e1..88ed5cfd 100644 --- a/src/nexgen/command_line/I19_2_cli.py +++ b/src/nexgen/command_line/I19_2_cli.py @@ -112,7 +112,7 @@ def nexgen_writer(args): if args.stop else None, n_imgs=args.num_imgs if args.num_imgs else None, - scan_axis=args.scan_axis if args.scan_axis 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, @@ -132,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( From 2f82a7c517c106ef802f40a2818cb03f2e746515 Mon Sep 17 00:00:00 2001 From: Noemi Frisina Date: Tue, 20 Feb 2024 18:11:21 +0000 Subject: [PATCH 03/13] Set beam_center to zero if not passed --- src/nexgen/command_line/I19_2_cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nexgen/command_line/I19_2_cli.py b/src/nexgen/command_line/I19_2_cli.py index 88ed5cfd..888df0b3 100644 --- a/src/nexgen/command_line/I19_2_cli.py +++ b/src/nexgen/command_line/I19_2_cli.py @@ -104,7 +104,7 @@ 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, From 389aa48805aeab28c66828389995170080f3dc9f Mon Sep 17 00:00:00 2001 From: Noemi Frisina Date: Tue, 20 Feb 2024 18:12:39 +0000 Subject: [PATCH 04/13] Update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 From ce99d2aaa283df8608fb1e895b94ab93bdf4247a Mon Sep 17 00:00:00 2001 From: Noemi Frisina Date: Wed, 21 Feb 2024 10:27:08 +0000 Subject: [PATCH 05/13] Try to get pydantic into docs --- docs/api_beamlines.rst | 2 +- docs/conf.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/api_beamlines.rst b/docs/api_beamlines.rst index ec15540b..5fa1dd3a 100644 --- a/docs/api_beamlines.rst +++ b/docs/api_beamlines.rst @@ -41,7 +41,7 @@ Some useful type definitions to use with these methods: -.. autoclass:: nexgen.beamlines.I19_2_nxs.CollectionParameters +.. pydantic:: nexgen.beamlines.I19_2_nxs.CollectionParameters :members: diff --git a/docs/conf.py b/docs/conf.py index 9d237ce0..654ef0d6 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -38,6 +38,7 @@ "sphinx.ext.viewcode", "sphinx_rtd_theme", "sphinx.ext.napoleon", + "sphinx-pydantic", ] # Add any paths that contain templates here, relative to this directory. From 75c8450d4e3152bbf53094aab112bd944f28b3c5 Mon Sep 17 00:00:00 2001 From: Noemi Frisina Date: Wed, 21 Feb 2024 10:38:32 +0000 Subject: [PATCH 06/13] Try again, hopefully better --- docs/api_beamlines.rst | 2 +- docs/conf.py | 2 +- pyproject.toml | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/api_beamlines.rst b/docs/api_beamlines.rst index 5fa1dd3a..46fd467d 100644 --- a/docs/api_beamlines.rst +++ b/docs/api_beamlines.rst @@ -41,7 +41,7 @@ Some useful type definitions to use with these methods: -.. pydantic:: nexgen.beamlines.I19_2_nxs.CollectionParameters +.. autopydantic_model:: nexgen.beamlines.I19_2_nxs.CollectionParameters :members: diff --git a/docs/conf.py b/docs/conf.py index 654ef0d6..9422d063 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -38,7 +38,7 @@ "sphinx.ext.viewcode", "sphinx_rtd_theme", "sphinx.ext.napoleon", - "sphinx-pydantic", + "sphinxcontrib.autodoc_pydantic", ] # Add any paths that contain templates here, relative to this directory. diff --git a/pyproject.toml b/pyproject.toml index f96eed6d..c9fac44c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,6 +39,7 @@ dev = [ "pytest-cov", "pytest-random-order", "sphinx-autobuild", + "autodoc_pydantic", # Needed for pydantic docs "bump2version", "pipdeptree", "ipython", From 76ad7abcad7438c05d60497c76df9e00f28cc82a Mon Sep 17 00:00:00 2001 From: Noemi Frisina Date: Wed, 21 Feb 2024 10:41:37 +0000 Subject: [PATCH 07/13] Pin some versions --- pyproject.toml | 2 +- requirements_doc.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c9fac44c..7eda74e5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,7 @@ dev = [ "pytest-cov", "pytest-random-order", "sphinx-autobuild", - "autodoc_pydantic", # Needed for pydantic docs + "autodoc_pydantic<2.0.0", # Needed for pydantic docs "bump2version", "pipdeptree", "ipython", diff --git a/requirements_doc.txt b/requirements_doc.txt index 009fe870..6ab0c3d4 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 From 5d0ca46abced90542eee93869ce9463000ba4529 Mon Sep 17 00:00:00 2001 From: Noemi Frisina Date: Wed, 21 Feb 2024 10:43:33 +0000 Subject: [PATCH 08/13] Fix requirements_doc typo --- requirements_doc.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_doc.txt b/requirements_doc.txt index 6ab0c3d4..909c3ea1 100644 --- a/requirements_doc.txt +++ b/requirements_doc.txt @@ -1,6 +1,6 @@ Sphinx==7.2.6 sphinx-rtd-theme==2.0.0 -autodoc-pydantic=1.9.0 +autodoc_pydantic==1.9.0 numpy==1.26.4 pint==0.23 h5py==3.10.0 From 139efe6e42608ccce46e240bf6cf2cd045689ffe Mon Sep 17 00:00:00 2001 From: Noemi Frisina Date: Wed, 21 Feb 2024 10:47:40 +0000 Subject: [PATCH 09/13] Try to show pydantic model --- docs/api_beamlines.rst | 3 ++- docs/conf.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/api_beamlines.rst b/docs/api_beamlines.rst index 46fd467d..af874d97 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 .. autopydantic_model:: nexgen.beamlines.I19_2_nxs.CollectionParameters - :members: + :model-show-config-summary: False diff --git a/docs/conf.py b/docs/conf.py index 9422d063..5cc35ebe 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -104,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 --------------------------------------- From 06c8e27499faf72fb9b693919f49beafddd78255 Mon Sep 17 00:00:00 2001 From: Noemi Frisina Date: Wed, 21 Feb 2024 10:49:58 +0000 Subject: [PATCH 10/13] Try to show pydantic model - again --- docs/beamlines.rst | 2 +- docs/conf.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/beamlines.rst b/docs/beamlines.rst index b18c9c3c..e6ebd35a 100644 --- a/docs/beamlines.rst +++ b/docs/beamlines.rst @@ -211,7 +211,7 @@ 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 SSX CLI diff --git a/docs/conf.py b/docs/conf.py index 5cc35ebe..b1bd5071 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -106,7 +106,7 @@ # -- Options for pydantic objects # autodoc_pydantic_model_show_json = True -# autodoc_pydantic_model_show_config_summary = True +autodoc_pydantic_model_show_config_summary = True # -- Options for HTMLHelp output --------------------------------------- From aa2093fb25ab4dc2e3e9b82c448dbdf154440ce0 Mon Sep 17 00:00:00 2001 From: Noemi Frisina Date: Wed, 21 Feb 2024 10:55:14 +0000 Subject: [PATCH 11/13] Add to CLI docs for I19-2 --- docs/beamlines.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/beamlines.rst b/docs/beamlines.rst index e6ebd35a..8e324f16 100644 --- a/docs/beamlines.rst +++ b/docs/beamlines.rst @@ -214,6 +214,20 @@ Manually generate a NeXus file for a dataset collected on Eiger detector using t 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 ------- From cdf2097ff11e3f5921bc8b3c4d1c1fba7eeb12a3 Mon Sep 17 00:00:00 2001 From: Noemi Frisina Date: Wed, 21 Feb 2024 10:56:19 +0000 Subject: [PATCH 12/13] Maybe if I use the correct name for the pydantic model --- docs/api_beamlines.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api_beamlines.rst b/docs/api_beamlines.rst index af874d97..7b5fd091 100644 --- a/docs/api_beamlines.rst +++ b/docs/api_beamlines.rst @@ -42,7 +42,7 @@ Some useful type definitions to use with these methods: Collection parameters schema for I19-2 -.. autopydantic_model:: nexgen.beamlines.I19_2_nxs.CollectionParameters +.. autopydantic_model:: nexgen.beamlines.I19_2_nxs.CollectionParams :model-show-config-summary: False From 4fe535bbbe2dded49e3564acc28d3b7d4d74557e Mon Sep 17 00:00:00 2001 From: Noemi Frisina Date: Wed, 21 Feb 2024 11:06:19 +0000 Subject: [PATCH 13/13] Update docs --- src/nexgen/beamlines/I19_2_nxs.py | 10 ++++++++++ 1 file changed, 10 insertions(+) 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(