From 37a65cb18de9d2ceed1973f3ef2847bc2e693cd5 Mon Sep 17 00:00:00 2001 From: Space Jonas Date: Fri, 7 Feb 2025 14:04:16 +0100 Subject: [PATCH] implement soft error handling when encountering coverage gaps in atmosphereCorrection.cpp --- .../corrections/atmosphereCorrection.cpp | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/src/astro/observation_models/corrections/atmosphereCorrection.cpp b/src/astro/observation_models/corrections/atmosphereCorrection.cpp index 12e40d12b..c8d5a0661 100644 --- a/src/astro/observation_models/corrections/atmosphereCorrection.cpp +++ b/src/astro/observation_models/corrections/atmosphereCorrection.cpp @@ -22,6 +22,7 @@ namespace observation_models bool TabulatedMediaReferenceCorrection::isTimeValid( const double time ) { + /* if( !std::isnan( startTime_ ) && time < startTime_ ) { throw std::runtime_error( "Error when computing tabulated media reference correction: selected time (" + std::to_string( time ) + @@ -33,21 +34,50 @@ bool TabulatedMediaReferenceCorrection::isTimeValid( const double time ) throw std::runtime_error( "Error when computing tabulated media reference correction: selected time (" + std::to_string( time ) + ") is over end time (" + std::to_string( endTime_ ) + ")." ); } + */ - return true; + ///// Warnings instead of error: + if ( !std::isnan( startTime_ ) && time < startTime_ ) + + { + std::cerr << "Warning when computing tabulated media reference correction: selected time (" + std::to_string( time ) + + ") is below start time (" + std::to_string( startTime_ ) + "). Applying 0 correction." << std::endl; + + return false; + } + + if ( !std::isnan( endTime_ ) && time > endTime_ ) + + { + std::cerr << "Warning when computing tabulated media reference correction: selected time (" + std::to_string( time ) + + ") is over end time (" + std::to_string( endTime_ ) + "). Applying 0 correction." << std::endl; + + return false; + } + + else + { + return true; + } } double PowerSeriesReferenceCorrection::computeReferenceCorrection( const double time ) { - isTimeValid( time ); + bool timeCover = isTimeValid( time ); const double normalizedTime = 2.0 * ( ( time - startTime_ ) / ( endTime_ - startTime_ ) ) - 1.0; double correction = 0; - for( unsigned int i = 0; i < coefficients_.size( ); ++i ) + if (timeCover == true) + { - correction += coefficients_.at( i ) * std::pow( normalizedTime, i ); + for ( unsigned int i = 0; i < coefficients_.size( ); ++i ) + { + correction += coefficients_.at( i ) * std::pow( normalizedTime, i ); + } + } + // else correction 0 return correction; }