Skip to content

Commit

Permalink
Corrected IFMS test; minor compiler warning corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicDirkx committed Oct 3, 2024
1 parent 52f5633 commit 02f19d9
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 41 deletions.
4 changes: 2 additions & 2 deletions include/tudat/simulation/estimation_setup/observations.h
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ class SingleObservationSet

void removeSingleObservation( unsigned int indexToRemove )
{
if ( indexToRemove >= numberOfObservations_ )
if ( static_cast< int >( indexToRemove ) >= numberOfObservations_ )
{
throw std::runtime_error( "Error when removing single observation from SingleObservationSet, index incompatible with number of observations." );
}
Expand Down Expand Up @@ -810,7 +810,7 @@ class SingleObservationSet
{
throw std::runtime_error( "Error when moving observation back from filtered observation set, filtered observation set is empty." );
}
if ( index >= getNumberOfFilteredObservations( ) )
if ( static_cast< int >( index ) >= getNumberOfFilteredObservations( ) )
{
throw std::runtime_error( "Error when moving observation back from filtered observation set, index incompatible with number of observations." );
}
Expand Down
11 changes: 9 additions & 2 deletions include/tudat/simulation/estimation_setup/processOdfFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@ std::shared_ptr< observation_models::SingleObservationSet< ObservationScalarType
std::vector< Eigen::Vector3d > originalEarthFixedPositions;
for ( unsigned int i = 0; i < originalObservationTimesTdb.size( ); ++i )
{
originalEarthFixedPositions.push_back( simulation_setup::getApproximateDsnGroundStationPositions( ).at( originalDopplerData->getLinkEnds( ).at( receiver ).stationName_ ) );
originalEarthFixedPositions.push_back( simulation_setup::getCombinedApproximateGroundStationPositions( ).at( originalDopplerData->getLinkEnds( ).at( receiver ).stationName_ ) );
}

std::vector< TimeType > originalObservationTimesUtc = timeScaleConverter.getCurrentTimes< TimeType >(
Expand Down Expand Up @@ -1326,10 +1326,17 @@ std::shared_ptr< observation_models::SingleObservationSet< ObservationScalarType
}
}

std::string stationName = originalDopplerData->getLinkEnds( ).at( receiver ).stationName_;
if( simulation_setup::getCombinedApproximateGroundStationPositions( ).count( stationName ) == 0 )
{
throw std::runtime_error( "Error in Doppler data compression, could not retrieve approximate station position for " + stationName );
}
Eigen::Vector3d stationPosition = simulation_setup::getCombinedApproximateGroundStationPositions( ).at( stationName );

std::vector< Eigen::Vector3d > compressedEarthFixedPositions;
for ( unsigned int i = 0; i < compressedObservationTimesUtc.size( ); ++i )
{
compressedEarthFixedPositions.push_back( simulation_setup::getApproximateDsnGroundStationPositions( ).at( originalDopplerData->getLinkEnds( ).at( receiver ).stationName_ ) );
compressedEarthFixedPositions.push_back( stationPosition );
}
std::vector< TimeType > compressedObservationTimesTdb = timeScaleConverter.getCurrentTimes< TimeType >(
basic_astrodynamics::utc_scale, basic_astrodynamics::tdb_scale, compressedObservationTimesUtc, compressedEarthFixedPositions );
Expand Down
21 changes: 7 additions & 14 deletions include/tudat/simulation/estimation_setup/processTrackingTxtFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -536,16 +536,14 @@ class ProcessedTrackingTxtFileContents
* @param processedTrackingTxtFileContents
* @param observableTypesToProcess
* @param ancillarySettings
* @param startAndEndTimesToProcess
* @return observation collection
*/
template< typename ObservationScalarType = double, typename TimeType = double >
std::map<ObservableType, std::map<LinkEnds, std::vector<std::shared_ptr<SingleObservationSet<ObservationScalarType, TimeType> > > > >
createTrackingTxtFileObservationSets(
const std::shared_ptr<observation_models::ProcessedTrackingTxtFileContents< ObservationScalarType, TimeType > > processedTrackingTxtFileContents,
std::vector<ObservableType> observableTypesToProcess = std::vector<ObservableType>(),
const ObservationAncilliarySimulationSettings& ancillarySettings = ObservationAncilliarySimulationSettings(),
const std::pair<TimeType, TimeType> startAndEndTimesToProcess = std::make_pair<TimeType, TimeType>(TUDAT_NAN, TUDAT_NAN))
const ObservationAncilliarySimulationSettings& ancillarySettings = ObservationAncilliarySimulationSettings() )
{

// Make sure processing the tracking file was successful
Expand Down Expand Up @@ -636,16 +634,15 @@ std::shared_ptr<observation_models::ObservationCollection<ObservationScalarType,
createTrackingTxtFilesObservationCollection(
const std::vector< std::shared_ptr<observation_models::ProcessedTrackingTxtFileContents< ObservationScalarType, TimeType > > > processedTrackingTxtFileContents,
std::vector<ObservableType> observableTypesToProcess = std::vector<ObservableType>(),
const ObservationAncilliarySimulationSettings& ancillarySettings = ObservationAncilliarySimulationSettings(),
const std::pair<TimeType, TimeType> startAndEndTimesToProcess = std::make_pair<TimeType, TimeType>(TUDAT_NAN, TUDAT_NAN))
const ObservationAncilliarySimulationSettings& ancillarySettings = ObservationAncilliarySimulationSettings())
{
std::map<ObservableType, std::map<LinkEnds, std::vector<std::shared_ptr<SingleObservationSet<ObservationScalarType, TimeType> > > > > observationSets;

for( unsigned int i = 0; i < processedTrackingTxtFileContents.size( ); i++ )
{
std::map<ObservableType, std::map<LinkEnds, std::vector<std::shared_ptr<SingleObservationSet<ObservationScalarType, TimeType> > > > >
processedObervationSet = createTrackingTxtFileObservationSets< ObservationScalarType, TimeType >(
processedTrackingTxtFileContents.at( i ), observableTypesToProcess, ancillarySettings, startAndEndTimesToProcess );
processedTrackingTxtFileContents.at( i ), observableTypesToProcess, ancillarySettings );
for( auto it : processedObervationSet )
{
for( auto it2 : it.second )
Expand All @@ -665,11 +662,10 @@ std::shared_ptr<observation_models::ObservationCollection<ObservationScalarType,
createTrackingTxtFileObservationCollection(
const std::shared_ptr<observation_models::ProcessedTrackingTxtFileContents< ObservationScalarType, TimeType > > processedTrackingTxtFileContents,
std::vector<ObservableType> observableTypesToProcess = std::vector<ObservableType>(),
const ObservationAncilliarySimulationSettings& ancillarySettings = ObservationAncilliarySimulationSettings(),
const std::pair<TimeType, TimeType> startAndEndTimesToProcess = std::make_pair<TimeType, TimeType>(TUDAT_NAN, TUDAT_NAN))
const ObservationAncilliarySimulationSettings& ancillarySettings = ObservationAncilliarySimulationSettings())
{
return createTrackingTxtFilesObservationCollection< ObservationScalarType, TimeType >(
{ processedTrackingTxtFileContents }, observableTypesToProcess, ancillarySettings, startAndEndTimesToProcess );
{ processedTrackingTxtFileContents }, observableTypesToProcess, ancillarySettings );
}

/*!
Expand All @@ -679,7 +675,6 @@ createTrackingTxtFileObservationCollection(
* @param observableTypesToProcess Vector of observable types that need to be in the collection
* @param earthFixedGroundStationPositions map of ground station positions
* @param ancillarySettings
* @param startAndEndTimesToProcess
* @return observation collection
*/
template< typename ObservationScalarType = double, typename TimeType = double >
Expand All @@ -689,8 +684,7 @@ createTrackingTxtFileObservationCollection(
const std::string spacecraftName,
const std::vector<ObservableType> observableTypesToProcess = std::vector<ObservableType>(),
const std::map<std::string, Eigen::Vector3d> earthFixedGroundStationPositions = simulation_setup::getCombinedApproximateGroundStationPositions(),
const ObservationAncilliarySimulationSettings& ancillarySettings = ObservationAncilliarySimulationSettings(),
std::pair<TimeType, TimeType> startAndEndTimesToProcess = std::make_pair<TimeType, TimeType>(TUDAT_NAN, TUDAT_NAN))
const ObservationAncilliarySimulationSettings& ancillarySettings = ObservationAncilliarySimulationSettings())
{
// Create processed tracking file contents
auto processedTrackingTxtFileContents = std::make_shared<observation_models::ProcessedTrackingTxtFileContents< ObservationScalarType, TimeType > >(
Expand All @@ -699,8 +693,7 @@ createTrackingTxtFileObservationCollection(
// Create observation collection and return
return createTrackingTxtFileObservationCollection(processedTrackingTxtFileContents,
observableTypesToProcess,
ancillarySettings,
startAndEndTimesToProcess);
ancillarySettings);
}

void setStationFrequenciesFromTrackingData(
Expand Down
6 changes: 3 additions & 3 deletions src/astro/ground_stations/oceanTideEarthDeformation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ std::vector<std::map<std::string, Eigen::Matrix<double, 3, 11> > > readBlqFile(
std::vector<std::vector<std::string> > unparsedSiteBlock;
unparsedSiteBlock.resize( 11 );

// Initialized number of parsed sites.
int numberOfSitesParsed = 0;
// // Initialized number of parsed sites.
// int numberOfSitesParsed = 0;

// Declare current site characteristics
std::string currentSiteName;
Expand Down Expand Up @@ -114,7 +114,7 @@ std::vector<std::map<std::string, Eigen::Matrix<double, 3, 11> > > readBlqFile(
amplitudeMap[ currentSiteName ] = currentDataMatrix.block( 0, 0, 3, 11 );
phaseMap[ currentSiteName ] =
convertDegreesToRadians<Eigen::MatrixXd>( currentDataMatrix.block( 3, 0, 3, 11 ));
numberOfSitesParsed++;
// numberOfSitesParsed++;
}

if ( !stream.fail( ) && !stream.eof( ))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ BOOST_AUTO_TEST_CASE( testDsnNWayAveragedDopplerModel )
// Compare value of observations
// Min/max values from Verma (2022), "A Python-based tool for constructing observables from the DSN’s closed-loop
// archival tracking data files", fig. 4 right
std::pair< double, double > vermaFirstBlockMinMaxResidual = std::make_pair( -0.04, 0.10 );
std::pair< double, double > vermaSecondBlockMinMaxResidual = std::make_pair( -0.06, 0.07 );
// std::pair< double, double > vermaFirstBlockMinMaxResidual = std::make_pair( -0.04, 0.10 );
// std::pair< double, double > vermaSecondBlockMinMaxResidual = std::make_pair( -0.06, 0.07 );
// Min/max values obtained with current code
std::pair< double, double > firstBlockMinMaxResidual = std::make_pair( -0.080, 0.120 );
std::pair< double, double > secondBlockMinMaxResidual = std::make_pair( -0.08, 0.06 );
Expand Down
2 changes: 1 addition & 1 deletion tests/src/astro/observation_models/unitTestIfmsMex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ BOOST_AUTO_TEST_CASE(testIfmsObservationMex)
// Create and process observation collection
auto observedUncompressedObservationCollection = observation_models::createTrackingTxtFilesObservationCollection< long double, Time>(
processedIfmsFiles, {dsn_n_way_averaged_doppler}, ancilliarySettings );
setTrackingDataInformationInBodies( processedIfmsFiles, bodies, {dsn_n_way_averaged_doppler} );
setTrackingDataInformationInBodies( processedIfmsFiles, bodies, dsn_n_way_averaged_doppler );
std::shared_ptr< observation_models::ObservationCollection< long double, Time > > observedObservationCollection =
createCompressedDopplerCollection( observedUncompressedObservationCollection, 60.0 );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ std::shared_ptr< ObservationCollection< double, double > > setUpObservationColle
std::vector< double > rangeObsTimes, dopplerObsTimes, angularPositionObsTimes;
obsStartTimes = { { one_way_range, initialEphemerisTime + 1000.0 }, { one_way_doppler, initialEphemerisTime + 1000.0 + 86400.0 },
{ angular_position, initialEphemerisTime + 1000.0 + 2.0 * 86400.0 } };
for( unsigned int j = 0; j < numberOfObservations; j++ )
for( int j = 0; j < numberOfObservations; j++ )
{
rangeObsTimes.push_back( initialEphemerisTime + 1000.0 + static_cast< double >( j ) * observationsInterval );
dopplerObsTimes.push_back( initialEphemerisTime + 1000.0 + 86400.0 + static_cast< double >( j ) * observationsInterval );
Expand Down Expand Up @@ -223,15 +223,15 @@ BOOST_AUTO_TEST_CASE( test_ObservationCollectionParser )
{
const double startTime = double( 1.0E7 );
const int numberOfDaysOfData = 3;
unsigned int nbObs = 300;
unsigned int numberOfObservations = 300;
double obsInterval = 20.0;

std::vector< LinkEnds > stationReceiverLinkEnds;
std::vector< LinkEnds > stationTransmitterLinkEnds;
std::map< ObservableType, double > obsStartTimes;
std::map< ObservableType, std::vector< double > > baseTimeList;
std::shared_ptr< ObservationCollection< double, double > > simulatedObservations = setUpObservationCollectionToTest(
startTime, numberOfDaysOfData, nbObs, obsInterval, stationReceiverLinkEnds, stationTransmitterLinkEnds, obsStartTimes, baseTimeList );
startTime, numberOfDaysOfData, numberOfObservations, obsInterval, stationReceiverLinkEnds, stationTransmitterLinkEnds, obsStartTimes, baseTimeList );

// Check full list of observable types
std::vector< ObservableType > observableTypes = simulatedObservations->getObservableTypes( );
Expand Down Expand Up @@ -277,11 +277,11 @@ BOOST_AUTO_TEST_CASE( test_ObservationCollectionParser )
{
if ( it.first != angular_position )
{
trueTimeBoundsList.push_back( std::make_pair( it.second, it.second + ( nbObs - 1 ) * obsInterval ) );
trueTimeBoundsList.push_back( std::make_pair( it.second, it.second + ( numberOfObservations - 1 ) * obsInterval ) );
}
else
{
trueTimeBoundsList.push_back( std::make_pair( it.second, it.second + ( nbObs - 1 ) * obsInterval + 2000.0 ) );
trueTimeBoundsList.push_back( std::make_pair( it.second, it.second + ( numberOfObservations - 1 ) * obsInterval + 2000.0 ) );
}
}
BOOST_CHECK( timeBoundsList.size( ) == trueTimeBoundsList.size( ) );
Expand Down Expand Up @@ -532,15 +532,15 @@ BOOST_AUTO_TEST_CASE( test_ObservationsFiltering )
{
const double startTime = double( 1.0E7 );
const int numberOfDaysOfData = 3;
unsigned int nbObs = 300;
unsigned int numberOfObservations = 300;
double obsInterval = 20.0;

std::vector< LinkEnds > stationReceiverLinkEnds;
std::vector< LinkEnds > stationTransmitterLinkEnds;
std::map< ObservableType, double > obsStartTimes;
std::map< ObservableType, std::vector< double > > baseTimeList;
std::shared_ptr< ObservationCollection< double, double > > simulatedObservations = setUpObservationCollectionToTest(
startTime, numberOfDaysOfData, nbObs, obsInterval, stationReceiverLinkEnds, stationTransmitterLinkEnds, obsStartTimes, baseTimeList );
startTime, numberOfDaysOfData, numberOfObservations, obsInterval, stationReceiverLinkEnds, stationTransmitterLinkEnds, obsStartTimes, baseTimeList );

// Retrieve start indices and sizes for observation sets
std::map< ObservableType, std::map< LinkEnds, std::vector< std::pair< int, int > > > > obsSetsStartAndSize = simulatedObservations->getObservationSetStartAndSize( );
Expand Down Expand Up @@ -621,11 +621,11 @@ BOOST_AUTO_TEST_CASE( test_ObservationsFiltering )
}
if ( observableIt.first == angular_position )
{
BOOST_CHECK( indices.second == 2.0 * nbObs );
BOOST_CHECK( indices.second == 2.0 * numberOfObservations );
}
if ( observableIt.first == one_way_doppler )
{
BOOST_CHECK( indices.second == nbObs );
BOOST_CHECK( indices.second == static_cast< int >( numberOfObservations ) );
}
startIndex += indices.second;
}
Expand Down Expand Up @@ -666,7 +666,7 @@ BOOST_AUTO_TEST_CASE( test_ObservationsFiltering )

// Test filtering based on epoch values and time bounds
std::vector< double > rangeObsTimes = baseTimeList.at( one_way_range );
std::pair< double, double > timeBounds = std::make_pair( rangeObsTimes[ int(nbObs/3) ], rangeObsTimes[ 2*int(nbObs/3) ] );
std::pair< double, double > timeBounds = std::make_pair( rangeObsTimes[ int(numberOfObservations/3) ], rangeObsTimes[ 2*int(numberOfObservations/3) ] );
std::vector< double > epochsToFilter;
std::vector< double > epochsLeft;
for ( auto time : rangeObsTimes )
Expand Down Expand Up @@ -701,7 +701,7 @@ BOOST_AUTO_TEST_CASE( test_ObservationsFiltering )
remainingObsTimes = simulatedObservations->getObservationTimes( observationParser( one_way_range ) );
for ( unsigned int k = 0 ; k < remainingObsTimes.size( ) ; k++ )
{
BOOST_CHECK( remainingObsTimes.at( k ).size( ) == nbObs );
BOOST_CHECK( remainingObsTimes.at( k ).size( ) == numberOfObservations );
}


Expand All @@ -725,7 +725,7 @@ BOOST_AUTO_TEST_CASE( test_ObservationsFiltering )
remainingObsTimes = simulatedObservations->getObservationTimes( observationParser( one_way_range ) );
for ( unsigned int k = 0 ; k < remainingObsTimes.size( ) ; k++ )
{
BOOST_CHECK( remainingObsTimes.at( k ).size( ) == nbObs );
BOOST_CHECK( remainingObsTimes.at( k ).size( ) == numberOfObservations );
}

// Test filtering based on residual values
Expand Down Expand Up @@ -794,19 +794,19 @@ BOOST_AUTO_TEST_CASE( test_ObservationsSplitting )

const double startTime = double( 1.0E7 );
const int numberOfDaysOfData = 3;
unsigned int nbObs = 300;
unsigned int numberOfObservations = 300;
double obsInterval = 20.0;

std::vector< LinkEnds > stationReceiverLinkEnds;
std::vector< LinkEnds > stationTransmitterLinkEnds;
std::map< ObservableType, double > obsStartTimes;
std::map< ObservableType, std::vector< double > > baseTimeList;
std::shared_ptr< ObservationCollection< double, double > > simulatedObservations = setUpObservationCollectionToTest(
startTime, numberOfDaysOfData, nbObs, obsInterval, stationReceiverLinkEnds, stationTransmitterLinkEnds, obsStartTimes, baseTimeList );
startTime, numberOfDaysOfData, numberOfObservations, obsInterval, stationReceiverLinkEnds, stationTransmitterLinkEnds, obsStartTimes, baseTimeList );


// Test splitting based on time tags
int indexSplitEpoch = int(nbObs/3);
int indexSplitEpoch = int(numberOfObservations/3);
std::vector< double > rangeObsTimes = baseTimeList.at( one_way_range );
double splitEpoch = rangeObsTimes.at( indexSplitEpoch );
std::vector< double > timeTags = { rangeObsTimes.at( 0 ), splitEpoch, rangeObsTimes.back( ) };
Expand All @@ -816,7 +816,7 @@ BOOST_AUTO_TEST_CASE( test_ObservationsSplitting )
std::vector< std::shared_ptr< SingleObservationSet< > > > splitObsSets = simulatedObservations->getSingleObservationSets( observationParser( stationTransmitterLinkEnds[ 0 ] ) );
BOOST_CHECK( splitObsSets.size( ) == 2 );
BOOST_CHECK( splitObsSets.at( 0 )->getNumberOfObservables( ) == indexSplitEpoch+1 );
BOOST_CHECK( splitObsSets.at( 1 )->getNumberOfObservables( ) == nbObs - (indexSplitEpoch+1) );
BOOST_CHECK( splitObsSets.at( 1 )->getNumberOfObservables( ) == numberOfObservations - (indexSplitEpoch+1) );

// Check that all observations in the first set occur before splitEpoch
for ( auto time : splitObsSets.at( 0 )->getObservationTimes( ) )
Expand All @@ -840,7 +840,7 @@ BOOST_AUTO_TEST_CASE( test_ObservationsSplitting )
BOOST_CHECK( splitObsSets.size( ) == 3 );
BOOST_CHECK( splitObsSets.at( 0 )->getNumberOfObservables( ) == indexSplitEpoch );
BOOST_CHECK( splitObsSets.at( 1 )->getNumberOfObservables( ) == indexSplitEpoch );
BOOST_CHECK( splitObsSets.at( 2 )->getNumberOfObservables( ) == nbObs - (2*indexSplitEpoch+1) );
BOOST_CHECK( splitObsSets.at( 2 )->getNumberOfObservables( ) == numberOfObservations - (2*indexSplitEpoch+1) );

// Check that the time span of the new observation set meets the threshold
for ( unsigned int i = 0 ; i < 3 ; i++ )
Expand Down

0 comments on commit 02f19d9

Please sign in to comment.