Skip to content

Commit 4481c67

Browse files
committed
applied doppler calculation changes
1 parent 06e3a40 commit 4481c67

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

gs/backend/positioning/doppler_shift.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,40 @@
11
from typing import Final
22

3-
from skyfield.api import EarthSatellite, Topos, load
3+
from skyfield.api import EarthSatellite, Topos, load, Timescale, Time
44

55
SPEED_OF_LIGHT_METERS_PER_SECOND: Final[int] = 299_792_458
6+
TRANSMISSION_FREQUENCY_HZ: Final[float] = 433_920_000 # Default frequency, UW-Orbital's 433.920 MHz band
67

78
"""
89
@brief Holds logic for calculating doppler shift from TLS and ground station coordinates
910
@details Since we're not actually getting TLE or interfacing with HackRF it's not hooked up to anything yet
1011
"""
1112

12-
13-
def load_satellite(tle_line1: str, tle_line2: str, name: str = "UW_SAT") -> EarthSatellite:
13+
# Change: made function take in time as a parameter instead
14+
def load_satellite(tle_line1: str, tle_line2: str, timescale: Timescale, name: str = "UW_SAT") -> EarthSatellite:
1415
"""
1516
@brief Loads satellite from TLE lines
1617
@param tle_line1: First line of TLE
1718
@param tle_line2: Second line of TLE
19+
@param timescale: Time for which satellite position is being calculated
1820
@param name: Optional satellite name
1921
@returns EarthSatellite object
2022
"""
21-
return EarthSatellite(tle_line1, tle_line2, name, load.timescale())
22-
23+
return EarthSatellite(tle_line1, tle_line2, name, timescale)
2324

25+
# Change: made function take in time as a parameter
2426
def calculate_relative_velocity(
25-
satellite: EarthSatellite, observer_latitude_deg: float, observer_longitude_deg: float, observer_altitude_m: float
27+
satellite: EarthSatellite, observer_latitude_deg: float, observer_longitude_deg: float, observer_altitude_m: float, time_current: Time
2628
) -> float:
2729
"""
2830
@brief Computes relative velocity between satellite and observer
2931
@param satellite: EarthSatellite object
3032
@param observer_latitude_degree: Latitude of observer in degrees
3133
@param observer_longitude_deg: Longitude of observer in degrees
3234
@param observer_altitude_m: Altitude of observer in meters
35+
@param time_current: Time for which relative velocity is being calculated
3336
@returns Relative radial velocity in m/s (positive is moving away)
3437
"""
35-
time_current = load.timescale().now()
3638

3739
observer = Topos(
3840
latitude_degrees=observer_latitude_deg,
@@ -71,22 +73,27 @@ def compute_doppler_shift(frequency_hz: float, relative_velocity_m_s: float) ->
7173
)
7274

7375

76+
# Change: made trans freq a constant in the file that is passed instead of a parameter to the function
7477
def calculate_doppler(
7578
tle_line1: str,
7679
tle_line2: str,
7780
observer_latitude_deg: float,
7881
observer_longitude_deg: float,
7982
observer_altitude_m: float,
80-
transmission_frequency_hz: float = 433_920_000, # Default frequency, UW-Orbital's 433.920 MHz band
83+
timescale: Timescale,
84+
time_current: Time
8185
) -> float:
8286
"""
8387
@brief High-level function to compute Doppler shift
8488
@param tle_line1: First line of TLE data
8589
@param tle_line2: Second line of TLE data
86-
@param observer_coords: Tuple of (latitude_deg, longitude_deg, altitude_m)
87-
@param transmission_frequency_hz: Frequency of the satellite transmission in Hz
90+
@param observer_latitude_deg: Latitude of observer in degrees
91+
@param observer_longitude_deg: Longitude of observer in degrees
92+
@param observer_altitude_m: Altitude of observer in meters
93+
@param timescale: Time for which satellite position is being calculated
94+
@param time_current: Time for which Doppler shift is being calculated
8895
@returns Doppler-shifted frequency in Hz
8996
"""
90-
sat = load_satellite(tle_line1, tle_line2)
91-
rv = calculate_relative_velocity(sat, observer_latitude_deg, observer_longitude_deg, observer_altitude_m)
92-
return compute_doppler_shift(transmission_frequency_hz, rv)
97+
sat = load_satellite(tle_line1, tle_line2, timescale)
98+
rv = calculate_relative_velocity(sat, observer_latitude_deg, observer_longitude_deg, observer_altitude_m, time_current)
99+
return compute_doppler_shift(TRANSMISSION_FREQUENCY_HZ, rv)

0 commit comments

Comments
 (0)