diff --git a/image_analysis/scale_merge/RotationScaleMerge.cpp b/image_analysis/scale_merge/RotationScaleMerge.cpp index c336367d3..5e09d1674 100644 --- a/image_analysis/scale_merge/RotationScaleMerge.cpp +++ b/image_analysis/scale_merge/RotationScaleMerge.cpp @@ -4505,6 +4505,18 @@ RotationScaleMerge::Result RotationScaleMerge::MergeAndStats(int n_groups, bool if (o.on_ice) a.on_ice = true; if (!std::isfinite(a.d) && std::isfinite(o.d) && o.d > 0.0f) a.d = o.d; } + // A merged reflection's d from the cell the completeness denominator is enumerated with, not + // from whichever frame first observed it: a per-frame cell puts a reflection near a shell edge + // on the other side of it from its possible twin, and a shell then reads above 100 %. + if (reference_cell) { + const CrystalLattice latt(*reference_cell); + for (int g = 0; g < n_groups; ++g) { + if (!std::isfinite(acc[g].d)) continue; + const double q = (group_h[g] * latt.Astar() + group_k[g] * latt.Bstar() + + group_l[g] * latt.Cstar()).Length(); + if (q > 1e-6) acc[g].d = static_cast(1.0 / q); + } + } // ---- Export merged reflections. ---- for (int g = 0; g < n_groups; ++g) { const auto &a = acc[g]; @@ -4940,7 +4952,7 @@ RotationScaleMerge::Result RotationScaleMerge::MergeAndStats(int n_groups, bool if (!(sigma_corr > 0.0f) || !std::isfinite(sigma_corr)) continue; const double w = 1.0 / (static_cast(sigma_corr) * sigma_corr); AnomAcc &a = anom[cell >> 1]; - a.d = o.d; + a.d = acc[o.group].d; a.swI[cell & 1][anom_half[i]] += w * static_cast(I_corr); a.sw[cell & 1][anom_half[i]] += w; a.nh[cell & 1][anom_half[i]]++;