diff --git a/image_analysis/CMakeLists.txt b/image_analysis/CMakeLists.txt index e8bc48a8..40bd209f 100644 --- a/image_analysis/CMakeLists.txt +++ b/image_analysis/CMakeLists.txt @@ -32,7 +32,9 @@ ADD_LIBRARY(JFJochImageAnalysis STATIC WriteMmcif.cpp WriteMmcif.h LoadFCalcFromMtz.cpp - LoadFCalcFromMtz.h) + LoadFCalcFromMtz.h + UpdateReflectionResolution.cpp + UpdateReflectionResolution.h) FIND_PACKAGE(Eigen3 3.4 REQUIRED NO_MODULE) # provides Eigen3::Eigen diff --git a/image_analysis/UpdateReflectionResolution.cpp b/image_analysis/UpdateReflectionResolution.cpp new file mode 100644 index 00000000..b803c70e --- /dev/null +++ b/image_analysis/UpdateReflectionResolution.cpp @@ -0,0 +1,23 @@ +// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute +// SPDX-License-Identifier: GPL-3.0-only + +#include "UpdateReflectionResolution.h" +#include "../common/CrystalLattice.h" + +void UpdateReflectionResolution(const UnitCell &cell, std::vector > &reflections) { + CrystalLattice latt(cell); + const auto astar = latt.Astar(); + const auto bstar = latt.Bstar(); + const auto cstar = latt.Cstar(); + + for (auto &image: reflections) { + for (auto &r: image) { + Coord q = r.h * astar + r.k * bstar + r.l * cstar; + auto qlen = q.Length(); + if (qlen > 1e-6) + r.d = 1/qlen; + else + r.d = NAN; + } + } +} diff --git a/image_analysis/UpdateReflectionResolution.h b/image_analysis/UpdateReflectionResolution.h new file mode 100644 index 00000000..6c3c26ad --- /dev/null +++ b/image_analysis/UpdateReflectionResolution.h @@ -0,0 +1,8 @@ +// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute +// SPDX-License-Identifier: GPL-3.0-only + +#include +#include "../common/Reflection.h" +#include "../common/UnitCell.h" + +void UpdateReflectionResolution(const UnitCell &cell, std::vector > &reflections); diff --git a/image_analysis/scale_merge/ScaleOnTheFly.cpp b/image_analysis/scale_merge/ScaleOnTheFly.cpp index 02b23b8f..cc3a9c64 100644 --- a/image_analysis/scale_merge/ScaleOnTheFly.cpp +++ b/image_analysis/scale_merge/ScaleOnTheFly.cpp @@ -355,21 +355,3 @@ ScalingResult ScaleOnTheFly::Scale(std::vector > &reflec return result; } - -void UpdateReflectionResolution(const UnitCell &cell, std::vector > &reflections) { - CrystalLattice latt(cell); - const auto astar = latt.Astar(); - const auto bstar = latt.Bstar(); - const auto cstar = latt.Cstar(); - - for (auto &image: reflections) { - for (auto &r: image) { - Coord q = r.h * astar + r.k * bstar + r.l * cstar; - auto qlen = q.Length(); - if (qlen > 1e6) - r.d = 1/qlen; - else - r.d = NAN; - } - } -} diff --git a/image_analysis/scale_merge/ScaleOnTheFly.h b/image_analysis/scale_merge/ScaleOnTheFly.h index b42c71e8..fd214dd3 100644 --- a/image_analysis/scale_merge/ScaleOnTheFly.h +++ b/image_analysis/scale_merge/ScaleOnTheFly.h @@ -22,8 +22,6 @@ struct ScaleOnTheFlyResult { bool succesful = false; }; -void UpdateReflectionResolution(const UnitCell &cell, std::vector > &reflections); - class ScaleOnTheFly { constexpr static size_t MIN_REFLECTIONS = 20; diff --git a/tools/jfjoch_process.cpp b/tools/jfjoch_process.cpp index 300d6ccf..df83107e 100644 --- a/tools/jfjoch_process.cpp +++ b/tools/jfjoch_process.cpp @@ -29,6 +29,7 @@ #include "../image_analysis/scale_merge/Merge.h" #include "../image_analysis/scale_merge/SearchSpaceGroup.h" #include "../image_analysis/WriteMmcif.h" +#include "../image_analysis/UpdateReflectionResolution.h" void print_usage(Logger &logger) { logger.Info("Usage ./jfjoch_analysis {} "); @@ -616,7 +617,7 @@ int main(int argc, char **argv) { auto rejected_uc = CalcMergeMaskUnitCell(experiment, *consensus_cell, indexer.GetUnitCells(), merging_mask_uc); if (rejected_uc > 0) logger.Info("Rejected {} images for merging due to unit cell being too far from consensus", rejected_uc); - UpdateReflectionResolution(consensus_cell.value(), indexer.GetReflections()); + // UpdateReflectionResolution(consensus_cell.value(), indexer.GetReflections()); logger.Info("Reflection resolution updated based on consensus unit cell"); } else logger.Info("Consensus unit cell not found - calculation tool {:.2f} ms", consensus_duration * 1e3); diff --git a/tools/jfjoch_scale.cpp b/tools/jfjoch_scale.cpp index 8e49fcdb..3d08c322 100644 --- a/tools/jfjoch_scale.cpp +++ b/tools/jfjoch_scale.cpp @@ -29,6 +29,7 @@ #include "../image_analysis/scale_merge/Merge.h" #include "../image_analysis/scale_merge/SearchSpaceGroup.h" #include "../image_analysis/WriteMmcif.h" +#include "../image_analysis/UpdateReflectionResolution.h" void print_usage(Logger &logger) { logger.Info("Usage ./jfjoch_analysis {} ");