Skip to content

Add NXstress smoke-test demo script#5

Draft
Copilot wants to merge 4 commits into
EWM12482_NeXus_prototypefrom
copilot/ewm12482-implement-smoke-test-script
Draft

Add NXstress smoke-test demo script#5
Copilot wants to merge 4 commits into
EWM12482_NeXus_prototypefrom
copilot/ewm12482-implement-smoke-test-script

Conversation

Copy link
Copy Markdown

Copilot AI commented May 1, 2026

Summary

Implements the "by hand" smoke-test script requested in the issue, demonstrating the full feature set of the new NXstress I/O implementation.

Changes

New file: tests/scripts/cis_tests/NXstress_demo_script.py

A standalone script (ignored by pytest per the directory's README.rst) that walks through:

  1. Load – opens tests/data/3393_PWHT-TD.h5 into a HidraWorkspace via HidraProjectFile.

  2. Fit – calls generate_PeakCollection_from_workspace (from tests/util/peak_collection_helpers.py) with a fit_dic whose peak_label values follow the peak_tag convention required by NXstress._parse_peak_tag:

    • "Fe 311" for the first peak (2θ range 87.6 – 91.6°, d₀ = 1.08 Å)
    • "Fe 222" for the second peak (2θ range 93.5 – 95.9°, d₀ = 1.03 Å)

    These labels match the hklPhase log stored in the data file (b'Fe 311, Fe 222').

  3. Write – writes the workspace and fitted list[PeakCollection] to NXstress_demo_output.nxs using NXstress as a context manager.

  4. Read back – re-opens the NXstress file and performs a brief round-trip consistency check (sub-run count and peak-collection count).

Modified file: tests/util/peak_collection_helpers.py

Added the two imports that generate_PeakCollection_from_workspace already uses but were missing from the module:

from pyrs.core.workspaces import HidraWorkspace
from pyrs.peaks import FitEngineFactory as PeakFitEngineFactory  # type: ignore

Usage

python tests/scripts/cis_tests/NXstress_demo_script.py

Requires a full PyRS environment (mantid, scipy, nexusformat, etc.). Output NXstress file is written to the current working directory as NXstress_demo_output.nxs.

ekapadi and others added 4 commits March 11, 2026 14:55
  Please run `pixi run build-dev-docs` and then see:
    `docs/_build/developer/design/nexus/IO_prototype.html`
    (built from: `docs/developer/source/design/nexus/IO_prototype.rst`).
Copilot finished work on behalf of ekapadi May 1, 2026 10:31
Copilot AI requested a review from ekapadi May 1, 2026 10:31
@ekapadi ekapadi force-pushed the EWM12482_NeXus_prototype branch 2 times, most recently from b4a2257 to 4cab5d9 Compare May 11, 2026 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants