Skip to content

Commit

Permalink
Merge pull request #251 from tudat-team/feature/doppler_interface_update
Browse files Browse the repository at this point in the history
Feature/doppler interface update
  • Loading branch information
DominicDirkx authored Oct 16, 2024
2 parents 5406a13 + 34bba3c commit fdbf1ca
Show file tree
Hide file tree
Showing 12 changed files with 620 additions and 478 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ class DopplerMeasuredFrequencyObservationModel : public ObservationModel< 1, Obs
( stationStates_.count( transmitter ) == 0 ) ?
Eigen::Vector3d::Zero( ) : stationStates_.at( transmitter )->getNominalCartesianPosition( );
TimeType transmitterTime = time - lightTime;

TimeType transmitterUtcTime = terrestrialTimeScaleConverter_->getCurrentTime< TimeType >(
basic_astrodynamics::tdb_scale, basic_astrodynamics::utc_scale, transmitterTime, nominalTransmittingStationState );

Expand All @@ -161,13 +162,11 @@ class DopplerMeasuredFrequencyObservationModel : public ObservationModel< 1, Obs
ObservationScalarType twoWayDoppler = twoWayDopplerModel_->computeIdealObservationsWithLinkEndData(
time, linkEndAssociatedWithTime, linkEndTimes, linkEndStates, ancillarySettings)( 0, 0 ) / dopplerMultiplicationTerm;


ObservationScalarType receivedFrequency =
( transmittedFrequency * ( mathematical_constants::getFloatingInteger< ObservationScalarType >( 1 ) + twoWayDoppler ) ) *
turnaroundRatio_(uplinkBand, downlinkBand);

Eigen::Matrix< ObservationScalarType, 1, 1 > observation = (Eigen::Matrix< ObservationScalarType, 1, 1 >() << receivedFrequency).finished();

return observation;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,8 @@ class OneWayDopplerObservationModel: public ObservationModel< 1, ObservationScal
computeDopplerProperTimeInfluenceTaylorSeriesExpansion(
transmitterProperTimeDifference, receiverProperTimeDifference, taylorSeriesExpansionOrder_ );

// Compute first-order (geometrical) one-way Doppler contribution

// Compute first-order (geometrical) one-way Doppler contribution
lightTimePartialWrtReceiverPosition_ =
lightTimeCalculator_->getPartialOfLightTimeWrtLinkEndPosition(
transmitterState_, receiverState_, transmissionTime, receptionTime, true );
Expand Down
2 changes: 1 addition & 1 deletion include/tudat/io/readOdfFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ class OdfCommonDataBlock
// Returns the observable time in UTC seconds since the reference time specified in the header.
Time getObservableTime( )
{
return Time( static_cast< double >( integerTimeTag_ ) ) + Time( static_cast< double >( fractionalTimeTag_ ) / 1000.0 );
return Time( static_cast< double >( integerTimeTag_ ) ) + Time( static_cast< double >( fractionalTimeTag_ ) / 1000.0 );
}

// Returns the observable value in SI units.
Expand Down
19 changes: 16 additions & 3 deletions include/tudat/io/readTrackingTxtFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ enum class TrackingDataType
transmission_frequency_constant_term,
transmission_frequency_linear_term,
doppler_predicted_frequency_hz,
doppler_troposphere_correction
doppler_troposphere_correction,
scan_nr
};
/*!
* Simple converter class that can convert a string data field to a double.
Expand Down Expand Up @@ -261,7 +262,8 @@ static const std::map<std::string, std::shared_ptr<TrackingFileFieldConverter>>
{"transmission_frequency_constant_term", std::make_shared<TrackingFileFieldConverter>(TrackingDataType::transmission_frequency_constant_term)},
{"transmission_frequency_linear_term", std::make_shared<TrackingFileFieldConverter>(TrackingDataType::transmission_frequency_linear_term)},
{"doppler_predicted_frequency_hz", std::make_shared<TrackingFileFieldConverter>(TrackingDataType::doppler_predicted_frequency_hz)},
{"doppler_troposphere_correction", std::make_shared<TrackingFileFieldConverter>(TrackingDataType::doppler_troposphere_correction)}
{"doppler_troposphere_correction", std::make_shared<TrackingFileFieldConverter>(TrackingDataType::doppler_troposphere_correction)},
{"scan_number", std::make_shared<TrackingFileFieldConverter>(TrackingDataType::scan_nr)}

};

Expand Down Expand Up @@ -419,7 +421,7 @@ class TrackingTxtFileContents
* @return TrackingFileContents
*/
static inline std::shared_ptr<TrackingTxtFileContents> createTrackingTxtFileContents(const std::string& fileName,
std::vector<std::string>& columnTypes,
const std::vector<std::string>& columnTypes,
char commentSymbol = '#',
const std::string& valueSeparators = ",: \t",
const bool ignoreOmittedColumns = false )
Expand Down Expand Up @@ -448,6 +450,17 @@ inline std::shared_ptr< TrackingTxtFileContents> readIfmsFile(const std::string&
rawFileContents->addMetaData( TrackingDataType::file_name, fileName );
return rawFileContents;
}

inline std::shared_ptr< TrackingTxtFileContents> readFdetsFile(
const std::string& fileName,
const std::vector<std::string>& columnTypes ={ "utc_datetime_string", "signal_to_noise_ratio", "normalised_spectral_max", "doppler_measured_frequency_hz", "doppler_noise_hz" } )
{
auto rawFileContents = createTrackingTxtFileContents(fileName, columnTypes, '#', ", \t");
rawFileContents->addMetaData(TrackingDataType::file_name, fileName );
return rawFileContents;
}


} // namespace input_output
} // namespace tudat

Expand Down
89 changes: 27 additions & 62 deletions include/tudat/simulation/estimation_setup/processOdfFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,42 +71,6 @@ class ProcessedOdfFileSingleLinkData
observableType_( observableType )
{ }

void splitSingleLinkDataBase( std::shared_ptr< ProcessedOdfFileSingleLinkData< TimeType > > firstBlockDataSet,
std::shared_ptr< ProcessedOdfFileSingleLinkData< TimeType > > secondBlockDataSet,
const int splitIndex )
{
utilities::getVectorStartBlock( firstBlockDataSet->unprocessedObservationTimes_, unprocessedObservationTimes_, splitIndex );
utilities::getVectorStartBlock( firstBlockDataSet->processedObservationTimes_, processedObservationTimes_, splitIndex );
utilities::getVectorStartBlock( firstBlockDataSet->observableValues_, observableValues_, splitIndex );
utilities::getVectorStartBlock( firstBlockDataSet->receiverDownlinkDelays_, receiverDownlinkDelays_, splitIndex );
utilities::getVectorStartBlock( firstBlockDataSet->downlinkBandIds_, downlinkBandIds_, splitIndex );
utilities::getVectorStartBlock( firstBlockDataSet->uplinkBandIds_, uplinkBandIds_, splitIndex );
utilities::getVectorStartBlock( firstBlockDataSet->referenceBandIds_, referenceBandIds_, splitIndex );
utilities::getVectorStartBlock( firstBlockDataSet->originFiles_, originFiles_, splitIndex );
utilities::getVectorStartBlock( firstBlockDataSet->unprocessedObservationTimes_, unprocessedObservationTimes_, splitIndex );

utilities::getVectorEndBlock( secondBlockDataSet->unprocessedObservationTimes_, unprocessedObservationTimes_, splitIndex );
utilities::getVectorEndBlock( secondBlockDataSet->processedObservationTimes_, processedObservationTimes_, splitIndex );
utilities::getVectorEndBlock( secondBlockDataSet->observableValues_, observableValues_, splitIndex );
utilities::getVectorEndBlock( secondBlockDataSet->receiverDownlinkDelays_, receiverDownlinkDelays_, splitIndex );
utilities::getVectorStartBlock( secondBlockDataSet->downlinkBandIds_, downlinkBandIds_, splitIndex );
utilities::getVectorEndBlock( secondBlockDataSet->uplinkBandIds_, uplinkBandIds_, splitIndex );
utilities::getVectorEndBlock( secondBlockDataSet->referenceBandIds_, referenceBandIds_, splitIndex );
utilities::getVectorEndBlock( secondBlockDataSet->originFiles_, originFiles_, splitIndex );
utilities::getVectorEndBlock( secondBlockDataSet->unprocessedObservationTimes_, unprocessedObservationTimes_, splitIndex );
}

virtual void splitSingleLinkDataDerived( std::shared_ptr< ProcessedOdfFileSingleLinkData< TimeType > > firstBlockDataSet,
std::shared_ptr< ProcessedOdfFileSingleLinkData< TimeType > > secondBlockDataSet,
const int splitIndex ) = 0;

void splitSingleLinkData( std::shared_ptr< ProcessedOdfFileSingleLinkData< TimeType > > firstBlockDataSet,
std::shared_ptr< ProcessedOdfFileSingleLinkData< TimeType > > secondBlockDataSet,
const int splitIndex )
{
splitSingleLinkDataDerived( firstBlockDataSet, secondBlockDataSet, splitIndex );
splitSingleLinkDataDerived( firstBlockDataSet, secondBlockDataSet, splitIndex );
}

// Destructor
virtual ~ProcessedOdfFileSingleLinkData( ){ }
Expand Down Expand Up @@ -202,32 +166,6 @@ class ProcessedOdfFileDopplerData: public ProcessedOdfFileSingleLinkData< TimeTy
// Destructor
~ProcessedOdfFileDopplerData( ){ }

void splitSingleLinkDataDerived( std::shared_ptr< ProcessedOdfFileSingleLinkData< TimeType > > firstBlockDataSet,
std::shared_ptr< ProcessedOdfFileSingleLinkData< TimeType > > secondBlockDataSet,
const int splitIndex )
{
std::shared_ptr<ProcessedOdfFileDopplerData< TimeType > > firstBlockDataSetDerived =
std::make_shared<ProcessedOdfFileDopplerData< TimeType > >( this->observableType_, this->receivingStation_, transmittingStation_ );
std::shared_ptr<ProcessedOdfFileDopplerData< TimeType > > secondBlockDataSetDerived =
std::make_shared<ProcessedOdfFileDopplerData< TimeType > >( this->observableType_, this->receivingStation_, transmittingStation_ );

utilities::getVectorStartBlock( firstBlockDataSetDerived->receiverChannels_, receiverChannels_, splitIndex );
utilities::getVectorStartBlock( firstBlockDataSetDerived->referenceFrequencies_, referenceFrequencies_, splitIndex );
utilities::getVectorStartBlock( firstBlockDataSetDerived->countInterval_, countInterval_, splitIndex );
utilities::getVectorStartBlock( firstBlockDataSetDerived->transmitterUplinkDelays_, transmitterUplinkDelays_, splitIndex );
utilities::getVectorStartBlock( firstBlockDataSetDerived->receiverRampingFlags_, receiverRampingFlags_, splitIndex );

utilities::getVectorEndBlock( secondBlockDataSetDerived->receiverChannels_, receiverChannels_, splitIndex );
utilities::getVectorEndBlock( secondBlockDataSetDerived->referenceFrequencies_, referenceFrequencies_, splitIndex );
utilities::getVectorEndBlock( secondBlockDataSetDerived->countInterval_, countInterval_, splitIndex );
utilities::getVectorEndBlock( secondBlockDataSetDerived->transmitterUplinkDelays_, transmitterUplinkDelays_, splitIndex );
utilities::getVectorEndBlock( secondBlockDataSetDerived->receiverRampingFlags_, receiverRampingFlags_, splitIndex );

firstBlockDataSet = firstBlockDataSetDerived;
secondBlockDataSet = secondBlockDataSetDerived;
}


// Name of the transmitting ground station
std::string transmittingStation_;

Expand Down Expand Up @@ -1266,6 +1204,7 @@ std::shared_ptr< observation_models::ObservationCollection< ObservationScalarTyp
sortedObservationSets );
}


template< typename ObservationScalarType = double, typename TimeType = double >
std::shared_ptr< observation_models::SingleObservationSet< ObservationScalarType, TimeType > > compressDopplerData(
const std::shared_ptr< observation_models::SingleObservationSet< ObservationScalarType, TimeType > > originalDopplerData,
Expand Down Expand Up @@ -1472,6 +1411,32 @@ void setOdfInformationInBodies(
vehicleSystems->setTransponderTurnaroundRatio( getTurnaroundRatio );
}


template< typename ObservationScalarType = double, typename TimeType = Time >
std::shared_ptr< observation_models::ObservationCollection< ObservationScalarType, TimeType > > createOdfObservedObservationCollectionFromFile(
simulation_setup::SystemOfBodies& bodies,
const std::vector< std::string >& odfFileNames,
const std::string& targetName,
const bool verboseOutput = true,
const std::map< std::string, Eigen::Vector3d >& earthFixedGroundStationPositions =
simulation_setup::getApproximateDsnGroundStationPositions( ) )
{

std::vector< std::shared_ptr< input_output::OdfRawFileContents > > rawOdfDataVector;
for( std::string odfFileName : odfFileNames )
{
rawOdfDataVector.push_back( std::make_shared< input_output::OdfRawFileContents>( odfFileName ) );
}

std::shared_ptr< ProcessedOdfFileContents< TimeType > > processedOdfFileContents =
std::make_shared< ProcessedOdfFileContents< TimeType > >( rawOdfDataVector, targetName, verboseOutput, earthFixedGroundStationPositions );
observation_models::setOdfInformationInBodies( processedOdfFileContents, bodies );

// Create observed observation collection
return observation_models::createOdfObservedObservationCollection< ObservationScalarType, TimeType >(
processedOdfFileContents );
}

} // namespace observation_models

} // namespace tudat
Expand Down
71 changes: 71 additions & 0 deletions include/tudat/simulation/estimation_setup/processTrackingTxtFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,77 @@ void setTrackingDataInformationInBodies(

}


template< typename ObservationScalarType = double, typename TimeType = Time >
std::shared_ptr< observation_models::ObservationCollection< ObservationScalarType, TimeType > > createIfmsObservedObservationCollectionFromFiles(
const std::vector< std::string >& ifmsFileNames,
simulation_setup::SystemOfBodies& bodies,
const std::string& targetName,
const std::string& groundStationName,
const FrequencyBands& receptionBand,
const FrequencyBands& transmissionBand,
const std::map< std::string, Eigen::Vector3d >& earthFixedGroundStationPositions =
simulation_setup::getCombinedApproximateGroundStationPositions( ) )
{
std::vector< std::shared_ptr< input_output::TrackingTxtFileContents > > rawIfmsDataList;

for( std::string ifmsFileName : ifmsFileNames )
{
rawIfmsDataList.push_back( input_output::readIfmsFile( ifmsFileName ) );
}

std::vector< std::shared_ptr< ProcessedTrackingTxtFileContents< ObservationScalarType, TimeType > > > processedIfmsFiles;
for( unsigned int i = 0; i < rawIfmsDataList.size( ); i++ )
{
rawIfmsDataList.at( i )->addMetaData( input_output::TrackingDataType::receiving_station_name, groundStationName );
rawIfmsDataList.at( i )->addMetaData( input_output::TrackingDataType::transmitting_station_name, groundStationName);
processedIfmsFiles.push_back( std::make_shared<observation_models::ProcessedTrackingTxtFileContents< ObservationScalarType, TimeType > >(
rawIfmsDataList.at( i ), targetName, earthFixedGroundStationPositions ) );
}

setTrackingDataInformationInBodies(
processedIfmsFiles, bodies, dsn_n_way_averaged_doppler );

ObservationAncilliarySimulationSettings ancilliarySettings;
ancilliarySettings.setAncilliaryDoubleVectorData(frequency_bands, { static_cast< double >( transmissionBand ), static_cast< double >( receptionBand ) });
ancilliarySettings.setAncilliaryDoubleData( doppler_reference_frequency, 0.0 );
ancilliarySettings.setAncilliaryDoubleData( reception_reference_frequency_band, convertFrequencyBandToDouble( receptionBand ) );

return observation_models::createTrackingTxtFilesObservationCollection< ObservationScalarType, TimeType >(
processedIfmsFiles, std::vector<ObservableType>(), ancilliarySettings );
}

template< typename ObservationScalarType = double, typename TimeType = Time >
std::shared_ptr< observation_models::ObservationCollection< ObservationScalarType, TimeType > > createFdetsObservedObservationCollectionFromFile(
const std::string& fdetsFileName,
const double& baseFrequency,
const std::vector<std::string>& columnTypes,
const std::string& targetName,
const std::string& transmittingStationName,
const std::string& receivingStationName,
const FrequencyBands& receptionBand,
const FrequencyBands& transmissionBand,
const std::map< std::string, Eigen::Vector3d >& earthFixedGroundStationPositions =
simulation_setup::getCombinedApproximateGroundStationPositions( ) )
{
using namespace input_output;
std::shared_ptr<TrackingTxtFileContents> fdetsFileContents = readFdetsFile( fdetsFileName, columnTypes );
fdetsFileContents->addMetaData( TrackingDataType::receiving_station_name, receivingStationName );
fdetsFileContents->addMetaData( TrackingDataType::transmitting_station_name, transmittingStationName );
fdetsFileContents->addMetaData( TrackingDataType::doppler_base_frequency, baseFrequency);

std::vector< std::shared_ptr< ProcessedTrackingTxtFileContents< ObservationScalarType, TimeType > > > processedFdetsFiles;
processedFdetsFiles.push_back( std::make_shared<observation_models::ProcessedTrackingTxtFileContents< ObservationScalarType, TimeType > >(
fdetsFileContents, targetName, earthFixedGroundStationPositions ) );

// Define ancilliary settings
ObservationAncilliarySimulationSettings ancilliarySettings;
ancilliarySettings.setAncilliaryDoubleVectorData(frequency_bands, { static_cast< double >( transmissionBand ), static_cast< double >( receptionBand ) });

return observation_models::createTrackingTxtFilesObservationCollection< ObservationScalarType, TimeType >(
processedFdetsFiles, std::vector<ObservableType>( ), ancilliarySettings );
}

} // namespace observation_models
} // namespace tudat

Expand Down
Binary file modified tests/data.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/src/astro/observation_models/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ TUDAT_ADD_TEST_CASE(NWayRangeObservationModel PRIVATE_LINKS ${Tudat_ESTIMATION_L

TUDAT_ADD_TEST_CASE(NWayRangeRateObservationModel PRIVATE_LINKS ${Tudat_ESTIMATION_LIBRARIES})

#TUDAT_ADD_TEST_CASE(DopplerMeasuredFrequencyObservationModel PRIVATE_LINKS ${Tudat_ESTIMATION_LIBRARIES})
TUDAT_ADD_TEST_CASE(DopplerMeasuredFrequencyObservationModel PRIVATE_LINKS ${Tudat_ESTIMATION_LIBRARIES})

TUDAT_ADD_TEST_CASE(RelativeAngularPositionModel PRIVATE_LINKS ${Tudat_ESTIMATION_LIBRARIES})

Expand Down
Loading

0 comments on commit fdbf1ca

Please sign in to comment.