Some checks failed
Build Packages / build:rpm (ubuntu2204) (push) Failing after 10m1s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 10m30s
Build Packages / build:rpm (rocky8) (push) Failing after 10m32s
Build Packages / build:rpm (rocky9) (push) Failing after 10m38s
Build Packages / Generate python client (push) Successful in 27s
Build Packages / Create release (push) Has been skipped
Build Packages / Build documentation (push) Successful in 49s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 11m39s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 12m37s
Build Packages / build:rpm (rocky8_sls9) (push) Failing after 12m56s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 13m24s
Build Packages / Unit tests (push) Failing after 3m26s
Build Packages / build:rpm (ubuntu2404) (push) Failing after 6m21s
61 lines
2.2 KiB
C++
61 lines
2.2 KiB
C++
// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include "HDF5DataFilePluginReflection.h"
|
|
#include "../include/spdlog/fmt/fmt.h"
|
|
#include "../common/Reflection.h"
|
|
|
|
void HDF5DataFilePluginReflection::OpenFile(HDF5File &data_file, const DataMessage &msg) {
|
|
reflection_group = std::make_unique<HDF5Group>(data_file, "/entry/reflections");
|
|
reflection_group->NXClass("NXcollection");
|
|
|
|
}
|
|
|
|
void HDF5DataFilePluginReflection::Write(const DataMessage &msg, uint64_t image_number) {
|
|
if (!reflection_group || msg.reflections.empty())
|
|
return;
|
|
|
|
std::vector<int32_t> h, k, l;
|
|
std::vector<float> I, sigma, d, lp;
|
|
std::vector<float> image, phi, pred_x, pred_y, bkg, partiality, zeta;
|
|
|
|
for (const auto &refl : msg.reflections) {
|
|
image.emplace_back(refl.image_number);
|
|
h.emplace_back(refl.h);
|
|
k.emplace_back(refl.k);
|
|
l.emplace_back(refl.l);
|
|
I.emplace_back(refl.I);
|
|
sigma.emplace_back(refl.sigma);
|
|
d.emplace_back(refl.d);
|
|
pred_x.emplace_back(refl.predicted_x);
|
|
pred_y.emplace_back(refl.predicted_y);
|
|
bkg.emplace_back(refl.bkg);
|
|
lp.emplace_back(1.0/refl.rlp);
|
|
partiality.emplace_back(refl.partiality);
|
|
phi.emplace_back(refl.delta_phi_deg);
|
|
zeta.emplace_back(refl.zeta);
|
|
}
|
|
|
|
std::string image_group_name = fmt::format("image_{:06d}", image_number);
|
|
HDF5Group image_group(*reflection_group, image_group_name);
|
|
image_group.NXClass("NXreflections");
|
|
image_group.SaveVector("h", h);
|
|
image_group.SaveVector("k", k);
|
|
image_group.SaveVector("l", l);
|
|
image_group.SaveVector("d", d)->Units("Angstrom");
|
|
image_group.SaveVector("delta_phi", phi);
|
|
image_group.SaveVector("predicted_x", pred_x);
|
|
image_group.SaveVector("predicted_y", pred_y);
|
|
image_group.SaveVector("int_sum", I);
|
|
image_group.SaveVector("int_err", sigma);
|
|
image_group.SaveVector("background_mean", bkg);
|
|
image_group.SaveVector("observed_frame", image);
|
|
image_group.SaveVector("lp", lp);
|
|
image_group.SaveVector("partiality", partiality);
|
|
image_group.SaveVector("zeta", zeta);
|
|
}
|
|
|
|
void HDF5DataFilePluginReflection::WriteFinal(HDF5File &data_file) {
|
|
|
|
}
|