在python上绘制卫星轨道

问题描述

在对轨道运动使用 RK4 数值积分方法后,我试图绘制卫星绕地球和月球的轨道。但我不太清楚如何显示或创建图像。我恳请是否有人知道如何做到这一点。以下是绘图的代码部分;

from matplotlib import pyplot as plt

# We only plot the x,y components (view on the ecliptic plane)

x,y,v_x,v_y,t = Orbit(x_0,y_0,v_x0,v_y0,tmin,tmax,N)
kinetic_energy,potential_energy,total_energy = Energy(x,v_y)

# Set a dark background... since... space is dark
plt.style.use('dark_background')

# Create a figure and ax
fig,ax = plt.subplots(figsize=(12,8))

# Create a yellow circle that represents the Sun,add it to the ax
Earth_circ = plt.Circle((0.0,0.0),R_E,color='yellow',alpha=0.8)
ax.add_artist(Earth_circ)

# Plot the SSB movement
ax.plot(x,ls='solid',color='royalblue')

# Set some parameters for the plot,set an equal ratio,set a grid,and set
# the x and y limits
ax.set_aspect('equal')
ax.grid(True,linestyle='dashed',alpha=0.5)

# Set Axes limits to trajectory coordinate range,with some padding

xmin,xmax = min(x),max(x)
ymin,ymax = min(y),max(y)
dx,dy = xmax - xmin,ymax - ymin
PAD = 0.05
ax.set_xlim(xmin - PAD*dx,xmax + PAD*dx)
ax.set_ylim(ymin - PAD*dy,ymax + PAD*dy)

# Some labelling
ax.set_xlabel('X in Earths-Radius')
ax.set_ylabel('Y in Earths-Radius')

# Saving the figure in high quality
plt.tight_layout()

plt.savefig('orbit.png',dpi=300)
plt.show()

The image shows the plot that comes out.

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)