Merge rc187-ms-laspartic
This commit is contained in:
commit
481b46f45f
4 files changed
+59
-7
No files matched your search
@@ -389,15 +389,24 @@ JointSweepRelation RelateJointSweeps(const std::vector<JointMemberSweep> &sweeps
|
||||
if (sweeps.empty())
|
||||
return out;
|
||||
// The best sweep on its own: of the sweeps whose error model resolved an ISa, the one reaching the
|
||||
// finest resolution, ties broken by the higher ISa (a sweep that merged nothing comes last).
|
||||
// finest resolution, ties broken by the higher ISa (a sweep that merged nothing comes last). Sweeps of
|
||||
// one crystal mostly stop at the same detector edge, their d_min apart in the third decimal by which
|
||||
// reflections happen to be measured there: within 1% of the finest they reach the same resolution.
|
||||
const auto accuracy_known = [&](size_t k) { return sweeps[k].isa > 0.0; }; // false on NaN
|
||||
const auto d_min = [&](size_t k) { return std::isfinite(sweeps[k].d_min) ? sweeps[k].d_min : INFINITY; };
|
||||
const bool any_known = std::any_of(sweeps.begin(), sweeps.end(), [](const JointMemberSweep &s) { return s.isa > 0.0; });
|
||||
double finest = INFINITY;
|
||||
for (size_t k = 0; k < sweeps.size(); ++k)
|
||||
if (accuracy_known(k) == any_known)
|
||||
finest = std::min(finest, d_min(k));
|
||||
const auto reaches_finest = [&](size_t k) { return d_min(k) <= 1.01 * finest; };
|
||||
const auto better = [&](size_t k, size_t than) {
|
||||
if (accuracy_known(k) != accuracy_known(than))
|
||||
return accuracy_known(k);
|
||||
const double dk = std::isfinite(sweeps[k].d_min) ? sweeps[k].d_min : INFINITY;
|
||||
const double dt = std::isfinite(sweeps[than].d_min) ? sweeps[than].d_min : INFINITY;
|
||||
if (dk != dt)
|
||||
return dk < dt;
|
||||
if (reaches_finest(k) != reaches_finest(than))
|
||||
return reaches_finest(k);
|
||||
if (!reaches_finest(k) && d_min(k) != d_min(than))
|
||||
return d_min(k) < d_min(than);
|
||||
return (std::isfinite(sweeps[k].isa) ? sweeps[k].isa : 0.0) > (std::isfinite(sweeps[than].isa) ? sweeps[than].isa : 0.0);
|
||||
};
|
||||
out.reference = 0;
|
||||
@@ -431,6 +440,12 @@ JointSweepRelation RelateJointSweeps(const std::vector<JointMemberSweep> &sweeps
|
||||
if (!std::isfinite(choice.cc)) {
|
||||
s.decision = "no axes";
|
||||
s.why_left_out = "it shares too few reflections with the reference sweep to be put on its axes";
|
||||
} else if (ref.twin_overlap_index > 0 && sweeps[k].twin_overlap_index == 0) {
|
||||
// The reference's integration left out the reflections the other twin domain overlaps; this
|
||||
// sweep's kept them, and there each holds both domains' intensity.
|
||||
s.decision = "twin overlap";
|
||||
s.why_left_out = "its integration kept the reflections the other twin domain overlaps, which the "
|
||||
"reference sweep's left out";
|
||||
}
|
||||
}
|
||||
axes_mark.Stop();
|
||||
|
||||
@@ -35,6 +35,7 @@ struct JointMemberSweep {
|
||||
double isa = NAN; // ... and its ISa, NaN where b was not resolved
|
||||
double distance_mm = NAN; // the detector distance its run ended at
|
||||
std::optional<CellEsd> cell_esd; // its cell's e.s.d.s, where its run measured them
|
||||
int twin_overlap_index = 0; // its run's ProcessResult::twin_overlap_index
|
||||
double reprocessed_from_mm = NAN; // where processed again (SharedCellTarget): its first run's
|
||||
};
|
||||
|
||||
|
||||
@@ -4259,10 +4259,12 @@ int RugnuxCli::RunJointSweeps(const RugnuxSweepPlan &plan) {
|
||||
m.d_min = merged.statistics.overall.d_min;
|
||||
m.isa = sweep.member_result->error_model_isa_resolved ? sweep.member_result->error_model_isa : NAN;
|
||||
m.distance_mm = sweep.member_result->used_distance_mm;
|
||||
m.twin_overlap_index = sweep.member_result->twin_overlap_index;
|
||||
m.cell_esd = sweep.member_result->cell_esd;
|
||||
logger.Info("Sweep {}: {} frames, {} in {:.3f} {:.3f} {:.3f} {:.2f} {:.2f} {:.2f} at {:.2f} mm, {} fulls, "
|
||||
"{} merged", k + 1, m.n_frames, m.space_group.xhm(), m.cell.a, m.cell.b, m.cell.c,
|
||||
m.cell.alpha, m.cell.beta, m.cell.gamma, m.distance_mm, m.fulls.size(), m.merged.size());
|
||||
"{} merged to {:.3f} A, ISa {:.1f}", k + 1, m.n_frames, m.space_group.xhm(), m.cell.a, m.cell.b,
|
||||
m.cell.c, m.cell.alpha, m.cell.beta, m.cell.gamma, m.distance_mm, m.fulls.size(), m.merged.size(),
|
||||
m.d_min, m.isa);
|
||||
} else
|
||||
logger.Warning("Sweep {} ({}) gave no merge", k + 1, plan.sweeps[k].label);
|
||||
return m;
|
||||
|
||||
@@ -182,6 +182,40 @@ TEST_CASE("RelateJointSweeps_ReferenceIsTheBestMeasuredSweepNotTheFinestResoluti
|
||||
CHECK(relation.sweeps[1].decision == "no axes");
|
||||
}
|
||||
|
||||
TEST_CASE("RelateJointSweeps_SweepsAtTheSameEdgeAreTiedOnResolution", "[Rugnux]") {
|
||||
// Both sweeps stop at the same detector edge; the second's d_min is finer in the third decimal only, by
|
||||
// the reflections it happened to measure there. That is a tie, and the higher ISa (the first) decides it.
|
||||
const auto truth = Truth(1);
|
||||
std::vector<JointMemberSweep> sweeps;
|
||||
sweeps.push_back(MakeSweep(truth, gemmi::Op::identity(), 100, 2, 10.0));
|
||||
sweeps.push_back(MakeSweep(truth, gemmi::Op::identity(), 100, 3, 10.0));
|
||||
sweeps[0].isa = 40.0;
|
||||
sweeps[1].isa = 20.0;
|
||||
sweeps[1].d_min = sweeps[0].d_min * 0.995;
|
||||
|
||||
CHECK(RelateJointSweeps(sweeps).reference == 0);
|
||||
// ... but a resolution finer beyond that is a better sweep.
|
||||
sweeps[1].d_min = sweeps[0].d_min * 0.95;
|
||||
CHECK(RelateJointSweeps(sweeps).reference == 1);
|
||||
}
|
||||
|
||||
TEST_CASE("RelateJointSweeps_ASweepThatKeptTheTwinOverlapIsLeftOut", "[Rugnux]") {
|
||||
// The reference's integration left out the reflections the other twin domain overlaps (index 2); the
|
||||
// third sweep's kept them. Its intensities agree elsewhere, so only the integration tells them apart.
|
||||
const auto truth = Truth(1);
|
||||
std::vector<JointMemberSweep> sweeps;
|
||||
for (uint32_t seed = 2; seed <= 4; ++seed)
|
||||
sweeps.push_back(MakeSweep(truth, gemmi::Op::identity(), 100, seed, 10.0));
|
||||
sweeps[0].isa = 200.0;
|
||||
sweeps[0].twin_overlap_index = sweeps[1].twin_overlap_index = 2;
|
||||
|
||||
const auto relation = RelateJointSweeps(sweeps);
|
||||
REQUIRE(relation.reference == 0);
|
||||
CHECK(relation.sweeps[1].included);
|
||||
CHECK_FALSE(relation.sweeps[2].included);
|
||||
CHECK(relation.sweeps[2].decision == "twin overlap");
|
||||
}
|
||||
|
||||
TEST_CASE("RelateJointSweeps_ASweepTheMergeCannotMeasureJoins", "[Rugnux]") {
|
||||
// A cell of a few dozen unique reflections: too few for the isomorphism ratio, and the held-out
|
||||
// residual of the merge moves by less than its own noise. Nothing measured refuses the sweep, so it
|
||||
|
||||
Reference in new issue
Block a user