fc68a9baed
Build Packages / Unit tests (push) Skipped
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 8m34s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 10m0s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 10m23s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 10m23s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 11m16s
Build Packages / build:rpm (rocky9_sls9) (push) Successful in 11m49s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 8m32s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 9m15s
Build Packages / XDS test (durin plugin) (push) Successful in 7m16s
Build Packages / Generate python client (push) Successful in 16s
Build Packages / build:rpm (rocky9) (push) Successful in 10m12s
Build Packages / Create release (push) Skipped
Build Packages / Build documentation (push) Successful in 47s
Build Packages / DIALS test (push) Successful in 10m18s
Build Packages / XDS test (JFJoch plugin) (push) Successful in 5m46s
Build Packages / build:rpm (rocky8) (push) Successful in 1h41m2s
Build Packages / XDS test (neggia plugin) (push) Successful in 1h59m18s
This is an UNSTABLE release. The release has significant modifications for data processing - in case of troubles go back to 1.0.0-rc.144. jfjoch_process: Generate a dedicated file (_process.h5), which can be used as a replacement for the _master.h5 file for a reanalyzed dataset. jfjoch_process: Improve the performance of scaling and merging, implement on the fly scaling. jfjoch_writer: All final data analysis results are repopulated in the _master.h5 file. jfjoch_scale: Dedicated tool for rescaling/merging existing data. jfjoch_viewer: Fix bugs where pixel labels where displayed on a wrong pixel. WARNING! Scaling and merging are experimental at the moment, and may not provide reasonable results for the time being. Reviewed-on: #56
92 lines
2.6 KiB
C++
92 lines
2.6 KiB
C++
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include "CalcISigma.h"
|
|
#include "Regression.h"
|
|
#include "../../common/ResolutionShells.h"
|
|
|
|
void CalcISigma(DataMessage &msg) {
|
|
CalcISigma(msg, msg.reflections);
|
|
}
|
|
|
|
void CalcISigma(DataMessage &msg, const std::vector<Reflection> &reflections) {
|
|
if (reflections.empty())
|
|
return;
|
|
|
|
const int nshells = 20;
|
|
ResolutionShells shells(1.5, 50.0, nshells);
|
|
|
|
std::vector<float> Isigma_sum(nshells);
|
|
std::vector<float> count(nshells);
|
|
|
|
for (const auto &r: reflections) {
|
|
auto s = shells.GetShell(r.d);
|
|
if (s && (r.sigma != 0.0)) {
|
|
Isigma_sum[*s] += r.I / r.sigma;
|
|
++count[*s];
|
|
}
|
|
}
|
|
|
|
std::vector<float> result(nshells);
|
|
for (int i = 0; i < nshells; ++i) {
|
|
if (count[i] > 0)
|
|
result[i] = Isigma_sum[i] / count[i];
|
|
else
|
|
result[i] = 0.0f;
|
|
}
|
|
|
|
msg.integration_Isigma = result;
|
|
msg.integration_Isigma_one_over_d_square = shells.GetShellMeanOneOverResSq();
|
|
}
|
|
|
|
void CalcWilsonBFactor(DataMessage &msg,
|
|
bool replace_b) {
|
|
CalcWilsonBFactor(msg, msg.reflections, replace_b);
|
|
}
|
|
|
|
void CalcWilsonBFactor(DataMessage &msg,
|
|
const std::vector<Reflection> &reflections,
|
|
bool replace_b) {
|
|
if (reflections.empty())
|
|
return;
|
|
|
|
const int nshells = 20;
|
|
ResolutionShells shells(1.5, 6.0, nshells);
|
|
|
|
std::vector<float> I_sum(nshells);
|
|
std::vector<float> count(nshells);
|
|
|
|
for (const auto& r: reflections) {
|
|
auto s = shells.GetShell(r.d);
|
|
if (s && (r.sigma != 0.0)) {
|
|
I_sum[*s] += r.I;
|
|
++count[*s];
|
|
}
|
|
}
|
|
|
|
std::vector<float> log_I_mean(nshells);
|
|
|
|
int32_t valid_shells = nshells;
|
|
for (int i = 0; i < nshells; ++i) {
|
|
if (count[i] > 0 && I_sum[i] > 0) {
|
|
log_I_mean[i] = std::log(I_sum[i] / count[i]);
|
|
} else {
|
|
log_I_mean[i] = 0.0f;
|
|
// First shell that has improper value limits how far the Wilson plot is interpolated
|
|
valid_shells = std::min(valid_shells, i + 1);
|
|
}
|
|
}
|
|
|
|
auto shells_mean_one_over_d_square = shells.GetShellMeanOneOverResSq();
|
|
|
|
if (replace_b && valid_shells > 2) {
|
|
auto reg_result = regression(shells_mean_one_over_d_square, log_I_mean, valid_shells);
|
|
|
|
if (reg_result.r_square > 0.3)
|
|
msg.b_factor = -2.0f * reg_result.slope;
|
|
}
|
|
|
|
msg.integration_B_logI = log_I_mean;
|
|
msg.integration_B_one_over_d_square = shells_mean_one_over_d_square;
|
|
}
|