Source code for tudatpy.data.processTrk234.converters.radioBase

"""
Base class for radiometric converters sharing helper functions.
"""

from tudatpy.dynamics.environment_setup.ground_station import (
    # from tudatpy.dynamics.environment import (
    get_approximate_dsn_ground_station_positions,
)
from tudatpy.estimation.observations_setup.ancillary_settings import FrequencyBands  # type:ignore
from tudatpy.estimation.observable_models_setup import links
from tudatpy.astro import time_representation
from . import Converter
from trk234 import bands, SFDU
from datetime import datetime


[docs] class RadioBase(Converter): trkModeDict = { 0: "Unknown", 1: "1W", 2: "2W", 3: "3W", } time_scale_converter = time_representation.default_time_scale_converter() frequencyBandsDict = { "S": FrequencyBands.s_band, "X": FrequencyBands.x_band, # "K": FrequencyBands.ku_band, "Ka": FrequencyBands.ka_band, } stationDict = get_approximate_dsn_ground_station_positions()
[docs] def get_band(self, sfdu: SFDU) -> tuple[str, str]: """ Returns the uplink and downlink radio bands for a given SFDU record. The secondary CHDO has to be decoded before calling this function. Parameters ---------- sfdu : trk234.SFDU The SFDU record to extract the radio bands from. Returns ------- tuple(str, str) A tuple containing the uplink and downlink radio bands. """ return ( bands[sfdu.sec_chdo.ul_band_dl], bands[sfdu.sec_chdo.vld_dl_band], )
[docs] def get_tracking_mode(self, sfdu: SFDU) -> str: """ Returns the tracking mode for a given SFDU record. The secondary CHDO has to be decoded before calling this function. Parameters ---------- sfdu : trk234.SFDU The SFDU record to extract the tracking mode from. Returns ------- str The tracking mode of the SFDU record. """ trkMode = ( self.trkModeDict[sfdu.sec_chdo.vld_dop_mode] if sfdu.sec_chdo.vld_dop_mode != 0 else sfdu.tracking_mode() ) return trkMode
[docs] def from_datetime_UTC_to_TDB(self, datetime_utc: datetime, station: str) -> float: """ Convert a datetime object in UTC into seconds since J2000 in TDB. Parameters ---------- datetime_utc : datetime The datetime object to convert. Returns ------- float The time in seconds since J2000 in TDB. """ if station not in self.stationDict: raise KeyError( "Error when processing TNF file, converting time from UTC to TDB: \n" + "the position of the ground station {} was not specified.".format( station ) ) epoch_utc = time_representation.DateTime.from_python_datetime(datetime_utc).to_epoch() epoch_tdb = self.time_scale_converter.convert_time( input_scale=time_representation.utc_scale, output_scale=time_representation.tdb_scale, input_value=epoch_utc, earth_fixed_position=self.stationDict[station], ) return epoch_tdb