jfjoch_process: Add French-Wilson (completely written by Opus 4.6...need to understand it properly first :) )

This commit is contained in:
2026-02-08 19:02:48 +01:00
parent 6e28ad3523
commit 69ebbed8fb
6 changed files with 285 additions and 1 deletions
+30
View File
@@ -24,6 +24,7 @@
#include "../image_analysis/IndexAndRefine.h"
#include "../receiver/JFJochReceiverPlots.h"
#include "../compression/JFJochCompressor.h"
#include "../image_analysis/scale_merge/FrenchWilson.h"
void print_usage(Logger &logger) {
logger.Info("Usage ./jfjoch_analysis {<options>} <input.h5>");
@@ -424,6 +425,35 @@ int main(int argc, char **argv) {
logger.Info("Wrote {} image records to {}", scale_result->image_ids.size(), img_path);
}
}
// --- French-Wilson: convert I → F ---
{
// Build d-spacings vector parallel to merged
std::vector<double> d_spacings(scale_result->merged.size());
for (size_t i = 0; i < scale_result->merged.size(); ++i)
d_spacings[i] = scale_result->merged[i].d;
FrenchWilsonOptions fw_opts;
fw_opts.acentric = true; // typical for MX
fw_opts.num_bins = 20;
auto fw = FrenchWilson(scale_result->merged, d_spacings, fw_opts);
const std::string fw_path = output_prefix + "_amplitudes.hkl";
std::ofstream fw_file(fw_path);
if (!fw_file) {
logger.Error("Cannot open {} for writing", fw_path);
} else {
fw_file << "# h k l F sigmaF I_fw sigmaI\n";
for (const auto& r : fw) {
fw_file << r.h << " " << r.k << " " << r.l << " "
<< r.F << " " << r.sigmaF << " "
<< r.I << " " << r.sigmaI << "\n";
}
fw_file.close();
logger.Info("French-Wilson: wrote {} amplitudes to {}", fw.size(), fw_path);
}
}
} else {
logger.Warning("Scaling skipped — too few reflections accumulated (need >= 20)");
logger.Info("Scaling wall-clock time: {:.2f} s", scale_time);