rugnux: write the refined geometry as <prefix>_XDS.INP

A rotation run now writes the geometry it integrated at as an XDS input
beside the report: ORGX/ORGY (the PONI, 1-based), DETECTOR_DISTANCE, the
detector axes carrying the tilt, wavelength, the rotation axis the run
integrated at (ProcessResult::used_rotation_axis, after any sign rescue),
oscillation (with an adopted rotation scale), starting angle/frame, data
range, NX/NY/QX/QY, OVERLOAD, sensor thickness, space group and cell (left
commented where the group is not in its number's reference setting),
FRIEDEL'S_LAW per -A and the merged resolution range. HDF5 inputs get the
master file as an x_??????.h5 template and a LIB= line to point at the
reader plugin; a CBF series gets its ???? template and its own frame
numbers. The report names the file (XDS_INPUT=). Conventions per Kabsch
(2010) Acta Cryst. D66, 125-132.

The rotation axis goes out negated: rugnux turns the crystal by -phi about
its axis (IndexAndRefine), XDS by +phi about ROTATION_AXIS. Checked with
XDS IDXREF on two exports (one CBF, one HDF5 via durin): the negated axis
indexes 99.5% / 14% of the spots, rugnux's own sign 37% / 0.04%. On the
CBF set XDS then ran DEFPIX/INTEGRATE/CORRECT from the file unchanged
(apart from the job list): 99.8% complete, ISa 23.3, direct beam within
0.15 px and cell within 0.07 A of rugnux's.

Output only; no result changes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SVmAWnzCmRKAXVUCdc4iNi
This commit is contained in:
leonarski_fandClaude Opus 5.5 committed 2026-10-09 18:36:25 +02:00
1 parent 2632b77eb5
commit 244f3c0f9d
11 files changed
+266 -1

No files matched your search

+34
View File
@@ -7,6 +7,7 @@
#include "../image_analysis/scale_merge/Merge.h"
#include "../reader/JFJochHDF5Reader.h"
#include "../rugnux/ResultReport.h"
#include "../rugnux/XDSInput.h"
#include "../common/CUDAWrapper.h"
#include "../writer/FileWriter.h"
@@ -1263,3 +1264,36 @@ TEST_CASE("ResultReport_OverloadsAndOverlaps", "[Diagnostics]") {
CHECK(text.find("Attenuate the beam") != std::string::npos);
CHECK(text.find("Move the detector back") != std::string::npos);
}
TEST_CASE("XDSInput_Render", "[Diagnostics]") {
DiffractionExperiment x(DetJF(1));
x.BeamX_pxl(500.0f).BeamY_pxl(400.0f).DetectorDistance_mm(100.0f);
x.Goniometer(GoniometerAxis("omega", 10.0f, 0.1f, Coord(1, 0, 0), {}));
ProcessResult result;
// The refined geometry, not the file's, goes out - 1-based, untilted here.
result.used_beam_x_pxl = 510.0f;
result.used_beam_y_pxl = 395.5f;
result.used_distance_mm = 120.0f;
result.used_rotation_axis = Coord(-1, 0, 0);
const auto text = RenderXDSInput("/data/x_master.h5", x, result, 0, 900);
CHECK(text.find("\nORGX= 511.00 ORGY= 396.50\n") != std::string::npos);
CHECK(text.find("\nDETECTOR_DISTANCE= 120.000\n") != std::string::npos);
CHECK(text.find("\nDIRECTION_OF_DETECTOR_X-AXIS= 1.000000 0.000000 0.000000\n") != std::string::npos);
// XDS turns the crystal the other way about the axis it is given.
CHECK(text.find("\nROTATION_AXIS= 1.000000 0.000000 0.000000\n") != std::string::npos);
CHECK(text.find("\nNAME_TEMPLATE_OF_DATA_FRAMES= /data/x_??????.h5\n") != std::string::npos);
CHECK(text.find("\nDATA_RANGE= 1 900\n") != std::string::npos);
CHECK(text.find("\nSTARTING_ANGLE= 10.0000\n") != std::string::npos);
CHECK(text.find("\nOSCILLATION_RANGE= 0.100000\n") != std::string::npos);
}
TEST_CASE("XDSInput_CBFTemplate", "[Diagnostics]") {
DiffractionExperiment x(DetJF(1));
x.Goniometer(GoniometerAxis("omega", 0.0f, 0.1f, Coord(1, 0, 0), {}));
const auto text = RenderXDSInput("/data/run_2_0101.cbf", x, ProcessResult{}, 0, 50);
CHECK(text.find("\nNAME_TEMPLATE_OF_DATA_FRAMES= /data/run_2_????.cbf\n") != std::string::npos);
CHECK(text.find("\nDATA_RANGE= 101 150\n") != std::string::npos);
CHECK(text.find("\nSTARTING_FRAME= 101\n") != std::string::npos);
CHECK(text.find("\nDETECTOR= PILATUS") != std::string::npos);
}