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

I19-2 CLI bugfixes #193

Merged
merged 13 commits into from
Feb 21, 2024
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions docs/api_beamlines.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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



Expand Down
16 changes: 15 additions & 1 deletion docs/beamlines.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 ---------------------------------------

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ dev = [
"pytest-cov",
"pytest-random-order",
"sphinx-autobuild",
"autodoc_pydantic<2.0.0", # Needed for pydantic docs
"bump2version",
"pipdeptree",
"ipython",
Expand Down
1 change: 1 addition & 0 deletions requirements_doc.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 10 additions & 0 deletions src/nexgen/beamlines/I19_2_nxs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
19 changes: 16 additions & 3 deletions src/nexgen/command_line/I19_2_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,15 @@
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,
Expand All @@ -131,7 +132,12 @@
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(

Check warning on line 135 in src/nexgen/command_line/I19_2_cli.py

View check run for this annotation

Codecov / codecov/patch

src/nexgen/command_line/I19_2_cli.py#L135

Added line #L135 was not covered by tests
"--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(
Expand Down Expand Up @@ -205,6 +211,13 @@
"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(

Check warning on line 214 in src/nexgen/command_line/I19_2_cli.py

View check run for this annotation

Codecov / codecov/patch

src/nexgen/command_line/I19_2_cli.py#L214

Added line #L214 was not covered by tests
"-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",
Expand Down
Loading