From 39a98692e289f1f6a0b32ee9ef8ec5f9961bc43f Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Thu, 17 Sep 2026 08:34:49 +0200 Subject: [PATCH] marCCD/SMV: keep the default frame time when the header's exposure is not a time One deposited marCCD sweep carries -2093438692 in its exposure field. Passed on as written that is a negative count time, DiffractionExperiment refuses it, and the whole dataset fails to open - over a number that feeds no geometry, no indexing and no merge. With the field ignored when it is implausible, that sweep processes and matches its deposition: P2_12_12_1, cell within 0.12%, and 1.375 A against a deposited 2.0. Neither format guarantees the field. The same guard is in the SMV reader, whose TIME key is no better attested, and both say what they did rather than passing over it silently. Co-Authored-By: Claude Opus 5 (1M context) --- reader/JFJochMarCCDReader.cpp | 19 ++++++++++++++----- reader/JFJochSMVReader.cpp | 19 ++++++++++++++----- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/reader/JFJochMarCCDReader.cpp b/reader/JFJochMarCCDReader.cpp index 5e3cdc902..5e517cf25 100644 --- a/reader/JFJochMarCCDReader.cpp +++ b/reader/JFJochMarCCDReader.cpp @@ -91,11 +91,20 @@ void JFJochMarCCDReader::ReadFiles(const std::string &path) { } dataset_->experiment.IncidentEnergy_keV(WVL_1A_IN_KEV / static_cast(header0_.wavelength_A)); - dataset_->experiment.FrameTime( - std::chrono::duration_cast( - std::chrono::duration(header0_.exposure_s)), - std::chrono::duration_cast( - std::chrono::duration(header0_.exposure_s))); + // Only when the header states a sane one. The exposure field is not always filled in: one + // deposited sweep carries -2093438692 there, which is not a time at all, and passing it on + // refuses the whole dataset over a number that affects no geometry and no result. A day is a + // generous upper bound for a single frame. + if (header0_.exposure_s > 0.0 && header0_.exposure_s < 86400.0) + dataset_->experiment.FrameTime( + std::chrono::duration_cast( + std::chrono::duration(header0_.exposure_s)), + std::chrono::duration_cast( + std::chrono::duration(header0_.exposure_s))); + else + Logger("MarCCDReader").Warning("{} states an implausible exposure time ({} s); the " + "default frame time is kept. Nothing in the geometry or the " + "merge depends on it.", files_[0], header0_.exposure_s); // The rotation angle of every image, from its own header. Reading one costs a 4 kB read, so on // a sweep of several thousand frames this is worth spreading over the cores, as the CBF path diff --git a/reader/JFJochSMVReader.cpp b/reader/JFJochSMVReader.cpp index 44f8def96..51e0a5d6c 100644 --- a/reader/JFJochSMVReader.cpp +++ b/reader/JFJochSMVReader.cpp @@ -92,11 +92,20 @@ void JFJochSMVReader::ReadFiles(const std::string &path) { } dataset_->experiment.IncidentEnergy_keV(WVL_1A_IN_KEV / static_cast(header0_.wavelength_A)); - dataset_->experiment.FrameTime( - std::chrono::duration_cast( - std::chrono::duration(header0_.exposure_s)), - std::chrono::duration_cast( - std::chrono::duration(header0_.exposure_s))); + // Only when the header states a sane one. The exposure field is not always filled in: one + // deposited sweep carries -2093438692 there, which is not a time at all, and passing it on + // refuses the whole dataset over a number that affects no geometry and no result. A day is a + // generous upper bound for a single frame. + if (header0_.exposure_s > 0.0 && header0_.exposure_s < 86400.0) + dataset_->experiment.FrameTime( + std::chrono::duration_cast( + std::chrono::duration(header0_.exposure_s)), + std::chrono::duration_cast( + std::chrono::duration(header0_.exposure_s))); + else + Logger("SMVReader").Warning("{} states an implausible exposure time ({} s); the " + "default frame time is kept. Nothing in the geometry or the " + "merge depends on it.", files_[0], header0_.exposure_s); // The rotation angle of every image, from its own header. Reading one costs a 4 kB read, so on // a sweep of several thousand frames this is worth spreading over the cores, as the CBF path