RadialIntegrationProfile: Extra routines to handle GPU/CPU/FPGA workflows in more versatile way
This commit is contained in:
@@ -147,6 +147,7 @@ TEST_CASE("RadialIntegrationProfile","[RadialIntegration]") {
|
||||
count[i] = i;
|
||||
}
|
||||
REQUIRE_NOTHROW(profile.Add(sum, count));
|
||||
REQUIRE_NOTHROW(profile.Add(sum, count));
|
||||
|
||||
std::vector<float> sum_wr(mapping.GetBinNumber() - 1);
|
||||
REQUIRE_THROWS(profile.Add(sum_wr, count));
|
||||
@@ -162,6 +163,58 @@ TEST_CASE("RadialIntegrationProfile","[RadialIntegration]") {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("RadialIntegrationProfile_operatorAdd","[RadialIntegration]") {
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
x.DetectorDistance_mm(50).BeamX_pxl(1000).BeamY_pxl(1000);
|
||||
x.QSpacingForRadialInt_recipA(0.1).LowQForRadialInt_recipA(0.1).HighQForRadialInt_recipA(4);
|
||||
|
||||
RadialIntegrationMapping mapping(x);
|
||||
|
||||
RadialIntegrationProfile profile0(mapping, x), profile1(mapping, x);
|
||||
|
||||
std::vector<float> sum(mapping.GetBinNumber());
|
||||
std::vector<float> count(mapping.GetBinNumber());
|
||||
|
||||
for (int i = 0; i < mapping.GetBinNumber(); i++) {
|
||||
sum[i] = i * i * 4;
|
||||
count[i] = i;
|
||||
}
|
||||
REQUIRE_NOTHROW(profile0.Add(sum, count));
|
||||
REQUIRE_NOTHROW(profile1 += profile0);
|
||||
|
||||
JFJochProtoBuf::Plot plot;
|
||||
profile1.GetPlot(plot);
|
||||
|
||||
REQUIRE(plot.x_size() == mapping.GetBinNumber());
|
||||
REQUIRE(plot.y_size() == mapping.GetBinNumber());
|
||||
for (int i = 0; i < mapping.GetBinNumber(); i++) {
|
||||
REQUIRE(plot.x(i) == Approx(mapping.GetBinToQ()[i]));
|
||||
REQUIRE(plot.y(i) == Approx(i * 4));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("RadialIntegrationProfile_GetMeanValueOfBins","[RadialIntegration]") {
|
||||
DiffractionExperiment x(DetectorGeometry(8, 2, 8, 36));
|
||||
x.DetectorDistance_mm(50).BeamX_pxl(1000).BeamY_pxl(1000);
|
||||
x.QSpacingForRadialInt_recipA(0.1).LowQForRadialInt_recipA(0.1).HighQForRadialInt_recipA(4);
|
||||
|
||||
RadialIntegrationMapping mapping(x);
|
||||
|
||||
RadialIntegrationProfile profile(mapping, x);
|
||||
|
||||
std::vector<float> sum(mapping.GetBinNumber());
|
||||
std::vector<float> count(mapping.GetBinNumber());
|
||||
|
||||
for (int i = 0; i < mapping.GetBinNumber(); i++) {
|
||||
sum[i] = i * i * 4;
|
||||
count[i] = i;
|
||||
}
|
||||
REQUIRE_NOTHROW(profile.Add(sum, count));
|
||||
|
||||
REQUIRE(profile.GetMeanValueOfBins(0,2) == Approx ((sum[0] + sum[1] + sum[2]) / (count[0] + count[1] + count[2])));
|
||||
REQUIRE(profile.GetMeanValueOfBins(5,7) == Approx ((sum[5] + sum[6] + sum[7]) / (count[5] + count[6] + count[7])));
|
||||
}
|
||||
|
||||
TEST_CASE("RadialIntegration_Process","[RadialIntegration]") {
|
||||
std::vector<uint16_t> pixel_to_bin = {0,1,2,4,3,1,2,3};
|
||||
std::vector<int16_t> test_image = {7,6,5,4,3,2,1,0};
|
||||
@@ -311,19 +364,4 @@ TEST_CASE("RadialIntegrationGPU_GetResult","[RadialIntegration]") {
|
||||
REQUIRE(result[3] == (3 + 0) / 2.0);
|
||||
}
|
||||
|
||||
TEST_CASE("RadialIntegrationGPU_GetRangeValue","[RadialIntegration]") {
|
||||
std::vector<uint16_t> pixel_to_bin = {0,1,2,4,3,1,2,3};
|
||||
std::vector<int16_t> test_image = {7,6,5,4,3,2,1,0};
|
||||
std::vector<uint8_t> one_byte_mask = {1,1,1,1,1,1,1,1};
|
||||
|
||||
GPUImageAnalysis image_analysis(8, 1, one_byte_mask, pixel_to_bin, 4);
|
||||
image_analysis.SetInputBuffer(test_image.data());
|
||||
image_analysis.LoadDataToGPU();
|
||||
image_analysis.RunRadialIntegration();
|
||||
|
||||
REQUIRE(image_analysis.GetRadialIntegrationRangeValue(0, 7) == Approx((0+1+2+3+5+6+7) / 7.0));
|
||||
REQUIRE(image_analysis.GetRadialIntegrationRangeValue(2, 2) == Approx((5+1) / 2.0));
|
||||
REQUIRE(image_analysis.GetRadialIntegrationRangeValue(2, 3) == Approx((5+3+1+0) / 4.0));
|
||||
REQUIRE(image_analysis.GetRadialIntegrationRangeValue(15, 15) == 0); // Empty set
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user