Reference dataset (a): LoadReferenceMtz adds column selection + cell/SG/resolution + a data-vs-reference consistency check; jfjoch_process/jfjoch_scale gain --reference-column; the viewer gets a Reference section in the MX settings dock (worker-owned, independent of the loaded dataset) that flows into reprocessing jobs. 3D combine (-P rot3d): Combine3D weight-sums a reflection's per-frame partials into one counting-limited full before merging (orthogonal ScalingSettings::combine_3d flag, not a partiality model), with a de-biased Poisson variance. Crystal 2: ISa 1.7->8.4, R-meas ~67%->18.9%, intensities unchanged (CCref held). Quality metrics (b): R-meas (Diederichs-Karplus) + redundancy columns in MergeStats; ISa logged. jfjoch fulls 18.9% vs XDS 4.5% (same ASU/run). Profile-fit integrator (experimental): ProfileIntegrate2D (--integrator gaussian|empirical) is a reference-free, rot3d-compatible profile-fit extraction (the decomposed PixelRefine intensity step). Gaussian: R-meas 18.9->14.6%, ISa ->9.5. Anisotropy/per-region add nothing (the discriminating info is in the discarded rocking direction). See NEXTGEN_INTEGRATOR.md. --dump-observations exports the unmerged fulls for XDS comparison. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
56 lines
3.0 KiB
C++
56 lines
3.0 KiB
C++
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#pragma once
|
|
|
|
#include <optional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "../common/Reflection.h"
|
|
#include "../common/UnitCell.h"
|
|
|
|
// A column an MTZ offers as reference intensities/structure factors (type 'J' mean intensity or
|
|
// 'F' amplitude). Surfaced so the caller (CLI flag / viewer combo) can pick which one to scale
|
|
// against and report the choice, rather than the loader silently guessing.
|
|
struct ReferenceMtzColumn {
|
|
std::string label;
|
|
char type = '\0'; // 'J' = mean intensity, 'F' = structure-factor amplitude
|
|
};
|
|
|
|
// Reference reflections loaded from an MTZ, plus the metadata a user needs to judge whether the
|
|
// reference matches the data being scaled: which column was used, the cell / space group it was
|
|
// recorded in, its resolution range and reflection count.
|
|
struct ReferenceMtzData {
|
|
std::vector<MergedReflection> reflections; // h,k,l,I,d set (sigma stays NaN)
|
|
std::optional<UnitCell> cell;
|
|
std::optional<int> space_group_number;
|
|
std::string space_group_name; // Hermann-Mauguin short symbol, for display
|
|
std::string point_group; // point-group symbol, for the consistency check
|
|
std::string used_column;
|
|
char used_column_type = '\0';
|
|
bool squared = false; // an 'F' column was squared to an intensity
|
|
bool default_column = true; // column was auto-selected, not user-specified
|
|
std::vector<ReferenceMtzColumn> candidate_columns;
|
|
double d_min = 0.0;
|
|
double d_max = 0.0;
|
|
};
|
|
|
|
// Load reference reflections from an MTZ. With no column requested the smart default is used:
|
|
// a calculated structure factor F-model (squared to an intensity), else a merged/observed
|
|
// intensity column (IMEAN/I/IOBS/...), else any mean-intensity (J) column - this also lets
|
|
// PixelRefine be self-seeded from the data's own previous merge. A requested column overrides
|
|
// the default (an 'F'-type column is squared, a 'J'-type used directly). Throws if the requested
|
|
// column is missing or no usable column exists.
|
|
ReferenceMtzData LoadReferenceMtz(const std::string& path,
|
|
const std::optional<std::string>& column = std::nullopt);
|
|
|
|
// Compare a loaded reference against the data it will scale. Returns an empty string when they are
|
|
// consistent (or when the data cell / space group is unknown, so nothing can be said); otherwise a
|
|
// one-line, human-readable description of the mismatch to warn the user about. Reference intensities
|
|
// keyed in a different point group or cell do not correspond to the data, so this is the check that
|
|
// makes reference-based scaling and CCref trustworthy.
|
|
std::string ReferenceConsistencyWarning(const ReferenceMtzData& reference,
|
|
const std::optional<UnitCell>& data_cell,
|
|
std::optional<int> data_space_group_number);
|