From 7d48dc9eff2f258798de7cd77bd7923e887b8261 Mon Sep 17 00:00:00 2001 From: James Beilsten-Edmands <30625594+jbeilstenedmands@users.noreply.github.com> Date: Mon, 9 Feb 2026 17:09:36 +0000 Subject: [PATCH 1/2] Update the detector model after refinement to improve indexing percentage Output model data in same style as dials.index --- baseline/indexer/indexer.cc | 50 ++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/baseline/indexer/indexer.cc b/baseline/indexer/indexer.cc index 5f4d7fa9..9bc1867b 100644 --- a/baseline/indexer/indexer.cc +++ b/baseline/indexer/indexer.cc @@ -23,6 +23,7 @@ #include #include #include +#include #include "assign_indices.cc" #include "combinations.cc" @@ -372,14 +373,6 @@ int main(int argc, char **argv) { expt.set_crystal(best_xtal); expt.beam().set_s0(best_beam.get_s0()); expt.detector().update(best_panel.get_d_matrix()); - gemmi::UnitCell bestcell = best_xtal.get_unit_cell(); - logger.info("Best cell (P1): {:.2f} {:.2f} {:.2f} {:.2f} {:.2f} {:.2f}", - bestcell.a, - bestcell.b, - bestcell.c, - bestcell.alpha, - bestcell.beta, - bestcell.gamma); // Save the indexed experiment list. json elist_out = expt.to_json(); @@ -396,7 +389,7 @@ int main(int argc, char **argv) { // Recalculate the rlp and s1 vectors based on the updated models. xyz_to_rlp_results final_results = - xyz_to_rlp(xyzobs_px, detector.panels()[0], expt.beam(), scan, gonio); + xyz_to_rlp(xyzobs_px, expt.detector().panels()[0], expt.beam(), scan, gonio); strong_reflections.add_column(std::string("xyzobs.mm.value"), final_results.xyzobs_mm.extent(0), 3, @@ -432,9 +425,42 @@ int main(int argc, char **argv) { // Index the data with the refined models. assign_indices_results assign_results = assign_indices_global( expt.crystal().get_A_matrix(), final_results.rlp, final_results.xyzobs_mm); - logger.info("Indexed {}/{} reflections using the refined models", - assign_results.number_indexed, - xyzobs_px.extent(0)); + + // Print useful log output of results. + int n_indexed = assign_results.number_indexed; + int n_total = xyzobs_px.extent(0); + double percentage_indexed = 100.0 * static_cast(n_indexed) / n_total; + logger.info("Indexed {}/{} reflections using the refined models ({:.2f}\% indexed)", + n_indexed, n_total, percentage_indexed); + gemmi::UnitCell cell = expt.crystal().get_unit_cell(); + Matrix3d U = expt.crystal().get_U_matrix(); + Matrix3d B = expt.crystal().get_B_matrix(); + Matrix3d A = expt.crystal().get_A_matrix(); + + const std::string msg = fmt::format( + "Crystal:\n" + " Unit cell: {:.4f} {:.4f} {:.4f} {:.4f} {:.4f} {:.4f}\n" + " Space group: P 1\n" + " U matrix: [[{:>7.4f}, {:>7.4f}, {:>7.4f}],\n" + " [{:>7.4f}, {:>7.4f}, {:>7.4f}],\n" + " [{:>7.4f}, {:>7.4f}, {:>7.4f}]]\n" + " B matrix: [[{:>7.4f}, {:>7.4f}, {:>7.4f}],\n" + " [{:>7.4f}, {:>7.4f}, {:>7.4f}],\n" + " [{:>7.4f}, {:>7.4f}, {:>7.4f}]]\n" + " A = UB: [[{:>7.4f}, {:>7.4f}, {:>7.4f}],\n" + " [{:>7.4f}, {:>7.4f}, {:>7.4f}],\n" + " [{:>7.4f}, {:>7.4f}, {:>7.4f}]]", + cell.a, cell.b, cell.c, cell.alpha, cell.beta, cell.gamma, + U(0,0), U(0,1), U(0,2), U(1,0), U(1,1), U(1,2), U(2,0), U(2,1), U(2,2), + B(0,0), B(0,1), B(0,2), B(1,0), B(1,1), B(1,2), B(2,0), B(2,1), B(2,2), + A(0,0), A(0,1), A(0,2), A(1,0), A(1,1), A(1,2), A(2,0), A(2,1), A(2,2) + ); + std::istringstream iss(msg); + std::string line; + while (std::getline(iss, line)) { + logger.info("{}", line); + } + strong_reflections.add_column(std::string("miller_index"), assign_results.miller_indices.extent(0), assign_results.miller_indices.extent(1), From c4483ac30aa1bcb06afea3c9e9ba53a5f09830f6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 9 Feb 2026 17:13:04 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- baseline/indexer/indexer.cc | 73 ++++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 21 deletions(-) diff --git a/baseline/indexer/indexer.cc b/baseline/indexer/indexer.cc index 9bc1867b..a99c1d5b 100644 --- a/baseline/indexer/indexer.cc +++ b/baseline/indexer/indexer.cc @@ -20,10 +20,10 @@ #include #include #include +#include #include #include #include -#include #include "assign_indices.cc" #include "combinations.cc" @@ -425,36 +425,67 @@ int main(int argc, char **argv) { // Index the data with the refined models. assign_indices_results assign_results = assign_indices_global( expt.crystal().get_A_matrix(), final_results.rlp, final_results.xyzobs_mm); - + // Print useful log output of results. int n_indexed = assign_results.number_indexed; int n_total = xyzobs_px.extent(0); double percentage_indexed = 100.0 * static_cast(n_indexed) / n_total; - logger.info("Indexed {}/{} reflections using the refined models ({:.2f}\% indexed)", - n_indexed, n_total, percentage_indexed); + logger.info( + "Indexed {}/{} reflections using the refined models ({:.2f}\% indexed)", + n_indexed, + n_total, + percentage_indexed); gemmi::UnitCell cell = expt.crystal().get_unit_cell(); Matrix3d U = expt.crystal().get_U_matrix(); Matrix3d B = expt.crystal().get_B_matrix(); Matrix3d A = expt.crystal().get_A_matrix(); const std::string msg = fmt::format( - "Crystal:\n" - " Unit cell: {:.4f} {:.4f} {:.4f} {:.4f} {:.4f} {:.4f}\n" - " Space group: P 1\n" - " U matrix: [[{:>7.4f}, {:>7.4f}, {:>7.4f}],\n" - " [{:>7.4f}, {:>7.4f}, {:>7.4f}],\n" - " [{:>7.4f}, {:>7.4f}, {:>7.4f}]]\n" - " B matrix: [[{:>7.4f}, {:>7.4f}, {:>7.4f}],\n" - " [{:>7.4f}, {:>7.4f}, {:>7.4f}],\n" - " [{:>7.4f}, {:>7.4f}, {:>7.4f}]]\n" - " A = UB: [[{:>7.4f}, {:>7.4f}, {:>7.4f}],\n" - " [{:>7.4f}, {:>7.4f}, {:>7.4f}],\n" - " [{:>7.4f}, {:>7.4f}, {:>7.4f}]]", - cell.a, cell.b, cell.c, cell.alpha, cell.beta, cell.gamma, - U(0,0), U(0,1), U(0,2), U(1,0), U(1,1), U(1,2), U(2,0), U(2,1), U(2,2), - B(0,0), B(0,1), B(0,2), B(1,0), B(1,1), B(1,2), B(2,0), B(2,1), B(2,2), - A(0,0), A(0,1), A(0,2), A(1,0), A(1,1), A(1,2), A(2,0), A(2,1), A(2,2) - ); + "Crystal:\n" + " Unit cell: {:.4f} {:.4f} {:.4f} {:.4f} {:.4f} {:.4f}\n" + " Space group: P 1\n" + " U matrix: [[{:>7.4f}, {:>7.4f}, {:>7.4f}],\n" + " [{:>7.4f}, {:>7.4f}, {:>7.4f}],\n" + " [{:>7.4f}, {:>7.4f}, {:>7.4f}]]\n" + " B matrix: [[{:>7.4f}, {:>7.4f}, {:>7.4f}],\n" + " [{:>7.4f}, {:>7.4f}, {:>7.4f}],\n" + " [{:>7.4f}, {:>7.4f}, {:>7.4f}]]\n" + " A = UB: [[{:>7.4f}, {:>7.4f}, {:>7.4f}],\n" + " [{:>7.4f}, {:>7.4f}, {:>7.4f}],\n" + " [{:>7.4f}, {:>7.4f}, {:>7.4f}]]", + cell.a, + cell.b, + cell.c, + cell.alpha, + cell.beta, + cell.gamma, + U(0, 0), + U(0, 1), + U(0, 2), + U(1, 0), + U(1, 1), + U(1, 2), + U(2, 0), + U(2, 1), + U(2, 2), + B(0, 0), + B(0, 1), + B(0, 2), + B(1, 0), + B(1, 1), + B(1, 2), + B(2, 0), + B(2, 1), + B(2, 2), + A(0, 0), + A(0, 1), + A(0, 2), + A(1, 0), + A(1, 1), + A(1, 2), + A(2, 0), + A(2, 1), + A(2, 2)); std::istringstream iss(msg); std::string line; while (std::getline(iss, line)) {