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 / build:jfjoch:ubuntu2204:cuda (push) Successful in 26m59s
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 / 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:jfjoch:ubuntu2404:cuda (push) Successful in 31m50s
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>
146 lines
6.3 KiB
C++
146 lines
6.3 KiB
C++
// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include <catch2/catch_all.hpp>
|
|
|
|
#include "../common/DiffractionExperiment.h"
|
|
#include "../common/ScanResultGenerator.h"
|
|
#include "../reader/JFJochMultiReader.h"
|
|
|
|
namespace {
|
|
// A stills collection of n frames held in memory: frame i answers with one spot at x = tag + i, so
|
|
// which input and which of its frames was read can be told from the spot.
|
|
class FakeStills : public JFJochReader {
|
|
uint64_t n;
|
|
float tag;
|
|
bool LoadImage_i(std::shared_ptr<JFJochReaderDataset> &, DataMessage &, std::vector<uint8_t> &,
|
|
int64_t, bool) override { return false; }
|
|
public:
|
|
FakeStills(uint64_t n_, float tag_, const DiffractionExperiment &x, std::vector<uint32_t> mask,
|
|
std::vector<float> efficiency = {}) : n(n_), tag(tag_) {
|
|
auto d = std::make_shared<JFJochReaderDataset>();
|
|
d->experiment = x;
|
|
d->pixel_mask = std::make_shared<const PixelMask>(mask);
|
|
d->efficiency = std::move(efficiency);
|
|
SetStartMessage(d);
|
|
}
|
|
[[nodiscard]] uint64_t GetNumberOfImages() const override { return n; }
|
|
void Close() override {}
|
|
bool ReadRawImage(int64_t, JFJochReaderRawImage &) override { return true; }
|
|
std::vector<SpotToSave> ReadSpots(int64_t image) const override {
|
|
SpotToSave s;
|
|
s.x = tag + static_cast<float>(image);
|
|
return {s};
|
|
}
|
|
};
|
|
|
|
DiffractionExperiment Stills() {
|
|
DiffractionExperiment x(DetJF(1));
|
|
x.BeamX_pxl(500).BeamY_pxl(250).DetectorDistance_mm(100).IncidentEnergy_keV(12.4);
|
|
return x;
|
|
}
|
|
|
|
std::vector<uint32_t> EmptyMask(const DiffractionExperiment &x) {
|
|
return std::vector<uint32_t>(x.GetXPixelsNum() * x.GetYPixelsNum(), 0);
|
|
}
|
|
}
|
|
|
|
TEST_CASE("JFJochMultiReader_Concatenates", "[JFJochMultiReader][portable]") {
|
|
const auto x = Stills();
|
|
auto mask_a = EmptyMask(x);
|
|
auto mask_b = EmptyMask(x);
|
|
mask_a[3] = 1;
|
|
mask_b[7] = 4;
|
|
|
|
std::vector<std::unique_ptr<JFJochReader>> inputs;
|
|
inputs.push_back(std::make_unique<FakeStills>(3, 100.0f, x, mask_a, std::vector<float>{0.5f, 0.5f, 0.5f}));
|
|
inputs.push_back(std::make_unique<FakeStills>(2, 200.0f, x, mask_b));
|
|
JFJochMultiReader reader(std::move(inputs));
|
|
|
|
REQUIRE(reader.GetNumberOfImages() == 5);
|
|
REQUIRE(reader.GetNumberOfInputs() == 2);
|
|
CHECK(reader.FirstImage(1) == 3);
|
|
CHECK(reader.ImagesInInput(1) == 2);
|
|
|
|
CHECK(reader.ReadSpots(0)[0].x == Catch::Approx(100.0f));
|
|
CHECK(reader.ReadSpots(2)[0].x == Catch::Approx(102.0f));
|
|
CHECK(reader.ReadSpots(3)[0].x == Catch::Approx(200.0f));
|
|
CHECK(reader.ReadSpots(4)[0].x == Catch::Approx(201.0f));
|
|
CHECK_THROWS(reader.ReadSpots(5));
|
|
|
|
const auto dataset = reader.GetDataset();
|
|
const auto &mask = dataset->pixel_mask->GetMask();
|
|
CHECK(mask[3] == 1);
|
|
CHECK(mask[7] == 4);
|
|
CHECK(mask[5] == 0);
|
|
|
|
// The second input states no efficiency: its frames count as fully collected.
|
|
REQUIRE(dataset->efficiency.size() == 5);
|
|
CHECK(dataset->efficiency[2] == Catch::Approx(0.5f));
|
|
CHECK(dataset->efficiency[3] == Catch::Approx(1.0f));
|
|
}
|
|
|
|
TEST_CASE("JFJochMultiReader_RefusesOtherGeometry", "[JFJochMultiReader][portable]") {
|
|
const auto x = Stills();
|
|
auto other = Stills();
|
|
|
|
SECTION("distance") { other.DetectorDistance_mm(101); }
|
|
SECTION("beam centre") { other.BeamX_pxl(503); }
|
|
SECTION("wavelength") { other.IncidentEnergy_keV(12.6); }
|
|
|
|
std::vector<std::unique_ptr<JFJochReader>> inputs;
|
|
inputs.push_back(std::make_unique<FakeStills>(1, 0.0f, x, EmptyMask(x)));
|
|
inputs.push_back(std::make_unique<FakeStills>(1, 0.0f, other, EmptyMask(other)));
|
|
CHECK_THROWS(JFJochMultiReader(std::move(inputs)));
|
|
}
|
|
|
|
TEST_CASE("JFJochMultiReader_RefusesRotation", "[JFJochMultiReader][portable]") {
|
|
const auto x = Stills();
|
|
auto rotation = Stills();
|
|
rotation.Goniometer(GoniometerAxis("omega", 0.0f, 0.1f, Coord(1, 0, 0), {}));
|
|
|
|
std::vector<std::unique_ptr<JFJochReader>> inputs;
|
|
inputs.push_back(std::make_unique<FakeStills>(1, 0.0f, x, EmptyMask(x)));
|
|
inputs.push_back(std::make_unique<FakeStills>(1, 0.0f, rotation, EmptyMask(rotation)));
|
|
CHECK_THROWS(JFJochMultiReader(std::move(inputs)));
|
|
}
|
|
|
|
TEST_CASE("JFJochMultiReader_RotationAsStills", "[JFJochMultiReader][portable]") {
|
|
auto rotation = Stills();
|
|
rotation.Goniometer(GoniometerAxis("omega", 0.0f, 0.1f, Coord(1, 0, 0), {}));
|
|
|
|
std::vector<std::unique_ptr<JFJochReader>> inputs;
|
|
inputs.push_back(std::make_unique<FakeStills>(2, 0.0f, rotation, EmptyMask(rotation)));
|
|
inputs.push_back(std::make_unique<FakeStills>(3, 100.0f, rotation, EmptyMask(rotation)));
|
|
JFJochMultiReader reader(std::move(inputs), true);
|
|
CHECK(reader.GetNumberOfImages() == 5);
|
|
CHECK(!reader.GetDataset()->experiment.GetGoniometer().has_value());
|
|
CHECK(reader.ReadSpots(2)[0].x == Catch::Approx(100.0f));
|
|
}
|
|
|
|
TEST_CASE("JFJochMultiReader_DropsGridScan", "[JFJochMultiReader][portable]") {
|
|
// Two fixed-target chips, a grid scan each: read together they are one stills run, not one grid.
|
|
// The first input's grid (6 elements) would throw on every image number past its own.
|
|
auto x = Stills();
|
|
x.ImagesPerTrigger(6).GridScan(GridScanSettings(3, 10.0f, 10.0f, true, false).ImageNum(6));
|
|
|
|
std::vector<std::unique_ptr<JFJochReader>> inputs;
|
|
inputs.push_back(std::make_unique<FakeStills>(6, 0.0f, x, EmptyMask(x)));
|
|
inputs.push_back(std::make_unique<FakeStills>(6, 100.0f, x, EmptyMask(x)));
|
|
JFJochMultiReader reader(std::move(inputs));
|
|
REQUIRE(reader.GetNumberOfImages() == 12);
|
|
CHECK(!reader.GetDataset()->experiment.GetGoniometer().has_value());
|
|
CHECK(!reader.GetDataset()->experiment.GetGridScan().has_value());
|
|
|
|
// As rugnux sets the run up: the combined dataset's experiment over every image of every input.
|
|
DiffractionExperiment run(reader.GetDataset()->experiment);
|
|
run.ImagesPerTrigger(static_cast<int64_t>(reader.GetNumberOfImages()));
|
|
ScanResultGenerator scan_result(run);
|
|
for (int64_t i = 0; i < 12; i++) {
|
|
DataMessage message;
|
|
message.number = i;
|
|
REQUIRE_NOTHROW(scan_result.Add(message));
|
|
}
|
|
CHECK(scan_result.GetResult().images.size() == 12);
|
|
}
|