import math


def GsoAzimuth(fss_lat, fss_lon, sat_lon):
  """Computes the azimuth angle from earth station toward GSO satellite.

  Based on Appendix D of FCC 05-56.

  Inputs:
    fss_lat:   Latitude of earth station (degrees)
    fss_lon:   Longitude of earth station (degrees)
    sat_lon:   Longitude of satellite (degrees)

  Returns:
    the azimuth angle of the pointing arc from earth station to GSO satellite.
  """
  fss_lat = math.radians(fss_lat)
  fss_lon = math.radians(fss_lon)
  sat_lon = math.radians(sat_lon)
  if fss_lat > 0:
    azimuth = math.pi - math.atan2(math.tan(sat_lon-fss_lon),
                                   math.sin(fss_lat))
  else:
    azimuth = math.atan2(math.tan(sat_lon-fss_lon),
                         math.sin(-fss_lat))
    if azimuth < 0: azimuth += 2*math.pi

  return math.degrees(azimuth)