JFJochReceiver: Per-data-file radial integration profile

This commit is contained in:
2023-05-06 10:54:28 +02:00
parent 59fbeab176
commit 0d2fa850a2
8 changed files with 190 additions and 104 deletions
+19 -26
View File
@@ -35,7 +35,6 @@ JFJochReceiver::JFJochReceiver(const JFJochProtoBuf::ReceiverInput &settings,
frame_transformation_nthreads((experiment.GetSummation() >= threaded_summation_threshold) ?
2 : in_forward_and_sum_nthreads),
preview_publisher(in_preview_publisher),
rad_int_profile_window(experiment.GetSpotFindingBin()),
ndatastreams(experiment.GetDataStreamsNum()),
data_acquisition_ready(ndatastreams),
frame_transformation_ready((experiment.GetImageNum() > 0) ? frame_transformation_nthreads : 0)
@@ -76,6 +75,11 @@ JFJochReceiver::JFJochReceiver(const JFJochProtoBuf::ReceiverInput &settings,
logger.Info("GPU support missing");
rad_int_mapping = std::make_unique<RadialIntegrationMapping>(experiment, one_byte_mask.data());
rad_int_profile = std::make_unique<RadialIntegrationProfile>(*rad_int_mapping);
for (int i = 0; i < experiment.GetDataFileCount(); i++)
rad_int_profile_per_file.emplace_back(std::make_unique<RadialIntegrationProfile>(*rad_int_mapping));
spot_finder_mask = calib->CalculateOneByteMask(experiment);
}
@@ -446,7 +450,13 @@ int64_t JFJochReceiver::FrameTransformationThread() {
bkg_estimate.AddElement(image_number, bkg_estimate_val);
spot_finder->GetRadialIntegrationProfile(message.rad_int_profile);
AddRadialIntegrationProfile(message.rad_int_profile);
rad_int_profile->Add(spot_finder->GetRadialIntegrationSum(),
spot_finder->GetRadialIntegrationCount());
if (image_number % experiment.GetDataFileCount() < rad_int_profile_per_file.size())
rad_int_profile_per_file[image_number % experiment.GetDataFileCount()]
->Add(spot_finder->GetRadialIntegrationSum(),
spot_finder->GetRadialIntegrationCount());
}
if (push_images_to_writer) {
@@ -636,29 +646,6 @@ JFJochProtoBuf::DataProcessingSettings JFJochReceiver::GetDataProcessingSettings
return data_processing_settings;
}
void JFJochReceiver::AddRadialIntegrationProfile(const std::vector<float> &result) {
std::unique_lock<std::mutex> ul(rad_int_profile_mutex);
if (rad_int_profile.empty())
rad_int_profile = result;
else if (rad_int_profile.size() == result.size()) {
for (int i = 0; i < rad_int_profile.size(); i++)
rad_int_profile[i] += (result[i] - rad_int_profile[i]) / rad_int_profile_window;
} else {
// Throw exception?
Abort();
}
}
void JFJochReceiver::GetRadialIntegrationProfile(JFJochProtoBuf::Plot &plot) {
std::unique_lock<std::mutex> ul(rad_int_profile_mutex);
const auto &bin_to_q = rad_int_mapping->GetBinToQ();
if (!rad_int_profile.empty()) {
*plot.mutable_x() = {bin_to_q.begin(), bin_to_q.end()};
*plot.mutable_y() = {rad_int_profile.begin(), rad_int_profile.end()};
}
}
JFJochProtoBuf::Plot JFJochReceiver::GetPlots(const JFJochProtoBuf::PlotRequest &request) {
JFJochProtoBuf::Plot ret;
auto nbins = experiment.GetSpotFindingBin();
@@ -667,7 +654,13 @@ JFJochProtoBuf::Plot JFJochReceiver::GetPlots(const JFJochProtoBuf::PlotRequest
switch (request.type()) {
case JFJochProtoBuf::RAD_INT:
GetRadialIntegrationProfile(ret);
if (request.has_file_number()) {
if (request.file_number() < rad_int_profile_per_file.size())
rad_int_profile_per_file[request.file_number()]->GetPlot(ret);
} else {
if (rad_int_profile)
rad_int_profile->GetPlot(ret);
}
break;
case JFJochProtoBuf::SPOT_COUNT:
spot_count.GetPlot(ret, nbins);
+5 -9
View File
@@ -23,7 +23,8 @@
#include "../common/ThreadSafeFIFO.h"
#include "../common/ZMQPreviewPublisher.h"
#include "../image_analysis/RadialIntegration.h"
#include "../image_analysis/RadialIntegrationMapping.h"
#include "../image_analysis/RadialIntegrationProfile.h"
#include "../common/StatusVector.h"
#include "../jungfrau/JFConversionFixedPoint.h"
@@ -41,10 +42,8 @@ class JFJochReceiver {
std::vector<std::future<int64_t>> data_acquisition_futures;
std::unique_ptr<RadialIntegrationMapping> rad_int_mapping;
std::vector<float> rad_int_profile;
const size_t rad_int_profile_window;
std::mutex rad_int_profile_mutex;
std::unique_ptr<RadialIntegrationProfile> rad_int_profile;
std::vector<std::unique_ptr<RadialIntegrationProfile>> rad_int_profile_per_file;
std::vector<uint8_t> spot_finder_mask;
@@ -99,10 +98,7 @@ class JFJochReceiver {
FrameTransformation &transformation, DataMessage &message);
void Abort(const JFJochException &e);
void FinalizeMeasurement();
JFJochProtoBuf::DataProcessingSettings GetDataProcessingSettings();
void AddRadialIntegrationProfile(const std::vector<float> &result);
void GetRadialIntegrationProfile(JFJochProtoBuf::Plot &plots);
JFJochProtoBuf::DataProcessingSettings GetDataProcessingSettings();
void UpdateMaxImage(int64_t image_number);
public: