b9af590ff5
Build Packages / Unit tests (push) Failing after 9m5s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 15m3s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 15m28s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 15m59s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 17m15s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 17m26s
Build Packages / build:rpm (rocky8) (push) Successful in 18m11s
Build Packages / build:rpm (rocky9_sls9) (push) Successful in 18m58s
Build Packages / build:rpm (rocky9) (push) Successful in 11m14s
Build Packages / Generate python client (push) Successful in 1m33s
Build Packages / Create release (push) Has been skipped
Build Packages / Build documentation (push) Successful in 1m57s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 9m38s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 11m38s
Build Packages / XDS test (neggia plugin) (push) Successful in 8m56s
Build Packages / XDS test (JFJoch plugin) (push) Successful in 9m56s
Build Packages / XDS test (durin plugin) (push) Successful in 10m13s
Build Packages / DIALS test (push) Successful in 13m10s
57 lines
1.8 KiB
C++
57 lines
1.8 KiB
C++
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include <cmath>
|
|
|
|
#include "HKLKey.h"
|
|
#include "gemmi/symmetry.hpp"
|
|
|
|
HKLKey CanonicalHKL(int32_t h, int32_t k, int32_t l, bool merge_friedel, const std::optional<gemmi::SpaceGroup> &in_sg) {
|
|
HKLKey key{h, k, l, true};
|
|
|
|
if (!in_sg.has_value()) {
|
|
if (!merge_friedel) {
|
|
const HKLKey neg{-h, -k, -l, true};
|
|
if (std::tie(key.h, key.k, key.l) < std::tie(neg.h, neg.k, neg.l)) {
|
|
key.h = -key.h;
|
|
key.k = -key.k;
|
|
key.l = -key.l;
|
|
key.plus = false;
|
|
}
|
|
}
|
|
} else {
|
|
gemmi::SpaceGroup sg = in_sg.value();
|
|
const auto ops = sg.operations();
|
|
const gemmi::ReciprocalAsu asu(&sg);
|
|
|
|
const gemmi::Op::Miller in{h, k, l};
|
|
const auto [hkl, sign_plus] = asu.to_asu_sign(in, ops);
|
|
|
|
key.h = hkl[0];
|
|
key.k = hkl[1];
|
|
key.l = hkl[2];
|
|
key.plus = merge_friedel ? true : sign_plus;
|
|
}
|
|
return key;
|
|
}
|
|
|
|
HKLKey CanonicalHKL(const Reflection &r, bool merge_friedel, const std::optional<gemmi::SpaceGroup> &sg) {
|
|
return CanonicalHKL(r.h, r.k, r.l, merge_friedel, sg);
|
|
}
|
|
|
|
HKLKey CanonicalHKL(const MergedReflection &r, bool merge_friedel, const std::optional<gemmi::SpaceGroup> &sg) {
|
|
return CanonicalHKL(r.h, r.k, r.l, merge_friedel, sg);
|
|
}
|
|
|
|
bool AcceptReflection(const Reflection &r, double d_min_limit) {
|
|
if (!std::isfinite(r.I))
|
|
return false;
|
|
if (!std::isfinite(r.d) || r.d <= 0.0f)
|
|
return false;
|
|
if (d_min_limit > 0.0 && r.d < d_min_limit)
|
|
return false;
|
|
if (!std::isfinite(r.rlp) || r.rlp == 0.0f)
|
|
return false;
|
|
return true;
|
|
}
|