diff --git a/common/DiffractionExperiment.cpp b/common/DiffractionExperiment.cpp index 21068756..8ca90dc6 100644 --- a/common/DiffractionExperiment.cpp +++ b/common/DiffractionExperiment.cpp @@ -614,8 +614,11 @@ void DiffractionExperiment::CheckDataProcessingSettings(const SpotFindingSetting check_finite("Spot finding low resolution limit", settings.low_resolution_limit); // An unset high-resolution limit means "as far as the detector reaches", so there is nothing to check. - if (settings.high_resolution_limit.value_or(0.0f) > 0) { + // A value that is present still has to be finite - NaN fails every comparison below, so testing it + // inside the branch would let it through unchecked. + if (settings.high_resolution_limit.has_value()) check_finite("Spot finding high resolution limit", *settings.high_resolution_limit); + if (settings.high_resolution_limit.value_or(0.0f) > 0) { check_min("Spot finding high resolution limit", *settings.high_resolution_limit, 0.5); check_max("Spot finding high resolution limit", *settings.high_resolution_limit, 50.0); if (settings.low_resolution_limit > 0) { diff --git a/image_analysis/spot_finding/SpotUtils.cpp b/image_analysis/spot_finding/SpotUtils.cpp index 638e0c7c..210cf595 100644 --- a/image_analysis/spot_finding/SpotUtils.cpp +++ b/image_analysis/spot_finding/SpotUtils.cpp @@ -147,8 +147,11 @@ void SpotAnalyze(const DiffractionExperiment &experiment, CountSpots(output, spots_out, spot_finding_settings.cutoff_spot_count_low_res); + // 0 spells "no limit" everywhere else the limit is read (value_or(0) then compares against it), so it + // has to mean the same here - passing it on as a resolution makes ResolutionShells throw per image. + const auto &spot_d_min = spot_finding_settings.high_resolution_limit; GenerateSpotPlot(output, spots_out, - spot_finding_settings.high_resolution_limit.value_or(experiment.GetDetectorMaxResolution_A())); + spot_d_min.value_or(0.0f) > 0 ? *spot_d_min : experiment.GetDetectorMaxResolution_A()); output.resolution_estimate = GetResolution(spots_out);