#!/usr/bin/pyton3
# ====================================================================
# plot the earth's rotational (eastward) speed at latitudes +90 to -90
# ====================================================================
import math
import matplotlib.pyplot as plt
description = '''\
+----------------------------------------------+
| plot the earth's rotational (eastward) speed |
| at latitudes +90 to -90 each degree |
+----------------------------------------------+'''
print(description)
# ---- earth stats
circumference = 24901.0 # miles
period = 24.0 # days
# --------------------------------------------------------------------
# ---- speed at latitude
# --------------------------------------------------------------------
def speed(latitude,circumference,period):
equator_raidus = circumference / (math.pi*2.0)
latitude_raidus = equator_raidus * math.cos(math.radians(latitude))
latitude_circumference = 2.0 * math.pi * latitude_raidus
return latitude_circumference / period
# --------------------------------------------------------------------
# main
# --------------------------------------------------------------------
if __name__ == '__main__':
# ---- x,y values (latitude and speed)
x = []
y = []
step = 2
for lat in range(-90,90+step,step):
x.append(speed(lat,circumference,period))
y.append(lat)
print()
print(f'speed range is {min(x):.2f} to {max(x):.2f}')
print(f'latitude range is {y[0]} to {y[-1]}')
# ---- plot
plt.title('Earth\'s Rotation Speed at Latitude')
plt.xlabel('Speed')
plt.ylabel('Latitude')
plt.grid(True)
plt.plot(x,y,color='black',linewidth=1.0)
plt.show()