Member-only story
Python Shorts — Antenna Aim
A series of short Python programming examples. Today we’ll aim a satellite antenna at any geostationary satellite within sight of your location on the earth.
Satellites orbit at a speed based on their distance from the earth. The International Space Station is about 250 miles up, and it takes roughly an hour and a half to complete each orbit. The Moon is 238,900 miles away from the earth, and it takes about 27 days to complete one orbit.
Geostationary Satellites
Geostationary satellites orbit between these two extremes, at a very special altitude of 22,236 miles, where each orbit takes exactly one day. They are located above the equator, orbiting in the same direction that the Earth spins, with the result that they appear to stay in one spot above the Earth all the time.
satellite_aim.py
The following short Python program calculates the azimuth and elevation angles you need to rotate and pivot an antenna to aim directly at one of these satellites.
from math import *lat, lon = 33.37589, -104.50792
sat_lon = -127.8rlat = radians(lat)
rlon = radians(lon)
rsat = radians(sat_lon)L = rsat - rlon
D = acos(cos(rlat) * cos(L))
az = degrees(acos(-tan(rlat) / tan(D)))
az = az…