PixelRefine: make factored Terms 1+2 the model, remove old wiring
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 25m0s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 26m42s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 27m7s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 28m25s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 29m44s
Build Packages / build:rpm (rocky9_sls9) (push) Successful in 32m14s
Build Packages / build:rpm (rocky8) (push) Successful in 24m39s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 23m52s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 25m19s
Build Packages / Generate python client (push) Successful in 23s
Build Packages / XDS test (durin plugin) (push) Successful in 20m42s
Build Packages / Create release (push) Skipped
Build Packages / build:rpm (rocky9) (push) Successful in 27m2s
Build Packages / Build documentation (push) Successful in 1m23s
Build Packages / DIALS test (push) Successful in 31m5s
Build Packages / XDS test (JFJoch plugin) (push) Successful in 14m55s
Build Packages / XDS test (neggia plugin) (push) Successful in 13m7s
Build Packages / Unit tests (push) Successful in 2h14m40s

PixelRefine is now an intensity-only operation: geometry is fixed (refined
upstream by XtalOptimizer) and the only objective is the factored per-reflection
likelihood (FACTORED_MODEL.md Terms 1+2) - measured per-resolution profile width
R1 plus one Fisher-weighted intensity/scaling residual per reflection, fitting
the per-image scale G and B. Validated on crystal 2 (fixed_master.h5 as stills,
1.7 A): CC1/2 84-92%, CCref 77-92%, flat - reproduces the env-flag prototype and
matches the rotation path from the stills path.

Removed:
- the per-pixel ShoeboxResidual loss and PixelResidual cost functor;
- all in-PixelRefine geometry refinement (orientation/cell/beam/distance/R),
  the regularised-orientation LSQ, signal-weighting, and the global sweep;
- Term 3 (per-spot recentring) - a confirmed no-op on both crystals;
- the diagnostic scaffolding (covariance, centroid, adaptive_R1) and the
  PR_* env knobs + stderr dumps in IndexAndRefine;
- the PredictImage/ChiSquaredImage renderers and the entire viewer
  PixelRefine window/table/params + worker bindings + shoebox overlay.

The sweep box-integrator background median became mean (consistency) by virtue
of removing the sweep. METHODS.md rewritten for the current model; findings
recorded in FINDINGS-2026-06.md. Net -2200 lines.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-13 22:02:18 +02:00
co-authored by Claude Opus 4.8
parent 6f2033db00
commit 100fe7b7e7
18 changed files with 569 additions and 2780 deletions
-34
View File
@@ -446,28 +446,6 @@ bool IndexAndRefine::PixelRefineIntegrate(DataMessage &msg,
if (const auto bw = experiment.GetBandwidthFWHM())
prd.bandwidth = bw.value() / 2.3548; // FWHM -> sigma
// TEMPORARY diagnostic knobs to probe the effect of the (currently fixed) spot
// widths R[0] (radial/partiality) and R[1] (tangential/profile). Remove after.
if (const char *r0 = std::getenv("PR_R0")) prd.R[0] = std::stod(r0);
if (const char *r1 = std::getenv("PR_R1")) prd.R[1] = std::stod(r1);
// TEMPORARY: PR_COV refines G,B,R and dumps their per-image correlation matrix.
if (std::getenv("PR_COV")) {
prd.refine_scale = true; prd.refine_B = true; prd.refine_R = true;
prd.compute_covariance = true;
}
if (std::getenv("PR_FIX_R0")) prd.fix_R0 = true; // hold R0, refine R1 only
if (std::getenv("PR_FIX_R")) prd.refine_R = false; // hold R0 and R1: G-B correlation only
if (std::getenv("PR_ADAPT_R1")) prd.adaptive_R1 = true; // measure R1 from spot moments
if (std::getenv("PR_CENTROID")) prd.measure_centroid = true; // observed-vs-predicted offset
if (std::getenv("PR_RECENTER")) prd.recenter_profile = true; // recentre profile on centroid
if (const char *s = std::getenv("PR_RECENTER_SIGNIF")) prd.recenter_min_signif = std::stod(s);
if (std::getenv("PR_INTENSITY")) { // factored-likelihood Term 1: per-reflection intensity residual
prd.intensity_residual = true;
prd.refine_orientation = false; prd.refine_R = false;
prd.refine_scale = true; prd.refine_B = true;
}
if (std::getenv("PR_SHAPE")) prd.shape_R1 = true; // Term 2: per-resolution R1 from spot moments
std::vector<uint8_t> buffer;
const uint8_t *ptr = image.GetUncompressedPtr(buffer);
switch (image.GetMode()) {
@@ -487,18 +465,6 @@ bool IndexAndRefine::PixelRefineIntegrate(DataMessage &msg,
return false;
}
if (prd.covariance_valid)
fprintf(stderr, "[cov] GB=%.3f GR0=%.3f GR1=%.3f BR0=%.3f BR1=%.3f R0R1=%.3f\n",
prd.corr_GB, prd.corr_GR0, prd.corr_GR1, prd.corr_BR0, prd.corr_BR1, prd.corr_R0R1);
if (prd.adaptive_R1)
fprintf(stderr, "[R1] %.5f\n", prd.R[1]);
if (prd.shape_R1 && std::isfinite(prd.shape_R1_lores))
fprintf(stderr, "[shapeR1] lores=%.5f hires=%.5f\n", prd.shape_R1_lores, prd.shape_R1_hires);
if (prd.measure_centroid && std::isfinite(prd.centroid_lo_tang_c))
fprintf(stderr, "[res] lo_s=%.1f lo_tc=%.3f lo_tp=%.3f lo_rc=%.3f hi_s=%.1f hi_tc=%.3f hi_tp=%.3f hi_rc=%.3f\n",
prd.centroid_lo_signif, prd.centroid_lo_tang_c, prd.centroid_lo_tang_p, prd.centroid_lo_rad_c,
prd.centroid_hi_signif, prd.centroid_hi_tang_c, prd.centroid_hi_tang_p, prd.centroid_hi_rad_c);
// PixelRefine output flows into the normal save/merge path: the refined
// geometry/lattice and the already-scaled reflections become the outcome.
i_outcome.reflections = std::move(prd.reflections);