v1.0.0-rc.141 #51
@@ -200,7 +200,7 @@ void AcquisitionDevice::InitializeEmptyPixelMask(const DiffractionExperiment &ex
|
||||
|
||||
|
||||
void AcquisitionDevice::InitializeDataProcessing(const DiffractionExperiment &experiment,
|
||||
const AzimuthalIntegration &azint) {
|
||||
const AzimuthalIntegrationMapping &azint) {
|
||||
auto offset = experiment.GetFirstModuleOfDataStream(data_stream);
|
||||
size_t modules = experiment.GetModulesNum(data_stream);
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "Completion.h"
|
||||
#include "../fpga/pcie_driver/jfjoch_fpga.h"
|
||||
#include "../common/NetworkAddressConvert.h"
|
||||
#include "../common/AzimuthalIntegration.h"
|
||||
#include "../common/AzimuthalIntegrationMapping.h"
|
||||
|
||||
struct AcquisitionDeviceStatistics {
|
||||
uint64_t good_packets;
|
||||
@@ -101,7 +101,7 @@ public:
|
||||
void InitializePixelMask(const DiffractionExperiment &experiment, const PixelMask &mask_raw);
|
||||
virtual void InitializePixelMask(const uint32_t *module_mask, size_t module_number);
|
||||
void InitializeROIMap(const DiffractionExperiment& experiment, const std::vector<uint16_t>& raw_roi_map);
|
||||
void InitializeDataProcessing(const DiffractionExperiment &experiment, const AzimuthalIntegration& azint);
|
||||
void InitializeDataProcessing(const DiffractionExperiment &experiment, const AzimuthalIntegrationMapping& azint);
|
||||
|
||||
const AcquisitionCounters& Counters() const;
|
||||
|
||||
|
||||
@@ -1,173 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "AzimuthalIntegration.h"
|
||||
#include "JFJochException.h"
|
||||
#include "DiffractionGeometry.h"
|
||||
#include "RawToConvertedGeometry.h"
|
||||
|
||||
AzimuthalIntegration::AzimuthalIntegration(const AzimuthalIntegrationSettings& in_settings, size_t width, size_t height,
|
||||
float wavelength)
|
||||
: settings(in_settings), width(width), height(height), wavelength(wavelength) {
|
||||
if (width <= 0)
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Detector width must be above 0");
|
||||
|
||||
if (height <= 0)
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Detector height must be above 0");
|
||||
|
||||
if (settings.GetBinCount() >= UINT16_MAX)
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Cannot handle more than 65534 az. int. bins");
|
||||
}
|
||||
|
||||
AzimuthalIntegration::AzimuthalIntegration(const DiffractionExperiment &experiment,
|
||||
const PixelMask& mask)
|
||||
: AzimuthalIntegration(experiment.GetAzimuthalIntegrationSettings(),
|
||||
experiment.GetXPixelsNum(),
|
||||
experiment.GetYPixelsNum(),
|
||||
experiment.GetWavelength_A()) {
|
||||
|
||||
polarization_factor = experiment.GetPolarizationFactor();
|
||||
|
||||
if (!experiment.IsGeometryTransformed())
|
||||
SetupRawGeom(experiment, mask.GetMaskRaw(experiment));
|
||||
else
|
||||
SetupConvGeom(experiment.GetDiffractionGeometry(),mask.GetMask());
|
||||
|
||||
UpdateMaxBinNumber();
|
||||
}
|
||||
|
||||
void AzimuthalIntegration::SetupConvGeom(const DiffractionGeometry &geom,
|
||||
const std::vector<uint32_t> &mask) {
|
||||
pixel_to_bin.resize(width * height, UINT16_MAX);
|
||||
pixel_resolution.resize(width * height, 0);
|
||||
corrections.resize(width * height, 0);
|
||||
|
||||
if (mask.size() != width * height)
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Mask size invalid");
|
||||
for (int row = 0; row < height; row++)
|
||||
for (int col = 0; col < width; col++)
|
||||
SetupPixel(geom, mask, row * width + col, col, row);
|
||||
}
|
||||
|
||||
void AzimuthalIntegration::SetupRawGeom(const DiffractionExperiment &experiment,
|
||||
const std::vector<uint32_t> &mask) {
|
||||
if (mask.size() != RAW_MODULE_SIZE * experiment.GetModulesNum())
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Mask size invalid");
|
||||
|
||||
pixel_to_bin.resize(RAW_MODULE_SIZE * experiment.GetModulesNum(), UINT16_MAX);
|
||||
pixel_resolution.resize(RAW_MODULE_SIZE * experiment.GetModulesNum(), 0);
|
||||
corrections.resize(RAW_MODULE_SIZE * experiment.GetModulesNum(), 0);
|
||||
|
||||
auto geom = experiment.GetDiffractionGeometry();
|
||||
|
||||
for (int m = 0; m < experiment.GetModulesNum(); m++) {
|
||||
for (int pxl = 0; pxl < RAW_MODULE_SIZE; pxl++) {
|
||||
auto [x,y] = RawToConvertedCoordinate(experiment, m, pxl);
|
||||
SetupPixel(geom, mask, m * RAW_MODULE_SIZE + pxl, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AzimuthalIntegration::SetupPixel(const DiffractionGeometry &geom,
|
||||
const std::vector<uint32_t> &mask,
|
||||
uint32_t pxl, uint32_t col, uint32_t row) {
|
||||
if (mask[pxl] != 0)
|
||||
return;
|
||||
|
||||
auto x = static_cast<float>(col);
|
||||
auto y = static_cast<float>(row);
|
||||
float d = geom.PxlToRes(x, y);
|
||||
float phi_rad = geom.Phi_rad(x, y);
|
||||
|
||||
pixel_resolution[pxl] = d;
|
||||
|
||||
float corr = 1.0;
|
||||
if (settings.IsSolidAngleCorrection())
|
||||
corr /= geom.CalcAzIntSolidAngleCorr(x, y);
|
||||
if (settings.IsPolarizationCorrection() && polarization_factor)
|
||||
corr /= geom.CalcAzIntPolarizationCorr(x, y, polarization_factor.value());
|
||||
corrections[pxl] = corr;
|
||||
|
||||
if (d > 0) {
|
||||
float q = 2.0f * static_cast<float>(M_PI) / d;
|
||||
pixel_to_bin[pxl] = settings.GetBin(q, phi_rad * 180.0 / M_PI);
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t AzimuthalIntegration::GetBinNumber() const {
|
||||
return settings.GetBinCount();
|
||||
}
|
||||
|
||||
const std::vector<uint16_t> &AzimuthalIntegration::GetPixelToBin() const {
|
||||
return pixel_to_bin;
|
||||
}
|
||||
|
||||
const std::vector<float> &AzimuthalIntegration::GetBinToQ() const {
|
||||
return bin_to_q;
|
||||
}
|
||||
|
||||
const std::vector<float> &AzimuthalIntegration::GetBinToD() const {
|
||||
return bin_to_d;
|
||||
}
|
||||
|
||||
const std::vector<float> &AzimuthalIntegration::GetBinToTwoTheta() const {
|
||||
return bin_to_2theta;
|
||||
}
|
||||
|
||||
const std::vector<float> &AzimuthalIntegration::GetBinToPhi() const {
|
||||
return bin_to_phi;
|
||||
}
|
||||
|
||||
uint16_t AzimuthalIntegration::QToBin(float q) const {
|
||||
return settings.QToBin(q);
|
||||
}
|
||||
|
||||
void AzimuthalIntegration::UpdateMaxBinNumber() {
|
||||
bin_to_q.resize(settings.GetBinCount());
|
||||
bin_to_d.resize(settings.GetBinCount());
|
||||
bin_to_2theta.resize(settings.GetBinCount());
|
||||
bin_to_phi.resize(settings.GetBinCount());
|
||||
|
||||
for (int j = 0; j < settings.GetAzimuthalBinCount(); j++) {
|
||||
for (int i = 0; i < settings.GetQBinCount(); i++) {
|
||||
bin_to_q[j * settings.GetQBinCount() + i] = static_cast<float>(settings.GetQSpacing_recipA() * (i + 0.5) + settings.GetLowQ_recipA());
|
||||
bin_to_d[j * settings.GetQBinCount() + i] = 2.0f * static_cast<float>(M_PI) / bin_to_q[j * settings.GetQBinCount() + i];
|
||||
bin_to_2theta[j * settings.GetQBinCount() + i] = 2.0f * asinf(bin_to_q[i] * wavelength / (4.0f * static_cast<float>(M_PI))) * 180.0f /
|
||||
static_cast<float>(M_PI);
|
||||
bin_to_phi[j * settings.GetQBinCount() + i] = static_cast<float>(j) * 360.0f / static_cast<float>(settings.GetAzimuthalBinCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<float> &AzimuthalIntegration::Corrections() const {
|
||||
return corrections;
|
||||
}
|
||||
|
||||
const std::vector<float> &AzimuthalIntegration::Resolution() const {
|
||||
return pixel_resolution;
|
||||
}
|
||||
|
||||
const AzimuthalIntegrationSettings &AzimuthalIntegration::Settings() const {
|
||||
return settings;
|
||||
}
|
||||
|
||||
size_t AzimuthalIntegration::GetWidth() const {
|
||||
return width;
|
||||
}
|
||||
|
||||
size_t AzimuthalIntegration::GetHeight() const {
|
||||
return height;
|
||||
}
|
||||
|
||||
int32_t AzimuthalIntegration::GetAzimuthalBinCount() const {
|
||||
return settings.GetAzimuthalBinCount();
|
||||
}
|
||||
|
||||
int32_t AzimuthalIntegration::GetQBinCount() const {
|
||||
return settings.GetQBinCount();
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#include <cmath>
|
||||
#include <thread>
|
||||
#include <future>
|
||||
|
||||
#include "AzimuthalIntegrationMapping.h"
|
||||
#include "JFJochException.h"
|
||||
#include "DiffractionGeometry.h"
|
||||
#include "RawToConvertedGeometry.h"
|
||||
|
||||
AzimuthalIntegrationMapping::AzimuthalIntegrationMapping(const DiffractionExperiment &experiment,
|
||||
const PixelMask& mask,
|
||||
size_t in_nthreads)
|
||||
: settings(experiment.GetAzimuthalIntegrationSettings()),
|
||||
wavelength(experiment.GetWavelength_A()),
|
||||
width(experiment.GetXPixelsNumConv()),
|
||||
height(experiment.GetYPixelsNumConv()) {
|
||||
|
||||
if (width <= 0)
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Detector width must be above 0");
|
||||
|
||||
if (height <= 0)
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Detector height must be above 0");
|
||||
|
||||
if (settings.GetBinCount() >= UINT16_MAX)
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Cannot handle more than 65534 az. int. bins");
|
||||
|
||||
polarization_factor = experiment.GetPolarizationFactor();
|
||||
|
||||
if (in_nthreads == 0)
|
||||
nthreads = std::thread::hardware_concurrency();
|
||||
else
|
||||
nthreads = in_nthreads;
|
||||
|
||||
nthreads = std::clamp<size_t>(nthreads, 1, 64);
|
||||
|
||||
if (!experiment.IsGeometryTransformed())
|
||||
SetupRawGeom(experiment, mask.GetMaskRaw(experiment), nthreads);
|
||||
else
|
||||
SetupConvGeom(experiment.GetDiffractionGeometry(),mask.GetMask(), nthreads);
|
||||
|
||||
UpdateMaxBinNumber();
|
||||
}
|
||||
|
||||
void AzimuthalIntegrationMapping::SetupConvGeomRows(const DiffractionGeometry &geom, const std::vector<uint32_t> &mask,
|
||||
size_t row0, size_t row_end) {
|
||||
for (size_t row = row0; row < row_end && row < height; row++) {
|
||||
for (size_t col = 0; col < width; col++)
|
||||
SetupPixel(geom, mask, row * width + col, col, row);
|
||||
}
|
||||
}
|
||||
|
||||
void AzimuthalIntegrationMapping::SetupConvGeom(const DiffractionGeometry &geom,
|
||||
const std::vector<uint32_t> &mask,
|
||||
size_t nthreads) {
|
||||
pixel_to_bin.resize(width * height, UINT16_MAX);
|
||||
pixel_resolution.resize(width * height, 0);
|
||||
corrections.resize(width * height, 0);
|
||||
|
||||
if (mask.size() != width * height)
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Mask size invalid");
|
||||
|
||||
if (nthreads <= 1) {
|
||||
SetupConvGeomRows(geom, mask, 0, height);
|
||||
} else {
|
||||
nthreads = std::min(nthreads, height);
|
||||
std::vector<std::future<void>> futures;
|
||||
|
||||
for (size_t t = 0; t < nthreads; ++t)
|
||||
futures.emplace_back(std::async(std::launch::async,
|
||||
&AzimuthalIntegrationMapping::SetupConvGeomRows,
|
||||
this, std::cref(geom), std::cref(mask), t * height / nthreads, (t + 1) * height / nthreads));
|
||||
|
||||
for (auto &f: futures)
|
||||
f.get();
|
||||
}
|
||||
}
|
||||
|
||||
void AzimuthalIntegrationMapping::SetupRawGeom(const DiffractionExperiment &experiment,
|
||||
const std::vector<uint32_t> &mask, size_t nthreads) {
|
||||
if (mask.size() != RAW_MODULE_SIZE * experiment.GetModulesNum())
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Mask size invalid");
|
||||
|
||||
pixel_to_bin.resize(RAW_MODULE_SIZE * experiment.GetModulesNum(), UINT16_MAX);
|
||||
pixel_resolution.resize(RAW_MODULE_SIZE * experiment.GetModulesNum(), 0);
|
||||
corrections.resize(RAW_MODULE_SIZE * experiment.GetModulesNum(), 0);
|
||||
|
||||
auto geom = experiment.GetDiffractionGeometry();
|
||||
|
||||
if (nthreads <= 1) {
|
||||
for (int m = 0; m < experiment.GetModulesNum(); m++) {
|
||||
for (int pxl = 0; pxl < RAW_MODULE_SIZE; pxl++) {
|
||||
auto [x,y] = RawToConvertedCoordinate(experiment, m, pxl);
|
||||
SetupPixel(geom, mask, m * RAW_MODULE_SIZE + pxl, x, y);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
nthreads = std::min<size_t>(nthreads, experiment.GetModulesNum());
|
||||
std::vector<std::future<void>> futures;
|
||||
futures.reserve(nthreads);
|
||||
|
||||
for (size_t t = 0; t < nthreads; ++t) {
|
||||
const size_t module_begin = t * experiment.GetModulesNum() / nthreads;
|
||||
const size_t module_end = (t + 1) * experiment.GetModulesNum() / nthreads;
|
||||
|
||||
futures.emplace_back(std::async(std::launch::async, [&, module_begin, module_end] {
|
||||
for (size_t m = module_begin; m < module_end; ++m) {
|
||||
for (int pxl = 0; pxl < RAW_MODULE_SIZE; ++pxl) {
|
||||
auto [x, y] = RawToConvertedCoordinate(experiment, m, pxl);
|
||||
SetupPixel(geom, mask, m * RAW_MODULE_SIZE + pxl, x, y);
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
for (auto &f: futures)
|
||||
f.get();
|
||||
}
|
||||
}
|
||||
|
||||
void AzimuthalIntegrationMapping::SetupPixel(const DiffractionGeometry &geom,
|
||||
const std::vector<uint32_t> &mask,
|
||||
uint32_t pxl, uint32_t col, uint32_t row) {
|
||||
if (mask[pxl] != 0)
|
||||
return;
|
||||
|
||||
auto x = static_cast<float>(col);
|
||||
auto y = static_cast<float>(row);
|
||||
float d = geom.PxlToRes(x, y);
|
||||
float phi_rad = geom.Phi_rad(x, y);
|
||||
|
||||
pixel_resolution[pxl] = d;
|
||||
|
||||
float corr = 1.0;
|
||||
if (settings.IsSolidAngleCorrection())
|
||||
corr /= geom.CalcAzIntSolidAngleCorr(x, y);
|
||||
if (settings.IsPolarizationCorrection() && polarization_factor)
|
||||
corr /= geom.CalcAzIntPolarizationCorr(x, y, polarization_factor.value());
|
||||
corrections[pxl] = corr;
|
||||
|
||||
if (d > 0) {
|
||||
float q = 2.0f * static_cast<float>(M_PI) / d;
|
||||
pixel_to_bin[pxl] = settings.GetBin(q, phi_rad * 180.0 / M_PI);
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t AzimuthalIntegrationMapping::GetBinNumber() const {
|
||||
return settings.GetBinCount();
|
||||
}
|
||||
|
||||
const std::vector<uint16_t> &AzimuthalIntegrationMapping::GetPixelToBin() const {
|
||||
return pixel_to_bin;
|
||||
}
|
||||
|
||||
const std::vector<float> &AzimuthalIntegrationMapping::GetBinToQ() const {
|
||||
return bin_to_q;
|
||||
}
|
||||
|
||||
const std::vector<float> &AzimuthalIntegrationMapping::GetBinToD() const {
|
||||
return bin_to_d;
|
||||
}
|
||||
|
||||
const std::vector<float> &AzimuthalIntegrationMapping::GetBinToTwoTheta() const {
|
||||
return bin_to_2theta;
|
||||
}
|
||||
|
||||
const std::vector<float> &AzimuthalIntegrationMapping::GetBinToPhi() const {
|
||||
return bin_to_phi;
|
||||
}
|
||||
|
||||
uint16_t AzimuthalIntegrationMapping::QToBin(float q) const {
|
||||
return settings.QToBin(q);
|
||||
}
|
||||
|
||||
void AzimuthalIntegrationMapping::UpdateMaxBinNumber() {
|
||||
bin_to_q.resize(settings.GetBinCount());
|
||||
bin_to_d.resize(settings.GetBinCount());
|
||||
bin_to_2theta.resize(settings.GetBinCount());
|
||||
bin_to_phi.resize(settings.GetBinCount());
|
||||
|
||||
for (int j = 0; j < settings.GetAzimuthalBinCount(); j++) {
|
||||
for (int i = 0; i < settings.GetQBinCount(); i++) {
|
||||
bin_to_q[j * settings.GetQBinCount() + i] = static_cast<float>(settings.GetQSpacing_recipA() * (i + 0.5) + settings.GetLowQ_recipA());
|
||||
bin_to_d[j * settings.GetQBinCount() + i] = 2.0f * static_cast<float>(M_PI) / bin_to_q[j * settings.GetQBinCount() + i];
|
||||
bin_to_2theta[j * settings.GetQBinCount() + i] = 2.0f * asinf(bin_to_q[i] * wavelength / (4.0f * static_cast<float>(M_PI))) * 180.0f /
|
||||
static_cast<float>(M_PI);
|
||||
bin_to_phi[j * settings.GetQBinCount() + i] = static_cast<float>(j) * 360.0f / static_cast<float>(settings.GetAzimuthalBinCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<float> &AzimuthalIntegrationMapping::Corrections() const {
|
||||
return corrections;
|
||||
}
|
||||
|
||||
const std::vector<float> &AzimuthalIntegrationMapping::Resolution() const {
|
||||
return pixel_resolution;
|
||||
}
|
||||
|
||||
const AzimuthalIntegrationSettings &AzimuthalIntegrationMapping::Settings() const {
|
||||
return settings;
|
||||
}
|
||||
|
||||
size_t AzimuthalIntegrationMapping::GetWidth() const {
|
||||
return width;
|
||||
}
|
||||
|
||||
size_t AzimuthalIntegrationMapping::GetHeight() const {
|
||||
return height;
|
||||
}
|
||||
|
||||
int32_t AzimuthalIntegrationMapping::GetAzimuthalBinCount() const {
|
||||
return settings.GetAzimuthalBinCount();
|
||||
}
|
||||
|
||||
int32_t AzimuthalIntegrationMapping::GetQBinCount() const {
|
||||
return settings.GetQBinCount();
|
||||
}
|
||||
|
||||
size_t AzimuthalIntegrationMapping::GetNThreads() const {
|
||||
return nthreads;
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "DiffractionExperiment.h"
|
||||
#include "PixelMask.h"
|
||||
|
||||
class AzimuthalIntegration {
|
||||
class AzimuthalIntegrationMapping {
|
||||
protected:
|
||||
const AzimuthalIntegrationSettings settings;
|
||||
const float wavelength;
|
||||
@@ -25,22 +25,21 @@ protected:
|
||||
|
||||
std::optional<float> polarization_factor;
|
||||
|
||||
size_t nthreads;
|
||||
|
||||
void UpdateMaxBinNumber();
|
||||
AzimuthalIntegration(const AzimuthalIntegrationSettings& settings,
|
||||
size_t width, size_t height, float wavelength);
|
||||
|
||||
void SetupRawGeom(const DiffractionExperiment& experiment,
|
||||
const std::vector<uint32_t> &mask);
|
||||
|
||||
void SetupConvGeom(const DiffractionGeometry &geom,
|
||||
const std::vector<uint32_t> &mask);
|
||||
void SetupRawGeom(const DiffractionExperiment& experiment, const std::vector<uint32_t> &mask, size_t nthreads);
|
||||
void SetupConvGeomRows(const DiffractionGeometry &geom, const std::vector<uint32_t> &mask, size_t row0, size_t row_end);
|
||||
void SetupConvGeom(const DiffractionGeometry &geom, const std::vector<uint32_t> &mask, size_t nthreads);
|
||||
|
||||
void SetupPixel(const DiffractionGeometry &geom, const std::vector<uint32_t> &mask,
|
||||
uint32_t pxl, uint32_t col, uint32_t row);
|
||||
public:
|
||||
|
||||
AzimuthalIntegration(const DiffractionExperiment& experiment,
|
||||
const PixelMask& mask);
|
||||
AzimuthalIntegrationMapping(const DiffractionExperiment& experiment,
|
||||
const PixelMask& mask,
|
||||
size_t nthreads = 0);
|
||||
|
||||
[[nodiscard]] uint16_t GetBinNumber() const;
|
||||
[[nodiscard]] const std::vector<uint16_t>&GetPixelToBin() const;
|
||||
@@ -56,6 +55,7 @@ public:
|
||||
[[nodiscard]] const AzimuthalIntegrationSettings& Settings() const;
|
||||
[[nodiscard]] int32_t GetAzimuthalBinCount() const;
|
||||
[[nodiscard]] int32_t GetQBinCount() const;
|
||||
[[nodiscard]] size_t GetNThreads() const;
|
||||
};
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ inline float sum_to_count(float sum, uint64_t count) {
|
||||
return sum / (static_cast<float>(count));
|
||||
}
|
||||
|
||||
AzimuthalIntegrationProfile::AzimuthalIntegrationProfile(const AzimuthalIntegration &mapping)
|
||||
AzimuthalIntegrationProfile::AzimuthalIntegrationProfile(const AzimuthalIntegrationMapping &mapping)
|
||||
: sum(mapping.GetBinNumber(), 0),
|
||||
sum2(mapping.GetBinNumber(), 0),
|
||||
count(mapping.GetBinNumber(), 0),
|
||||
@@ -23,7 +23,7 @@ AzimuthalIntegrationProfile::AzimuthalIntegrationProfile(const AzimuthalIntegrat
|
||||
azim_bins(mapping.GetAzimuthalBinCount()) {
|
||||
}
|
||||
|
||||
void AzimuthalIntegrationProfile::Clear(const AzimuthalIntegration &mapping) {
|
||||
void AzimuthalIntegrationProfile::Clear(const AzimuthalIntegrationMapping &mapping) {
|
||||
std::unique_lock ul(m);
|
||||
|
||||
bin_to_d = mapping.GetBinToD();
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <mutex>
|
||||
#include "MultiLinePlot.h"
|
||||
|
||||
#include "AzimuthalIntegration.h"
|
||||
#include "AzimuthalIntegrationMapping.h"
|
||||
#include "../acquisition_device/AcquisitionDevice.h"
|
||||
|
||||
class AzimuthalIntegrationProfile {
|
||||
@@ -28,8 +28,8 @@ class AzimuthalIntegrationProfile {
|
||||
|
||||
const std::vector<float>& GetXAxis(PlotAzintUnit unit) const;
|
||||
public:
|
||||
explicit AzimuthalIntegrationProfile(const AzimuthalIntegration &mapping);
|
||||
void Clear(const AzimuthalIntegration &mapping);
|
||||
explicit AzimuthalIntegrationProfile(const AzimuthalIntegrationMapping &mapping);
|
||||
void Clear(const AzimuthalIntegrationMapping &mapping);
|
||||
void SetTitle(const std::string& input);
|
||||
void Add(const DeviceOutput &result);
|
||||
void Add(const std::vector<float> &sum, const std::vector<uint32_t> &count);
|
||||
|
||||
@@ -72,8 +72,8 @@ ADD_LIBRARY(JFJochCommon STATIC
|
||||
AzimuthalIntegrationSettings.h
|
||||
AzimuthalIntegrationProfile.h
|
||||
AzimuthalIntegrationProfile.cpp
|
||||
AzimuthalIntegration.h
|
||||
AzimuthalIntegration.cpp
|
||||
AzimuthalIntegrationMapping.h
|
||||
AzimuthalIntegrationMapping.cpp
|
||||
CheckPath.h
|
||||
AutoIncrVector.h
|
||||
ModuleSummation.cpp
|
||||
|
||||
@@ -247,6 +247,10 @@ void DectrisSimplonClient::EndAcquisitionFinished() {
|
||||
}
|
||||
|
||||
void DectrisSimplonClient::StartAcquisition(const DiffractionExperiment& experiment) {
|
||||
SetConfigIfDifferent(SimplonModule::Detector, "photon_energy", experiment.GetIncidentEnergy_keV() * 1e3f, 0.01f);
|
||||
auto thr = experiment.GetEigerThreshold_keV();
|
||||
SetConfigIfDifferent(SimplonModule::Detector, "threshold_energy", thr * 1e3f, 0.01);
|
||||
|
||||
SetConfigIfDifferent(SimplonModule::Detector, "count_time", std::chrono::duration<float>(experiment.GetFrameCountTime()).count(), 1e-9);
|
||||
SetConfigIfDifferent(SimplonModule::Detector, "frame_time", std::chrono::duration<float>(experiment.GetFrameTime()).count(), 1e-9);
|
||||
SetConfigIfDifferent(SimplonModule::Detector, "nimages", experiment.GetFrameNumPerTrigger());
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
## 1.0.0
|
||||
### 1.0.0-rc.141
|
||||
This is an UNSTABLE release. The release has significant modifications and bug fixes, if things go wrong, it is better to revert to 1.0.0-rc.132.
|
||||
|
||||
* jfjoch_broker: Azimuthal integration mapping is generated with parallel computations, significantly reducing setup times
|
||||
* frontend: Fix selection of FFTW in indexing settings
|
||||
|
||||
### 1.0.0-rc.140
|
||||
This is an UNSTABLE release. The release has significant modifications and bug fixes, if things go wrong, it is better to revert to 1.0.0-rc.132.
|
||||
|
||||
|
||||
@@ -148,8 +148,8 @@ class IndexingSettings extends Component<MyProps, MyState> {
|
||||
onChange={this.handleAlgorithmChange}
|
||||
>
|
||||
<MenuItem value={indexing_algorithm.FFBIDX}>FFBIDX (known unit cell) - GPU</MenuItem>
|
||||
<MenuItem value={indexing_algorithm.FFT}>FFT (guess unit cell) - GPU</MenuItem>
|
||||
<MenuItem value={indexing_algorithm.FFT}>FFT (guess unit cell) - CPU</MenuItem>
|
||||
<MenuItem value={indexing_algorithm.FFT}>FFT (guess unit cell) - GPU with CuFFT library</MenuItem>
|
||||
<MenuItem value={indexing_algorithm.FFTW}>FFT (guess unit cell) - CPU with FFTW library</MenuItem>
|
||||
<MenuItem value={indexing_algorithm.AUTO}>Auto (FFBIDX if unit cell provided, FFT otherwise)</MenuItem>
|
||||
<MenuItem value={indexing_algorithm.NONE}>No indexing</MenuItem>
|
||||
</Select>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
|
||||
MXAnalysisWithoutFPGA::MXAnalysisWithoutFPGA(const DiffractionExperiment &in_experiment,
|
||||
const AzimuthalIntegration &in_integration,
|
||||
const AzimuthalIntegrationMapping &in_integration,
|
||||
const PixelMask &in_mask,
|
||||
IndexAndRefine &in_indexer)
|
||||
: experiment(in_experiment),
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "../common/JFJochMessages.h"
|
||||
#include "../common/DiffractionExperiment.h"
|
||||
#include "../common/AzimuthalIntegration.h"
|
||||
#include "../common/AzimuthalIntegrationMapping.h"
|
||||
#include "../common/PixelMask.h"
|
||||
#include "../common/AzimuthalIntegrationProfile.h"
|
||||
#include "bragg_prediction/BraggPrediction.h"
|
||||
@@ -22,7 +22,7 @@
|
||||
// MXAnalysisWithoutFPGA is not thread safe - it has to owned by a single thread
|
||||
class MXAnalysisWithoutFPGA {
|
||||
const DiffractionExperiment &experiment;
|
||||
const AzimuthalIntegration &integration;
|
||||
const AzimuthalIntegrationMapping &integration;
|
||||
|
||||
std::vector<uint8_t> decompression_buffer;
|
||||
|
||||
@@ -43,7 +43,7 @@ class MXAnalysisWithoutFPGA {
|
||||
float mask_low_res;
|
||||
void UpdateMaskResolution(const SpotFindingSettings& settings);
|
||||
public:
|
||||
MXAnalysisWithoutFPGA(const DiffractionExperiment &experiment, const AzimuthalIntegration &integration,
|
||||
MXAnalysisWithoutFPGA(const DiffractionExperiment &experiment, const AzimuthalIntegrationMapping &integration,
|
||||
const PixelMask &mask, IndexAndRefine &indexer);
|
||||
void Analyze(DataMessage &output, AzimuthalIntegrationProfile &profile, const SpotFindingSettings &spot_finding_settings);
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "AzIntEngine.h"
|
||||
|
||||
AzIntEngine::AzIntEngine(const AzimuthalIntegration &integration)
|
||||
AzIntEngine::AzIntEngine(const AzimuthalIntegrationMapping &integration)
|
||||
: integration(integration),
|
||||
npixel(integration.GetPixelToBin().size()),
|
||||
azint_sum(integration.GetBinNumber(), 0.0f),
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../common/AzimuthalIntegration.h"
|
||||
#include "../../common/AzimuthalIntegrationMapping.h"
|
||||
#include "../../common/AzimuthalIntegrationProfile.h"
|
||||
#include "../image_preprocessing/ImagePreprocessorBuffer.h"
|
||||
|
||||
@@ -11,12 +11,12 @@ class AzIntEngine {
|
||||
protected:
|
||||
const uint16_t azint_bins;
|
||||
const size_t npixel;
|
||||
const AzimuthalIntegration& integration;
|
||||
const AzimuthalIntegrationMapping& integration;
|
||||
std::vector<float> azint_sum;
|
||||
std::vector<float> azint_sum2;
|
||||
std::vector<uint32_t> azint_count;
|
||||
public:
|
||||
AzIntEngine(const AzimuthalIntegration& integration);
|
||||
AzIntEngine(const AzimuthalIntegrationMapping& integration);
|
||||
virtual ~AzIntEngine() = default;
|
||||
virtual void Run(const ImagePreprocessorBuffer &image, AzimuthalIntegrationProfile &profile) = 0;
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "AzIntEngineCPU.h"
|
||||
|
||||
AzIntEngineCPU::AzIntEngineCPU(const AzimuthalIntegration &integration)
|
||||
AzIntEngineCPU::AzIntEngineCPU(const AzimuthalIntegrationMapping &integration)
|
||||
: AzIntEngine(integration) {}
|
||||
|
||||
void AzIntEngineCPU::Run(const ImagePreprocessorBuffer &image, AzimuthalIntegrationProfile &profile){
|
||||
|
||||
@@ -7,6 +7,6 @@
|
||||
|
||||
class AzIntEngineCPU : public AzIntEngine {
|
||||
public:
|
||||
AzIntEngineCPU(const AzimuthalIntegration& integration);
|
||||
AzIntEngineCPU(const AzimuthalIntegrationMapping& integration);
|
||||
void Run(const ImagePreprocessorBuffer &image, AzimuthalIntegrationProfile &profile) override;
|
||||
};
|
||||
@@ -88,7 +88,7 @@ void gpu_azim(
|
||||
}
|
||||
}
|
||||
|
||||
AzIntEngineGPU::AzIntEngineGPU(const AzimuthalIntegration &integration, std::shared_ptr<CudaStream> stream)
|
||||
AzIntEngineGPU::AzIntEngineGPU(const AzimuthalIntegrationMapping &integration, std::shared_ptr<CudaStream> stream)
|
||||
: AzIntEngine(integration),
|
||||
stream(stream),
|
||||
gpu_azint_correction(npixel),
|
||||
|
||||
@@ -23,6 +23,6 @@ class AzIntEngineGPU : public AzIntEngine {
|
||||
CudaRegisteredVector<float> cpu_sum2_reg;
|
||||
CudaRegisteredVector<uint32_t> cpu_count_reg;
|
||||
public:
|
||||
AzIntEngineGPU(const AzimuthalIntegration& integration, std::shared_ptr<CudaStream> stream);
|
||||
AzIntEngineGPU(const AzimuthalIntegrationMapping& integration, std::shared_ptr<CudaStream> stream);
|
||||
void Run(const ImagePreprocessorBuffer &image, AzimuthalIntegrationProfile &profile) override;
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "ImageSpotFinder.h"
|
||||
#include "SpotFindingSettings.h"
|
||||
#include "../../common/AzimuthalIntegration.h"
|
||||
#include "../../common/AzimuthalIntegrationMapping.h"
|
||||
#include "../../common/DiffractionSpot.h"
|
||||
|
||||
// This is "slow" spot finder for image-based analysis
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "../common/DiffractionGeometry.h"
|
||||
#include "../common/DiffractionExperiment.h"
|
||||
#include "../common/PixelMask.h"
|
||||
#include "../common/AzimuthalIntegration.h"
|
||||
#include "../common/AzimuthalIntegrationMapping.h"
|
||||
|
||||
struct JFJochReaderDataset {
|
||||
std::string arm_date;
|
||||
|
||||
@@ -33,7 +33,6 @@ JFJochReceiver::JFJochReceiver(const DiffractionExperiment &in_experiment,
|
||||
serialmx_filter(in_experiment),
|
||||
numa_policy(in_numa_policy),
|
||||
pixel_mask(in_pixel_mask),
|
||||
az_int_mapping(experiment, pixel_mask),
|
||||
indexer(experiment, indexing_thread_pool) {
|
||||
logger.Info("Initializing receiver");
|
||||
// Ensure there is nothing running for now
|
||||
@@ -46,7 +45,13 @@ JFJochReceiver::JFJochReceiver(const DiffractionExperiment &in_experiment,
|
||||
current_status.SetEfficiency({});
|
||||
current_status.SetStatus(JFJochReceiverStatus{}); // GetStatus() is virtual function and cannot be called yet!
|
||||
|
||||
plots.Setup(experiment, az_int_mapping);
|
||||
auto start_time_point = std::chrono::steady_clock::now();
|
||||
az_int_mapping = std::make_unique<AzimuthalIntegrationMapping>(experiment, pixel_mask);
|
||||
auto end_time_point = std::chrono::steady_clock::now();
|
||||
auto duration = std::chrono::duration<float>(end_time_point - start_time_point);
|
||||
logger.Info("Azimuthal integration mapping done in {:.5f} s with {} threads", duration.count(), az_int_mapping->GetNThreads());
|
||||
|
||||
plots.Setup(experiment, *az_int_mapping);
|
||||
|
||||
push_images_to_writer = (experiment.GetImageNum() > 0) && (!experiment.GetFilePrefix().empty());
|
||||
|
||||
@@ -110,12 +115,12 @@ void JFJochReceiver::SendStartMessage() {
|
||||
StartMessage message{};
|
||||
experiment.FillMessage(message);
|
||||
message.arm_date = time_UTC(std::chrono::system_clock::now());
|
||||
message.az_int_q_bin_count = az_int_mapping.GetQBinCount();
|
||||
message.az_int_bin_to_q = az_int_mapping.GetBinToQ();
|
||||
message.az_int_bin_to_two_theta = az_int_mapping.GetBinToTwoTheta();
|
||||
message.az_int_phi_bin_count = az_int_mapping.GetAzimuthalBinCount();
|
||||
if (az_int_mapping.GetAzimuthalBinCount() > 1)
|
||||
message.az_int_bin_to_phi = az_int_mapping.GetBinToPhi();
|
||||
message.az_int_q_bin_count = az_int_mapping->GetQBinCount();
|
||||
message.az_int_bin_to_q = az_int_mapping->GetBinToQ();
|
||||
message.az_int_bin_to_two_theta = az_int_mapping->GetBinToTwoTheta();
|
||||
message.az_int_phi_bin_count = az_int_mapping->GetAzimuthalBinCount();
|
||||
if (az_int_mapping->GetAzimuthalBinCount() > 1)
|
||||
message.az_int_bin_to_phi = az_int_mapping->GetBinToPhi();
|
||||
message.writer_notification_zmq_addr = image_pusher.GetWriterNotificationSocketAddress();
|
||||
message.rois = experiment.ROI().ExportMetadata();
|
||||
message.max_spot_count = experiment.GetMaxSpotCount();
|
||||
|
||||
@@ -82,7 +82,7 @@ protected:
|
||||
std::vector<std::unique_ptr<ADUHistogram>> adu_histogram_module;
|
||||
PixelMask pixel_mask;
|
||||
|
||||
AzimuthalIntegration az_int_mapping;
|
||||
std::unique_ptr<AzimuthalIntegrationMapping> az_int_mapping;
|
||||
|
||||
std::optional<uint64_t> max_delay;
|
||||
std::mutex max_delay_mutex;
|
||||
|
||||
@@ -311,8 +311,8 @@ void JFJochReceiverFPGA::FrameTransformationThread(uint32_t threadid) {
|
||||
|
||||
frame_transformation_ready.count_down();
|
||||
|
||||
uint16_t az_int_min_bin = std::floor(az_int_mapping.QToBin(experiment.GetLowQForBkgEstimate_recipA()));
|
||||
uint16_t az_int_max_bin = std::ceil(az_int_mapping.QToBin(experiment.GetHighQForBkgEstimate_recipA()));
|
||||
uint16_t az_int_min_bin = std::floor(az_int_mapping->QToBin(experiment.GetLowQForBkgEstimate_recipA()));
|
||||
uint16_t az_int_max_bin = std::ceil(az_int_mapping->QToBin(experiment.GetHighQForBkgEstimate_recipA()));
|
||||
|
||||
int64_t image_number;
|
||||
while (images_to_go.Get(image_number) != 0) {
|
||||
@@ -340,7 +340,7 @@ void JFJochReceiverFPGA::FrameTransformationThread(uint32_t threadid) {
|
||||
|
||||
ImageMetadata metadata(experiment);
|
||||
|
||||
AzimuthalIntegrationProfile az_int_profile_image(az_int_mapping);
|
||||
AzimuthalIntegrationProfile az_int_profile_image(*az_int_mapping);
|
||||
|
||||
auto local_spot_finding_settings = GetSpotFindingSettings();
|
||||
|
||||
@@ -678,5 +678,5 @@ void JFJochReceiverFPGA::LoadCalibrationToFPGA(uint16_t data_stream) {
|
||||
acquisition_device[data_stream].InitializeROIMap(experiment, roi_map);
|
||||
|
||||
// Initialize data processing
|
||||
acquisition_device[data_stream].InitializeDataProcessing(experiment, az_int_mapping);
|
||||
acquisition_device[data_stream].InitializeDataProcessing(experiment, *az_int_mapping);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "../common/PixelMask.h"
|
||||
|
||||
#include "../image_analysis/spot_finding/StrongPixelSet.h"
|
||||
#include "../common/AzimuthalIntegration.h"
|
||||
#include "../common/AzimuthalIntegrationMapping.h"
|
||||
#include "../common/AzimuthalIntegrationProfile.h"
|
||||
|
||||
#include "../jungfrau/JFCalibration.h"
|
||||
|
||||
@@ -244,7 +244,7 @@ void JFJochReceiverLite::DataAnalysisThread(uint32_t id) {
|
||||
measurement_started.wait();
|
||||
|
||||
try {
|
||||
analysis = std::make_unique<MXAnalysisWithoutFPGA>(experiment, az_int_mapping, pixel_mask, indexer);
|
||||
analysis = std::make_unique<MXAnalysisWithoutFPGA>(experiment, *az_int_mapping, pixel_mask, indexer);
|
||||
} catch (const JFJochException &e) {
|
||||
Cancel(e);
|
||||
return;
|
||||
@@ -276,7 +276,7 @@ void JFJochReceiverLite::DataAnalysisThread(uint32_t id) {
|
||||
|
||||
auto image_start_time = std::chrono::high_resolution_clock::now();
|
||||
|
||||
AzimuthalIntegrationProfile profile(az_int_mapping);
|
||||
AzimuthalIntegrationProfile profile(*az_int_mapping);
|
||||
analysis->Analyze(data_msg, profile, GetSpotFindingSettings());
|
||||
|
||||
auto image_end_time = std::chrono::high_resolution_clock::now();
|
||||
|
||||
@@ -41,7 +41,7 @@ MultiLinePlot JFJochReceiverPlots::GetROIPlot(PlotType type, int64_t nbins, floa
|
||||
return ret;
|
||||
}
|
||||
|
||||
void JFJochReceiverPlots::Setup(const DiffractionExperiment &experiment, const AzimuthalIntegration &mapping) {
|
||||
void JFJochReceiverPlots::Setup(const DiffractionExperiment &experiment, const AzimuthalIntegrationMapping &mapping) {
|
||||
std::unique_lock ul(m);
|
||||
|
||||
az_int_profile = std::make_unique<AzimuthalIntegrationProfile>(mapping);
|
||||
|
||||
@@ -104,7 +104,7 @@ class JFJochReceiverPlots {
|
||||
MultiLinePlot GetROIPlot(PlotType type, int64_t nbins, float start, float incr,
|
||||
const std::optional<float> &fill_value) const;
|
||||
public:
|
||||
void Setup(const DiffractionExperiment& experiment, const AzimuthalIntegration& mapping);
|
||||
void Setup(const DiffractionExperiment& experiment, const AzimuthalIntegrationMapping& mapping);
|
||||
|
||||
void Add(const DataMessage& msg, const AzimuthalIntegrationProfile &profile);
|
||||
void AddEmptyImage(const DataMessage& msg);
|
||||
|
||||
@@ -4,19 +4,19 @@
|
||||
#include <catch2/catch_all.hpp>
|
||||
|
||||
#include "../common/AzimuthalIntegrationProfile.h"
|
||||
#include "../common/AzimuthalIntegration.h"
|
||||
#include "../common/AzimuthalIntegrationMapping.h"
|
||||
|
||||
TEST_CASE("AzimuthalIntegrationMapping_Constructor","[AzimuthalIntegration]") {
|
||||
DiffractionExperiment x(DetJF4M());
|
||||
|
||||
REQUIRE(x.GetPixelsNum() == 2164*2068);
|
||||
|
||||
std::unique_ptr<AzimuthalIntegration> radial;
|
||||
std::unique_ptr<AzimuthalIntegrationMapping> radial;
|
||||
|
||||
x.QSpacingForAzimInt_recipA(0.1).QRangeForAzimInt_recipA(0.1, 5);
|
||||
|
||||
PixelMask pixel_mask(x);
|
||||
REQUIRE_NOTHROW(radial = std::make_unique<AzimuthalIntegration>(x, pixel_mask));
|
||||
REQUIRE_NOTHROW(radial = std::make_unique<AzimuthalIntegrationMapping>(x, pixel_mask));
|
||||
}
|
||||
|
||||
TEST_CASE("AzimuthalIntegrationMapping_GetBinNumber","[AzimuthalIntegration]") {
|
||||
@@ -25,7 +25,7 @@ TEST_CASE("AzimuthalIntegrationMapping_GetBinNumber","[AzimuthalIntegration]") {
|
||||
x.QSpacingForAzimInt_recipA(0.1).QRangeForAzimInt_recipA(0.1, 4);
|
||||
|
||||
PixelMask pixel_mask(x);
|
||||
AzimuthalIntegration mapping(x, pixel_mask);
|
||||
AzimuthalIntegrationMapping mapping(x, pixel_mask);
|
||||
REQUIRE(mapping.GetBinNumber() == 39);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ TEST_CASE("AzimuthalIntegrationMapping_GetBinNumber_mask","[AzimuthalIntegration
|
||||
|
||||
PixelMask pixel_mask_obj(x);
|
||||
pixel_mask_obj.LoadUserMask(x, pixel_mask);
|
||||
AzimuthalIntegration mapping(x, pixel_mask_obj);
|
||||
AzimuthalIntegrationMapping mapping(x, pixel_mask_obj);
|
||||
REQUIRE(mapping.GetBinNumber() == 89);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ TEST_CASE("AzimuthalIntegrationMapping_GetBinNumber_DetectorLimit","[AzimuthalIn
|
||||
|
||||
x.QSpacingForAzimInt_recipA(0.1).QRangeForAzimInt_recipA(0.1, 9.9);
|
||||
PixelMask pixel_mask(x);
|
||||
AzimuthalIntegration mapping(x, pixel_mask);
|
||||
AzimuthalIntegrationMapping mapping(x, pixel_mask);
|
||||
|
||||
REQUIRE(mapping.GetBinNumber() == 98);
|
||||
}
|
||||
@@ -68,7 +68,7 @@ TEST_CASE("AzimuthalIntegrationMapping_GetBinToQ","[AzimuthalIntegration]") {
|
||||
x.QSpacingForAzimInt_recipA(0.1).QRangeForAzimInt_recipA(0.1, 4);
|
||||
|
||||
PixelMask pixel_mask(x);
|
||||
AzimuthalIntegration mapping(x, pixel_mask);
|
||||
AzimuthalIntegrationMapping mapping(x, pixel_mask);
|
||||
|
||||
auto bin_to_q = mapping.GetBinToQ();
|
||||
|
||||
@@ -89,7 +89,7 @@ TEST_CASE("AzimuthalIntegrationMapping_GetBinToPhi","[AzimuthalIntegration]") {
|
||||
x.ImportAzimuthalIntegrationSettings(settings);
|
||||
|
||||
PixelMask pixel_mask(x);
|
||||
AzimuthalIntegration mapping(x, pixel_mask);
|
||||
AzimuthalIntegrationMapping mapping(x, pixel_mask);
|
||||
|
||||
auto &bin_to_q = mapping.GetBinToQ();
|
||||
|
||||
@@ -134,7 +134,7 @@ TEST_CASE("AzimuthalIntegrationMapping_GetMapping","[AzimuthalIntegration]") {
|
||||
x.ImportAzimuthalIntegrationSettings(settings);
|
||||
|
||||
PixelMask pixel_mask(x);
|
||||
AzimuthalIntegration mapping(x, pixel_mask);
|
||||
AzimuthalIntegrationMapping mapping(x, pixel_mask);
|
||||
|
||||
auto map = mapping.GetPixelToBin();
|
||||
|
||||
@@ -153,7 +153,7 @@ TEST_CASE("AzimuthalIntegrationMapping_QToBin","[AzimuthalIntegration]") {
|
||||
x.QSpacingForAzimInt_recipA(0.1).QRangeForAzimInt_recipA(0.1, 4);
|
||||
|
||||
PixelMask pixel_mask(x);
|
||||
AzimuthalIntegration mapping(x, pixel_mask);
|
||||
AzimuthalIntegrationMapping mapping(x, pixel_mask);
|
||||
|
||||
REQUIRE(mapping.QToBin(0.0) == 0);
|
||||
REQUIRE(std::floor(mapping.QToBin(0.200001)) == 1);
|
||||
@@ -167,7 +167,7 @@ TEST_CASE("AzimuthalIntegrationProfile","[AzimuthalIntegration]") {
|
||||
x.QSpacingForAzimInt_recipA(0.1).QRangeForAzimInt_recipA(0.1, 4);
|
||||
|
||||
PixelMask pixel_mask(x);
|
||||
AzimuthalIntegration mapping(x, pixel_mask);
|
||||
AzimuthalIntegrationMapping mapping(x, pixel_mask);
|
||||
|
||||
AzimuthalIntegrationProfile profile(mapping);
|
||||
|
||||
@@ -204,7 +204,7 @@ TEST_CASE("AzimuthalIntegrationProfile_operatorAdd","[AzimuthalIntegration]") {
|
||||
x.QSpacingForAzimInt_recipA(0.1).QRangeForAzimInt_recipA(0.1, 4);
|
||||
|
||||
PixelMask pixel_mask(x);
|
||||
AzimuthalIntegration mapping(x, pixel_mask);
|
||||
AzimuthalIntegrationMapping mapping(x, pixel_mask);
|
||||
|
||||
AzimuthalIntegrationProfile profile0(mapping), profile1(mapping);
|
||||
|
||||
@@ -235,7 +235,7 @@ TEST_CASE("AzimuthalIntegrationProfile_GetMeanValueOfBins","[AzimuthalIntegratio
|
||||
x.QSpacingForAzimInt_recipA(0.1).QRangeForAzimInt_recipA(0.1, 4);
|
||||
|
||||
PixelMask pixel_mask(x);
|
||||
AzimuthalIntegration mapping(x, pixel_mask);
|
||||
AzimuthalIntegrationMapping mapping(x, pixel_mask);
|
||||
|
||||
AzimuthalIntegrationProfile profile(mapping);
|
||||
|
||||
@@ -268,7 +268,7 @@ TEST_CASE("AzimuthalIntegrationProfile_GetResult1D","[AzimuthalIntegration]") {
|
||||
x.ImportAzimuthalIntegrationSettings(settings);
|
||||
|
||||
PixelMask pixel_mask(x);
|
||||
AzimuthalIntegration mapping(x, pixel_mask);
|
||||
AzimuthalIntegrationMapping mapping(x, pixel_mask);
|
||||
AzimuthalIntegrationProfile profile(mapping);
|
||||
|
||||
REQUIRE(mapping.GetQBinCount() == 3);
|
||||
@@ -308,3 +308,99 @@ TEST_CASE("AzimuthalIntegrationProfile_GetResult1D","[AzimuthalIntegration]") {
|
||||
CHECK(result_1d[1] == Catch::Approx(21.0f));
|
||||
CHECK(result_1d[2] == Catch::Approx(22.0f));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
static void RequireVectorsEqual(const std::vector<T> &ref,
|
||||
const std::vector<T> &other,
|
||||
const std::string &name,
|
||||
int nthreads) {
|
||||
INFO(name << ", threads=" << nthreads);
|
||||
REQUIRE(ref.size() == other.size());
|
||||
CHECK(memcmp(ref.data(), other.data(), sizeof(T) * ref.size()) == 0);
|
||||
}
|
||||
|
||||
static void CheckAzimuthalIntegrationMappingThreadingExact(const DiffractionExperiment &experiment) {
|
||||
PixelMask pixel_mask(experiment);
|
||||
|
||||
AzimuthalIntegrationMapping mapping_1(experiment, pixel_mask, 1);
|
||||
AzimuthalIntegrationMapping mapping_2(experiment, pixel_mask, 2);
|
||||
AzimuthalIntegrationMapping mapping_16(experiment, pixel_mask, 16);
|
||||
AzimuthalIntegrationMapping mapping_0(experiment, pixel_mask, 0);
|
||||
|
||||
REQUIRE(mapping_1.GetBinNumber() == mapping_2.GetBinNumber());
|
||||
REQUIRE(mapping_1.GetBinNumber() == mapping_16.GetBinNumber());
|
||||
REQUIRE(mapping_1.GetBinNumber() == mapping_0.GetBinNumber());
|
||||
|
||||
REQUIRE(mapping_1.GetQBinCount() == mapping_2.GetQBinCount());
|
||||
REQUIRE(mapping_1.GetQBinCount() == mapping_16.GetQBinCount());
|
||||
REQUIRE(mapping_1.GetQBinCount() == mapping_0.GetQBinCount());
|
||||
|
||||
REQUIRE(mapping_1.GetAzimuthalBinCount() == mapping_2.GetAzimuthalBinCount());
|
||||
REQUIRE(mapping_1.GetAzimuthalBinCount() == mapping_16.GetAzimuthalBinCount());
|
||||
REQUIRE(mapping_1.GetAzimuthalBinCount() == mapping_0.GetAzimuthalBinCount());
|
||||
|
||||
RequireVectorsEqual(mapping_1.GetPixelToBin(), mapping_2.GetPixelToBin(), "pixel_to_bin", 2);
|
||||
RequireVectorsEqual(mapping_1.GetPixelToBin(), mapping_16.GetPixelToBin(), "pixel_to_bin", 16);
|
||||
RequireVectorsEqual(mapping_1.GetPixelToBin(), mapping_0.GetPixelToBin(), "pixel_to_bin", 0);
|
||||
|
||||
RequireVectorsEqual(mapping_1.Resolution(), mapping_2.Resolution(), "resolution", 2);
|
||||
RequireVectorsEqual(mapping_1.Resolution(), mapping_16.Resolution(), "resolution", 16);
|
||||
RequireVectorsEqual(mapping_1.Resolution(), mapping_0.Resolution(), "resolution", 0);
|
||||
|
||||
RequireVectorsEqual(mapping_1.Corrections(), mapping_2.Corrections(), "corrections", 2);
|
||||
RequireVectorsEqual(mapping_1.Corrections(), mapping_16.Corrections(), "corrections", 16);
|
||||
RequireVectorsEqual(mapping_1.Corrections(), mapping_0.Corrections(), "corrections", 0);
|
||||
|
||||
RequireVectorsEqual(mapping_1.GetBinToQ(), mapping_2.GetBinToQ(), "bin_to_q", 2);
|
||||
RequireVectorsEqual(mapping_1.GetBinToQ(), mapping_16.GetBinToQ(), "bin_to_q", 16);
|
||||
RequireVectorsEqual(mapping_1.GetBinToQ(), mapping_0.GetBinToQ(), "bin_to_q", 0);
|
||||
|
||||
RequireVectorsEqual(mapping_1.GetBinToD(), mapping_2.GetBinToD(), "bin_to_d", 2);
|
||||
RequireVectorsEqual(mapping_1.GetBinToD(), mapping_16.GetBinToD(), "bin_to_d", 16);
|
||||
RequireVectorsEqual(mapping_1.GetBinToD(), mapping_0.GetBinToD(), "bin_to_d", 0);
|
||||
|
||||
RequireVectorsEqual(mapping_1.GetBinToTwoTheta(), mapping_2.GetBinToTwoTheta(), "bin_to_2theta", 2);
|
||||
RequireVectorsEqual(mapping_1.GetBinToTwoTheta(), mapping_16.GetBinToTwoTheta(), "bin_to_2theta", 16);
|
||||
RequireVectorsEqual(mapping_1.GetBinToTwoTheta(), mapping_0.GetBinToTwoTheta(), "bin_to_2theta", 0);
|
||||
|
||||
RequireVectorsEqual(mapping_1.GetBinToPhi(), mapping_2.GetBinToPhi(), "bin_to_phi", 2);
|
||||
RequireVectorsEqual(mapping_1.GetBinToPhi(), mapping_16.GetBinToPhi(), "bin_to_phi", 16);
|
||||
RequireVectorsEqual(mapping_1.GetBinToPhi(), mapping_0.GetBinToPhi(), "bin_to_phi", 0);
|
||||
}
|
||||
|
||||
TEST_CASE("AzimuthalIntegrationMapping_Threading_FixedGeometry_2000x2000", "[AzimuthalIntegration]") {
|
||||
DiffractionExperiment x(DetDECTRIS(2000, 2000, "E16M", ""));
|
||||
x.DetectorDistance_mm(50).BeamX_pxl(1000).BeamY_pxl(1000);
|
||||
x.QSpacingForAzimInt_recipA(0.1).QRangeForAzimInt_recipA(0.1, 10);
|
||||
x.PolarizationFactor(0.99f);
|
||||
|
||||
REQUIRE(x.IsGeometryTransformed());
|
||||
|
||||
CheckAzimuthalIntegrationMappingThreadingExact(x);
|
||||
}
|
||||
|
||||
TEST_CASE("AzimuthalIntegrationMapping_Threading_RawGeometry_18Modules", "[AzimuthalIntegration]") {
|
||||
DiffractionExperiment x(DetJF9M());
|
||||
x.Raw();
|
||||
x.DetectorDistance_mm(100).BeamX_pxl(1500).BeamY_pxl(1500);
|
||||
x.QSpacingForAzimInt_recipA(0.05).QRangeForAzimInt_recipA(0.1, 8.0);
|
||||
x.PolarizationFactor(0.99f);
|
||||
|
||||
REQUIRE(!x.IsGeometryTransformed());
|
||||
REQUIRE(x.GetModulesNum() == 18);
|
||||
|
||||
CheckAzimuthalIntegrationMappingThreadingExact(x);
|
||||
}
|
||||
|
||||
TEST_CASE("AzimuthalIntegrationMapping_Threading_ConvertedGeometry_18Modules", "[AzimuthalIntegration]") {
|
||||
DiffractionExperiment x(DetJF9M());
|
||||
x.Conversion();
|
||||
x.DetectorDistance_mm(100).BeamX_pxl(1500).BeamY_pxl(1500);
|
||||
x.QSpacingForAzimInt_recipA(0.05).QRangeForAzimInt_recipA(0.1, 8.0);
|
||||
x.PolarizationFactor(0.99f);
|
||||
|
||||
REQUIRE(x.IsGeometryTransformed());
|
||||
REQUIRE(x.GetModulesNum() == 18);
|
||||
|
||||
CheckAzimuthalIntegrationMappingThreadingExact(x);
|
||||
}
|
||||
@@ -442,7 +442,7 @@ TEST_CASE("HDF5MasterFile_RadInt", "[HDF5][Full]") {
|
||||
x.FilePrefix("test01_rad_int").ImagesPerTrigger(950);
|
||||
|
||||
PixelMask pixel_mask(x);
|
||||
AzimuthalIntegration mapping(x, pixel_mask);
|
||||
AzimuthalIntegrationMapping mapping(x, pixel_mask);
|
||||
AzimuthalIntegrationProfile profile(mapping);
|
||||
|
||||
StartMessage start_message;
|
||||
@@ -622,7 +622,7 @@ TEST_CASE("HDF5Writer_Rad_Int_Profile", "[HDF5][Full]") {
|
||||
x.QSpacingForAzimInt_recipA(0.1).QRangeForAzimInt_recipA(0.1, 4.0);
|
||||
|
||||
PixelMask pixel_mask(x);
|
||||
AzimuthalIntegration mapping(x, pixel_mask);
|
||||
AzimuthalIntegrationMapping mapping(x, pixel_mask);
|
||||
|
||||
std::vector<float> rad_int_profile(mapping.GetBinNumber(), 4.0);
|
||||
std::vector<float> rad_int_avg(mapping.GetBinNumber(), 0.33);
|
||||
@@ -989,7 +989,7 @@ TEST_CASE("HDF5Writer_NXmxIntegrated_AzInt", "[HDF5][Full]") {
|
||||
x.SetFileWriterFormat(FileWriterFormat::NXmxIntegrated).OverwriteExistingFiles(true);
|
||||
|
||||
PixelMask pixel_mask(x);
|
||||
AzimuthalIntegration mapping(x, pixel_mask);
|
||||
AzimuthalIntegrationMapping mapping(x, pixel_mask);
|
||||
|
||||
{
|
||||
RegisterHDF5Filter();
|
||||
|
||||
@@ -949,7 +949,7 @@ TEST_CASE("JFJochReader_Azint", "[HDF5][Full]") {
|
||||
|
||||
std::vector<uint16_t> image(x.GetPixelsNum());
|
||||
|
||||
AzimuthalIntegration azint(x, PixelMask(x));
|
||||
AzimuthalIntegrationMapping azint(x, PixelMask(x));
|
||||
RegisterHDF5Filter();
|
||||
{
|
||||
StartMessage start_message;
|
||||
@@ -1433,7 +1433,7 @@ TEST_CASE("JFJochReader_NXmxIntegrated", "[HDF5][Full]") {
|
||||
image[1] = 123;
|
||||
image[5678] = 321;
|
||||
|
||||
AzimuthalIntegration azint(x, PixelMask(x));
|
||||
AzimuthalIntegrationMapping azint(x, PixelMask(x));
|
||||
RegisterHDF5Filter();
|
||||
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ TEST_CASE("JFJochReceiverPlots") {
|
||||
experiment.Goniometer(GoniometerAxis("omega", 15, 2, Coord(0,1,0), {}));
|
||||
|
||||
PixelMask mask(experiment);
|
||||
AzimuthalIntegration integration(experiment, mask);
|
||||
AzimuthalIntegrationMapping integration(experiment, mask);
|
||||
|
||||
JFJochReceiverPlots plots;
|
||||
plots.Setup(experiment, integration);
|
||||
@@ -48,7 +48,7 @@ TEST_CASE("JFJochReceiverPlots_Angle") {
|
||||
experiment.Goniometer(GoniometerAxis("omega", 15, 2, Coord(0,1,0), {}));
|
||||
|
||||
PixelMask mask(experiment);
|
||||
AzimuthalIntegration integration(experiment, mask);
|
||||
AzimuthalIntegrationMapping integration(experiment, mask);
|
||||
|
||||
JFJochReceiverPlots plots;
|
||||
plots.Setup(experiment, integration);
|
||||
@@ -91,7 +91,7 @@ TEST_CASE("JFJochReceiverPlots_Grid") {
|
||||
experiment.ImportDatasetSettings(dataset);
|
||||
|
||||
PixelMask mask(experiment);
|
||||
AzimuthalIntegration integration(experiment, mask);
|
||||
AzimuthalIntegrationMapping integration(experiment, mask);
|
||||
|
||||
JFJochReceiverPlots plots;
|
||||
plots.Setup(experiment, integration);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "../common/Logger.h"
|
||||
#include "../common/DiffractionExperiment.h"
|
||||
#include "../common/PixelMask.h"
|
||||
#include "../common/AzimuthalIntegration.h"
|
||||
#include "../common/AzimuthalIntegrationMapping.h"
|
||||
#include "../common/time_utc.h"
|
||||
#include "../common/print_license.h"
|
||||
#include "../image_analysis/MXAnalysisWithoutFPGA.h"
|
||||
@@ -346,7 +346,7 @@ int main(int argc, char **argv) {
|
||||
// If dataset has a mask you wish to use, you might need to load it into pixel_mask here
|
||||
// e.g. pixel_mask.LoadUserMask(dataset->pixel_mask, ...);
|
||||
|
||||
AzimuthalIntegration mapping(experiment, pixel_mask);
|
||||
AzimuthalIntegrationMapping mapping(experiment, pixel_mask);
|
||||
IndexerThreadPool indexer_pool(experiment.GetIndexingSettings());
|
||||
|
||||
// Statistics collector
|
||||
|
||||
@@ -296,7 +296,7 @@ void JFJochImageReadingWorker::LoadImage(int64_t image_number, int64_t summation
|
||||
|
||||
void JFJochImageReadingWorker::UpdateAzint_i(const JFJochReaderDataset *dataset) {
|
||||
if (dataset) {
|
||||
azint_mapping = std::make_unique<AzimuthalIntegration>(curr_experiment, dataset->pixel_mask);
|
||||
azint_mapping = std::make_unique<AzimuthalIntegrationMapping>(curr_experiment, dataset->pixel_mask);
|
||||
index_and_refine = std::make_unique<IndexAndRefine>(curr_experiment, indexing.get());
|
||||
image_analysis = std::make_unique<MXAnalysisWithoutFPGA>(curr_experiment, *azint_mapping, dataset->pixel_mask,
|
||||
*index_and_refine.get());
|
||||
|
||||
@@ -52,7 +52,7 @@ private:
|
||||
std::unique_ptr<IndexerThreadPool> indexing;
|
||||
|
||||
std::shared_ptr<JFJochReaderImage> current_image_ptr;
|
||||
std::unique_ptr<AzimuthalIntegration> azint_mapping;
|
||||
std::unique_ptr<AzimuthalIntegrationMapping> azint_mapping;
|
||||
std::unique_ptr<MXAnalysisWithoutFPGA> image_analysis;
|
||||
std::unique_ptr<IndexAndRefine> index_and_refine;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user