Skip to content

Commit

Permalink
revert changes on error handling in atmosphereCorrection.cpp (I am so…
Browse files Browse the repository at this point in the history
…rry)
  • Loading branch information
jo11he committed Feb 7, 2025
1 parent 37a65cb commit baf3d57
Showing 1 changed file with 4 additions and 34 deletions.
38 changes: 4 additions & 34 deletions src/astro/observation_models/corrections/atmosphereCorrection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ 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 ) +
Expand All @@ -34,50 +33,21 @@ 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_ ) + ")." );
}
*/

///// 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;
}
return true;
}

double PowerSeriesReferenceCorrection::computeReferenceCorrection( const double time )
{
bool timeCover = isTimeValid( time );
isTimeValid( time );

const double normalizedTime = 2.0 * ( ( time - startTime_ ) / ( endTime_ - startTime_ ) ) - 1.0;

double correction = 0;
if (timeCover == true)

for( unsigned int i = 0; i < coefficients_.size( ); ++i )
{
for ( unsigned int i = 0; i < coefficients_.size( ); ++i )
{
correction += coefficients_.at( i ) * std::pow( normalizedTime, i );
}

correction += coefficients_.at( i ) * std::pow( normalizedTime, i );
}
// else correction 0

return correction;
}
Expand Down

0 comments on commit baf3d57

Please sign in to comment.