Repository navigation
Description
Summary
#1141 makes stress/strain analysis reject a project file without a known calibration (user decision, 2026-11-25: "option 2"). The rejection is in StrainField(filename=...) itself, not only in the Strain/Stress viewer. The project files the tests use were all reduced before #1053: their instrument/calibration group is empty. So every stress/strain test that loads one would be refused.
This issue decides which data the tests actually need, and replaces them with files reduced today. It blocks #1141.
Affected today
About 60 tests in these files load project files for stress/strain:
| Test file | Tests |
|---|---|
tests/integration/test_fields_from_files.py |
17 |
tests/integration/test_texture_fitting_model.py |
10 |
tests/integration/test_nxstress_viewer_roundtrip.py |
10 |
tests/integration/test_write_stress_csv.py |
9 |
tests/integration/test_strainstress_direction.py |
9 |
tests/integration/test_d0_grid.py |
6 |
tests/integration/test_fields.py |
6 |
tests/ui/test_stress_strain_viewer.py |
6 |
tests/integration/test_texture_fit_layouts.py |
1 |
Project files referenced (count of references):
| File | Refs | Raw NeXus in tests/data |
|---|---|---|
HB2B_1320.h5 |
34 | no |
HB2B_1327.h5 |
10 | no |
HB2B_1328.h5 |
7 | no |
HB2B_1331.h5, HB2B_1332.h5 |
3 each | no |
HB2B_1628.h5 |
2 | no |
HB2B_1599.h5, HB2B_1599_texture.h5, HB2B_1423.h5, HB2B_1060_first3_subruns.h5, HB2B_999.h5, HB2B_1327_2.h5, HB2B_1320_direction_22.h5 |
1 each | no |
HB2B_1017.h5 |
1 | yes (HB2B_1017.nxs.h5) |
The unit tests in test_fields.py and test_stress_facade.py build data in memory and are not affected.
To decide
- Which runs the tests need. For each test: what property of the data it relies on (a strain grid, three directions, a d₀ grid, texture, a specific peak). Several files may be replaceable by fewer runs, or by in-memory data where the test only needs structure.
- Re-reduce with no calibration file. A file reduced today records the nominal calibration with its hash (
source: "none", written since Calibration content hash: a calibration identifies itself and owns the "same calibration?" check #1141), which stress/strain analysis accepts. Needs the raw NeXus from the/HFIRarchive, and a machine that has it. - Refit the peaks with the windows and profiles the tests expect: the current files carry fitted peaks.
- Expected values. Run the tests against the new files. Values that change must be checked as right, not accepted as they come: d-spacings may move with reduction changes since these files were made (Make build_instrument delegate to DetectorModel (single source for detector geometry) #1011 detector model, float64 fixes, binning), and with the nominal wavelength, which is not physical. Regenerate the gold CSVs where needed.
- Size. Keep the new binary data small (subsets of sub-runs where a test needs only a few).
Suggested first step: re-reduce HB2B_1320 (34 references) without a calibration, refit it, and run its tests. This shows whether the existing expected values survive or must be regenerated, and sizes the rest.
Constraints
- Test data and expected values feed checks of scientific results, so every changed expected value needs the maintainer's review.
- No invented provenance: the existing files must not be stamped with a calibration record they were not reduced with.
Blocks: #1141. Refs #1053, #1146, #1147.
Known cause of changed expected values: HB2B_1017.h5 predates the time-average fix (found 2026-11-25)
tests/data/HB2B_1017.h5 was added on 2019-11-12, before PR #196 (2019-12-05) fixed #193 ("Samples logs do not filter properly into project file": logs averaged across scan-index boundaries). Its arm angles are wrong for sub-runs 1 and 2:
| Sub-run | Raw NeXus 2theta during the sub-run |
Raw set point | Old HB2B_1017.h5 (2theta / set point) |
Today's conversion |
|---|---|---|---|---|
| 1 | 69.995° | 70 | 83.33° / 75 | 70.0° |
| 2 | 80.000° | 80 | 88.75° / 88.75 | 80.0° |
| 3 | 97.502° | 97.5 | 97.50° / 97.5 | 97.5° |
The old values mix neighbouring positions: 75 lies between the start position (100°) and 70°, and 88.75 = (80 + 97.5)/2. Today's conversion matches the raw log. So tests built on HB2B_1017.h5 check numbers from buggy conversion, and re-reduced data will differ for this known reason.
The other stress/strain project files (1320, 1327, 1328, 1331, 1332, 1628, 1599, 1423, 1060) were added in 2020, after #196. They should not have this error, but may differ from a fresh conversion for other reasons: the 2024 time-averaging changes (#872, #880), and reduction changes since. Check those case by case.
A re-reduction of run 1017 already exists for the GUI tests of #1141: tests/data/HB2B_1017_reduced.h5, made by tests/scripts/make_HB2B_1017_reduced.py. It has no calibration file (nominal record), the correct arm angles, no mask, 1000 bins and no raw counts.
Done: run 1017 (2026-11-25, in PR #1163)
tests/data/HB2B_1017.h5 is regenerated in place from HB2B_1017.nxs.h5 by tests/scripts/make_HB2B_1017.py. It now has:
- the correct arm angles;
- today's pixel size (the old file recorded 0.3 mm; PyRS uses 0.3/1024 m);
- the nominal calibration record;
- the raw counts.
HB2B_1017_NoMask_Gold.h5 is regenerated with it; HB2B_1017_Pixels_Gold.h5 is unchanged.
All of HB2B_1017's users pass: the powder-pattern gold tests, reduction, texture and peak fitting, and the GUI suite. The checks and the reasons are in docs/ground_truths.md on that branch. The runs whose raw data are only on /HFIR remain here.
Activity
#1141/#1148: regenerate HB2B_1017.h5 from the raw run (correct arm an…