Build Packages / Create release (push) Successful in 16s
Build Packages / build:rugnux:aarch64 (cross) (push) Successful in 8m27s
Build Packages / build:rugnux-tgz (x86_64) (push) Successful in 9m15s
Build Packages / build:viewer-tgz:cpu (push) Successful in 10m11s
Build Packages / build:viewer-tgz:cuda (push) Successful in 12m6s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 15m44s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 16m1s
Build Packages / build:windows:nocuda (push) Successful in 17m29s
Build Packages / build:windows:cuda (push) Successful in 19m58s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 24m7s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 19m8s
Build Packages / build:rugnux:windows (push) Successful in 10m58s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 20m46s
Build Packages / Generate python client (push) Successful in 53s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 20m13s
Build Packages / Build documentation (push) Successful in 1m36s
Build Packages / build:rpm (rocky9_sls9) (push) Successful in 19m57s
Build Packages / build:rpm (rocky8) (push) Successful in 18m7s
Build Packages / build:rpm (rocky9) (push) Successful in 18m54s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 19m32s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 17m30s
Build Packages / Unit tests (push) Successful in 1h39m2s
* Fixed `jfjoch_broker` cancelling every data collection with a CUDA "out of memory" error after long operation: GPU memory no longer leaks with each collection. * Rugnux scales a rotation sweep until the per-frame scales settle instead of for a fixed three rounds, and says so when they did not - merged intensities, and the space group, resolution cut and frame rejection read off them, change accordingly; `--scaling-iterations` is now the cap on that loop (default 100). * Rugnux places every frame of a marCCD, SMV or miniCBF series at the spindle angle its own header states, so a series with missing frames, or with angles written modulo 360, is no longer read at the wrong geometry or refused. * Every rotation run writes two diagnostic files beside its reflections: `<prefix>_detector.jpg`, the detector projection with the pixel mask and the detected beam-stop shadow drawn on it, and `<prefix>_plot.txt`, one row per image. Reviewed-on: #82 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
145 lines
4.0 KiB
C++
145 lines
4.0 KiB
C++
// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include "XdsIntegrateParser.h"
|
|
|
|
#include <fstream>
|
|
#include <limits>
|
|
#include <sstream>
|
|
#include <stdexcept>
|
|
|
|
#include "../common/ResolutionShells.h"
|
|
#include "../common/hkl_key.h"
|
|
|
|
IntegrateMap ParseXdsIntegrateHkl(const std::string& filename) {
|
|
std::ifstream in(filename);
|
|
if (!in.is_open()) {
|
|
throw std::runtime_error("Failed to open INTEGRATE.HKL file: " + filename);
|
|
}
|
|
|
|
IntegrateMap result;
|
|
std::string line;
|
|
|
|
while (std::getline(in, line)) {
|
|
if (line.empty()) continue;
|
|
char c0 = line.front();
|
|
if (c0 == '!' || c0 == '#') continue;
|
|
|
|
std::istringstream iss(line);
|
|
int32_t h, k, l;
|
|
double I, sigma;
|
|
double xcal, ycal, zcal, rlp, peak, corr;
|
|
int32_t maxc;
|
|
|
|
if (!(iss >> l >> k >> h >> I >> sigma >> xcal >> ycal >> zcal >> rlp >> peak >> corr >> maxc)) {
|
|
continue;
|
|
}
|
|
|
|
HKLData entry;
|
|
entry.h = -h;
|
|
entry.k = k;
|
|
entry.l = l;
|
|
entry.I = I;
|
|
entry.sigma = sigma;
|
|
entry.rlp = rlp;
|
|
entry.image_number = zcal;
|
|
|
|
double v = 0.0;
|
|
while (iss >> v) {
|
|
entry.tail.push_back(v);
|
|
}
|
|
|
|
result[hkl_key(-h, k, l)].push_back(std::move(entry));
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
namespace {
|
|
double SumIntensity(const std::vector<HKLData>& v) {
|
|
double s = 0.0;
|
|
for (const auto& e : v)
|
|
s += e.I;
|
|
return s;
|
|
}
|
|
} // namespace
|
|
|
|
CcHalfByResolutionResult ComputeCcByResolution(
|
|
const CrystalLattice& lattice,
|
|
const IntegrateMap& ours,
|
|
const IntegrateMap& xds,
|
|
float d_min,
|
|
float d_max,
|
|
int32_t nshells) {
|
|
|
|
ResolutionShells shells(d_min, d_max, nshells);
|
|
|
|
std::vector<double> sum_x(nshells, 0.0);
|
|
std::vector<double> sum_y(nshells, 0.0);
|
|
std::vector<double> sum_x2(nshells, 0.0);
|
|
std::vector<double> sum_y2(nshells, 0.0);
|
|
std::vector<double> sum_xy(nshells, 0.0);
|
|
std::vector<int32_t> n(nshells, 0);
|
|
|
|
const Coord astar = lattice.Astar();
|
|
const Coord bstar = lattice.Bstar();
|
|
const Coord cstar = lattice.Cstar();
|
|
|
|
for (const auto& [key, ours_list] : ours) {
|
|
auto it = xds.find(key);
|
|
if (it == xds.end())
|
|
continue;
|
|
|
|
const auto& xds_list = it->second;
|
|
|
|
for (const auto &i_x: xds_list) {
|
|
for (const auto &i_o: ours_list) {
|
|
if (std::fabs(i_x.image_number - i_o.image_number) > 30.0)
|
|
continue;
|
|
|
|
int64_t h = i_x.h;
|
|
int64_t k = i_x.k;
|
|
int64_t l = i_x.l;
|
|
|
|
Coord recip = astar * h + bstar * k + cstar * l;
|
|
double recip_len = std::sqrt(recip.x * recip.x + recip.y * recip.y + recip.z * recip.z);
|
|
if (recip_len <= 0.0)
|
|
continue;
|
|
|
|
float d = static_cast<float>(1.0 / recip_len);
|
|
auto shell = shells.GetShell(d);
|
|
if (!shell)
|
|
continue;
|
|
|
|
int idx = shell.value();
|
|
n[idx] += 1;
|
|
sum_x[idx] += i_o.I;
|
|
sum_y[idx] += i_x.I;
|
|
sum_x2[idx] += i_o.I * i_o.I;
|
|
sum_y2[idx] += i_x.I * i_x.I;
|
|
sum_xy[idx] += i_o.I * i_x.I;
|
|
}
|
|
}
|
|
}
|
|
|
|
CcHalfByResolutionResult result;
|
|
result.cc.resize(nshells, std::numeric_limits<double>::quiet_NaN());
|
|
result.pairs = n;
|
|
result.shell_mean_one_over_d2 = shells.GetShellMeanOneOverResSq();
|
|
|
|
for (int i = 0; i < nshells; ++i) {
|
|
if (n[i] < 2)
|
|
continue;
|
|
|
|
double denom_x = n[i] * sum_x2[i] - sum_x[i] * sum_x[i];
|
|
double denom_y = n[i] * sum_y2[i] - sum_y[i] * sum_y[i];
|
|
double denom = std::sqrt(denom_x * denom_y);
|
|
if (denom <= 0.0)
|
|
continue;
|
|
|
|
result.cc[i] = (n[i] * sum_xy[i] - sum_x[i] * sum_y[i]) / denom;
|
|
}
|
|
|
|
return result;
|
|
} |