Updates March 2023
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
// Copyright (2019-2024) Paul Scherrer Institute
|
||||
|
||||
#include "AzimuthalIntegration.h"
|
||||
#include "../common/JFJochException.h"
|
||||
#include "../common/RawToConvertedGeometry.h"
|
||||
#include "../common/DiffractionGeometry.h"
|
||||
|
||||
AzimuthalIntegration::AzimuthalIntegration(const DiffractionExperiment& experiment, const AzimuthalIntegrationMapping &mapping) :
|
||||
pixel_to_bin(experiment.GetPixelsNum(), UINT16_MAX),
|
||||
corrections(experiment.GetPixelsNum(), 1.0),
|
||||
nbins(mapping.GetBinNumber()),
|
||||
sum(mapping.GetBinNumber(), 0),
|
||||
count(mapping.GetBinNumber(), 0)
|
||||
{
|
||||
auto mapping_raw = mapping.GetPixelToBinMappingRaw();
|
||||
RawToConvertedGeometry(experiment, pixel_to_bin.data(), mapping_raw.data());
|
||||
|
||||
auto &bin_to_q = mapping.GetBinToQ();
|
||||
|
||||
solid_angle_corr.resize(mapping.GetBinNumber());
|
||||
for (int i = 0; i < mapping.GetBinNumber(); i++)
|
||||
solid_angle_corr[i] = 1.0 / CalcAzIntSolidAngleCorr(experiment, bin_to_q[i]);
|
||||
}
|
||||
|
||||
void AzimuthalIntegration::Process(const int16_t *data, size_t npixel) {
|
||||
if (npixel != pixel_to_bin.size())
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Mismatch in size of pixel-to-bin mapping and image");
|
||||
|
||||
for (int i = 0; i < npixel; i++) {
|
||||
auto bin = pixel_to_bin[i];
|
||||
auto value = data[i];
|
||||
if ((value > INT16_MIN + 4) && (value < INT16_MAX - 4) && (bin < nbins)) {
|
||||
sum[bin] += value;
|
||||
count[bin] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AzimuthalIntegration::GetResult(std::vector<double> &result) const {
|
||||
result.resize(nbins);
|
||||
|
||||
for (int i = 0; i < nbins; i++) {
|
||||
if (count[i] > 0)
|
||||
result[i] = static_cast<double>(sum[i]) / static_cast<double>(count[i]) * solid_angle_corr[i];
|
||||
else
|
||||
result[i] = 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user