Scaling/Merging: Clean-up data structures

This commit is contained in:
2026-05-25 18:23:18 +02:00
parent 61776a446e
commit ea36b26a4f
12 changed files with 190 additions and 630 deletions
+9 -18
View File
@@ -696,12 +696,6 @@ int main(int argc, char **argv) {
logger.Info("UC: a={:.2f} b={:.2f} c={:.2f} alpha={:.2f} beta={:.2f} gamma={:.2f}",
consensus_cell->a, consensus_cell->b, consensus_cell->c,
consensus_cell->alpha, consensus_cell->beta, consensus_cell->gamma);
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());
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);
end_msg.unit_cell = consensus_cell;
@@ -709,8 +703,6 @@ int main(int argc, char **argv) {
if (run_scaling || !reference_data.empty()) {
logger.Info("Running scaling (mosaicity refinement) ...");
std::vector<float> scale_cc;
if (reference_data.empty()) {
// If reference data are given, there is live scaling (no need to go again)
ScalingResult scale_result(0);
@@ -718,7 +710,7 @@ int main(int argc, char **argv) {
auto scale_start = std::chrono::steady_clock::now();
for (int i = 0; i < scaling_iter; i++) {
auto iter_start = std::chrono::steady_clock::now();
auto merge_result = MergeAll(experiment, indexer.GetIntegrationOutcome(), merging_mask_uc);
auto merge_result = MergeAll(experiment, indexer.GetIntegrationOutcome(), false);
scale_result = indexer.ScaleAllImages(merge_result);
scale_result.SaveToFile(output_prefix + "_iter" + std::to_string(i) + "_scale.dat");
auto iter_end = std::chrono::steady_clock::now();
@@ -726,7 +718,6 @@ int main(int argc, char **argv) {
logger.Info("Scaling iteration {} took {:.3f} seconds", i, iter_time);
}
scale_cc = scale_result.image_cc;
end_msg.image_scale_factor = scale_result.image_scale_g;
end_msg.image_scale_cc = scale_result.image_cc;
end_msg.image_scale_mosaicity = scale_result.mosaicity_deg;
@@ -735,18 +726,18 @@ int main(int argc, char **argv) {
auto scale_end = std::chrono::steady_clock::now();
double scale_time = std::chrono::duration<double>(scale_end - scale_start).count();
logger.Info("Scaling completed in {:.2f} s", scale_time);
} else
scale_cc = indexer.GetImageCC();
}
auto merge_start = std::chrono::steady_clock::now();
auto rejected_cc = CalcMergeMaskCC(experiment, scale_cc, merging_mask_uc);
if (rejected_cc > 0)
logger.Info("Rejected {} images for merging due to low CC with reference", rejected_cc);
MergeOnTheFly merge_engine(experiment);
if (consensus_cell.has_value())
merge_engine.ReferenceCell(*consensus_cell);
for (auto &i : indexer.GetIntegrationOutcome())
merge_engine.AddImage(i);
auto merged_reflections = MergeAll(experiment, indexer.GetIntegrationOutcome(), merging_mask_uc);
auto merged_statistics = MergeStats(experiment, merged_reflections, indexer.GetIntegrationOutcome(), *consensus_cell, merging_mask_uc,
reference_data);
auto merged_reflections = merge_engine.ExportReflections();
auto merged_statistics = merge_engine.MergeStats(merged_reflections, indexer.GetIntegrationOutcome(), reference_data);
auto merge_end = std::chrono::steady_clock::now();
double merge_time = std::chrono::duration<double>(merge_end - merge_start).count();