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>
136 lines
4.4 KiB
C++
136 lines
4.4 KiB
C++
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include <cmath>
|
|
|
|
#include "GoniometerAxis.h"
|
|
#include "JFJochException.h"
|
|
|
|
#define check_finite(param, val) if (!std::isfinite(val)) throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, param)
|
|
|
|
GoniometerAxis::GoniometerAxis(const std::string& in_name,
|
|
float in_start,
|
|
float in_increment,
|
|
const Coord &in_axis,
|
|
const std::optional<Coord> &in_helical_step) {
|
|
if (in_name.empty())
|
|
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
|
"Name of goniometer axis cannot be empty");
|
|
|
|
check_finite("Rotation angle increment", in_increment);
|
|
check_finite("Rotation angle start", in_start);
|
|
|
|
if (in_axis.Length() == 0.0f)
|
|
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
|
"Rotation axis cannot have 0 length");
|
|
|
|
name = in_name;
|
|
start = in_start;
|
|
increment = in_increment;
|
|
axis = in_axis.Normalize(); // Make sure rotation axis is normalized!
|
|
helical_step = in_helical_step;
|
|
}
|
|
|
|
GoniometerAxis &GoniometerAxis::ScreeningWedge(const std::optional<float> &input) {
|
|
screening_wedge = input;
|
|
return *this;
|
|
}
|
|
|
|
GoniometerAxis &GoniometerAxis::Axis(const Coord &input) {
|
|
float len = input.Length();
|
|
if (len == 0.0f)
|
|
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
|
"Rotation axis cannot have 0 length");
|
|
// increment *= len;
|
|
axis = input.Normalize();
|
|
return *this;
|
|
}
|
|
|
|
std::string GoniometerAxis::GetName() const {
|
|
return name;
|
|
}
|
|
|
|
float GoniometerAxis::GetStart_deg() const {
|
|
return start;
|
|
}
|
|
|
|
float GoniometerAxis::GetIncrement_deg() const {
|
|
return increment;
|
|
}
|
|
|
|
Coord GoniometerAxis::GetAxis() const {
|
|
return axis;
|
|
}
|
|
|
|
std::optional<Coord> GoniometerAxis::GetHelicalStep() const {
|
|
return helical_step;
|
|
}
|
|
|
|
Coord GoniometerAxis::GetPosition(int64_t image_number) const {
|
|
return helical_step.value_or(Coord()) * static_cast<float>(image_number);
|
|
}
|
|
|
|
float GoniometerAxis::GetAngle_deg(float image_number) const {
|
|
return start + increment * image_number;
|
|
}
|
|
|
|
std::vector<double> GoniometerAxis::GetAxisVector() const {
|
|
return {axis[0], axis[1], axis[2]};
|
|
}
|
|
|
|
std::vector<double> GoniometerAxis::GetXContainer_m(int64_t max_image_number) const {
|
|
if (!helical_step.has_value())
|
|
return {};
|
|
std::vector<double> angle_container(max_image_number);
|
|
for (int32_t i = 0; i < max_image_number; i++)
|
|
angle_container[i] = helical_step->x * i * 1e-6;
|
|
return angle_container;
|
|
}
|
|
|
|
std::vector<double> GoniometerAxis::GetYContainer_m(int64_t max_image_number) const {
|
|
if (!helical_step.has_value())
|
|
return {};
|
|
std::vector<double> angle_container(max_image_number);
|
|
for (int32_t i = 0; i < max_image_number; i++)
|
|
angle_container[i] = helical_step->y * i * 1e-6;
|
|
return angle_container;
|
|
}
|
|
|
|
std::vector<double> GoniometerAxis::GetZContainer_m(int64_t max_image_number) const {
|
|
if (!helical_step.has_value())
|
|
return {};
|
|
std::vector<double> angle_container(max_image_number);
|
|
for (int32_t i = 0; i < max_image_number; i++)
|
|
angle_container[i] = helical_step->z * i * 1e-6;
|
|
return angle_container;
|
|
}
|
|
|
|
std::vector<double> GoniometerAxis::GetAngleContainer(int64_t max_image_number) const {
|
|
std::vector<double> angle_container(max_image_number);
|
|
for (int32_t i = 0; i < max_image_number; i++)
|
|
angle_container[i] = GetAngle_deg(i);
|
|
return angle_container;
|
|
}
|
|
|
|
std::optional<float> GoniometerAxis::GetScreeningWedge() const {
|
|
return screening_wedge;
|
|
}
|
|
|
|
float GoniometerAxis::GetWedge_deg() const {
|
|
if (!screening_wedge.has_value())
|
|
return GetIncrement_deg();
|
|
return *screening_wedge;
|
|
}
|
|
|
|
std::vector<double> GoniometerAxis::GetAngleContainerEnd(int64_t max_image_number) const {
|
|
float wedge = GetWedge_deg();
|
|
std::vector<double> angle_container(max_image_number);
|
|
for (int32_t i = 0; i < max_image_number; i++)
|
|
angle_container[i] = GetAngle_deg(i) + wedge;
|
|
return angle_container;
|
|
}
|
|
|
|
RotMatrix GoniometerAxis::GetTransformationAngle(float angle_deg) const {
|
|
auto angle_rad = angle_deg / 180.0f * static_cast<float>(M_PI);
|
|
return {angle_rad, axis};
|
|
} |