jfjoch_process: First pixel refine integration

This commit is contained in:
2026-06-08 15:37:27 +02:00
parent 6f31159607
commit 155c53acd8
12 changed files with 203 additions and 35 deletions
+15 -11
View File
@@ -308,10 +308,8 @@ struct PixelResidual {
PixelRefine::PixelRefine(const DiffractionExperiment &experiment,
const AzimuthalIntegrationMapping &mapping,
const std::vector<MergedReflection> &reference,
BraggPrediction &prediction)
: prediction(prediction),
mapping(mapping),
const std::vector<MergedReflection> &reference)
: mapping(mapping),
xpixel(experiment.GetXPixelsNum()),
ypixel(experiment.GetYPixelsNum()),
experiment(experiment),
@@ -324,6 +322,7 @@ PixelRefine::PixelRefine(const DiffractionExperiment &experiment,
template<class T>
void PixelRefine::Run(const T *image,
const AzimuthalIntegrationProfile &profile,
BraggPrediction &prediction,
PixelRefineData &data) {
data.solved = false;
data.reflections.clear();
@@ -694,7 +693,12 @@ void PixelRefine::Run(const T *image,
r.sigma = static_cast<float>(std::sqrt(1.0 / den));
r.bkg = static_cast<float>(bkg_sum / static_cast<double>(n));
r.observed = true;
r.image_scale_corr = (r.partiality > 0.0f) ? r.rlp / r.partiality : NAN;
// Put I onto a common (merge-ready) scale: I * image_scale_corr is the
// full-spot, scale/DW-corrected intensity. Fold in the refined G, the
// per-reflection B_term and the partiality (rlp = 1 here).
const double B_term = std::exp(-data.B_factor / (4.0 * g.d * g.d));
const double denom = static_cast<double>(r.partiality) * data.scale_factor * B_term;
r.image_scale_corr = (denom > 0.0) ? static_cast<float>(r.rlp / denom) : NAN;
} else {
r.I = 0.0f;
r.sigma = NAN;
@@ -706,9 +710,9 @@ void PixelRefine::Run(const T *image,
}
// Explicit instantiations for the supported (uncompressed) image pixel types.
template void PixelRefine::Run<int8_t>(const int8_t *, const AzimuthalIntegrationProfile &, PixelRefineData &);
template void PixelRefine::Run<int16_t>(const int16_t *, const AzimuthalIntegrationProfile &, PixelRefineData &);
template void PixelRefine::Run<int32_t>(const int32_t *, const AzimuthalIntegrationProfile &, PixelRefineData &);
template void PixelRefine::Run<uint8_t>(const uint8_t *, const AzimuthalIntegrationProfile &, PixelRefineData &);
template void PixelRefine::Run<uint16_t>(const uint16_t *, const AzimuthalIntegrationProfile &, PixelRefineData &);
template void PixelRefine::Run<uint32_t>(const uint32_t *, const AzimuthalIntegrationProfile &, PixelRefineData &);
template void PixelRefine::Run<int8_t>(const int8_t *, const AzimuthalIntegrationProfile &, BraggPrediction &, PixelRefineData &);
template void PixelRefine::Run<int16_t>(const int16_t *, const AzimuthalIntegrationProfile &, BraggPrediction &, PixelRefineData &);
template void PixelRefine::Run<int32_t>(const int32_t *, const AzimuthalIntegrationProfile &, BraggPrediction &, PixelRefineData &);
template void PixelRefine::Run<uint8_t>(const uint8_t *, const AzimuthalIntegrationProfile &, BraggPrediction &, PixelRefineData &);
template void PixelRefine::Run<uint16_t>(const uint16_t *, const AzimuthalIntegrationProfile &, BraggPrediction &, PixelRefineData &);
template void PixelRefine::Run<uint32_t>(const uint32_t *, const AzimuthalIntegrationProfile &, BraggPrediction &, PixelRefineData &);