v1.0.0-rc.124 (#31)
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
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:
@@ -9,7 +9,7 @@ struct XtalResidual {
|
||||
XtalResidual(double x, double y,
|
||||
double lambda,
|
||||
double pixel_size,
|
||||
const Eigen::Matrix3d &gonio_back_rot,
|
||||
double angle_rad,
|
||||
double exp_h, double exp_k,
|
||||
double exp_l,
|
||||
gemmi::CrystalSystem symmetry)
|
||||
@@ -19,7 +19,7 @@ struct XtalResidual {
|
||||
exp_h(exp_h),
|
||||
exp_k(exp_k),
|
||||
exp_l(exp_l),
|
||||
gonio_back_rot_(gonio_back_rot),
|
||||
angle_rad(angle_rad),
|
||||
symmetry(symmetry) {
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ struct XtalResidual {
|
||||
const T *const beam_y,
|
||||
const T *const distance_mm,
|
||||
const T *const detector_rot,
|
||||
const T *const rotation_axis,
|
||||
const T *const p0,
|
||||
const T *const p1,
|
||||
const T *const p2,
|
||||
@@ -59,7 +60,13 @@ struct XtalResidual {
|
||||
|
||||
// Apply goniometer "back-to-start" rotation:
|
||||
// brings observed reciprocal from image orientation into reference crystal frame
|
||||
Eigen::Matrix<T, 3, 3> R_gonio_back = gonio_back_rot_.cast<T>();
|
||||
T v[3], rot_arr[9];
|
||||
v[0] = T(angle_rad) * rotation_axis[0];
|
||||
v[1] = T(angle_rad) * rotation_axis[1];
|
||||
v[2] = T(angle_rad) * rotation_axis[2];
|
||||
ceres::AngleAxisToRotationMatrix(v, rot_arr);
|
||||
|
||||
Eigen::Matrix<T, 3, 3> R_gonio_back(rot_arr);
|
||||
Eigen::Matrix<T, 3, 1> e_obs_recip = R_gonio_back * e_obs_recip_raw;
|
||||
|
||||
Eigen::Matrix<T, 3, 1> e_pred;
|
||||
@@ -139,7 +146,7 @@ struct XtalResidual {
|
||||
const double exp_h;
|
||||
const double exp_k;
|
||||
const double exp_l;
|
||||
const Eigen::Matrix3d gonio_back_rot_;
|
||||
const double angle_rad;
|
||||
gemmi::CrystalSystem symmetry;
|
||||
};
|
||||
|
||||
@@ -382,6 +389,8 @@ bool XtalOptimizerInternal(XtalOptimizerData &data,
|
||||
|
||||
double latt_vec0[3], latt_vec1[3], latt_vec2[3];
|
||||
|
||||
double rot_vec[3] = {1, 0, 0};
|
||||
|
||||
switch (data.crystal_system) {
|
||||
case gemmi::CrystalSystem::Orthorhombic:
|
||||
LatticeToRodriguesAndLengths_GS(data.latt, latt_vec0, latt_vec1);
|
||||
@@ -413,23 +422,33 @@ bool XtalOptimizerInternal(XtalOptimizerData &data,
|
||||
break;
|
||||
}
|
||||
|
||||
if (data.axis) {
|
||||
rot_vec[0] = data.axis->GetAxis().x;
|
||||
rot_vec[1] = data.axis->GetAxis().y;
|
||||
rot_vec[2] = data.axis->GetAxis().z;
|
||||
}
|
||||
|
||||
const float tolerance_sq = tolerance * tolerance;
|
||||
|
||||
// Add residuals for each point
|
||||
for (const auto &pt: spots) {
|
||||
if (!data.index_ice_rings && pt.ice_ring)
|
||||
continue;
|
||||
|
||||
Eigen::Matrix3d gonio_back_rot = Eigen::Matrix3d::Identity();
|
||||
|
||||
Coord axis = Coord(1,0,0);
|
||||
float angle_rad = 0.0;
|
||||
|
||||
Coord recip = data.geom.DetectorToRecip(pt.x, pt.y);
|
||||
|
||||
if (data.axis) {
|
||||
auto rot = data.axis->GetTransformation(pt.image);
|
||||
const float angle_deg = data.axis->GetAngle_deg(pt.image) + data.axis->GetWedge_deg() / 2.0f;
|
||||
auto rot = data.axis->GetTransformationAngle(angle_deg);
|
||||
recip = rot * recip;
|
||||
|
||||
Eigen::Matrix3d Rg;
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 3; ++j) {
|
||||
Rg(i, j) = static_cast<double>(rot.arr()[i + j * 3]);
|
||||
}
|
||||
}
|
||||
gonio_back_rot = Rg.transpose();
|
||||
angle_rad = angle_deg * M_PI / 180.0;
|
||||
axis = data.axis->GetAxis();
|
||||
}
|
||||
|
||||
double h_fp = recip * vec0;
|
||||
@@ -442,16 +461,15 @@ bool XtalOptimizerInternal(XtalOptimizerData &data,
|
||||
|
||||
double norm_sq = (h - h_fp) * (h - h_fp) + (k - k_fp) * (k - k_fp) + (l - l_fp) * (l - l_fp);
|
||||
|
||||
if (norm_sq > tolerance * tolerance)
|
||||
if (norm_sq > tolerance_sq)
|
||||
continue;
|
||||
|
||||
|
||||
problem.AddResidualBlock(
|
||||
new ceres::AutoDiffCostFunction<XtalResidual, 3, 1, 1, 1, 2, 3, 3, 3>(
|
||||
new ceres::AutoDiffCostFunction<XtalResidual, 3, 1, 1, 1, 2, 3, 3, 3, 3>(
|
||||
new XtalResidual(pt.x, pt.y,
|
||||
data.geom.GetWavelength_A(),
|
||||
data.geom.GetPixelSize_mm(),
|
||||
gonio_back_rot,
|
||||
angle_rad,
|
||||
h, k, l,
|
||||
data.crystal_system)),
|
||||
nullptr,
|
||||
@@ -459,6 +477,7 @@ bool XtalOptimizerInternal(XtalOptimizerData &data,
|
||||
&beam_y,
|
||||
&distance_mm,
|
||||
detector_rot,
|
||||
rot_vec,
|
||||
latt_vec0,
|
||||
latt_vec1,
|
||||
latt_vec2
|
||||
@@ -491,25 +510,34 @@ bool XtalOptimizerInternal(XtalOptimizerData &data,
|
||||
}
|
||||
}
|
||||
|
||||
// Parameter bounds
|
||||
// Lengths
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
problem.SetParameterLowerBound(latt_vec1, i, data.min_length_A);
|
||||
problem.SetParameterUpperBound(latt_vec1, i, data.max_length_A);
|
||||
if (!data.refine_rotation_axis) {
|
||||
problem.SetParameterBlockConstant(rot_vec);
|
||||
}
|
||||
|
||||
if (data.crystal_system == gemmi::CrystalSystem::Monoclinic) {
|
||||
const double beta_lo = std::max(1e-6, M_PI * (data.min_angle_deg / 180.0));
|
||||
const double beta_hi = std::min(M_PI - 1e-6, M_PI * (data.max_angle_deg / 180.0));
|
||||
problem.SetParameterLowerBound(latt_vec2, 0, beta_lo);
|
||||
problem.SetParameterUpperBound(latt_vec2, 0, beta_hi);
|
||||
} else if (data.crystal_system == gemmi::CrystalSystem::Triclinic) {
|
||||
// α, β, γ bounds (radians)
|
||||
const double alo = M_PI * (data.min_angle_deg / 180.0);
|
||||
const double ahi = M_PI * (data.max_angle_deg / 180.0);
|
||||
if (!data.refine_unit_cell) {
|
||||
problem.SetParameterBlockConstant(latt_vec1);
|
||||
problem.SetParameterBlockConstant(latt_vec2);
|
||||
} else {
|
||||
// Parameter bounds
|
||||
// Lengths
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
problem.SetParameterLowerBound(latt_vec2, i, alo);
|
||||
problem.SetParameterUpperBound(latt_vec2, i, ahi);
|
||||
problem.SetParameterLowerBound(latt_vec1, i, data.min_length_A);
|
||||
problem.SetParameterUpperBound(latt_vec1, i, data.max_length_A);
|
||||
}
|
||||
|
||||
if (data.crystal_system == gemmi::CrystalSystem::Monoclinic) {
|
||||
const double beta_lo = std::max(1e-6, M_PI * (data.min_angle_deg / 180.0));
|
||||
const double beta_hi = std::min(M_PI - 1e-6, M_PI * (data.max_angle_deg / 180.0));
|
||||
problem.SetParameterLowerBound(latt_vec2, 0, beta_lo);
|
||||
problem.SetParameterUpperBound(latt_vec2, 0, beta_hi);
|
||||
} else if (data.crystal_system == gemmi::CrystalSystem::Triclinic) {
|
||||
// α, β, γ bounds (radians)
|
||||
const double alo = M_PI * (data.min_angle_deg / 180.0);
|
||||
const double ahi = M_PI * (data.max_angle_deg / 180.0);
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
problem.SetParameterLowerBound(latt_vec2, i, alo);
|
||||
problem.SetParameterUpperBound(latt_vec2, i, ahi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -536,6 +564,9 @@ bool XtalOptimizerInternal(XtalOptimizerData &data,
|
||||
if (data.refine_detector_angles)
|
||||
data.geom.PoniRot1_rad(detector_rot[0]).PoniRot2_rad(detector_rot[1]);
|
||||
|
||||
if (data.axis && data.refine_rotation_axis)
|
||||
data.axis.value().Axis(Coord(rot_vec[0], rot_vec[1], rot_vec[2]));
|
||||
|
||||
if (data.crystal_system == gemmi::CrystalSystem::Orthorhombic)
|
||||
data.latt = AngleAxisAndLengthsToLattice(latt_vec0, latt_vec1, false);
|
||||
else if (data.crystal_system == gemmi::CrystalSystem::Tetragonal) {
|
||||
@@ -599,5 +630,6 @@ bool XtalOptimizerInternal(XtalOptimizerData &data,
|
||||
bool XtalOptimizer(XtalOptimizerData &data, const std::vector<SpotToSave> &spots) {
|
||||
if (!XtalOptimizerInternal(data, spots, 0.3))
|
||||
return false;
|
||||
XtalOptimizerInternal(data, spots, 0.2);
|
||||
return XtalOptimizerInternal(data, spots, 0.1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user