Build Packages / Unit tests (push) Successful in 1h22m15s
Build Packages / build:windows:nocuda (push) Successful in 18m0s
Build Packages / build:windows:cuda (push) Successful in 20m30s
Build Packages / build:viewer-tgz:cpu (push) Successful in 10m32s
Build Packages / build:viewer-tgz:cuda (push) Successful in 11m39s
Build Packages / build:rugnux-tgz (x86_64) (push) Successful in 8m55s
Build Packages / build:rugnux:windows (push) Successful in 11m25s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 20m6s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 16m27s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 20m19s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 15m34s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 20m25s
Build Packages / build:rpm (rocky9_sls9) (push) Successful in 19m36s
Build Packages / build:rpm (rocky8) (push) Successful in 17m43s
Build Packages / build:rpm (rocky9) (push) Successful in 13m34s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 21m28s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 18m19s
Build Packages / DIALS test (push) Successful in 12m36s
Build Packages / XDS test (durin plugin) (push) Successful in 6m56s
Build Packages / XDS test (JFJoch plugin) (push) Successful in 6m48s
Build Packages / XDS test (neggia plugin) (push) Successful in 6m7s
Build Packages / Generate python client (push) Successful in 11s
Build Packages / Build documentation (push) Successful in 36s
Build Packages / Create release (push) Skipped
Build Packages / build:rugnux:aarch64 (cross) (push) Successful in 5m11s
* `rugnux --mode calibration` writes `<prefix>.json` beside the `.poni`, whose `dataset_settings` member is a `jfjoch_broker` `dataset_settings` body as it stands. * `rugnux` and `jfjoch_viewer` read PILATUS miniCBF sweeps natively, without conversion. * Masters written by other facilities open, including Eiger 1.x and third-party NXmx variants. * `rugnux` measures the beam centre on every run, and indexes with it when the file's value indexes nothing. * A detector swung out on a 2theta arm is placed where the file says it stands, and the calibration can hold the tilt fixed. * `rugnux` writes the unmerged MTZ by default, and a P1 merge beside it, so a wrong space group can be re-merged without reprocessing. * Significant improvements to symmetry handling in `rugnux`: the lattice, the point group, the setting and the systematic absences. * The `rugnux` report gives the resolution the CC1/2 fit reached, beside the range the reflections were written to. * The `rugnux` report gives the twinning statistics measured before the space group was decided, beside the ones measured after. * The `rugnux` report gives the strong-direction diffraction limit, and warns when CC1/2 is not monotone with resolution. * `rugnux` ranks screw axes on the evidence their absences carry, rather than on how many control reflections a candidate happens to have. * Twinning is no longer reported when the L-test contradicts it. * The `rugnux` report gives the detector tilt, the measured tilt and the direct beam beside the beam centre, and a post-refined beam centre is judged against the run's own measurement rather than the file's. * `--no-refine-tilt` holds the detector tilt at the value in the file, instead of zeroing it, when the calibration starts from the spots. * The `jfjoch_viewer` grid scan view draws the cells in the proportion of the scan steps, so the map has the shape of the scanned area. Reviewed-on: #76 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
57 lines
2.9 KiB
C++
57 lines
2.9 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 "../../common/DiffractionGeometry.h"
|
|
|
|
struct RingOptimizerInput {
|
|
float x;
|
|
float y;
|
|
double q_expected;
|
|
};
|
|
|
|
// What the ring fit knows about its own answer, from the covariance of the converged problem.
|
|
//
|
|
// The beam centre and the tilt are not independent: both displace a ring's radius as cos(phi), and
|
|
// only how that amplitude scales with the ring's radius tells them apart, which takes two well-sampled
|
|
// rings. On one ring they are exactly degenerate; on two they are merely badly correlated, and the fit
|
|
// still returns an answer - it just spends tens of pixels of beam centre to buy a tilt the data cannot
|
|
// support. The sigmas below say when that has happened and the correlations say why.
|
|
//
|
|
// Sigmas are in each parameter's own unit and are scaled by the residual variance of THIS fit
|
|
// (chi2_per_dof), so they are the usual "how far could this parameter move before the fit got visibly
|
|
// worse" and not Ceres' bare (J^T J)^-1. A tilt held fixed reports sigma 0 - it was not a parameter.
|
|
struct RingFitUncertainty {
|
|
bool valid = false; // false if the covariance could not be computed - itself a verdict:
|
|
// the problem is exactly rank-deficient at the solution
|
|
double sigma_beam_x_pxl = 0.0;
|
|
double sigma_beam_y_pxl = 0.0;
|
|
double sigma_distance_mm = 0.0;
|
|
double sigma_rot1_rad = 0.0;
|
|
double sigma_rot2_rad = 0.0;
|
|
// The two degenerate pairs. rot1 tips the detector about the vertical, so it trades against the
|
|
// beam centre in x; rot2 tips it about the horizontal and trades against y. |corr| approaching 1
|
|
// is the signature of a tilt the rings do not separate from a beam-centre shift.
|
|
double corr_beam_x_rot1 = 0.0;
|
|
double corr_beam_y_rot2 = 0.0;
|
|
double chi2_per_dof = 0.0; // in the residual's own (q^2) units - a scale, not a goodness of fit
|
|
int free_parameters = 0;
|
|
};
|
|
|
|
class RingOptimizer {
|
|
DiffractionGeometry reference;
|
|
bool refine_tilt;
|
|
public:
|
|
// refine_tilt = false holds the detector tilt (rot1/rot2) at the value the geometry came in with
|
|
// and fits only the beam centre and the distance. A tilted PONI is exact but not every consumer
|
|
// accepts one - XDS has no place to put it - so a calibration meant for such a program is better
|
|
// measured with the tilt pinned than with it refined and then dropped.
|
|
RingOptimizer(const DiffractionGeometry& geom, bool refine_tilt = true);
|
|
// unc, when given, receives the covariance of the converged fit. Computing it is a 5x5 SVD and
|
|
// costs nothing next to the solve, so there is no option to switch it off - pass nullptr instead.
|
|
DiffractionGeometry Run(const std::vector<RingOptimizerInput> &input,
|
|
RingFitUncertainty *unc = nullptr);
|
|
};
|