v1.0.0-rc.172 (#82)
Build Packages / Create release (push) Successful in 16s
Build Packages / build:rugnux:aarch64 (cross) (push) Successful in 8m27s
Build Packages / build:rugnux-tgz (x86_64) (push) Successful in 9m15s
Build Packages / build:viewer-tgz:cpu (push) Successful in 10m11s
Build Packages / build:viewer-tgz:cuda (push) Successful in 12m6s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 15m44s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 16m1s
Build Packages / build:windows:nocuda (push) Successful in 17m29s
Build Packages / build:windows:cuda (push) Successful in 19m58s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 24m7s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 19m8s
Build Packages / build:rugnux:windows (push) Successful in 10m58s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 20m46s
Build Packages / Generate python client (push) Successful in 53s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 20m13s
Build Packages / Build documentation (push) Successful in 1m36s
Build Packages / build:rpm (rocky9_sls9) (push) Successful in 19m57s
Build Packages / build:rpm (rocky8) (push) Successful in 18m7s
Build Packages / build:rpm (rocky9) (push) Successful in 18m54s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 19m32s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 17m30s
Build Packages / Unit tests (push) Successful in 1h39m2s

* Fixed `jfjoch_broker` cancelling every data collection with a CUDA "out of memory" error after long operation: GPU memory no longer leaks with each collection.
* Rugnux scales a rotation sweep until the per-frame scales settle instead of for a fixed three rounds, and says so when they did not - merged intensities, and the space group, resolution cut and frame rejection read off them, change accordingly; `--scaling-iterations` is now the cap on that loop (default 100).
* Rugnux places every frame of a marCCD, SMV or miniCBF series at the spindle angle its own header states, so a series with missing frames, or with angles written modulo 360, is no longer read at the wrong geometry or refused.
* Every rotation run writes two diagnostic files beside its reflections: `<prefix>_detector.jpg`, the detector projection with the pixel mask and the detected beam-stop shadow drawn on it, and `<prefix>_plot.txt`, one row per image.

Reviewed-on: #82
Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
This commit was merged in pull request #82.
This commit is contained in:
leonarski_f authored and leonarski_f committed 2026-09-22 06:48:37 +02:00
1 parent 30b6800289
commit 6dfe065365
285 files changed
+12194 -2588

No files matched your search

+158
View File
@@ -446,6 +446,54 @@ TEST_CASE("SearchSpaceGroup names an orthorhombic screw pair on the axes it lies
}
}
// A screw on a row the sweep never recorded is not a group the data refused, it is a question
// nobody asked: the run writes the member claiming no screw because a reflection file must carry
// one group, and without this the only trace of the ambiguity is a list of names that does not say
// which axis is open. Modelled on a real hexagonal set whose 00l row lies in the spindle's blind
// cone and which is reported as P 6 against a deposited P 63.
TEST_CASE("SearchSpaceGroup says which axis a missing row left the screw open on",
"[SearchSpaceGroup]") {
const gemmi::SpaceGroup& sg = gemmi::get_spacegroup_by_name("P 21 21 21");
const auto merged = GenerateMergedReflectionsForSpaceGroup(sg, 14);
SearchSpaceGroupOptions opt;
opt.merge_friedel = true;
opt.lattice_system = gemmi::CrystalSystem::Orthorhombic;
SECTION("every row measured - nothing is open") {
const auto result = SearchSpaceGroup(merged, opt);
INFO(SearchSpaceGroupResultToText(result));
REQUIRE(result.best_space_group.has_value());
CHECK(result.best_space_group->xhm() == "P 21 21 21");
CHECK(result.undetermined_screws.empty());
}
SECTION("the 00l row removed - the c screw is undetermined") {
std::vector<MergedReflection> without_00l;
for (const auto& r : merged)
if (r.h != 0 || r.k != 0)
without_00l.push_back(r);
const auto result = SearchSpaceGroup(without_00l, opt);
INFO(SearchSpaceGroupResultToText(result));
REQUIRE(result.best_space_group.has_value());
REQUIRE(result.undetermined_screws.size() == 1);
CHECK(result.undetermined_screws[0].axis == 'c');
CHECK(result.undetermined_screws[0].row_label == "00l");
CHECK(result.undetermined_screws[0].n_observed == 0);
// The a and b screws were measured and are unaffected: what the missing row costs is the
// third condition, not the two the data still carry.
CHECK(result.best_space_group->operations().is_systematically_absent({{1, 0, 0}}));
CHECK(result.best_space_group->operations().is_systematically_absent({{0, 1, 0}}));
// ...and the group the c row would have decided between is offered, not silently dropped.
bool offers_a_group_without_the_c_screw = false;
for (const auto& alt : result.alternatives)
if (!alt.operations().is_systematically_absent({{0, 0, 1}}))
offers_a_group_without_the_c_screw = true;
CHECK((offers_a_group_without_the_c_screw
|| !result.best_space_group->operations().is_systematically_absent({{0, 0, 1}})));
}
}
// The centring half of the same widening. A, B and C centring on one orthorhombic cell are three
// different lattices, and only C is a reference setting, so an A-centred crystal used to have its
// centring refused (its absent class is not the one C predicts) and came out primitive. The
@@ -499,6 +547,116 @@ TEST_CASE("SearchSpaceGroup does not promote triclinic data on a pseudo-orthorho
CHECK(result.point_group_order == 1);
}
// A screw zone is a handful of axial reflections and its evidence is a SUM over them, so it is
// decided by its largest member. Measured on a monoclinic crystal whose eight absent 0k0 are dead in
// every run: between two scaling passes that differed only in which weak frames were rejected, ONE
// of the eight moved from 14 +- 9 to 99 +- 10 (its two half-set merges reading 198 and 2.5, so it
// was never measured to the precision its sigma claimed) while the other seven did not move at all -
// and the zone went from 30.1 nats to 17.1 and lost the 2(1) under a bound of 20. Trimming the
// largest member and rescaling for the trim makes the two passes agree.
TEST_CASE("A screw zone's evidence does not hang on its largest absence", "[SearchSpaceGroup]") {
// Seven reflections at a hundredth of their row, and one that moved between the two passes.
const double dead_seven = 7 * 0.01;
const double before = ScrewZoneEvidence(TrimmedZoneSum(dead_seven + 0.03, 0.03, 8), 8);
const double after = ScrewZoneEvidence(TrimmedZoneSum(dead_seven + 0.39, 0.39, 8), 8);
CHECK(before == Catch::Approx(after).margin(0.01)); // the same seven reflections, the same verdict
CHECK(after > 20.0); // and the screw survives the move
// Untrimmed, that one reflection is the whole difference and it crosses the bound.
CHECK(ScrewZoneEvidence(dead_seven + 0.03, 8) > 20.0);
CHECK(ScrewZoneEvidence(dead_seven + 0.39, 8) < 20.0);
// Only ONE member is trimmed, whatever the zone holds: a zone with two strong absences is not a
// zone with a bad reflection in it, it is a zone that is not extinct.
CHECK(ScrewZoneEvidence(TrimmedZoneSum(dead_seven + 0.39 + 0.39, 0.39, 8), 8) < 20.0);
// On a uniform zone the rescale under-states rather than over-states - the safe direction.
CHECK(ScrewZoneEvidence(TrimmedZoneSum(8 * 0.01, 0.01, 8), 8) <
ScrewZoneEvidence(8 * 0.01, 8));
// A class that merged non-positive throughout is unchanged: sum and max are both zero, so the
// floor in ScrewZoneEvidence is what answers, exactly as before.
CHECK(TrimmedZoneSum(0.0, 0.0, 8) == 0.0);
}
// Screw ORDERS on one axial row are nested: 6_1 extinguishes l != 6n and 6_2/6_4 extinguish
// l != 3n, so 6_1's absent class is 6_2's plus the l = 3n that are not 6n, and the whole of the
// evidence between the two lies in that difference. Trimming the zone's largest member defends
// against one badly-measured reflection, but where the difference class holds the strongest
// reflection on the row it trimmed away the only datum that refutes 6_1 - which then read the row
// as dead, won on its two extra absences, and used the inflated evidence to excuse the very
// violation it had discarded. A member that is both flagged PRESENT and standing at its row's own
// mean is not an outlier, so it is not trimmed. Measured on a hexagonal crystal: nine absences at
// 50.6 nats with one violation beat seven at 43.3 with none, and read 6.8 once the violation - at
// 1.94 of its row - stayed in. The two sections here are the two sides of that bound.
TEST_CASE("SearchSpaceGroup does not trim away the reflection that refutes a screw order",
"[SearchSpaceGroup]") {
SearchSpaceGroupOptions opt;
opt.merge_friedel = true;
SECTION("an absence at its row's own strength decides against the order that claims it") {
const gemmi::SpaceGroup& sg = gemmi::get_spacegroup_by_name("P 64");
auto merged = GenerateMergedReflectionsForSpaceGroup(sg, 12);
// The 00l row as such a crystal records it: l = 3n present, everything else dead, and one
// l = 3n that is NOT 6n - the class 6_1 has to call absent and 6_4 does not - by far the
// strongest reflection on the row.
int on_row = 0;
for (auto& r : merged) {
if (r.h != 0 || r.k != 0)
continue;
const int l = std::abs(r.l);
++on_row;
if (l % 3 != 0) r.I = 0.0f; // extinguished by the 3n condition, in both candidates
else if (l % 6 == 0) r.I = 300.0f; // the control class 6_1 keeps for itself
else r.I = (l == 9) ? 4000.0f : 5.0f;
}
REQUIRE(on_row >= 8);
const auto result = SearchSpaceGroup(merged, opt);
INFO(SearchSpaceGroupResultToText(result));
REQUIRE(result.best_space_group.has_value());
std::vector<std::string> accepted{result.best_space_group->short_name()};
for (const auto& alt : result.alternatives)
accepted.push_back(alt.short_name());
// P6_2 and P6_4 are enantiomorphs and indistinguishable from intensities; P6_1/P6_5 are a
// different claim and must not be what comes out.
CHECK(std::find(accepted.begin(), accepted.end(), "P64") != accepted.end());
CHECK(std::find(accepted.begin(), accepted.end(), "P61") == accepted.end());
CHECK(std::find(accepted.begin(), accepted.end(), "P65") == accepted.end());
}
SECTION("one weak absence that moved is still an outlier, and the screw survives it") {
// The other side of the bound, and the case the trim was built for: a genuine 2_1 whose
// 0k0-odd class is dead but for one reflection at a third of its row, measured with a sigma
// that makes it read present. Trimmable as before - it is nowhere near the row's strength -
// and losing that would cost a real screw.
const gemmi::SpaceGroup& sg = gemmi::get_spacegroup_by_name("P 1 21 1");
auto merged = GenerateMergedReflectionsForSpaceGroup(sg, 18);
const gemmi::GroupOps gops = sg.operations();
int absent = 0;
float row_strength = 0.0f;
for (const auto& r : merged)
if (r.h == 0 && r.l == 0 && !gops.is_systematically_absent(gemmi::Op::Miller{{r.h, r.k, r.l}}))
row_strength = std::max(row_strength, r.I);
for (auto& r : merged) {
if (r.h != 0 || r.l != 0)
continue;
if (!gops.is_systematically_absent(gemmi::Op::Miller{{r.h, r.k, r.l}}))
continue;
++absent;
r.I = absent == 1 ? 0.3f * row_strength : 0.0f;
r.sigma = 0.3f;
}
REQUIRE(absent >= 6);
const auto result = SearchSpaceGroup(merged, opt);
INFO(SearchSpaceGroupResultToText(result));
REQUIRE(result.best_space_group.has_value());
CHECK(result.best_space_group->short_name() == "P21");
}
}
// A zone whose predicted absences were never measurable must not outscore a zone that is genuinely
// dead. sum_u is a sum of max(0, E^2)/row_mean, so it is EXACTLY zero when every absent reflection in
// the zone merged non-positive - and the Beta tail then diverges, worth ~690 nats per reflection. That