From 953302a9eb74a1fb7a771bacc7d9acbb6baf49cf Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Fri, 31 Jul 2026 11:51:22 +0200 Subject: [PATCH] Spot plot: the resolution axis comes from the detector, not from 1.5 A Dropping the fixed spot-finding limit left the reader still generating the spot-vs-resolution plot over shells that stop at 1.5 A, so a stored file reopened in the viewer showed a plot truncated at exactly the limit that was removed - GenerateSpotPlot drops every spot outside its shells. Pass the detector's own maximum resolution, as SpotAnalyze already does. That value is 0 when the geometry gives no scattering angle at all (no distance or no wavelength), and ResolutionShells throws on a non-positive d_min, once per image. There is no resolution axis to plot against in that case, so skip the plot. Co-Authored-By: Claude Opus 5 (1M context) --- image_analysis/spot_finding/SpotUtils.cpp | 4 ++++ reader/HDF5MetadataSource.cpp | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/image_analysis/spot_finding/SpotUtils.cpp b/image_analysis/spot_finding/SpotUtils.cpp index 210cf595..81dc4f4f 100644 --- a/image_analysis/spot_finding/SpotUtils.cpp +++ b/image_analysis/spot_finding/SpotUtils.cpp @@ -98,6 +98,10 @@ std::optional GetResolution(const std::vector &spots) { void GenerateSpotPlot(DataMessage &msg, const std::vector &spots, float d_min_A) { const int nshells = 20; + // The geometry gives no usable high-resolution corner (no distance or no wavelength), so there is + // no resolution axis to plot the spots against. ResolutionShells would throw on it, once per image. + if (d_min_A <= 0.0f || d_min_A >= 50.0f) + return; ResolutionShells shells(d_min_A, 50.0, nshells); std::vector intensity(nshells); diff --git a/reader/HDF5MetadataSource.cpp b/reader/HDF5MetadataSource.cpp index ab09ef50..989f9102 100644 --- a/reader/HDF5MetadataSource.cpp +++ b/reader/HDF5MetadataSource.cpp @@ -788,6 +788,7 @@ static void ReadSpotsFromFiles(HDF5Object &master_file, hsize_t source_image, int64_t image_number, const DiffractionGeometry &geom, + float plot_d_min_A, DataMessage &message) { auto spot_count_opt = ReadElementMasterFirst(master_file, source_file, @@ -899,7 +900,7 @@ static void ReadSpotsFromFiles(HDF5Object &master_file, message.spot_count_indexed = ReadElementMasterFirst( master_file, source_file, "/entry/MX/peakCountIndexed", master_image, source_image); - GenerateSpotPlot(message, message.spots, 1.5); + GenerateSpotPlot(message, message.spots, plot_d_min_A); } void HDF5MetadataSource::FillPerImage(DataMessage &message, int64_t requested_image, @@ -917,7 +918,8 @@ void HDF5MetadataSource::FillPerImage(DataMessage &message, int64_t requested_im const auto source_image = static_cast(image_id); ReadSpotsFromFiles(*master_file, *source_file, master_image, source_image, - requested_image, dataset->experiment.GetDiffractionGeometry(), message); + requested_image, dataset->experiment.GetDiffractionGeometry(), + dataset->experiment.GetDetectorMaxResolution_A(), message); if (!dataset->az_int_bin_to_q.empty()) { if (dataset->azimuthal_bins == 0) { @@ -1194,6 +1196,7 @@ std::vector HDF5MetadataSource::ReadSpots(int64_t requested_image) c image, meta_image_id, requested_image, cached_geom, + dataset_ ? dataset_->experiment.GetDetectorMaxResolution_A() : 0.0f, tmp_message); return tmp_message.spots;