48 lines
1.1 KiB
C++
48 lines
1.1 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 <sstream>
|
|
#include <stdexcept>
|
|
|
|
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;
|
|
|
|
if (!(iss >> h >> k >> l >> I >> sigma)) {
|
|
continue;
|
|
}
|
|
|
|
HKLData entry;
|
|
entry.h = h;
|
|
entry.k = k;
|
|
entry.l = l;
|
|
entry.I = I;
|
|
entry.sigma = sigma;
|
|
|
|
double v = 0.0;
|
|
while (iss >> v) {
|
|
entry.tail.push_back(v);
|
|
}
|
|
|
|
result[hkl_key_16(h, k, l)].push_back(std::move(entry));
|
|
}
|
|
|
|
return result;
|
|
} |