Skip to content

Commit

Permalink
Small update to transmission time computation
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicDirkx committed Nov 11, 2024
1 parent 9a4b73a commit fd90bab
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,23 @@ class TerrestrialTimeScaleConverter
return convertedTimes;
}

template< typename TimeType >
std::vector< TimeType > getCurrentTimesFromSinglePosition(
const basic_astrodynamics::TimeScales inputScale, const basic_astrodynamics::TimeScales outputScale,
const std::vector< TimeType >& inputTimeValues,
const Eigen::Vector3d& earthFixedPosition )
{
std::vector < TimeType > convertedTimes;
convertedTimes.resize( inputTimeValues.size( ) );

for ( unsigned int i = 0; i < inputTimeValues.size(); ++i )
{
convertedTimes [ i ] =
getCurrentTime( inputScale, outputScale, inputTimeValues.at( i ), earthFixedPosition );
}
return convertedTimes;
}

//! Function to reset all current times at given precision to NaN.
template< typename TimeType >
void resetTimes( )
Expand Down
43 changes: 9 additions & 34 deletions include/tudat/astro/ground_stations/transmittingFrequencies.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,47 +238,22 @@ class PiecewiseLinearFrequencyInterpolator: public StationFrequencyInterpolator
{
TimeType lookupTime = lookupTimeOriginal;
int lowerNearestNeighbour = -1;
try
{
lowerNearestNeighbour = startTimeLookupScheme_->findNearestLowerNeighbour( lookupTime );
}
catch( const std::exception& caughtException )
{
std::string exceptionText = std::string( caughtException.what( ) );
throw std::runtime_error(
"Error when interpolating ramp reference frequency: look up time (" + std::to_string(
static_cast< double >( lookupTime ) ) + ", caught exception: " + exceptionText );
}


// if( lookupTime > endTimes_.at( lowerNearestNeighbour ) || lookupTime < startTimes_.at ( lowerNearestNeighbour ) )
// {
// throw std::runtime_error(
// "Error when interpolating ramp reference frequency: look up time (" + std::to_string(
// static_cast< double >( lookupTime ) ) +
// ") is outside the ramp table interval (" + std::to_string( double( startTimes_.at( 0 ) ) ) + " to " +
// std::to_string( double( startTimes_.back( ) ) ) + ")." );
// }
if ( lookupTime > endTimes_.at( lowerNearestNeighbour ) )
{
lowerNearestNeighbour = endTimes_.size( ) - 1;
}
if ( lookupTime < startTimes_.at ( lowerNearestNeighbour ) )
if( lookupTimeOriginal < startTimes_.at( 0 ) )
{
lowerNearestNeighbour = 0;
}
else if ( invalidStartTimeLookupScheme_ != nullptr )
else
{
int invalidLowestNearestNeighbour = invalidStartTimeLookupScheme_->findNearestLowerNeighbour( lookupTime );
if ( lookupTime > invalidTimeBlocksStartTimes_.at ( invalidLowestNearestNeighbour ) &&
lookupTime < invalidTimeBlocksEndTimes_.at ( invalidLowestNearestNeighbour ) )
try
{
lowerNearestNeighbour = startTimeLookupScheme_->findNearestLowerNeighbour( lookupTime );
}
catch ( const std::exception &caughtException )
{
std::string exceptionText = std::string( caughtException.what( ));
throw std::runtime_error(
"Error when interpolating ramp reference frequency: look up time (" + std::to_string(
static_cast< double >( lookupTime ) ) +
") is in time interval without transmitted frequency (" +
std::to_string( double( invalidTimeBlocksStartTimes_.at ( invalidLowestNearestNeighbour ) ) ) + " to " +
std::to_string( double( invalidTimeBlocksEndTimes_.at ( invalidLowestNearestNeighbour ) ) ) + ")." );
static_cast< double >( lookupTime )) + ", caught exception: " + exceptionText );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ std::map< propagators::IntegratedStateType, orbit_determination::StateDerivative
std::string errorMessage = "Cannot yet create state derivative partial models for type " +
std::to_string( stateDerivativeIterator->first );
throw std::runtime_error( errorMessage );
}
}
}

return stateDerivativePartials;
return stateDerivativePartials;
}
//
//extern template std::map< propagators::IntegratedStateType, orbit_determination::StateDerivativePartialsMap > createStateDerivativePartials< double, double >(
Expand Down
16 changes: 5 additions & 11 deletions include/tudat/simulation/estimation_setup/processOdfFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -1536,19 +1536,14 @@ compressDopplerData(

earth_orientation::TerrestrialTimeScaleConverter timeScaleConverter =
earth_orientation::TerrestrialTimeScaleConverter( );
std::vector< Eigen::Vector3d > originalEarthFixedPositions;
for( unsigned int i = 0; i < originalObservationTimesTdb.size( ); ++i )
{
originalEarthFixedPositions.push_back(
simulation_setup::getCombinedApproximateGroundStationPositions( ).at(
originalDopplerData->getLinkEnds( ).at( receiver ).stationName_ ) );
}
Eigen::Vector3d stationPosition = simulation_setup::getCombinedApproximateGroundStationPositions( ).at(
originalDopplerData->getLinkEnds( ).at( receiver ).stationName_ );

std::vector< TimeType > originalObservationTimesUtc =
timeScaleConverter.getCurrentTimes< TimeType >( basic_astrodynamics::tdb_scale,
timeScaleConverter.getCurrentTimesFromSinglePosition< TimeType >( basic_astrodynamics::tdb_scale,
basic_astrodynamics::utc_scale,
originalObservationTimesTdb,
originalEarthFixedPositions );
stationPosition );

std::vector< Eigen::Matrix< ObservationScalarType, Eigen::Dynamic, 1 > > compressedObservations;
std::vector< TimeType > compressedObservationTimesUtc;
Expand Down Expand Up @@ -1597,8 +1592,6 @@ compressDopplerData(
"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 )
Expand Down Expand Up @@ -1665,6 +1658,7 @@ createCompressedDopplerCollection(
observation_models::SingleObservationSet< ObservationScalarType, TimeType > >
compressedDataSet = compressDopplerData< ObservationScalarType, TimeType >(
it.second.at( index ), compressionRatio );

if( compressedDataSet->getObservationTimes( ).size( ) )
{
compressedData->replaceSingleObservationSet( compressedDataSet, index );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ BOOST_AUTO_TEST_CASE( testPiecewiseLinearFrequencyInterpolator )
{
errorThrown = true;
}
// BOOST_CHECK( errorThrown );
BOOST_CHECK( errorThrown );

// Check whether error is thrown for discontinuous start/end times
startTimes.pop_back( );
Expand All @@ -116,24 +116,8 @@ BOOST_AUTO_TEST_CASE( testPiecewiseLinearFrequencyInterpolator )
{
errorThrown = true;
}
// BOOST_CHECK( errorThrown );

// Check whether error is thrown when accessing an invalid time block
startTimes.pop_back( );
startTimes.push_back( 10.1 );
frequencyInterpolator = PiecewiseLinearFrequencyInterpolator(
startTimes, endTimes, rampRates, startFrequency );
frequencyInterpolator.template getTemplatedCurrentFrequency< >( 10.15 );
try
{
frequencyInterpolator.template getTemplatedCurrentFrequency< >( 10.05 );
errorThrown = false;
}
catch( std::runtime_error const& )
{
errorThrown = true;
}
// BOOST_CHECK( errorThrown );
BOOST_CHECK( errorThrown );
x

}

Expand Down

0 comments on commit fd90bab

Please sign in to comment.