Build Packages / build:windows:nocuda (push) Waiting to run
Build Packages / build:windows:cuda (push) Waiting to run
Build Packages / build:viewer-tgz:cpu (push) Successful in 14m10s
Build Packages / build:viewer-tgz:cuda (push) Successful in 16m9s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 18m52s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 22m36s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 19m19s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 22m46s
Build Packages / build:rpm (rocky9_sls9) (push) Successful in 18m50s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 22m52s
Build Packages / build:rpm (rocky9) (push) Successful in 21m38s
Build Packages / build:rpm (rocky8) (push) Successful in 24m56s
Build Packages / XDS test (durin plugin) (push) Successful in 10m48s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 20m42s
Build Packages / Generate python client (push) Successful in 15s
Build Packages / Create release (push) Skipped
Build Packages / build:rpm (ubuntu2204) (push) Successful in 24m16s
Build Packages / Build documentation (push) Successful in 42s
Build Packages / DIALS test (push) Successful in 16m47s
Build Packages / XDS test (neggia plugin) (push) Successful in 7m2s
Build Packages / XDS test (JFJoch plugin) (push) Successful in 7m39s
Build Packages / Unit tests (push) Successful in 1h20m10s
This is an UNSTABLE release. It includes many experimental features, as well as many AI generated fixes. We recommend using rc.152 for production use. * **rugnux: significantly better quality of results, and faster.** A large rework of integration, scaling, merging, geometry refinement and space-group determination, together with measurements the program previously made no attempt at - the direct beam before indexing, the beam stop, the goniometer rotation scale, and the stretches of a sweep the crystal did not deliver. A rotation dataset typically gains observations at better <I/sigma> and R_meas, and every `mx` and `scale` run writes a `<prefix>_report.txt` results report modelled on XDS's `CORRECT.LP`. Many defaults moved with it: spot detection is self-calibrating, beam-stop detection and rotation geometry post-refinement are on, resolution limits default to as far as the detector reaches, and ice-ring handling engages only where the crystal is measured to have ice. * **jfjoch_viewer:** the beam-stop shadow, the detector calibration and the beam-centre measurement are reachable from "Analyze dataset"; the settings panel reports how the sample moved and how polarized the beam was; image rendering and interaction are faster. * **Performance:** bitshuffle+LZ4 images are decoded on the GPU rather than on the host, with the bitshuffle inverse fused into preprocessing so the decompressed frame is never held in device memory. * **Broker, writer, packaging and build:** image-slot lifetime and locking fixes, per-image datasets sized by the images actually written, the Debian/Ubuntu broker package renamed to `jfjoch`, and `image_analysis` compiling under MSVC again. **Breaking change to the rugnux command line:** * `--azint-only` and `--scale` are **removed**, replaced by `--mode azint` and `--mode scale`; the full pipeline is `--mode mx` and remains the default. A script passing the old flags now fails with the list of valid modes rather than silently running the wrong one. * `-t`/`--stride` is **refused on rotation data**: skipping frames cuts every reflection's rocking curve, so the combined fulls and their partiality would be measured over frames the sweep never recorded. Select a contiguous range with `-s`/`-e` instead. `--mode azint` and `--force-still` still take a stride. **Breaking changes to OpenAPI** - regenerate the client (`jfjoch-client` 1.0.0-rc.161, `frontend/src/client`) or read the affected fields as optional: * `image_scale_b` is removed from the `plot_type` enum, so a client requesting that plot now gets an error rather than a curve. * `azim_int_settings.high_q_recipA`, `spot_finding_settings.high_resolution_limit` and `spot_finding_settings.low_resolution_limit` are no longer `required`. All three mean "no limit at that end" when unset and are omitted from the response instead of carrying a placeholder value, which raises in a client generated from an rc.160-or-earlier spec. A value of 0 is still accepted and means the same thing. **Breaking changes to the stored formats** - a consumer reading these fields must treat them as optional: * The per-image image-scale B factor is no longer computed, so `/entry/MX/imageScaleBFactor` is absent from newly written HDF5 files and the corresponding key is absent from the CBOR DataMessage and END blocks. Files written by rc.160 and earlier still contain it and still open; nothing in the pipeline reads it any more. * `_reflns.jfjoch_diffrn_ISa` now carries the whole-range `1/sqrt(a*b)` that XDS's ISa denotes, and the error-model `a` and `b` are reported in XDS's convention; the strong-reflection asymptote moves to `_reflns.jfjoch_diffrn_ISa_asymptotic`. **A file written by an earlier version carries the asymptote under the plain `ISa` name.** Reviewed-on: #71 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
132 lines
5.4 KiB
C++
132 lines
5.4 KiB
C++
// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include "JFJochProcessController.h"
|
|
#include "../reader/JFJochHDF5Reader.h"
|
|
|
|
#include <QMetaType>
|
|
|
|
#include <cmath>
|
|
|
|
JFJochProcessController::JFJochProcessController(QObject *parent) : QObject(parent) {
|
|
qRegisterMetaType<ProcessResult>("ProcessResult");
|
|
qRegisterMetaType<std::shared_ptr<const JFJochReaderDataset>>("std::shared_ptr<const JFJochReaderDataset>");
|
|
}
|
|
|
|
JFJochProcessController::~JFJochProcessController() {
|
|
cancel();
|
|
joinWorker_();
|
|
}
|
|
|
|
void JFJochProcessController::joinWorker_() {
|
|
if (worker_.joinable())
|
|
worker_.join();
|
|
}
|
|
|
|
void JFJochProcessController::start(const QString &file_path, DiffractionExperiment experiment,
|
|
PixelMask pixel_mask, ProcessConfig config) {
|
|
if (running_.exchange(true))
|
|
return; // a job is already running
|
|
|
|
cancel_pending_ = false;
|
|
joinWorker_(); // reap the previous (finished) worker, if any
|
|
worker_ = std::thread(&JFJochProcessController::run_, this,
|
|
file_path, std::move(experiment), std::move(pixel_mask), std::move(config));
|
|
emit started();
|
|
}
|
|
|
|
void JFJochProcessController::cancel() {
|
|
cancel_pending_ = true;
|
|
if (auto *p = active_.load())
|
|
p->Cancel();
|
|
}
|
|
|
|
void JFJochProcessController::run_(QString file_path, DiffractionExperiment experiment,
|
|
PixelMask pixel_mask, ProcessConfig config) {
|
|
try {
|
|
JFJochHDF5Reader reader;
|
|
reader.ReadFile(file_path.toStdString());
|
|
|
|
// Seed the live dataset with the experiment so the chart has geometry context; per-image
|
|
// results are filled in by OnImageProcessed as the run progresses.
|
|
{
|
|
auto base = std::make_shared<JFJochReaderDataset>();
|
|
base->experiment = experiment;
|
|
std::lock_guard lock(live_mutex_);
|
|
live_dataset_ = std::move(base);
|
|
last_live_emit_ = {};
|
|
}
|
|
|
|
Rugnux process(reader, std::move(experiment), std::move(pixel_mask), std::move(config));
|
|
active_ = &process;
|
|
if (cancel_pending_)
|
|
process.Cancel();
|
|
|
|
ProcessResult result = process.Run(this);
|
|
|
|
active_ = nullptr;
|
|
running_ = false;
|
|
emit finished(result);
|
|
} catch (const std::exception &e) {
|
|
active_ = nullptr;
|
|
running_ = false;
|
|
emit failed(QString::fromStdString(e.what()));
|
|
}
|
|
}
|
|
|
|
void JFJochProcessController::OnPhase(const std::string &phase) {
|
|
emit phaseChanged(QString::fromStdString(phase));
|
|
}
|
|
|
|
void JFJochProcessController::OnProgress(uint64_t done, uint64_t total) {
|
|
// Throttle to ~200 updates so a long run does not flood the GUI event queue.
|
|
const uint64_t step = total > 200 ? total / 200 : 1;
|
|
if (done == total || done % step == 0)
|
|
emit progress(done, total);
|
|
}
|
|
|
|
void JFJochProcessController::OnImageProcessed(const DataMessage &msg) {
|
|
std::shared_ptr<JFJochReaderDataset> snapshot;
|
|
{
|
|
std::lock_guard lock(live_mutex_);
|
|
if (!live_dataset_)
|
|
return;
|
|
|
|
// Place each available per-image result at its ordinal; gaps (images still being processed
|
|
// by other threads) read back as NaN.
|
|
const int64_t i = msg.number;
|
|
auto put = [i](std::vector<float> &v, float val) {
|
|
if (static_cast<int64_t>(v.size()) <= i)
|
|
v.resize(i + 1, NAN);
|
|
v[i] = val;
|
|
};
|
|
auto &d = *live_dataset_;
|
|
// Map this ordinal back to its original image number (for the x-axis of subset/strided runs).
|
|
if (static_cast<int64_t>(d.source_image_number.size()) <= i)
|
|
d.source_image_number.resize(i + 1, 0);
|
|
d.source_image_number[i] = static_cast<int>(msg.original_number.value_or(msg.number));
|
|
if (msg.spot_count) put(d.spot_count, *msg.spot_count);
|
|
if (msg.spot_count_indexed) put(d.spot_count_indexed, *msg.spot_count_indexed);
|
|
if (msg.spot_count_low_res) put(d.spot_count_low_res, *msg.spot_count_low_res);
|
|
if (msg.spot_count_ice_rings) put(d.spot_count_ice_rings, *msg.spot_count_ice_rings);
|
|
if (msg.indexing_result) put(d.indexing_result, *msg.indexing_result ? 1.0f : 0.0f);
|
|
if (msg.indexing_lattice_count) put(d.indexing_lattice_count, *msg.indexing_lattice_count);
|
|
if (msg.bkg_estimate) put(d.bkg_estimate, *msg.bkg_estimate);
|
|
if (msg.resolution_estimate) put(d.resolution_estimate, *msg.resolution_estimate);
|
|
if (msg.profile_radius) put(d.profile_radius, *msg.profile_radius);
|
|
if (msg.mosaicity_deg) put(d.mosaicity_deg, *msg.mosaicity_deg);
|
|
if (msg.b_factor) put(d.b_factor, *msg.b_factor);
|
|
if (msg.integrated_reflections) put(d.integrated_reflections, *msg.integrated_reflections);
|
|
if (msg.image_scale_factor) put(d.image_scale_factor, *msg.image_scale_factor);
|
|
if (msg.image_scale_cc) put(d.image_scale_cc, *msg.image_scale_cc);
|
|
|
|
// Throttle to ~4 Hz so the GUI plots refresh smoothly without flooding the event queue.
|
|
const auto now = std::chrono::steady_clock::now();
|
|
if (now - last_live_emit_ < std::chrono::milliseconds(250))
|
|
return;
|
|
last_live_emit_ = now;
|
|
snapshot = std::make_shared<JFJochReaderDataset>(d); // immutable copy for the GUI thread
|
|
}
|
|
emit liveDataset(snapshot);
|
|
}
|