Stills module placement: no gauge on the refit with modules held as given
When the held-out test sends a module back to where it was given, the placement is refitted with that module held. The held module already fixes the frame the other modules are placed in; the module gauge (their moves zero in sum) fixed it a second time, and the fit, pulled between the two, crawled: on an 8-panel MPCCD run with one panel held, 53/51/101 Levenberg-Marquardt iterations a round (the last at the iteration cap) instead of 3-7, 65 s of a 94 s geometry step, and modules pressed against their bounds (a turn of exactly the 1.5 degree limit, a shift past 12 px). Without the gauge when a module is held: 7/4/3 iterations, the refit 7 s, the median spot residual 0.58 px instead of 0.66 px, the turns below 0.1 degree. Still battery against rc188-final-still, the four sets where a module is held (the others never reach the refit): sacla243 304.5 -> 226.8 s (step 2 92 -> 35 s), d_min 1.45 -> 1.35 A, R_split 3.35 -> 2.85%, R_free 0.1785 -> 0.1754; euxfel83, euxfel152, alvra103_int16 draws (R_free within 0.0014). Test: RefineGlobalGeometry_ModulePlacement_OneHeld (moves that do not sum to zero, recovered with one module held). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UqXYdJDrM65gxsCn2PrbfK
This commit is contained in:
1 parent
ba95634205
commit
bc0797013a
2 files changed
+54
-2
No files matched your search
@@ -590,12 +590,17 @@ GeometryRefinerResult RefineGlobalGeometry(const DiffractionGeometry &nominal_ge
|
||||
|
||||
// The refined modules' moves: bounded to what a misplaced module plausibly is, and held to
|
||||
// zero in sum by the gauge (ModuleGauge). A 1 px mean shift costs as much there as moving
|
||||
// every spot by 1 px would, ten times over.
|
||||
// every spot by 1 px would, ten times over. A module held as given (modules_held) already fixes
|
||||
// the frame the others are placed in; the gauge would fix it a second time, and the fit, pulled
|
||||
// between the two, crawls (on an 8-module detector with one module held: 50-100 iterations a
|
||||
// round instead of 3-7) and settles with modules pressed against their bounds.
|
||||
std::vector<size_t> moved;
|
||||
for (size_t m = 0; m < modules.size(); ++m)
|
||||
if (refined[m] && problem.HasParameterBlock(move[m].data()))
|
||||
moved.push_back(m);
|
||||
if (moved.size() >= 2) {
|
||||
const bool any_held = std::find(settings.modules_held.begin(), settings.modules_held.end(), true)
|
||||
!= settings.modules_held.end();
|
||||
if (moved.size() >= 2 && !any_held) {
|
||||
auto *gauge = new ModuleGauge;
|
||||
double lever = 0, total = 0;
|
||||
for (size_t m : moved)
|
||||
|
||||
@@ -123,6 +123,53 @@ TEST_CASE("RefineGlobalGeometry_ModulePlacement") {
|
||||
CHECK(scored.distance_mm == geom.GetDetectorDistance_mm());
|
||||
}
|
||||
|
||||
// A module held as given fixes the frame the others are placed in: their moves come out as they are, with no
|
||||
// gauge taking their sum away, and the beam stays where the held module puts it.
|
||||
TEST_CASE("RefineGlobalGeometry_ModulePlacement_OneHeld") {
|
||||
DiffractionExperiment exp;
|
||||
exp.IncidentEnergy_keV(WVL_1A_IN_KEV).BeamX_pxl(1000).BeamY_pxl(1000).DetectorDistance_mm(150);
|
||||
const DiffractionGeometry geom = exp.GetDiffractionGeometry();
|
||||
|
||||
// Module 0 where it was given, the others moved by amounts that do not sum to zero.
|
||||
std::vector<ModuleShift> truth(4);
|
||||
const double centre[4][2] = {{500, 500}, {1500, 500}, {500, 1500}, {1500, 1500}};
|
||||
const double move[4][3] = {{0.0, 0.0, 0.0}, {3.0, 1.0, 0.2}, {2.0, -2.0, -0.1}, {1.5, 2.5, 0.1}};
|
||||
for (int m = 0; m < 4; m++) {
|
||||
truth[m].x0 = centre[m][0];
|
||||
truth[m].y0 = centre[m][1];
|
||||
truth[m].dx = move[m][0];
|
||||
truth[m].dy = move[m][1];
|
||||
truth[m].rot_rad = move[m][2] * PI / 180.0;
|
||||
}
|
||||
const CrystalLattice latt(50, 60, 70, 90, 90, 90);
|
||||
const std::vector<GeomRefineFrame> frames = FramesOnMovedModules(exp, latt, truth);
|
||||
REQUIRE(frames.size() > 30);
|
||||
|
||||
GeometryRefinerSettings st;
|
||||
st.crystal_system = gemmi::CrystalSystem::Orthorhombic;
|
||||
st.num_threads = 2;
|
||||
st.refine_modules = true;
|
||||
st.modules_held = {true, false, false, false};
|
||||
for (const auto &t: truth) {
|
||||
ModuleShift start;
|
||||
start.x0 = t.x0;
|
||||
start.y0 = t.y0;
|
||||
st.modules.push_back(start);
|
||||
}
|
||||
|
||||
const auto placed = RefineGlobalGeometry(geom, latt.GetUnitCell(), frames, st);
|
||||
REQUIRE(placed.ok);
|
||||
CHECK(placed.median_residual_px < 0.1);
|
||||
for (int m = 0; m < 4; m++) {
|
||||
CHECK(placed.modules[m].dx == Catch::Approx(truth[m].dx).margin(0.1));
|
||||
CHECK(placed.modules[m].dy == Catch::Approx(truth[m].dy).margin(0.1));
|
||||
CHECK(placed.modules[m].rot_rad * 180.0 / PI == Catch::Approx(move[m][2]).margin(0.01));
|
||||
}
|
||||
CHECK(placed.beam_x_px == Catch::Approx(1000).margin(0.1));
|
||||
CHECK(placed.beam_y_px == Catch::Approx(1000).margin(0.1));
|
||||
CHECK(placed.distance_mm == Catch::Approx(150).margin(0.05));
|
||||
}
|
||||
|
||||
// The coarse search ahead of the placement: a module off by several pixels is found near where it is, and the
|
||||
// search gives the same answer on any number of threads.
|
||||
TEST_CASE("ScanModuleShifts_FindsShiftedModule") {
|
||||
|
||||
Reference in new issue
Block a user