2fa9293fda
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 15m38s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 16m32s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 17m5s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 17m12s
Build Packages / build:rpm (rocky8) (push) Successful in 17m26s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 18m4s
Build Packages / build:rpm (rocky9_sls9) (push) Successful in 18m41s
Build Packages / build:rpm (rocky9) (push) Successful in 11m20s
Build Packages / Generate python client (push) Successful in 35s
Build Packages / Build documentation (push) Successful in 1m2s
Build Packages / Create release (push) Skipped
Build Packages / build:rpm (ubuntu2204) (push) Successful in 12m45s
Build Packages / XDS test (neggia plugin) (push) Successful in 11m6s
Build Packages / XDS test (durin plugin) (push) Successful in 12m27s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 13m33s
Build Packages / XDS test (JFJoch plugin) (push) Successful in 12m48s
Build Packages / DIALS test (push) Successful in 15m5s
Build Packages / Unit tests (push) Successful in 1h1m39s
74 lines
2.1 KiB
C++
74 lines
2.1 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"
|
|
|
|
HKLKeyGenerator::HKLKeyGenerator(bool merge_friedel, int32_t space_group_number)
|
|
: HKLKeyGenerator(merge_friedel, *gemmi::find_spacegroup_by_number(space_group_number)) {
|
|
}
|
|
|
|
HKLKeyGenerator::HKLKeyGenerator(bool merge_friedel, const gemmi::SpaceGroup &sg)
|
|
: merge_friedel(merge_friedel),
|
|
sg(sg),
|
|
ops(sg.operations()),
|
|
asu(&sg) {
|
|
}
|
|
|
|
HKLKey HKLKeyGenerator::operator()(const MergedReflection &r) const {
|
|
return operator()(r.h, r.k, r.l);
|
|
}
|
|
|
|
HKLKey HKLKeyGenerator::operator()(const Reflection &r) const {
|
|
return operator()(r.h, r.k, r.l);
|
|
}
|
|
|
|
HKLKey HKLKeyGenerator::operator()(int32_t h, int32_t k, int32_t l) const {
|
|
HKLKey key{h, k, l, true};
|
|
|
|
if (sg.number == 1) {
|
|
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 = merge_friedel;
|
|
}
|
|
} else {
|
|
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;
|
|
}
|
|
|
|
bool AcceptReflection(const Reflection &r, std::optional<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 && r.d < d_min_limit)
|
|
return false;
|
|
if (!std::isfinite(r.rlp) || r.rlp == 0.0f)
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
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;
|
|
}
|