65 lines
2.4 KiB
C++
65 lines
2.4 KiB
C++
// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include "../reader/JFJochHDF5Reader.h"
|
|
#include "../image_analysis/indexing/IndexerFactory.h"
|
|
#include "../common/Logger.h"
|
|
#include "../image_analysis/RotationIndexer.h"
|
|
#include "../writer/FileWriter.h"
|
|
|
|
int main(int argc, char** argv) {
|
|
Logger logger("jfjoch_indexing_test");
|
|
|
|
if (argc != 2) {
|
|
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Usage: ./jfjoch_indexing_test <file>");
|
|
}
|
|
|
|
JFJochHDF5Reader reader;
|
|
reader.ReadFile(argv[1]);
|
|
if (!reader.GetDataset())
|
|
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Error opening file");
|
|
|
|
DiffractionExperiment experiment(reader.GetDataset()->experiment);
|
|
experiment.SetUnitCell({});
|
|
experiment.IndexingAlgorithm(IndexingAlgorithmEnum::FFT);
|
|
|
|
experiment.FilePrefix("output");
|
|
StartMessage msg;
|
|
experiment.FillMessage(msg);
|
|
// FileWriter fw(msg);
|
|
|
|
IndexerThreadPool indexer(experiment.GetIndexingSettings());
|
|
|
|
auto geom = experiment.GetDiffractionGeometry();
|
|
RotationIndexer rot_index(experiment, indexer);
|
|
|
|
for (int i = 0; i < reader.GetNumberOfImages(); i++) {
|
|
auto img = reader.LoadImage(i);
|
|
|
|
if (!img)
|
|
continue;
|
|
|
|
DataMessage msg = img->ImageData();
|
|
|
|
rot_index.ProcessImage(i, msg.spots);
|
|
if (i % 200 == 0)
|
|
logger.Info("Image {}", i);
|
|
}
|
|
auto latt_1 = rot_index.Finalize(false);
|
|
if (latt_1) {
|
|
auto uc = latt_1->GetUnitCell();
|
|
logger.Info("Unit cell {} {} {} {} {} {}", uc.a, uc.b, uc.c, uc.alpha, uc.beta, uc.gamma);
|
|
logger.Info("Latt1 {} {} {}", latt_1->Vec0().x, latt_1->Vec0().y, latt_1->Vec0().z);
|
|
logger.Info("Latt1 {} {} {}", latt_1->Vec1().x, latt_1->Vec1().y, latt_1->Vec1().z);
|
|
logger.Info("Latt1 {} {} {}", latt_1->Vec2().x, latt_1->Vec2().y, latt_1->Vec2().z);
|
|
}
|
|
auto latt_2 = rot_index.Finalize(true);
|
|
if (latt_2) {
|
|
|
|
auto uc = latt_2->GetUnitCell();
|
|
logger.Info("Unit cell {} {} {} {} {} {}", uc.a, uc.b, uc.c, uc.alpha, uc.beta, uc.gamma);
|
|
logger.Info("Latt1 {} {} {}", latt_2->Vec0().x, latt_2->Vec0().y, latt_2->Vec0().z);
|
|
logger.Info("Latt1 {} {} {}", latt_2->Vec1().x, latt_2->Vec1().y, latt_2->Vec1().z);
|
|
logger.Info("Latt1 {} {} {}", latt_2->Vec2().x, latt_2->Vec2().y, latt_2->Vec2().z);
|
|
}
|
|
} |