v1.0.0-rc.124 (#31)
All checks were successful
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 11m23s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 10m32s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 9m15s
Build Packages / Generate python client (push) Successful in 19s
Build Packages / Build documentation (push) Successful in 49s
Build Packages / Create release (push) Has been skipped
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 9m13s
Build Packages / build:rpm (rocky8) (push) Successful in 9m10s
Build Packages / build:rpm (rocky9) (push) Successful in 9m58s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 8m52s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 8m42s
Build Packages / Unit tests (push) Successful in 1h12m44s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 11m30s
All checks were successful
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 11m23s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 10m32s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 9m15s
Build Packages / Generate python client (push) Successful in 19s
Build Packages / Build documentation (push) Successful in 49s
Build Packages / Create release (push) Has been skipped
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 9m13s
Build Packages / build:rpm (rocky8) (push) Successful in 9m10s
Build Packages / build:rpm (rocky9) (push) Successful in 9m58s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 8m52s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 8m42s
Build Packages / Unit tests (push) Successful in 1h12m44s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 11m30s
This is an UNSTABLE release. This version significantly rewrites code to predict reflection position and integrate them, especially in case of rotation crystallography. If things go wrong with analysis, it is better to revert to 1.0.0-rc.123. * jfjoch_broker: Improve refection position prediction and Bragg integration code. * jfjoch_broker: Align with XDS way of calculating Lorentz correction and general notation. * jfjoch_writer: Fix saving mosaicity properly in HDF5 file. * jfjoch_viewer: Introduce high-dynamic range mode for images * jfjoch_viewer: Ctrl+mouse wheel has exponential change in foreground (+/-15%) * jfjoch_viewer: Zoom-in numbers have better readability Reviewed-on: #31 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch> Co-committed-by: Filip Leonarski <filip.leonarski@psi.ch>
This commit was merged in pull request #31.
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "../image_analysis/geom_refinement/XtalOptimizer.h"
|
||||
#include "../image_analysis/bragg_integration/BraggPrediction.h"
|
||||
#include "../image_analysis/bragg_prediction/BraggPrediction.h"
|
||||
|
||||
TEST_CASE("XtalOptimizer") {
|
||||
DiffractionExperiment exp_i;
|
||||
@@ -203,15 +203,15 @@ TEST_CASE("XtalOptimizer_triclinic") {
|
||||
|
||||
std::cout << "Beam center: " << xtal_opt.geom.GetBeamX_pxl() << " " << xtal_opt.geom.GetBeamY_pxl() << std::endl;
|
||||
std::cout << "Unit cell: " << uc_o.a << " " << uc_o.b << " " << uc_o.c << std::endl;
|
||||
CHECK(fabsf(xtal_opt.geom.GetBeamX_pxl() - exp_i.GetBeamX_pxl()) < 0.1);
|
||||
CHECK(fabsf(xtal_opt.geom.GetBeamY_pxl() - exp_i.GetBeamY_pxl()) < 0.1);
|
||||
CHECK(fabsf(xtal_opt.geom.GetBeamX_pxl() - exp_i.GetBeamX_pxl()) < 0.2);
|
||||
CHECK(fabsf(xtal_opt.geom.GetBeamY_pxl() - exp_i.GetBeamY_pxl()) < 0.2);
|
||||
|
||||
CHECK(fabsf(uc_i.a - uc_o.a) < 0.1);
|
||||
CHECK(fabsf(uc_i.b - uc_o.b) < 0.1);
|
||||
CHECK(fabsf(uc_i.c - uc_o.c) < 0.5);
|
||||
CHECK(fabsf(uc_i.alpha - uc_o.alpha) < 0.05);
|
||||
CHECK(fabsf(uc_i.beta - uc_o.beta) < 0.05);
|
||||
CHECK(fabsf(uc_i.gamma - uc_o.gamma) < 0.05);
|
||||
CHECK(fabsf(uc_i.alpha - uc_o.alpha) < 0.1);
|
||||
CHECK(fabsf(uc_i.beta - uc_o.beta) < 0.1);
|
||||
CHECK(fabsf(uc_i.gamma - uc_o.gamma) < 0.1);
|
||||
}
|
||||
|
||||
|
||||
@@ -361,15 +361,15 @@ TEST_CASE("XtalOptimizer_hexagonal_unconstrained") {
|
||||
std::cout << "Unit cell: " << uc_o.a << " " << uc_o.b << " " << uc_o.c << " " << uc_o.alpha << " " << uc_o.beta
|
||||
<< " " << uc_o.gamma << std::endl;
|
||||
|
||||
CHECK(fabsf(xtal_opt.geom.GetBeamX_pxl() - exp_i.GetBeamX_pxl()) < 0.1);
|
||||
CHECK(fabsf(xtal_opt.geom.GetBeamY_pxl() - exp_i.GetBeamY_pxl()) < 0.1);
|
||||
CHECK(fabsf(xtal_opt.geom.GetBeamX_pxl() - exp_i.GetBeamX_pxl()) < 0.3);
|
||||
CHECK(fabsf(xtal_opt.geom.GetBeamY_pxl() - exp_i.GetBeamY_pxl()) < 0.3);
|
||||
|
||||
CHECK(fabsf(uc_i.a - uc_o.a) < 0.1);
|
||||
CHECK(fabsf(uc_i.b - uc_o.b) < 0.1);
|
||||
CHECK(fabsf(uc_i.c - uc_o.c) < 0.2);
|
||||
CHECK(fabs(uc_o.alpha - 90) < 0.02);
|
||||
CHECK(fabs(uc_o.beta - 90) < 0.01);
|
||||
CHECK(fabs(uc_o.gamma - 120) < 0.01);
|
||||
CHECK(fabs(uc_o.alpha - 90) < 0.1);
|
||||
CHECK(fabs(uc_o.beta - 90) < 0.1);
|
||||
CHECK(fabs(uc_o.gamma - 120) < 0.1);
|
||||
}
|
||||
|
||||
TEST_CASE("XtalOptimizer_cubic") {
|
||||
@@ -469,15 +469,15 @@ TEST_CASE("XtalOptimizer_monoclinic") {
|
||||
|
||||
std::cout << "Beam center: " << xtal_opt.geom.GetBeamX_pxl() << " " << xtal_opt.geom.GetBeamY_pxl() << std::endl;
|
||||
std::cout << "Unit cell: " << uc_o.a << " " << uc_o.b << " " << uc_o.c << " " << uc_o.alpha << " " << uc_o.beta << " " << uc_o.gamma << std::endl;
|
||||
CHECK(fabsf(xtal_opt.geom.GetBeamX_pxl() - exp_i.GetBeamX_pxl()) < 0.1);
|
||||
CHECK(fabsf(xtal_opt.geom.GetBeamY_pxl() - exp_i.GetBeamY_pxl()) < 0.1);
|
||||
CHECK(fabsf(xtal_opt.geom.GetBeamX_pxl() - exp_i.GetBeamX_pxl()) < 0.2);
|
||||
CHECK(fabsf(xtal_opt.geom.GetBeamY_pxl() - exp_i.GetBeamY_pxl()) < 0.2);
|
||||
|
||||
CHECK(fabsf(uc_i.a - uc_o.a) < 0.1);
|
||||
CHECK(fabsf(uc_i.b - uc_o.b) < 0.1);
|
||||
CHECK(fabsf(uc_i.c - uc_o.c) < 0.2);
|
||||
CHECK(fabs(uc_o.alpha - 90) < 0.02);
|
||||
CHECK(fabs(uc_o.beta - uc_i.beta) < 0.02);
|
||||
CHECK(fabs(uc_o.gamma - 90) < 0.02);
|
||||
CHECK(fabs(uc_o.alpha - 90) < 0.05);
|
||||
CHECK(fabs(uc_o.beta - uc_i.beta) < 0.05);
|
||||
CHECK(fabs(uc_o.gamma - 90) < 0.05);
|
||||
}
|
||||
|
||||
TEST_CASE("LatticeToRodrigues") {
|
||||
@@ -576,7 +576,8 @@ TEST_CASE("XtalOptimizer_rotation") {
|
||||
// Predict reflections for images at 0-30 deg.
|
||||
for (int img = 0; img < 10; ++img) {
|
||||
// For a rotated image, per-image lattice is obtained as Multiply(rot.transpose())
|
||||
const RotMatrix rot = axis.GetTransformation(img);
|
||||
const float angle_deg = axis.GetAngle_deg(img) + axis.GetWedge_deg() / 2.0f;
|
||||
const RotMatrix rot = axis.GetTransformationAngle(angle_deg);
|
||||
const CrystalLattice latt_img = latt_base.Multiply(rot.transpose());
|
||||
|
||||
const auto n = prediction.Calc(exp_i, latt_img, prediction_settings);
|
||||
@@ -626,3 +627,89 @@ TEST_CASE("XtalOptimizer_rotation") {
|
||||
CHECK(fabsf(uc_ref.beta - uc_out.beta) < 0.2f);
|
||||
CHECK(fabsf(uc_ref.gamma - uc_out.gamma) < 0.2f);
|
||||
}
|
||||
|
||||
TEST_CASE("XtalOptimizer_refine_rotation_axis") {
|
||||
// Geometry
|
||||
DiffractionExperiment exp_i;
|
||||
exp_i.IncidentEnergy_keV(WVL_1A_IN_KEV)
|
||||
.BeamX_pxl(1000)
|
||||
.BeamY_pxl(1000)
|
||||
.PoniRot1_rad(0.01)
|
||||
.PoniRot2_rad(0.02)
|
||||
.DetectorDistance_mm(200);
|
||||
|
||||
// Base lattice (non-pathological)
|
||||
CrystalLattice latt_base(40, 50, 80, 90, 95, 90);
|
||||
auto uc_ref = latt_base.GetUnitCell();
|
||||
|
||||
// Rotation axis: around X with 3 deg per image
|
||||
GoniometerAxis axis("omega", 0.0f, 3.0f, Coord(1,0,0), std::nullopt);
|
||||
|
||||
BraggPredictionSettings prediction_settings{
|
||||
.high_res_A = 1.5,
|
||||
.ewald_dist_cutoff = 0.002
|
||||
};
|
||||
|
||||
std::vector<SpotToSave> spots;
|
||||
BraggPrediction prediction;
|
||||
|
||||
// Predict reflections for images at 0-30 deg.
|
||||
for (int img = 0; img < 10; ++img) {
|
||||
// For a rotated image, per-image lattice is obtained as Multiply(rot.transpose())
|
||||
const float angle_deg = axis.GetAngle_deg(img) + axis.GetWedge_deg() / 2.0f;
|
||||
const RotMatrix rot = axis.GetTransformationAngle(angle_deg);
|
||||
const CrystalLattice latt_img = latt_base.Multiply(rot.transpose());
|
||||
|
||||
const auto n = prediction.Calc(exp_i, latt_img, prediction_settings);
|
||||
for (int i = 0; i < n; ++i) {
|
||||
const auto& r = prediction.GetReflections().at(i);
|
||||
SpotToSave s{};
|
||||
s.x = r.predicted_x;
|
||||
s.y = r.predicted_y;
|
||||
s.image = img; // provide image index for rotation-aware refinement
|
||||
s.intensity = 1.0f; // minimal positive value
|
||||
s.ice_ring = false;
|
||||
s.indexed = true;
|
||||
spots.push_back(s);
|
||||
}
|
||||
}
|
||||
|
||||
// Seed slightly perturbed geometry and lattice; provide rotation axis for refinement
|
||||
XtalOptimizerData xtal_opt;
|
||||
xtal_opt.latt = CrystalLattice(39.7f, 50.6f, 79.6f, 90.0f, 94.5f, 90.5f);
|
||||
xtal_opt.geom.BeamX_pxl(1003).BeamY_pxl(997).DetectorDistance_mm(200.0)
|
||||
.PoniRot1_rad(0.01).PoniRot2_rad(0.02);
|
||||
xtal_opt.crystal_system = gemmi::CrystalSystem::Monoclinic;
|
||||
xtal_opt.axis = GoniometerAxis("omega", 0.0f, 3.0f,
|
||||
Coord(0.8, 0.05, 0.05).Normalize(),
|
||||
std::nullopt);
|
||||
xtal_opt.min_spots = 200;
|
||||
xtal_opt.refine_beam_center = true;
|
||||
xtal_opt.refine_distance_mm = false;
|
||||
xtal_opt.refine_detector_angles = false;
|
||||
xtal_opt.refine_rotation_axis = true;
|
||||
|
||||
auto t0 = std::chrono::high_resolution_clock::now();
|
||||
REQUIRE(XtalOptimizer(xtal_opt, spots));
|
||||
auto t1 = std::chrono::high_resolution_clock::now();
|
||||
std::cout << "XtalOptimizer (rotation 4 images) took "
|
||||
<< std::chrono::duration_cast<std::chrono::microseconds>(t1 - t0).count()
|
||||
<< " microseconds" << std::endl;
|
||||
|
||||
const auto uc_out = xtal_opt.latt.GetUnitCell();
|
||||
|
||||
// Geometry checks
|
||||
CHECK(fabsf(xtal_opt.geom.GetBeamX_pxl() - exp_i.GetBeamX_pxl()) < 0.2f);
|
||||
CHECK(fabsf(xtal_opt.geom.GetBeamY_pxl() - exp_i.GetBeamY_pxl()) < 0.2f);
|
||||
|
||||
// Lattice checks
|
||||
CHECK(fabsf(uc_ref.a - uc_out.a) < 0.2f);
|
||||
CHECK(fabsf(uc_ref.b - uc_out.b) < 0.2f);
|
||||
CHECK(fabsf(uc_ref.c - uc_out.c) < 0.3f);
|
||||
CHECK(fabsf(uc_ref.alpha - uc_out.alpha) < 0.2f);
|
||||
CHECK(fabsf(uc_ref.beta - uc_out.beta) < 0.2f);
|
||||
CHECK(fabsf(uc_ref.gamma - uc_out.gamma) < 0.2f);
|
||||
CHECK(fabsf(xtal_opt.axis->GetAxis().x - 1.0) < 0.01f);
|
||||
CHECK(fabsf(xtal_opt.axis->GetAxis().y) < 0.01f);
|
||||
CHECK(fabsf(xtal_opt.axis->GetAxis().z) < 0.01f);
|
||||
}
|
||||
Reference in New Issue
Block a user