DiffractionExperiment: Solid angle correction is saved with the master file
This commit is contained in:
@@ -511,6 +511,8 @@ void JFJochFrameDeserializer::ProcessStartMessageUserDataElement(CborValue &valu
|
||||
start_message.rad_int_bin_number = GetCBORInt(map_value);
|
||||
else if (key == "rad_int_bin_to_q")
|
||||
GetCBORFloatArray(map_value, start_message.rad_int_bin_to_q);
|
||||
else if (key == "rad_int_solid_angle_corr")
|
||||
GetCBORFloatArray(map_value, start_message.rad_int_solid_angle_corr);
|
||||
else if (key == "summation")
|
||||
start_message.summation = GetCBORUInt(map_value);
|
||||
else if (key == "storage_cell_number")
|
||||
|
||||
@@ -270,7 +270,7 @@ inline void CBOR_ENC_USER_DATA(CborEncoder &encoder, const StartMessage& message
|
||||
CborEncoder mapEncoder;
|
||||
|
||||
cborErr(cbor_encode_text_stringz(&encoder, "user_data"));
|
||||
cborErr(cbor_encoder_create_map(&encoder, &mapEncoder, 19));
|
||||
cborErr(cbor_encoder_create_map(&encoder, &mapEncoder, 20));
|
||||
|
||||
CBOR_ENC(mapEncoder, "file_prefix", message.file_prefix);
|
||||
CBOR_ENC(mapEncoder, "sample_name", message.sample_name);
|
||||
@@ -303,6 +303,7 @@ inline void CBOR_ENC_USER_DATA(CborEncoder &encoder, const StartMessage& message
|
||||
CBOR_ENC(mapEncoder, "instrument_name_short", message.instrument_name_short);
|
||||
CBOR_ENC(mapEncoder, "rad_int_bin_number", message.rad_int_bin_number);
|
||||
CBOR_ENC(mapEncoder, "rad_int_bin_to_q", message.rad_int_bin_to_q);
|
||||
CBOR_ENC(mapEncoder, "rad_int_solid_angle_corr", message.rad_int_solid_angle_corr);
|
||||
CBOR_ENC(mapEncoder, "summation", message.summation);
|
||||
cborErr(cbor_encoder_close_container(&encoder, &mapEncoder));
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ struct StartMessage {
|
||||
uint64_t summation;
|
||||
|
||||
std::vector<float> rad_int_bin_to_q;
|
||||
std::vector<float> rad_int_solid_angle_corr;
|
||||
};
|
||||
|
||||
#endif //JUNGFRAUJOCH_STARTMESSAGE_H
|
||||
|
||||
@@ -278,6 +278,7 @@ message PlotRequest {
|
||||
|
||||
message RadialIntegrationProfiles {
|
||||
map <string, Plot> plots = 1;
|
||||
repeated float solid_angle_correction = 2;
|
||||
}
|
||||
|
||||
// Writer
|
||||
|
||||
@@ -54,6 +54,10 @@ RadialIntegrationMapping::RadialIntegrationMapping(const DiffractionExperiment&
|
||||
bin_to_q.resize(max_bin_number + 1);
|
||||
for (int i = 0; i < max_bin_number + 1; i++)
|
||||
bin_to_q[i] = static_cast<float>(q_spacing * (i + 0.5) + low_q);
|
||||
|
||||
solid_angle_corr.resize(max_bin_number + 1);
|
||||
for (int i = 0; i < max_bin_number + 1; i++)
|
||||
solid_angle_corr[i] = 1.0f / experiment.CalcRadIntSolidAngleCorr(bin_to_q[i]);
|
||||
}
|
||||
|
||||
uint16_t RadialIntegrationMapping::GetBinNumber() const {
|
||||
@@ -68,6 +72,10 @@ const std::vector<float> &RadialIntegrationMapping::GetBinToQ() const {
|
||||
return bin_to_q;
|
||||
}
|
||||
|
||||
const std::vector<float> &RadialIntegrationMapping::GetSolidAngleCorr() const {
|
||||
return solid_angle_corr;
|
||||
}
|
||||
|
||||
double RadialIntegrationMapping::QToBin(double q) const {
|
||||
return std::min(static_cast<double>(max_bin_number), std::max(0.0, (q - low_q) / q_spacing));
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
class RadialIntegrationMapping {
|
||||
const double low_q, high_q, q_spacing;
|
||||
std::vector<float> bin_to_q;
|
||||
std::vector<float> solid_angle_corr;
|
||||
std::vector<uint16_t> pixel_to_bin;
|
||||
uint16_t max_bin_number;
|
||||
public:
|
||||
@@ -17,6 +18,7 @@ public:
|
||||
[[nodiscard]] uint16_t GetBinNumber() const;
|
||||
[[nodiscard]] const std::vector<uint16_t> &GetPixelToBinMapping() const;
|
||||
[[nodiscard]] const std::vector<float> &GetBinToQ() const;
|
||||
[[nodiscard]] const std::vector<float> &GetSolidAngleCorr() const;
|
||||
[[nodiscard]] double QToBin(double q) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -9,12 +9,10 @@ RadialIntegrationProfile::RadialIntegrationProfile(RadialIntegrationMapping &map
|
||||
: bin_to_q(mapping.GetBinToQ()),
|
||||
sum(mapping.GetBinNumber(), 0),
|
||||
count(mapping.GetBinNumber(), 0),
|
||||
corrections(mapping.GetBinNumber(), 1.0f){
|
||||
for (int i = 0; i < corrections.size(); i++)
|
||||
corrections[i] = 1.0f / experiment.CalcRadIntSolidAngleCorr(bin_to_q[i]);
|
||||
corrections(mapping.GetSolidAngleCorr()) {
|
||||
}
|
||||
|
||||
const std::vector<float> &RadialIntegrationProfile::GetSolidAngleCorrection() const {
|
||||
const std::vector<float> &RadialIntegrationProfile::GetSolidAngleCorr() const {
|
||||
return corrections;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
void Add(const std::vector<int32_t> &sum, const std::vector<int32_t> &count);
|
||||
std::vector<float> GetResult(bool solid_angle_correction) const;
|
||||
void GetPlot(JFJochProtoBuf::Plot &plot, bool solid_angle_correction) const;
|
||||
const std::vector<float> &GetSolidAngleCorrection() const;
|
||||
const std::vector<float> &GetSolidAngleCorr() const;
|
||||
};
|
||||
|
||||
#endif //JUNGFRAUJOCH_RADIALINTEGRATIONPROFILE_H
|
||||
|
||||
+66
-66
File diff suppressed because one or more lines are too long
@@ -153,6 +153,7 @@ JFJochReceiver::JFJochReceiver(const JFJochProtoBuf::ReceiverInput &settings,
|
||||
if (rad_int_mapping) {
|
||||
message.rad_int_bin_number = rad_int_mapping->GetBinNumber();
|
||||
message.rad_int_bin_to_q = rad_int_mapping->GetBinToQ();
|
||||
message.rad_int_solid_angle_corr = rad_int_mapping->GetSolidAngleCorr();
|
||||
} else
|
||||
message.rad_int_bin_number = 0;
|
||||
|
||||
@@ -704,12 +705,17 @@ JFJochProtoBuf::RadialIntegrationProfiles JFJochReceiver::GetRadialIntegrationPr
|
||||
|
||||
auto &map = *ret.mutable_plots();
|
||||
|
||||
if (rad_int_profile)
|
||||
if (rad_int_profile) {
|
||||
rad_int_profile->GetPlot(map["dataset"], true);
|
||||
auto &corr = rad_int_profile->GetSolidAngleCorr();
|
||||
for (const auto &i: corr)
|
||||
ret.add_solid_angle_correction(i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < rad_int_profile_per_file.size(); i++)
|
||||
rad_int_profile_per_file[i]->GetPlot(map["file" + std::to_string(i)], true);
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -59,7 +59,8 @@ TEST_CASE("CBORSerialize_Start", "[CBOR]") {
|
||||
.instrument_name_short = "PXIII",
|
||||
.rad_int_bin_number = 35,
|
||||
.summation = 567,
|
||||
.rad_int_bin_to_q = {0.1, 0.2, 0.3, 0.5}
|
||||
.rad_int_bin_to_q = {0.1, 0.2, 0.3, 0.5},
|
||||
.rad_int_solid_angle_corr = {10, 20, 30, 50}
|
||||
};
|
||||
message.pixel_mask["sc0"] = std::vector<uint32_t>(456*457, 15);
|
||||
|
||||
@@ -113,6 +114,7 @@ TEST_CASE("CBORSerialize_Start", "[CBOR]") {
|
||||
CHECK(output_message.rad_int_bin_number == message.rad_int_bin_number);
|
||||
CHECK(output_message.summation == message.summation);
|
||||
CHECK(output_message.rad_int_bin_to_q == message.rad_int_bin_to_q);
|
||||
CHECK(output_message.rad_int_solid_angle_corr == message.rad_int_solid_angle_corr);
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
CHECK(output_message.detector_translation[i] == message.detector_translation[i]);
|
||||
|
||||
@@ -262,6 +262,10 @@ void HDF5Metadata::RadInt(HDF5File *hdf5_file, const StartMessage &start, const
|
||||
HDF5Group(*hdf5_file, "/entry/result").NXClass("NXcollection");
|
||||
HDF5Group rad_int_group(*hdf5_file, "/entry/result/rad_int");
|
||||
rad_int_group.SaveVector("bin_to_q", start.rad_int_bin_to_q);
|
||||
|
||||
if (!start.rad_int_solid_angle_corr.empty())
|
||||
rad_int_group.SaveVector("solid_angle_corr", start.rad_int_solid_angle_corr);
|
||||
|
||||
for (const auto &[x,y] : end.rad_int_result)
|
||||
rad_int_group.SaveVector(x, y);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user