In this seminar, we will try to obtain the coordinates for several solar system objects and plot them in polar coordinates.
import numpy as np
from matplotlib import pylab as plt
from mpl_toolkits.basemap import Basemap
import ephem
First, we set the observer coordinates and time. The simplest way to set the time in ephem, is to use Greenwich mean time.
NHAO = ephem.Observer()
NHAO.lon = "134.3356"
NHAO.lat = "35.025"
NHAO.date= "2019/06/26 7:00"
SUN = ephem.Sun()
SUN.compute(NHAO)
print("Declination: ", float(SUN.dec)/np.pi*180.) ## (赤緯)
print("Right ascension: ", float(SUN.ra)/np.pi*180.) ## (赤経)
print("Elevation ", float(SUN.alt)/np.pi*180.)
print("Azimuth: ", float(SUN.az)/np.pi*180.)
ephem._libastro.builtin_planets()
NAMES = ephem._libastro.builtin_planets()[:10]
getattr(ephem, NAMES[0][2])
TEN_CO = []
for i in NAMES:
OBJ = getattr(ephem, i[2])()
OBJ.compute(NHAO)
ALT = float(OBJ.alt)/np.pi*180.
AZ = float(OBJ.az)/np.pi*180.
TEN_CO.append([AZ,ALT])
Let`s print the computed horizontal coordinates (Az, Alt).
TEN_CO
NHAO.date.datetime()
Let's plot the coordinates onto a cartesian map.
plt.figure(figsize = (12,9))
n = 0
for i in TEN_CO:
plt.plot(i[0],i[1], "o")
plt.text(i[0],i[1], NAMES[n][2])
n+=1 ### n = n+1
plt.xlabel("Azimuth [deg]")
plt.ylabel("Elevation [deg]")
plt.grid(True)
plt.show()
Following, we will plot the data points onto a 2D projection of a 3D sphere. Therefore, we can define a Basemap object, which requires the projection.
def sphere_plot(COORDINATES, NAMELIST, lon_0 = 0, lat_0 = 90):
plt.figure(figsize = (10,10))
SPHERE = Basemap(projection='ortho',
lon_0=lon_0,
lat_0=lat_0)
### create meridians and geodesics
SPHERE.drawmeridians(np.arange(0.,420.,30.))
SPHERE.drawparallels(np.arange(-90.,120.,15.))
horizon = SPHERE.drawparallels([0], color = "r", linewidth=4)
n = 0
for i in COORDINATES:
j0,j1 = SPHERE(i[0],i[1])
plt.plot(j0,j1, "o")
plt.text(j0,j1, NAMELIST[n][2])
n+=1 ### n = n+1
plt.show()
sphere_plot(TEN_CO,NAMES)
sphere_plot(TEN_CO,NAMES, -30,20)