v1.0.0-rc.31
This commit is contained in:
@@ -6,14 +6,13 @@
|
||||
#include "AzimuthalIntegrationMapping.h"
|
||||
#include "../common/JFJochException.h"
|
||||
#include "../common/DiffractionGeometry.h"
|
||||
#include "../common/RawToConvertedGeometry.h"
|
||||
|
||||
AzimuthalIntegrationMapping::AzimuthalIntegrationMapping(const DiffractionExperiment& experiment) :
|
||||
low_q(experiment.GetLowQForAzimInt_recipA()),
|
||||
high_q(experiment.GetHighQForAzimInt_recipA()),
|
||||
q_spacing(experiment.GetQSpacingForAzimInt_recipA()),
|
||||
pixel_to_bin_raw(experiment.GetModulesNum() * RAW_MODULE_SIZE),
|
||||
max_bin_number(0)
|
||||
{
|
||||
AzimuthalIntegrationMapping::AzimuthalIntegrationMapping(const AzimuthalIntegrationSettings &settings) :
|
||||
low_q(settings.GetLowQ_recipA()),
|
||||
high_q(settings.GetHighQ_recipA()),
|
||||
q_spacing(settings.GetQSpacing_recipA()),
|
||||
max_bin_number(0) {
|
||||
|
||||
if (q_spacing < 0.0)
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
@@ -31,20 +30,50 @@ AzimuthalIntegrationMapping::AzimuthalIntegrationMapping(const DiffractionExperi
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Cannot accommodate more than 65536 rings");
|
||||
|
||||
}
|
||||
|
||||
AzimuthalIntegrationMapping::AzimuthalIntegrationMapping(const DiffractionExperiment& experiment)
|
||||
: AzimuthalIntegrationMapping(experiment.GetAzimuthalIntegrationSettings())
|
||||
{
|
||||
pixel_to_bin.resize(experiment.GetModulesNum() * RAW_MODULE_SIZE);
|
||||
|
||||
DiffractionGeometry 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);
|
||||
double pixel_q = 2 * M_PI / PxlToRes(experiment, x, y);
|
||||
float pixel_q = 2 * M_PI / geom.PxlToRes(x, y);
|
||||
if ((pixel_q < low_q) || (pixel_q >= high_q))
|
||||
pixel_to_bin_raw[m * RAW_MODULE_SIZE + pxl] = UINT16_MAX;
|
||||
pixel_to_bin[m * RAW_MODULE_SIZE + pxl] = UINT16_MAX;
|
||||
else
|
||||
pixel_to_bin_raw[m * RAW_MODULE_SIZE + pxl] = std::floor((pixel_q - low_q) / q_spacing);
|
||||
pixel_to_bin[m * RAW_MODULE_SIZE + pxl] = std::floor((pixel_q - low_q) / q_spacing);
|
||||
}
|
||||
}
|
||||
|
||||
Setup();
|
||||
}
|
||||
|
||||
AzimuthalIntegrationMapping::AzimuthalIntegrationMapping(const DiffractionGeometry &geom, int64_t width, int64_t height,
|
||||
const AzimuthalIntegrationSettings &settings)
|
||||
: AzimuthalIntegrationMapping(settings) {
|
||||
pixel_to_bin.resize(width * height);
|
||||
for (int row = 0; row < height; row++) {
|
||||
for (int col = 0; col < width; col++) {
|
||||
float pixel_q = 2 * M_PI / geom.PxlToRes(col, row);
|
||||
if ((pixel_q < low_q) || (pixel_q >= high_q))
|
||||
pixel_to_bin[row * width + col] = UINT16_MAX;
|
||||
else
|
||||
pixel_to_bin[row * width + col] = std::floor((pixel_q - low_q) / q_spacing);
|
||||
|
||||
}
|
||||
}
|
||||
Setup();
|
||||
}
|
||||
|
||||
void AzimuthalIntegrationMapping::Setup() {
|
||||
// In principle max bin number is equal to std::floor((high_q - low_q) / q_spacing), but it might be lower than this
|
||||
// depending on detector distance and beam center position
|
||||
for (const auto &i: pixel_to_bin_raw) {
|
||||
for (const auto &i: pixel_to_bin) {
|
||||
if ((i != UINT16_MAX) && (i > max_bin_number))
|
||||
max_bin_number = i;
|
||||
}
|
||||
@@ -58,14 +87,14 @@ uint16_t AzimuthalIntegrationMapping::GetBinNumber() const {
|
||||
return max_bin_number + 1;
|
||||
}
|
||||
|
||||
const std::vector<uint16_t> &AzimuthalIntegrationMapping::GetPixelToBinMappingRaw() const {
|
||||
return pixel_to_bin_raw;
|
||||
const std::vector<uint16_t> &AzimuthalIntegrationMapping::GetPixelToBin() const {
|
||||
return pixel_to_bin;
|
||||
}
|
||||
|
||||
const std::vector<float> &AzimuthalIntegrationMapping::GetBinToQ() const {
|
||||
return bin_to_q;
|
||||
}
|
||||
|
||||
double AzimuthalIntegrationMapping::QToBin(double q) const {
|
||||
return std::min(static_cast<double>(max_bin_number), std::max(0.0, (q - low_q) / q_spacing));
|
||||
float AzimuthalIntegrationMapping::QToBin(float q) const {
|
||||
return std::min(static_cast<float>(max_bin_number), std::max(0.0f, (q - low_q) / q_spacing));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user