Skip to content

Commit

Permalink
Added fix for non-ordered observations
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicDirkx committed Oct 13, 2023
1 parent c68ba30 commit adea619
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions include/tudat/simulation/estimation_setup/observations.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class SingleObservationSet
throw std::runtime_error( "Error when creating SingleObservationSet, ObservationDependentVariableCalculator has incompatible link ends " );
}
}

if( observations_.size( ) != observationTimes_.size( ) )
{
throw std::runtime_error( "Error when making SingleObservationSet, input sizes are inconsistent." +
Expand All @@ -82,6 +83,26 @@ class SingleObservationSet
throw std::runtime_error( "Error when making SingleObservationSet, input observables not of consistent size." );
}
}

if( !std::is_sorted( observations_.begin( ), observations_.end( ) ) )
{
std::map< TimeType, Eigen::Matrix< ObservationScalarType, Eigen::Dynamic, 1 > > observationsMap;
for( unsigned int i = 0; i < observations_.size( ); i++ )
{
observationsMap[ observationTimes_.at( i ) ] = observations_.at( i );
}
observationTimes_ = utilities::createVectorFromMapKeys( observationsMap );
observations_ = utilities::createVectorFromMapValues( observationsMap );
if( observationsDependentVariables_.size( ) > 0 )
{
std::map< TimeType, Eigen::VectorXd > observationsDependentVariablesMap;
for( unsigned int i = 0; i < observationsDependentVariables_.size( ); i++ )
{
observationsDependentVariablesMap[ observationTimes_.at( i ) ] = observationsDependentVariables_.at( i );
}
observationsDependentVariables_ = utilities::createVectorFromMapValues( observationsDependentVariablesMap );
}
}
}


Expand Down

0 comments on commit adea619

Please sign in to comment.