From d555042dc6d1c16d01e220762ca5e034a43836af Mon Sep 17 00:00:00 2001 From: leonarski_f Date: Mon, 18 May 2026 13:38:23 +0200 Subject: [PATCH] jfjoch_scale: Seems to work (though unstable) --- tools/jfjoch_scale.cpp | 73 +++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 30 deletions(-) diff --git a/tools/jfjoch_scale.cpp b/tools/jfjoch_scale.cpp index 11f6df07..d9f22bf8 100644 --- a/tools/jfjoch_scale.cpp +++ b/tools/jfjoch_scale.cpp @@ -242,6 +242,20 @@ int main(int argc, char **argv) { logger.Info("Running scaling (mosaicity refinement) ..."); auto reflections = reader.ReadReflections(start_image, end_image); + size_t nimages = 0; + size_t nrefl = 0; + for (auto& image : reflections) { + if (!image.empty()) { + nimages++; + nrefl += image.size(); + + for (auto &r: image) { + r.image_scale_corr = 1.0; // restart these numbers, since we don't know any better + } + } + } + + logger.Info("Read {} reflections from {} images", nrefl, nimages); if (experiment.GetUnitCell()) { UpdateReflectionResolution(experiment.GetUnitCell().value(), reflections); @@ -325,39 +339,38 @@ int main(int argc, char **argv) { } } logger.Info(""); + } + // Print resolution-shell statistics table + merge_stats.Print(logger); - // Print resolution-shell statistics table - merge_stats.Print(logger); - - { - const std::string hkl_path = output_prefix + "_intensities.hkl"; - std::ofstream hkl_file(hkl_path); - if (!hkl_file) { - logger.Error("Cannot open {} for writing", hkl_path); - } else { - for (const auto &r: merge_result) { - hkl_file << r.h << " " << r.k << " " << r.l << " " - << r.I << " " << r.sigma - << "\n"; - } - hkl_file.close(); - logger.Info("Wrote {} reflections to {}", merge_result.size(), hkl_path); + { + const std::string hkl_path = output_prefix + "_intensities.hkl"; + std::ofstream hkl_file(hkl_path); + if (!hkl_file) { + logger.Error("Cannot open {} for writing", hkl_path); + } else { + for (const auto &r: merge_result) { + hkl_file << r.h << " " << r.k << " " << r.l << " " + << r.I << " " << r.sigma + << "\n"; } - } - - try { - const std::string cif_path = output_prefix + "_intensities.cif"; - - MmcifMetadata cif_meta; - - cif_meta.Fill(experiment); - cif_meta.data_block_name = output_prefix; - - WriteMmcifReflections(cif_path, merge_result, cif_meta); - logger.Info("Wrote mmCIF reflections to {}", cif_path); - } catch (const std::exception &e) { - logger.Error("Failed to write mmCIF: {}", e.what()); + hkl_file.close(); + logger.Info("Wrote {} reflections to {}", merge_result.size(), hkl_path); } } + + try { + const std::string cif_path = output_prefix + "_intensities.cif"; + + MmcifMetadata cif_meta; + + cif_meta.Fill(experiment); + cif_meta.data_block_name = output_prefix; + + WriteMmcifReflections(cif_path, merge_result, cif_meta); + logger.Info("Wrote mmCIF reflections to {}", cif_path); + } catch (const std::exception &e) { + logger.Error("Failed to write mmCIF: {}", e.what()); + } }