reader: a link to a file that is not there is not a dataset that exists

Every DECTRIS Eiger master links saturation_value, pixel_mask,
bit_depth_readout and serial_number into a companion <prefix>_meta.h5, and
that file is routinely not kept when a dataset is archived or deposited. The
existence test asked only whether the LINK was written, which it is, so every
optional-field guard in the reader answered yes and the read that followed
threw. A deposited Eiger 16M set could not be opened at all, over values the
reader was perfectly prepared to do without.

Exists() now asks the second question too - whether the object the link names
can be reached - so an orphaned link reads as absent and the fallbacks behind
it do their job.

The saturation value is then allowed to be missing outright, because on such a
file it is: neither the NXmx name nor the DECTRIS one is readable, and there is
no third place to look. Left unset, GetSaturationLimit() falls back to the
container's own overflow. That is the safe direction - it can only fail to call
a pixel saturated, where too LOW a value drops the whole reflection and
silently removes the strongest data - and the run says out loud that nothing
will be called saturated.

The set that could not be opened now processes to 2.17 A against a deposited
2.40 A, in the deposited space group, with a cell agreeing to 0.08%. Output is
byte-identical on datasets that already opened.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFEJG6WBQv8th4UJFNe53N
(cherry picked from commit 0637979f6d95b446406ab70d1f3982841d195b36)
This commit is contained in:
2026-08-30 21:43:54 +02:00
parent fb18457e6f
commit 6ed4ea541e
4 changed files with 62 additions and 5 deletions
+20 -4
View File
@@ -986,10 +986,26 @@ HDF5MetadataSource::OpenResult HDF5MetadataSource::Open(const std::string &filen
ReadLength_m(*master_file, "/entry/instrument/detector/sensor_thickness") * 1e6);
if (master_file->Exists("/entry/instrument/detector/sensor_material"))
detector.SensorMaterial(master_file->GetString("/entry/instrument/detector/sensor_material"));
detector.SaturationLimit(SaturationLimitFromValue(
ReadIntWithLegacyFallback(*master_file,
"/entry/instrument/detector/saturation_value",
"/entry/instrument/detector/detectorSpecific/countrate_correction_count_cutoff")));
// Optional, because a file that states no saturation value anywhere is a real and common
// thing: an Eiger master links saturation_value into a companion _meta.h5, and a deposited
// dataset frequently does not include that file, leaving neither the NXmx name nor the
// DECTRIS one readable. Left unset, DiffractionExperiment::GetSaturationLimit() falls back
// to the container's own overflow, which is the safe direction - it can only fail to call a
// pixel saturated, where too LOW a value drops the whole reflection and silently removes the
// strongest data (see BitDepthImage below). Refusing the file outright is the one option that
// helps nobody.
if (master_file->Exists("/entry/instrument/detector/saturation_value")
|| master_file->Exists("/entry/instrument/detector/detectorSpecific/countrate_correction_count_cutoff"))
detector.SaturationLimit(SaturationLimitFromValue(
ReadIntWithLegacyFallback(*master_file,
"/entry/instrument/detector/saturation_value",
"/entry/instrument/detector/detectorSpecific/countrate_correction_count_cutoff")));
else
Logger("HDF5Reader").Warning("The file states no saturation value - neither NXmx saturation_value nor "
"the DECTRIS countrate_correction_count_cutoff is readable, which is what "
"an Eiger master looks like when its companion _meta.h5 was not kept. No "
"pixel will be called saturated; if this detector overloads, its strongest "
"reflections will be integrated as if they were valid.");
// The reader hands every image out as signed int32 whatever the file stored (see PixelSigned
// below), so that is the container depth the rest of the code has to see. DetectorSetup defaults
// DECTRIS to 16 bits and GetByteDepthImage() prefers the detector's value over the image