Rotation merge: an observation with a negative background variance is left out, as in the stills merges

The negative-background-variance refusal lived only in AcceptReflection, which the rotation
merge does not call: its own admission test checked I, the correction and sigma only. Within
one rotation run the first-pass merge and the reindexing then saw a different population
from the final merge. The rotation merge now refuses such an observation too, and logs how
many it left out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HVeDQsU5a8AJUdJPgWevAK
This commit is contained in:
leonarski_fandClaude Opus 5.5 committed 2026-11-10 08:39:02 +01:00
1 parent 301762a8da
commit d06255b2f4
1 file changed
+8 -3
@@ -1206,14 +1206,14 @@ void RotationScaleMerge::BuildInRangeObservations(std::unique_ptr<SortKey[]> &ke
ingest_zeta.reset(new float[n_keep]);
if (x.GetBandwidthFWHM().value_or(0.0f) > 0.0f)
ingest_d.reset(new float[n_keep]);
std::atomic<int64_t> n_resolved{0};
std::atomic<int64_t> n_resolved{0}, n_negative_var{0};
partials.clear();
partials.resize(n_keep);
corr_ingested.resize(n_keep);
ParallelFor(n_frames, nthreads, [&](int o) {
int32_t src = src_start[o];
int32_t at = frame_start[o];
int64_t resolved = 0;
int64_t resolved = 0, negative_var = 0;
for (const auto &r : partials_out[o].reflections) {
if (!keep[src]) { ++src; continue; }
++src;
@@ -1228,7 +1228,8 @@ void RotationScaleMerge::BuildInRangeObservations(std::unique_ptr<SortKey[]> &ke
obs.frame = o;
obs.corr = r.image_scale_corr;
finite_ok[at] = (std::isfinite(r.I) && std::isfinite(obs.prescaling_corr) && obs.prescaling_corr != 0.0f
&& std::isfinite(r.sigma) && r.sigma > 0.0f) ? 1 : 0;
&& std::isfinite(r.sigma) && r.sigma > 0.0f && !(r.var_bkg < 0.0f)) ? 1 : 0;
negative_var += r.var_bkg < 0.0f; // refused as in AcceptReflection
ingest_delta_phi[at] = SmoothedDeltaPhi(sg, o, r.h, r.k, r.l, r.delta_phi_deg, resolved);
ingest_partiality[at] = r.partiality;
ingest_image_number[at] = r.image_number;
@@ -1238,6 +1239,7 @@ void RotationScaleMerge::BuildInRangeObservations(std::unique_ptr<SortKey[]> &ke
++at;
}
n_resolved += resolved;
n_negative_var += negative_var;
});
n_partials_obs = n_keep;
@@ -1245,6 +1247,9 @@ void RotationScaleMerge::BuildInRangeObservations(std::unique_ptr<SortKey[]> &ke
logger->Info("Smoothed per-frame geometry over +-{} frames (chosen by cross-validation); "
"recomputed delta_phi for {} of {} partials", sg.half, n_resolved.load(), n_keep);
if (n_negative_var > 0)
logger->Info("RotationScaleMerge: {} observations left out - their background variance is below zero",
n_negative_var.load());
if (n_keep < n_obs)
logger->Info("RotationScaleMerge: dropped {} of {} observations ({} of {} distinct hkl) outside the "
"requested resolution range - nothing downstream could have merged them",