Build Packages / Build documentation (push) Successful in 48s
Build Packages / build:portable:linux-x86_64:nocuda (push) Successful in 15m47s
Build Packages / build:portable:linux-x86_64:cuda (push) Successful in 23m19s
Build Packages / build:portable:windows-x86_64:nocuda (push) Successful in 18m47s
Build Packages / build:portable:macos-arm64:nocuda (push) Successful in 5m54s
Build Packages / build:rugnux:linux-aarch64:cuda (push) Successful in 11m27s
Build Packages / Unit tests (push) Successful in 1h50m25s
Build Packages / Validation Battery (push) Successful in 46m38s
Build Packages / build:jfjoch:rocky8:nocuda (push) Successful in 32m52s
Build Packages / build:jfjoch:rocky9:nocuda (push) Successful in 32m32s
Build Packages / build:jfjoch:ubuntu2204:nocuda (push) Successful in 28m34s
Build Packages / build:jfjoch:ubuntu2404:nocuda (push) Successful in 29m19s
Build Packages / build:jfjoch:rocky8:cuda-sls9 (push) Successful in 30m11s
Build Packages / build:jfjoch:rocky9:cuda-sls9 (push) Successful in 33m58s
Build Packages / build:jfjoch:rocky8:cuda (push) Successful in 31m26s
Build Packages / build:jfjoch:rocky9:cuda (push) Successful in 34m4s
Build Packages / build:jfjoch:ubuntu2204:cuda (push) Successful in 26m59s
Build Packages / build:jfjoch:ubuntu2404:cuda (push) Successful in 31m50s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 32m17s
Build Packages / Generate python client (push) Successful in 32s
Build Packages / Create release (push) Successful in 9s
Build Packages / build:portable:windows-x86_64:cuda (push) Successful in 19m38s
* jfjoch_broker (experimental): Live Rugnux covers serial collections from DECTRIS detectors; a rotation collection too large for the image buffer falls back to standard per-image processing with a warning, and a stream that ends without its end message finishes the collection instead of hanging it. * jfjoch_broker (experimental): Live Rugnux settings to build the solvent during refinement and to process a rotation collection as stills, a Clear action for the last result, a `_report.txt` for live rotation runs, R-free reported for the refined model, and ice-ring detection on by default for rotation as in the command line. * jfjoch_broker (experimental): More complete and reproducible live serial merges, analysed for twinning, pseudo-translation and anisotropy, with merging statistics by resolution shell in the live status. * jfjoch_writer: Live results with large models are written reliably; update jfjoch_writer together with jfjoch_broker. * Rugnux: Several masters can be processed together with `--force-still`, including grid scans; more robust and faster merging of several sweeps; improved twinning, pseudo-translation, anisotropy, anomalous-signal and space-group decisions. * Rugnux: Molecular replacement places the copies of a multi-copy solution together; the pseudo-translation warning quotes the Patterson peak and is not raised once a model is placed; the report advises on extending the rotation or reorienting the crystal where the coverage would gain from it. * Web frontend: Light and dark modes, a phone layout, a hideable page list, a redesigned Rugnux live page with step-through of the Fo-Fc peaks in the structure view. * jfjoch_viewer: A broker URL given on the command line follows the running collection. Reviewed-on: #97 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
100 lines
5.8 KiB
C++
100 lines
5.8 KiB
C++
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#pragma once
|
|
|
|
#include <exception>
|
|
#include <optional>
|
|
#include <Eigen/Dense>
|
|
|
|
#include "../../common/CrystalLattice.h"
|
|
|
|
#include "../../common/DiffractionExperiment.h"
|
|
#include "../../common/JFJochMessages.h"
|
|
#include "../../common/SpotToSave.h"
|
|
#include "SpindleBlindFraction.h"
|
|
|
|
struct IndexerResult {
|
|
std::vector<CrystalLattice> lattice;
|
|
float indexing_time_s;
|
|
bool executed = false; // If indexing was not performed (due to indexer being not-available) mark it, so indexing result is marked accordingly
|
|
// What the indexer threw, when it threw - the exception itself, so its category (a CUDA
|
|
// out-of-memory, say) reaches whoever decides what to do about it. A THIRD outcome, not a flavour
|
|
// of the other two: an empty lattice list with no error is a real negative result about the
|
|
// frame - it was examined and no lattice fits it - whereas an error says nothing about the frame
|
|
// at all, the indexer never having got to look, and will recur on the next one.
|
|
std::exception_ptr error;
|
|
// How much of a single sweep's blind cone this orientation makes unrecoverable, in [0,1].
|
|
// Absent when the frame gives nothing to decide on (no spindle defined, no lattice rows).
|
|
std::optional<float> spindle_blind_fraction;
|
|
std::optional<float> spindle_row_length_A;
|
|
std::optional<float> spindle_miss_angle_deg;
|
|
};
|
|
|
|
class Indexer {
|
|
protected:
|
|
int64_t viable_cell_min_spots = 9;
|
|
float indexing_tolerance = 0.1;
|
|
float dist_tolerance_vs_reference = 0.05;
|
|
// Rotation only: a candidate that is an integer supercell of the given cell is stepped down to it
|
|
// (see StepDownToReference). On stills it is not: a still is one frame, the given cell picks one
|
|
// crystal form among several in the stream, and a sub-lattice of a frame's supercell matches a
|
|
// NEIGHBOURING form within the tolerance as readily as the given one.
|
|
bool step_down_to_reference = false;
|
|
// Rotation data only (a scanning axis, so not a grid scan either): rows shorter than the FFT floor
|
|
// are looked for under the rows the transform reports past it (FFTIndexer::Fundamentals). Stills
|
|
// keep the search they had; nothing has been measured on them.
|
|
bool search_short_rows = false;
|
|
bool index_ice_rings = true;
|
|
|
|
DiffractionGeometry geom;
|
|
std::optional<UnitCell> reference_unit_cell;
|
|
// Lattice centring of the given space group ('P' without one).
|
|
char centering = 'P';
|
|
// Rows of the given conventional cell = to_conventional * rows of the cell from IndexingCell.
|
|
Eigen::Matrix3f to_conventional = Eigen::Matrix3f::Identity();
|
|
|
|
// The cell a known-cell indexer is given for a centred lattice: the Niggli-reduced primitive cell, so
|
|
// that every node of it is a reflection the crystal can have (the conventional cell of a centred
|
|
// lattice has 2x - A, B, C, I - 3x - R - or 4x - F - as many nodes, on which a wrong orientation fits
|
|
// as well as the true one), and so that its angles stay near 90 deg (the plain primitive cell of an
|
|
// elongated C cell has one far outside the window Refine accepts). The given cell itself for 'P'.
|
|
CrystalLattice IndexingCell(const UnitCell &cell);
|
|
// The lattices found on IndexingCell put back into the given conventional cell.
|
|
std::vector<CrystalLattice> ToConventional(const std::vector<CrystalLattice> &lattices) const;
|
|
// The rotation axis a subsequent sweep would use. Present on a grid scan too, where the axis is
|
|
// defined but stationary - that is exactly the case the spindle severity is for.
|
|
std::optional<Coord> spindle_axis;
|
|
float wavelength_A = 0;
|
|
// Half-angle of the blind double cone a sweep would leave: asin(lambda/2d) at the GEOMETRIC
|
|
// resolution of the setup - the detector corner at the recorded distance and wavelength - not at
|
|
// the still's own spot resolution. A weak, attenuated grid still reaching 3 A would score a row
|
|
// at an 11 deg miss-angle as exactly 0 while the real sweep, at the detector's 1.8 A, loses a
|
|
// fifth of its wider cone. The corner is an upper bound on any sweep collected without moving
|
|
// the detector, it is there on every frame, and it is unbiased where the still's spot list is
|
|
// systematically shallow; a wider cone errs towards reporting loss, which is the cheap error.
|
|
// 0 when the geometry cannot give it.
|
|
float spindle_theta_max_deg = 0;
|
|
|
|
virtual void SetupUnitCell(const std::optional<UnitCell>& cell) = 0;
|
|
virtual std::vector<CrystalLattice> RunInternal(const std::vector<Coord> &coord, size_t nspots) = 0;
|
|
// Set by RunInternal when the implementation computes it; read out by Run.
|
|
virtual std::optional<SpindleSeverity> GetSpindleSeverity() const { return {}; }
|
|
// The row pass alone, over the whole of `coord`, to produce the spindle severity without
|
|
// reducing or refining anything. Implemented by the FFT-family indexers, which own a row
|
|
// search; the others have nothing to answer with and return nothing.
|
|
virtual std::optional<SpindleSeverity> RunSeverityOnly(const std::vector<Coord> &coord) { return {}; }
|
|
public:
|
|
virtual ~Indexer() = default;
|
|
// The device memory the indexer holds for as long as it lives; 0 for one on the CPU.
|
|
virtual size_t DeviceBytes() const { return 0; }
|
|
void Setup(const DiffractionExperiment& experiment);
|
|
// severity_only = true runs RunSeverityOnly instead of indexing: no lattice comes back and
|
|
// `executed` stays false, since nothing was an indexing attempt. Used when the seed escalation
|
|
// indexed a frame from fewer spots than the severity's floor - the score must not be absent on
|
|
// precisely the frames that index cleanly.
|
|
IndexerResult Run(const std::vector<Coord> &coord, bool severity_only = false);
|
|
};
|
|
|
|
|