// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only #include "UpdateReflectionResolution.h" #include "../common/CrystalLattice.h" ResolutionStats UpdateReflectionResolution(const UnitCell &cell, std::vector > &reflections) { ResolutionStats ret; CrystalLattice latt(cell); const auto astar = latt.Astar(); const auto bstar = latt.Bstar(); const auto cstar = latt.Cstar(); for (auto &image: reflections) { if (!image.empty()) { ret.n_images++; ret.n_reflections += image.size(); } for (auto &r: image) { Coord q = r.h * astar + r.k * bstar + r.l * cstar; auto qlen = q.Length(); if (qlen > 1e-6) { const float d = 1/qlen; if (ret.d_high > d) ret.d_high = d; if (ret.d_low < d) ret.d_low = d; r.d = d; r.image_scale_corr = r.rlp / r.partiality; } else r.d = NAN; } } return ret; }