reader: match the legacy companion suffixes exactly, not any underscore

The legacy DECTRIS layout stores five companion scalars beside each goniometer
axis - AXIS_end, _start, _increment, _range_average, _range_total - and only the
bare name is the axis itself. The first cut rejected _end and _range, which left
_start and _increment to be offered to ReadAxis as axes in their own right.

Matching the full suffix set, anchored at the end of the name, also keeps a
genuine two_theta axis readable, which a "contains an underscore" test would not.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-28 21:56:12 +02:00
co-authored by Claude Opus 5
parent df3696e6e2
commit fa4aa30a1e
+12 -2
View File
@@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-only
#include <cmath>
#include <cstring>
#include <set>
#include "HDF5MetadataSource.h"
@@ -1212,8 +1213,17 @@ std::optional<GoniometerAxis> HDF5MetadataSource::ReadAxis(HDF5Object *file, con
return {};
} else if (!legacy_group) {
return {};
} else if (name.find("_end") != std::string::npos || name.find("_range") != std::string::npos) {
return {}; // the same companion datasets, by name, since there is no tag to go on
} else {
// The same companion datasets, recognised by name because there is no tag to go on. In the
// legacy layout each axis NAME carries five of them - AXIS_end, _start, _increment,
// _range_average, _range_total - and only the bare name is the axis itself. Matching the
// suffix rather than "contains an underscore" keeps a genuine two_theta axis readable.
static const char *const companions[] = {"_end", "_start", "_increment",
"_range_average", "_range_total"};
for (const char *suffix: companions)
if (name.size() > strlen(suffix)
&& name.compare(name.size() - strlen(suffix), strlen(suffix), suffix) == 0)
return {};
}
std::vector<double> end = file->ReadOptVector<double>(dname + "_end");