Orbite

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

from skyfield.

api import Loader, EarthSatellite


from skyfield.timelib import Time
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

def makecubelimits(axis, centers=(0.0,0.0,0.0), hw=(6378+400)):


lims = ax.get_xlim(), ax.get_ylim(), ax.get_zlim()
if centers == None:
centers = [0.5*sum(pair) for pair in lims]
if hw == None:
widths = [pair[1] - pair[0] for pair in lims]
hw = 0.5*max(widths)
ax.set_xlim(centers[0]-hw, centers[0]+hw)
ax.set_ylim(centers[1]-hw, centers[1]+hw)
ax.set_zlim(centers[2]-hw, centers[2]+hw)
print("hw was None so set to:", hw)
else:
try:
hwx, hwy, hwz = hw
print("ok hw requested: ", hwx, hwy, hwz)
ax.set_xlim(centers[0]-hwx, centers[0]+hwx)
ax.set_ylim(centers[1]-hwy, centers[1]+hwy)
ax.set_zlim(centers[2]-hwz, centers[2]+hwz)
except:
print("nope hw requested: ", hw)
ax.set_xlim(centers[0]-hw, centers[0]+hw)
ax.set_ylim(centers[1]-hw, centers[1]+hw)
ax.set_zlim(centers[2]-hw, centers[2]+hw)

return centers, hw

deg2rad=np.pi/180.0
ans2sec=365.25*24*3600.0
jours2sec=24*3600.0
km2m=10**3
nombrejoursparmois=(31+28+31+30+31+30+31+31+30+31+30+31)/12.0

e=0.0005053
G=6.674*((jours2sec)**2)*10**(-11) #constante de gravitation en
m^3.kg^-1.jours^-2
M_terre= 6*10**24 #masse du corps central en kg
mu_terre = G*M_terre #m^3/jours^2

i=51.6403*deg2rad
a= (400.0 + 6378.0)*10**3 #demi-axe de l'orbite en m
t_0=320.81 #donne dans le two-lines element en jours
M_0=308.7017 #donner dans le two-lines element en degres
omega=51.4587*deg2rad
Omega=338.1474*deg2rad

T=np.sqrt((a**3)*4*(np.pi)**2/(mu_terre)) #en jours


n=2*np.pi/T #en rad/jours
#TLE de l'enonce
TLE = """1 25544U 98067A 18320.81254693 .00016717 00000-0 10270-3 0 9010
2 25544 51.6403 338.1474 0005053 051.4587 308.7017 15.53998777022241"""
L1, L2 = TLE.splitlines()

halfpi, pi, twopi = [f*np.pi for f in [0.5, 1, 2]]


degs, rads = 180/pi, pi/180

load = Loader('~/Documents/fishing/SkyData')
data = load('de421.bsp')
ts = load.timescale()

planets = load('de421.bsp')
earth = planets['earth']

Roadster = EarthSatellite(L1, L2)

print(Roadster.epoch.tt)
hours = np.arange(0, 3, 0.1)

fig = plt.figure(figsize=[12, 10]) # [10, 8]


ax = fig.add_subplot(1, 1, 1, projection='3d')

for i in [1,10,20,30]:

time = ts.utc(2018, 12, i, hours)

Rpos = Roadster.at(time).position.km
Rposecl = Roadster.at(time).ecliptic_position().km

re = 6378.
theta = np.linspace(0, twopi, 201)

cth, sth, zth = [f(theta) for f in [np.cos, np.sin, np.zeros_like]]


lon0 = re*np.vstack((cth, zth, sth))
lons = []
for phi in rads*np.arange(0, 180, 25):
cph, sph = [f(phi) for f in [np.cos, np.sin]]
lon = np.vstack((lon0[0]*cph - lon0[1]*sph,
lon0[1]*cph + lon0[0]*sph,
lon0[2]) )
lons.append(lon)

lat0 = re*np.vstack((cth, sth, zth))


lats = []
for phi in rads*np.arange(-90, 90, 25):
cph, sph = [f(phi) for f in [np.cos, np.sin]]
lat = re*np.vstack((cth*cph, sth*cph, zth+sph))
lats.append(lat)

if True:
x, y, z = Rpos
ax.plot(x, y, z)
sintheta=np.sqrt(1-z**2/a**2)
costheta=z/a
sinphi=x/(a*np.sqrt(1-z**2/a**2))
cosphi=y/(a*np.sqrt(1-z**2/a**2))

urx=sintheta*cosphi
ury=sinphi*sintheta
urz=costheta

uthetax=-cosphi*costheta
uthetay=-sinphi*costheta
uthetaz=sintheta

uphix= -sinphi
uphiy= cosphi
uphiz= np.zeros(len(uphix))
for k in [0,10,20]:

ax.quiver(x[k],y[k],z[k],1000000.0*urx[k],1000000.0*ury[k],1000000.0*urz[k],colo
r='r')

ax.quiver(x[k],y[k],z[k],2000.0*uthetax[k],2000.0*uthetay[k],2000.0*uthetaz[k],c
olor='b')

ax.quiver(x[k],y[k],z[k],2000000.0*uphix[k],2000000.0*uphiy[k],2000000.0*uphiz[k
],color='g')

for x, y, z in lons:
ax.plot(x, y, z, '--k')

for x, y, z in lats:
ax.plot(x, y, z, '--k')

plt.show()

You might also like