Python - Satellite Slant Range

by matt392 in Circuits > Software

17 Views, 0 Favorites, 0 Comments

Python - Satellite Slant Range

slant-range.jpg
# Formula to compute Slant Range between 2 points
# Slant Range =
# (Square Root[(((Distance Bet Geocenter & Ground Station * Cosine(Elevation Angle))Squared)
# + ((Distance Bet GroundStationToSatellite+Distance Bet GeocenterToGround Station)Squared) 
# - ((Distance Bet Geocenter & Ground Station)Squared))]
# - [(Distance Bet Geocenter & Ground Station * cosine(Elevation Angle) )]

import math

print ("Formula to compute Slant Range between 2 points")

print ("The formula is: ")
print ("Slant Range=(Square Root(((Distance Bet Geocenter & Ground Station * Cosine(Elevation Angle))Squared)")
print ("+ ((Distance Bet Ground Station To Satellite+Distance Bet Geocenter To Ground Station)Squared) - ((Distance Bet Geocenter & Ground Station)Squared))" )
print ("- Distance Bet Geocenter & Ground Station * cosine(Elevation Angle)" )

#  Input the data
EnteredDistanceBetGroundStationSatellite = input ("Enter the Distance Bet Ground Station & Satellite: ")
EnteredDistanceBetGeocenterGroundStation = input ("Enter the Distance Bet Geocenter & Ground Station: ")
EnteredElevationAngle = input ("Enter the Elevation Angle: ")

# Convert entered numbers to float
DistanceBetGeocenterGroundStation = float(EnteredDistanceBetGeocenterGroundStation)
ElevationAngle = float(EnteredElevationAngle)
DistanceBetGroundStationSatellite = float(EnteredDistanceBetGroundStationSatellite)

# >> use math.sqrt()
# use (math.cos() )
# Calculate the left side of the equation first
Radius = DistanceBetGroundStationSatellite+DistanceBetGeocenterGroundStation
print ("The Radius is: ", Radius)

RadiusSquared = Radius**2
print ("The Radius squared is: ", RadiusSquared)

# convert iputted angle to radians first!
ElevationAngleInRadians = math.radians(ElevationAngle)
print ("The angle in radians is: ", ElevationAngleInRadians)
CosineElevationAngle = (math.cos(ElevationAngleInRadians))


print ("The Cosine of the elevation angle is: ", CosineElevationAngle)

DistanceGeocenterGroundStationTimesCosine = DistanceBetGeocenterGroundStation * CosineElevationAngle
print ("The distance between the geocenter and the ground station times the cosine of the elevation angle is: ", DistanceGeocenterGroundStationTimesCosine)

DistanceTimesCosineSquared = ( (DistanceGeocenterGroundStationTimesCosine)**2)
print ("The square of the previous number is: ", DistanceTimesCosineSquared)

DistanceGeocenterGroundStationSquared = DistanceBetGeocenterGroundStation**2
print ("The distance between the geocenter and ground station squared is: ", DistanceGeocenterGroundStationSquared)

NumberToBeSquareRooted = ( DistanceTimesCosineSquared + RadiusSquared - DistanceGeocenterGroundStationSquared)
print ("The number to be square rooted is: ", NumberToBeSquareRooted)

LeftSideOfEquation =( math.sqrt(NumberToBeSquareRooted) )
print ("The square root is: ", LeftSideOfEquation)

# Calculate the right side of the equation
RightSideOfEquation = (DistanceBetGeocenterGroundStation * (CosineElevationAngle) )
print ("The right side of the equation is: ", RightSideOfEquation)
       
SlantRange = LeftSideOfEquation - RightSideOfEquation

print ("The Slant Range is: ", SlantRange)

Downloads