JFJochReceiver: Per-data-file radial integration profile

This commit is contained in:
2023-05-06 10:28:45 +02:00
parent 59fbeab176
commit 0d2fa850a2
8 changed files with 190 additions and 104 deletions

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);