jfjoch_scale: Seems to work (though unstable)

This commit is contained in:
2026-05-18 13:38:23 +02:00
parent 7c0cc22e47
commit d555042dc6
+43 -30
View File
@@ -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());
}
}