Rugnux: report further lattices in the leftover spots, and the mosaicity
Rotation, report only: once the first pass has its lattice, the spots it leaves over (ice left out) are indexed again with a fresh rotation indexer, up to three times. A lattice is kept when the leftover validation spots sit on it far more often than at a displaced spindle angle (z >= 5, the first pass's own null), and classified against the main lattice: a misoriented domain of the same cell (split crystal), one turned by 180 deg (non-merohedral twin domain), one concentrated in part of the sweep (>= 60% of its spots in 2 of 8 blocks), a related cell (volume n or 1/n) or an unrelated one. Misorientation is the minimum over the bases whose metric matches, so a lattice symmetry is not read as one. EXTRA_LATTICE_* keys, a summary row, and a MULTIPLE_LATTICES warning where domains or an unrelated lattice hold >= 10% of the non-ice spot intensity (29 of 200 battery sets in the exploration census). Its own IndexAndRefine instances and indexer: merged MTZ byte-identical on three sets; 0.2-2.5 s per run. Also MOSAICITY_DEG (median, P10, P90 over frames) - the frame-order-smoothed sigma_M the merge computes partiality from, Kabsch's sigma_M as XDS's REFLECTING_RANGE_E.S.D. - in the report. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D1G8gJVAy6gp1K5Dz3NE5C
This commit is contained in:
1 parent
74363b7219
commit
ddf718f91b
8 files changed
+514
No files matched your search
@@ -866,3 +866,89 @@ TEST_CASE("ResultReport_RotationScale", "[Diagnostics]") {
|
||||
CHECK(kept.find("\nOSCILLATION_RANGE= 0.1000\n") != std::string::npos);
|
||||
CHECK(kept.find("\nGONIOMETER_ROTATION_SCALE_SUSPECT= FALSE\n") != std::string::npos);
|
||||
}
|
||||
|
||||
TEST_CASE("LeftoverLattice_Misorientation", "[Diagnostics]") {
|
||||
const CrystalLattice triclinic(52.0f, 61.0f, 73.0f, 81.0f, 76.0f, 69.0f);
|
||||
const auto rotated = [](const CrystalLattice &l, float deg, const Coord &axis) {
|
||||
const RotMatrix r(deg * static_cast<float>(PI) / 180.0f, axis);
|
||||
return CrystalLattice(r * l.Vec0(), r * l.Vec1(), r * l.Vec2());
|
||||
};
|
||||
const CrystalLattice turned = rotated(triclinic, 3.0f, Coord(0.3f, -0.5f, 0.8f));
|
||||
CHECK(LatticeMisorientationDeg(triclinic, turned) == Catch::Approx(3.0).margin(0.01));
|
||||
// The same lattice in another basis of the same metric (a cyclic relabelling written back) is
|
||||
// still 3 deg away.
|
||||
const CrystalLattice relabelled(turned.Vec1(), turned.Vec2(), turned.Vec0());
|
||||
CHECK(LatticeMisorientationDeg(triclinic, relabelled) == Catch::Approx(3.0).margin(0.01));
|
||||
// Turned by 180 deg about an axis that is no symmetry of a triclinic lattice: a twin domain.
|
||||
CHECK(LatticeMisorientationDeg(triclinic, rotated(triclinic, 180.0f, Coord(0.2f, 0.9f, 0.1f)))
|
||||
== Catch::Approx(180.0).margin(0.01));
|
||||
// A lattice symmetry is not a misorientation: tetragonal turned 90 deg about c.
|
||||
const CrystalLattice tetragonal(40.0f, 40.0f, 90.0f, 90.0f, 90.0f, 90.0f);
|
||||
CHECK(LatticeMisorientationDeg(tetragonal, rotated(tetragonal, 90.0f, tetragonal.Vec2())) < 0.01);
|
||||
// An unrelated cell has no matching basis.
|
||||
CHECK(std::isnan(LatticeMisorientationDeg(triclinic, CrystalLattice(45.0f, 45.0f, 120.0f, 90.0f, 90.0f, 90.0f))));
|
||||
}
|
||||
|
||||
TEST_CASE("LeftoverLattice_Classify", "[Diagnostics]") {
|
||||
CHECK(ClassifyLeftoverLattice(0.4, 1.0, 0.3) == LeftoverLatticeKind::Self);
|
||||
CHECK(ClassifyLeftoverLattice(2.7, 1.0, 0.3) == LeftoverLatticeKind::Domain);
|
||||
CHECK(ClassifyLeftoverLattice(179.9, 1.0, 0.3) == LeftoverLatticeKind::TwinDomain);
|
||||
CHECK(ClassifyLeftoverLattice(71.0, 1.0, 0.8) == LeftoverLatticeKind::Segmented);
|
||||
CHECK(ClassifyLeftoverLattice(NAN, 0.5, 0.3) == LeftoverLatticeKind::RelatedCell);
|
||||
CHECK(ClassifyLeftoverLattice(NAN, 3.02, 0.3) == LeftoverLatticeKind::RelatedCell);
|
||||
CHECK(ClassifyLeftoverLattice(NAN, 1.34, 0.3) == LeftoverLatticeKind::Foreign);
|
||||
}
|
||||
|
||||
TEST_CASE("ResultReport_LeftoverLattices", "[Diagnostics]") {
|
||||
DiffractionExperiment x(DetJF(1));
|
||||
ProcessResult result;
|
||||
result.consensus_cell = UnitCell{.a = 50.0f, .b = 60.0f, .c = 70.0f,
|
||||
.alpha = 90.0f, .beta = 100.0f, .gamma = 90.0f};
|
||||
LeftoverLatticeCensus census;
|
||||
census.primary_spots_pct = 60.0;
|
||||
census.primary_intensity_pct = 70.0;
|
||||
result.leftover_lattices = census;
|
||||
|
||||
auto text = RenderResultReport("p", "in.h5", x, result);
|
||||
CHECK(text.find("EXTRA_LATTICE_COUNT= 0") != std::string::npos);
|
||||
CHECK(text.find("Multiple lattices none found") != std::string::npos);
|
||||
CHECK(text.find("MULTIPLE_LATTICES= FALSE") != std::string::npos);
|
||||
|
||||
// A related cell carries intensity but is a question about the main cell, not a second crystal.
|
||||
LeftoverLattice related{.kind = LeftoverLatticeKind::RelatedCell, .cell = *result.consensus_cell,
|
||||
.volume_ratio = 0.5, .misorientation_deg = NAN, .z = 40.0,
|
||||
.spots_pct = 15.0, .intensity_pct = 12.0, .sweep_concentration = 0.3};
|
||||
result.leftover_lattices->lattices = {related};
|
||||
text = RenderResultReport("p", "in.h5", x, result);
|
||||
CHECK(text.find("EXTRA_LATTICE_1_KIND= RELATED_CELL") != std::string::npos);
|
||||
CHECK(text.find("EXTRA_LATTICE_1_MISORIENTATION_DEG") == std::string::npos);
|
||||
CHECK(text.find("MULTIPLE_LATTICES= FALSE") != std::string::npos);
|
||||
|
||||
LeftoverLattice domain{.kind = LeftoverLatticeKind::Domain, .cell = *result.consensus_cell,
|
||||
.volume_ratio = 1.0, .misorientation_deg = 2.7, .z = 250.0,
|
||||
.spots_pct = 20.0, .intensity_pct = 25.0, .sweep_concentration = 0.3};
|
||||
result.leftover_lattices->lattices = {domain, related};
|
||||
text = RenderResultReport("p", "in.h5", x, result);
|
||||
CHECK(text.find("EXTRA_LATTICE_COUNT= 2") != std::string::npos);
|
||||
CHECK(text.find("EXTRA_LATTICE_1_MISORIENTATION_DEG= 2.70") != std::string::npos);
|
||||
CHECK(text.find("EXTRA_LATTICE_INTENSITY_PCT= 25.0") != std::string::npos);
|
||||
CHECK(text.find("MULTIPLE_LATTICES= TRUE") != std::string::npos);
|
||||
CHECK(text.find("split crystal, 2.7 deg from the main lattice") != std::string::npos);
|
||||
const auto flags = text.find("\nPATHOLOGY_FLAGS= ");
|
||||
REQUIRE(flags != std::string::npos);
|
||||
CHECK(text.substr(flags, text.find('\n', flags + 1) - flags).find("MULTIPLE_LATTICES") != std::string::npos);
|
||||
}
|
||||
|
||||
TEST_CASE("ResultReport_Mosaicity", "[Diagnostics]") {
|
||||
DiffractionExperiment x(DetJF(1));
|
||||
ProcessResult result;
|
||||
CHECK(RenderResultReport("p", "in.h5", x, result).find("MOSAICITY_DEG") == std::string::npos);
|
||||
result.mosaicity_deg = 0.091;
|
||||
result.mosaicity_deg_p10 = 0.080;
|
||||
result.mosaicity_deg_p90 = 0.105;
|
||||
const auto text = RenderResultReport("p", "in.h5", x, result);
|
||||
CHECK(text.find("MOSAICITY_DEG= 0.091") != std::string::npos);
|
||||
CHECK(text.find("MOSAICITY_DEG_P10= 0.080") != std::string::npos);
|
||||
CHECK(text.find("MOSAICITY_DEG_P90= 0.105") != std::string::npos);
|
||||
CHECK(text.find("Mosaicity 0.091 deg") != std::string::npos);
|
||||
}
|
||||
Reference in new issue
Block a user