rugnux: --report-resolution, a second statistics table at a reference range

Comparing a run with another program's table has meant running rugnux AT that
program's resolution range (--scaling-high-resolution), which is a different
run: the range moves the cut, the space-group decision and everything after
them, so the comparison buys itself a different answer. --report-resolution
<dmin>[,<dmax>] instead leaves the run alone and adds a second table to
section 3 of the report - the REFRES_* keys and a shell table - binned from the
same merged reflections over the range given, with the completeness
denominator enumerated over that range and the shells in equal steps of 1/d^2
so they read row for row against a CORRECT.LP at the same range. Report-only:
the merged files and every decision are byte-identical with and without it.

The table holds only what the run kept. Where the reference range is finer
than the run's own limit, the shells past it are printed as not merged (with
their possible count) rather than as zeros, REFRES_SHELLS_PAST_LIMIT counts
them so a consumer can tell "not merged" from a measured zero, REFRES_
COMPLETENESS counts their reflections as missing, and the other overall numbers
are over the shells the run reached; nothing is read from the observations the
run judged to carry no signal. REFRES_ISA is the error model refitted on the
reflections of the table alone, in XDS's convention (rotation only; the stills
model is fitted over the whole range already).

On the rotation path the statistics block of MergeAndStats becomes a lambda
over a shell grid, called once for the run's own grid and once for the
reference one; the reference call floors every observation-level count at the
cut by group d, the rule the erase applied. The stills MergeStats takes a
declared range, whose bounds are the grid's whether or not any reflection
reaches them. Both --mode mx and --mode scale report it, the viewer's command
line echoes it, and the docs describe the keys.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
leonarski_fandClaude Fable 5.1 committed 2026-09-19 10:58:42 +02:00
1 parent 26a80caac4
commit 8a0da57941
15 files changed
+661 -267

No files matched your search

+55
View File
@@ -157,6 +157,61 @@ TEST_CASE("ResultReport_Render", "[Diagnostics]") {
!= std::string::npos);
}
// The reference-range table: REFRES_* keys beside the run's own, the shells past the run's own limit
// reported as not merged rather than as zeros, and no REFRES_ key at all when no range was given.
TEST_CASE("ResultReport_ReferenceRangeTable", "[Diagnostics]") {
DiffractionExperiment x(DetJF(1));
ProcessResult result;
result.consensus_cell = UnitCell{.a = 79.0f, .b = 79.0f, .c = 38.0f,
.alpha = 90.0f, .beta = 90.0f, .gamma = 90.0f};
result.space_group = *gemmi::find_spacegroup_by_number(96);
result.has_merge_statistics = true;
auto &own = result.merge_statistics.overall;
own.d_max = 45.0f; own.d_min = 1.6f; // the run's own limit
own.unique_reflections = 1000; own.possible_unique_reflections = 1000; own.total_observations = 5000;
own.mean_i_over_sigma = 10.0; own.r_meas = 0.1; own.cc_half = 0.99;
CHECK(RenderResultReport("prefix", "in.h5", x, result).find("REFRES_") == std::string::npos);
ScalingSettings s = x.GetScalingSettings();
s.ReportResolutionRange_A(ReportResolutionRange{1.2, 50.0});
x.ImportScalingSettings(s);
MergeStatistics rs;
auto shell = [](float d_max, float d_min, int unique, int possible, int obs) {
MergeStatisticsShell sh;
sh.d_max = d_max; sh.d_min = d_min;
sh.unique_reflections = unique; sh.possible_unique_reflections = possible; sh.total_observations = obs;
sh.mean_i_over_sigma = unique > 0 ? 8.0 : 0.0;
sh.cc_half = unique > 0 ? 0.9 : NAN;
sh.r_meas = unique > 0 ? 0.2 : NAN;
return sh;
};
rs.shells = {shell(50.0f, 2.0f, 600, 600, 3000), // within the run's own range
shell(2.0f, 1.5f, 300, 500, 1200), // the run's limit of 1.6 A falls inside
shell(1.5f, 1.2f, 0, 700, 0)}; // past it: not merged
rs.overall = shell(45.0f, 1.6f, 900, 1800, 4200);
result.reference_merge_statistics = rs;
result.reference_isa = 12.5;
const auto text = RenderResultReport("prefix", "in.h5", x, result);
CHECK(text.find("\nREFRES_RANGE= 50.000 1.200\n") != std::string::npos);
CHECK(text.find("\nREFRES_MEASURED_RANGE= 45.000 1.600\n") != std::string::npos);
CHECK(text.find("\nREFRES_SHELLS_PAST_LIMIT= 1\n") != std::string::npos);
CHECK(text.find("\nREFRES_UNIQUE_REFLECTIONS= 900\n") != std::string::npos);
CHECK(text.find("\nREFRES_COMPLETENESS= 50.0\n") != std::string::npos);
CHECK(text.find("\nREFRES_MULTIPLICITY= 4.67\n") != std::string::npos);
CHECK(text.find("\nREFRES_R_MEAS= 0.2000\n") != std::string::npos);
CHECK(text.find("\nREFRES_CC_HALF= 0.9000\n") != std::string::npos);
CHECK(text.find("\nREFRES_ISA= 12.50\n") != std::string::npos);
// The run's own keys are untouched by the second table.
CHECK(text.find("\nCOMPLETENESS= 100.0\n") != std::string::npos);
CHECK(text.find("\nINCLUDE_RESOLUTION_RANGE= 45.000 1.600\n") != std::string::npos);
// The shell past the limit is words, not zeros; the shell holding the limit is marked.
CHECK(text.find("1.20 past the run's own limit of 1.60 A: not merged (700 possible)") != std::string::npos);
CHECK(text.find("<- the run's own limit, 1.60 A, is inside this shell") != std::string::npos);
CHECK(text.find("the 1 shell\n") != std::string::npos);
}
TEST_CASE("ResultReport_RenderEmpty", "[Diagnostics]") {
// A clean run and a run that never looked must be distinguishable: both have a count of 0, and
// only the STATUS key separates them. This is the property a consumer relies on.