50 lines
1.7 KiB
C++
50 lines
1.7 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"
|
|
|
|
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.IndexingAlgorithm(IndexingAlgorithmEnum::Auto);
|
|
|
|
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();
|
|
|
|
auto output = rot_index.ProcessImage(i, msg.spots);
|
|
|
|
logger.Info("Result {} {}", msg.number, output.has_value());
|
|
if (output.has_value()) {
|
|
auto a = output->Vec0();
|
|
auto b = output->Vec1();
|
|
auto c = output->Vec2();
|
|
|
|
logger.Info("Lattice {:8.02f} {:8.02f} {:8.02f} {:8.02f} {:8.02f} {:8.02f} {:8.02f} {:8.02f} {:8.02f}",
|
|
a[0],a[1],a[2],b[0],b[1],b[2],c[0],c[1], c[2]);
|
|
}
|
|
}
|
|
|
|
} |