Build Packages / Create release (push) Successful in 26s
Build Packages / Build documentation (push) Successful in 1m43s
Build Packages / build:portable:macos-arm64:nocuda (push) Successful in 5m7s
Build Packages / build:portable:linux-x86_64:nocuda (push) Successful in 11m48s
Build Packages / build:rugnux:linux-aarch64:cuda (push) Successful in 7m22s
Build Packages / build:portable:linux-x86_64:cuda (push) Successful in 12m24s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 25m30s
Build Packages / build:portable:windows-x86_64:nocuda (push) Successful in 25m29s
Build Packages / build:portable:windows-x86_64:cuda (push) Successful in 29m41s
Build Packages / build:jfjoch:ubuntu2204:nocuda (push) Successful in 21m44s
Build Packages / build:jfjoch:rocky8:nocuda (push) Successful in 24m41s
Build Packages / build:jfjoch:rocky9:nocuda (push) Successful in 26m9s
Build Packages / build:jfjoch:ubuntu2404:nocuda (push) Successful in 26m3s
Build Packages / build:jfjoch:rocky8:cuda-sls9 (push) Successful in 28m28s
Build Packages / Generate python client (push) Successful in 27s
Build Packages / build:jfjoch:rocky9:cuda-sls9 (push) Successful in 31m16s
Build Packages / build:jfjoch:ubuntu2204:cuda (push) Successful in 20m44s
Build Packages / build:jfjoch:rocky8:cuda (push) Successful in 26m27s
Build Packages / build:jfjoch:ubuntu2404:cuda (push) Successful in 22m52s
Build Packages / build:jfjoch:rocky9:cuda (push) Successful in 27m44s
Build Packages / Unit tests (push) Successful in 1h46m55s
Build Packages / Validation Battery (push) Successful in 52m50s
* Rugnux: Several rotation sweeps of one crystal are merged as one dataset (`rugnux a_master.h5 b_master.h5`), on a common indexing and cell, with a non-isomorphous sweep left out and reported; `--sweeps separate` processes each sweep on its own. Bruker `.sfrm` frames and imgCIF files with a full goniometer axis chain are read. * Rugnux: More robust rotation processing - a retry with a more sensitive spot finder when no lattice is found, a self-consistent detector distance, long axes and doubled cells tested as hypotheses, a `-C` supercell multiple stepped down, and each ice ring merged, down-weighted or rejected on its own. * Rugnux: Serial stills are merged with a partiality-aware error model, reported as `ERROR_MODEL_A/B/C` with no ISa or R_merge/R_meas/R_pim; runs without `-S` have an overall intensity scale about 0.86-0.88 times that of earlier versions, with unchanged statistics. A second crystal form is left out of the merge and reported, the indexing ambiguity is resolved more reliably, and `--model` no longer influences processing. * Rugnux: The reported CC1/2 is the standard unweighted one, which can be lower than before on sweeps with weak frames; ISa comes with a 95% interval (`ISA_LOW`/`ISA_HIGH`). * Rugnux: Model refinement adds anisotropic/TLS, local NCS and twin refinement where R-free supports them; building waters and relabelling ions is now off by default (`--refine-solvent` turns it on). * NXmx: A detector of several modules is written as `module_0` ... `module_N` only, so DIALS reads each module as its own panel. * Other: JPEG previews use a bundled encoder (libjpeg-turbo no longer needed), Rugnux prints how to cite it, and the release archives contain the HTML documentation. Reviewed-on: #92 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
85 lines
3.5 KiB
C++
85 lines
3.5 KiB
C++
// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include "NXmxModules.h"
|
|
|
|
#include <cmath>
|
|
|
|
#include "../common/JFJochException.h"
|
|
|
|
namespace {
|
|
|
|
// A translation dataset as a vector in pixels of the internal frame (x = column, y = row, z = beam).
|
|
Coord ReadTranslation_px(HDF5Object &file, const std::string &path, double pixel_size_m, const RotMatrix &delta) {
|
|
HDF5DataSet ds(file, path);
|
|
std::vector<double> value;
|
|
ds.ReadVector(value);
|
|
const auto vec = ds.ReadAttrVec("vector");
|
|
if (value.empty() || vec.size() != 3)
|
|
throw JFJochException(JFJochExceptionCategory::HDF5, path + ": not a translation");
|
|
double scale = 1.0;
|
|
if (ds.AttrExists("units")) {
|
|
const std::string units = ds.ReadAttrStr("units");
|
|
if (units == "mm")
|
|
scale = 1e-3;
|
|
else if (units == "um" || units == "microns")
|
|
scale = 1e-6;
|
|
}
|
|
const double len_px = value[0] * scale / pixel_size_m;
|
|
// McStas -> internal is a half turn about z; the discrete image orientation is undone after it.
|
|
const Coord mcstas(static_cast<float>(-vec[0]), static_cast<float>(-vec[1]), static_cast<float>(vec[2]));
|
|
return delta.transpose() * (static_cast<float>(len_px) * mcstas);
|
|
}
|
|
|
|
} // namespace
|
|
|
|
std::string NXmxModuleGroup(HDF5Object &file, size_t n) {
|
|
// The index is written zero-padded to the width of the last one (module_00 ... module_15); the width is
|
|
// the one module 0 has.
|
|
for (size_t digits = 1; digits <= 3; digits++) {
|
|
const std::string first = "/entry/instrument/detector/module_" + std::string(digits - 1, '0') + "0/";
|
|
if (file.Exists(first + "data_origin")) {
|
|
std::string index = std::to_string(n);
|
|
if (index.size() < digits)
|
|
index.insert(0, digits - index.size(), '0');
|
|
const std::string base = "/entry/instrument/detector/module_" + index + "/";
|
|
return file.Exists(base + "data_origin") ? base : "";
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
|
|
DetectorModules ReadNXmxModules(HDF5Object &file, double pixel_size_m, const DetectorOrientation &orientation) {
|
|
const RotMatrix delta = orientation.Matrix();
|
|
std::vector<DetectorModule> out;
|
|
for (size_t n = 0;; n++) {
|
|
const std::string base = NXmxModuleGroup(file, n);
|
|
if (base.empty())
|
|
break;
|
|
const auto origin = file.ReadVector<int64_t>(base + "data_origin");
|
|
const auto size = file.ReadVector<int64_t>(base + "data_size");
|
|
if (origin.size() != 2 || size.size() != 2)
|
|
throw JFJochException(JFJochExceptionCategory::HDF5, base + ": only two-dimensional modules are read");
|
|
const Coord o = ReadTranslation_px(file, base + "module_offset", pixel_size_m, delta);
|
|
const Coord f = ReadTranslation_px(file, base + "fast_pixel_direction", pixel_size_m, delta);
|
|
const Coord s = ReadTranslation_px(file, base + "slow_pixel_direction", pixel_size_m, delta);
|
|
if (std::fabs(o.z) > 1e-3 || std::fabs(f.z) > 1e-6 || std::fabs(s.z) > 1e-6)
|
|
throw JFJochException(JFJochExceptionCategory::HDF5, base + ": a module out of the detector plane is not read");
|
|
DetectorModule m;
|
|
m.y0 = origin[0];
|
|
m.x0 = origin[1];
|
|
m.height = size[0];
|
|
m.width = size[1];
|
|
m.ox = o.x;
|
|
m.oy = o.y;
|
|
m.fx = f.x;
|
|
m.fy = f.y;
|
|
m.sx = s.x;
|
|
m.sy = s.y;
|
|
out.push_back(m);
|
|
}
|
|
if (out.size() < 2)
|
|
return {};
|
|
return DetectorModules(out);
|
|
}
|