Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 12m8s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 12m57s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 12m55s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 12m0s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 13m30s
Build Packages / Generate python client (push) Successful in 20s
Build Packages / Unit tests (push) Has been skipped
Build Packages / Create release (push) Has been skipped
Build Packages / Build documentation (push) Successful in 39s
Build Packages / build:rpm (rocky8) (push) Successful in 9m23s
Build Packages / build:rpm (rocky9_sls9) (push) Successful in 10m33s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 8m2s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 8m42s
Build Packages / build:rpm (rocky9) (push) Successful in 9m38s
This is an UNSTABLE release. This version adds scalign and merging. These are experimental at the moment, and should not be used for production analysis. If things go wrong with analysis, it is better to revert to 1.0.0-rc.124. * jfjoch_broker: Improve logic on switching on/off spot finding * jfjoch_broker: Increase maximum spot count for FFBIDX to 65536 * jfjoch_broker: Increase default maximum unit cell for FFT to 500 A (could have performance impact, TBD) * jfjoch_process: Add scalign and merging functionality - program is experimental at the moment and should not be used for production analysis * jfjoch_viewer: Display partiality and reciprocal Lorentz-polarization correction for each reflection * jfjoch_writer: Save more information about each reflection Reviewed-on: #32 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch> Co-committed-by: Filip Leonarski <filip.leonarski@psi.ch>
94 lines
3.2 KiB
C++
94 lines
3.2 KiB
C++
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
||
// SPDX-License-Identifier: GPL-3.0-only
|
||
|
||
#pragma once
|
||
|
||
#include <vector>
|
||
#include <cstdint>
|
||
#include <optional>
|
||
|
||
#include "../../common/Reflection.h"
|
||
#include "gemmi/symmetry.hpp"
|
||
|
||
struct ScaleMergeOptions {
|
||
int max_num_iterations = 100;
|
||
double max_solver_time_s = 1.0;
|
||
|
||
double image_number_rounding = 1.0;
|
||
double min_sigma = 1e-3;
|
||
|
||
// Symmetry canonicalization of HKL prior to merging/scaling.
|
||
// If not set, the routine uses raw HKL as-is.
|
||
std::optional<gemmi::SpaceGroup> space_group;
|
||
|
||
// If true, treat Friedel mates as equivalent (merge anomalous pairs).
|
||
// If false, keep them separate by including a sign flag in the HKL key.
|
||
bool merge_friedel = true;
|
||
|
||
// --- Kabsch(XDS)-style partiality model ---
|
||
// Rotation range (wedge) used in partiality calculation.
|
||
// Set to 0 to disable partiality correction.
|
||
double wedge_deg = 1.0;
|
||
|
||
// --- Mosaicity (user input in degrees; internally converted to radians) ---
|
||
bool refine_mosaicity = true;
|
||
bool per_image_mosaicity = true;
|
||
|
||
double mosaicity_init_deg = 0.17; // ~0.003 rad
|
||
double mosaicity_min_deg = 1e-3;
|
||
double mosaicity_max_deg = 2.0;
|
||
std::vector<double> mosaicity_init_deg_vec;
|
||
|
||
// --- Optional: regularize per-image scale k towards 1 (Kabsch-like) ---
|
||
bool regularize_scale_to_one = true;
|
||
double scale_regularization_sigma = 0.05;
|
||
bool log_scaling_residual = false;
|
||
|
||
double min_partiality_for_merge = 0.2;
|
||
bool smoothen_g = true;
|
||
bool smoothen_mos = true;
|
||
|
||
};
|
||
|
||
struct MergedReflection {
|
||
int h;
|
||
int k;
|
||
int l;
|
||
double I;
|
||
double sigma;
|
||
double d = 0.0;
|
||
};
|
||
|
||
/// Per-resolution-shell merging statistics
|
||
struct MergeStatisticsShell {
|
||
float d_min = 0.0f; ///< High-resolution limit of this shell (Å)
|
||
float d_max = 0.0f; ///< Low-resolution limit of this shell (Å)
|
||
float mean_one_over_d2 = 0; ///< Mean 1/d² in shell
|
||
int total_observations = 0; ///< Total number of (corrected) observations
|
||
int unique_reflections = 0; ///< Number of unique HKLs with observations
|
||
double rmeas = 0.0; ///< Redundancy-independent merging R-factor
|
||
double mean_i_over_sigma = 0.0; ///< Mean I/σ(I) of the merged reflections
|
||
double completeness = 0.0; ///< Fraction of possible reflections observed (0 if unknown)
|
||
int possible_reflections = 0;///< Theoretical number of reflections in this shell (0 if unknown)
|
||
};
|
||
|
||
/// Overall + per-shell merging statistics
|
||
struct MergeStatistics {
|
||
std::vector<MergeStatisticsShell> shells;
|
||
MergeStatisticsShell overall; ///< Statistics over all shells combined
|
||
};
|
||
|
||
struct ScaleMergeResult {
|
||
std::vector<MergedReflection> merged;
|
||
std::vector<double> image_scale_g;
|
||
std::vector<int> image_ids;
|
||
|
||
// One mosaicity value per image (degrees).
|
||
std::vector<double> mosaicity_deg;
|
||
|
||
/// Per-shell and overall merging statistics (populated after merging)
|
||
MergeStatistics statistics;
|
||
};
|
||
|
||
ScaleMergeResult ScaleAndMergeReflectionsCeres(const std::vector<Reflection>& observations,
|
||
const ScaleMergeOptions& opt = {}); |