Build Packages / Create release (push) Successful in 23s
Build Packages / build:rugnux-tgz (x86_64) (push) Successful in 10m6s
Build Packages / build:rugnux:aarch64 (cross) (push) Successful in 9m6s
Build Packages / build:viewer-tgz:cpu (push) Successful in 11m15s
Build Packages / build:viewer-tgz:cuda (push) Successful in 12m21s
Build Packages / build:windows:nocuda (push) Successful in 17m9s
Build Packages / build:windows:cuda (push) Successful in 19m49s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 25m42s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 16m0s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 14m54s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 17m7s
Build Packages / build:rugnux:windows (push) Successful in 10m47s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 17m4s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 17m8s
Build Packages / Generate python client (push) Successful in 45s
Build Packages / Build documentation (push) Successful in 1m45s
Build Packages / build:rpm (rocky9_sls9) (push) Successful in 19m23s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 19m20s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 18m43s
Build Packages / build:rpm (rocky8) (push) Successful in 19m31s
Build Packages / build:rpm (rocky9) (push) Successful in 20m16s
Build Packages / Unit tests (push) Successful in 1h41m19s
* Fixed a `jfjoch_broker` crash during indexing: sorting no longer misbehaves on non-finite values, and GPU FFT indexer kernel launches are now error-checked. * rugnux needs about a third less peak memory to scale, merge and post-refine rotation data, with identical results. * `rugnux --model`: the placed coordinate file carries the space group its own coordinates obey, and says so when that is not the group the reflection files beside it carry. * `jfjoch_viewer`: fixes in the dataset plots, inspector and layout; spot markers lose their black outline by default (a checkbox under "Image features" restores it) and the highest-pixel markers are white boxes around the pixel. Reviewed-on: #80 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
84 lines
2.6 KiB
C++
84 lines
2.6 KiB
C++
// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include <cmath>
|
|
#include "JFJochMath.h"
|
|
#include "ROIAzimuthal.h"
|
|
#include "JFJochException.h"
|
|
|
|
static float NormalizePhi_deg(float phi) {
|
|
phi = std::fmod(phi, 360.0f);
|
|
if (phi < 0)
|
|
phi += 360.0f;
|
|
return phi;
|
|
}
|
|
|
|
ROIAzimuthal::ROIAzimuthal(const std::string &in_name, float in_d_min_A, float in_d_max_A,
|
|
float in_phi_min_deg, float in_phi_max_deg)
|
|
: ROIElement(in_name),
|
|
phi_min_deg(NormalizePhi_deg(in_phi_min_deg)),
|
|
phi_max_deg(NormalizePhi_deg(in_phi_max_deg)) {
|
|
// isfinite, not just > 0: NaN passes every <= test and inf passes > 0 (see ROICircle).
|
|
if (!std::isfinite(in_d_min_A) || !std::isfinite(in_d_max_A)
|
|
|| (in_d_min_A <= 0) || (in_d_max_A <= 0)
|
|
|| !std::isfinite(in_phi_min_deg) || !std::isfinite(in_phi_max_deg))
|
|
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
|
"Resolution and angles must be positive finite numbers");
|
|
if (in_d_min_A > in_d_max_A) {
|
|
d_max_A = in_d_min_A;
|
|
d_min_A = in_d_max_A;
|
|
} else {
|
|
d_max_A = in_d_max_A;
|
|
d_min_A = in_d_min_A;
|
|
}
|
|
}
|
|
|
|
float ROIAzimuthal::GetDMin_A() const {
|
|
return d_min_A;
|
|
}
|
|
|
|
float ROIAzimuthal::GetDMax_A() const {
|
|
return d_max_A;
|
|
}
|
|
|
|
bool ROIAzimuthal::HasPhi() const {
|
|
return phi_min_deg != phi_max_deg;
|
|
}
|
|
|
|
float ROIAzimuthal::GetPhiMin_deg() const {
|
|
return phi_min_deg;
|
|
}
|
|
|
|
float ROIAzimuthal::GetPhiMax_deg() const {
|
|
return phi_max_deg;
|
|
}
|
|
|
|
bool ROIAzimuthal::CheckROI(int64_t x, int64_t y, float resolution, float phi_deg) const {
|
|
if (resolution < d_min_A || resolution > d_max_A)
|
|
return false;
|
|
if (phi_min_deg == phi_max_deg)
|
|
return true; // full ring: all angles
|
|
if (phi_min_deg <= phi_max_deg)
|
|
return (phi_deg >= phi_min_deg) && (phi_deg <= phi_max_deg);
|
|
return (phi_deg >= phi_min_deg) || (phi_deg <= phi_max_deg); // sector wraps across 0
|
|
}
|
|
|
|
float ROIAzimuthal::GetQMax_recipA() const {
|
|
return 2.0f * PI / d_min_A;
|
|
}
|
|
|
|
float ROIAzimuthal::GetQMin_recipA() const {
|
|
return 2.0f * PI / d_max_A;
|
|
}
|
|
|
|
ROIConfig ROIAzimuthal::ExportMetadata() const {
|
|
double qmin = GetQMin_recipA();
|
|
double qmax = GetQMax_recipA();
|
|
return ROIConfig{
|
|
.type = ROIConfig::ROIType::Azim,
|
|
.name = name,
|
|
.azim = ROIConfigAzim{.qmin = qmin, .qmax = qmax,
|
|
.phi_min = phi_min_deg, .phi_max = phi_max_deg}
|
|
};
|
|
}
|