-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtoolUtilizationExample.py
More file actions
118 lines (98 loc) · 2.93 KB
/
toolUtilizationExample.py
File metadata and controls
118 lines (98 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env python
# coding: utf-8
# In[ ]:
import twoBodyTool
import numpy as np
from scipy.integrate import odeint
from twoBodyTool import F, sv2coe
# Defining initial value of position and velocity vector
x0 = -6045
y0 = -3490
z0 = 2500
vx0 = -3.457
vy0 = 6.618
vz0 = 2.533
# Defining period of the orbit in second and its interval
t = np.linspace(0,8200,1000)
# Defining the solution as the result of second ode integral
solution = odeint(F,[x0,y0,z0,vx0,vy0,vz0],t)
# Defining results as aa empty array for plotting
results = []
# Example of loop function of the results data set
for data in range(0,1000):
r_test = np.squeeze(solution[data:data+1,0:3])
v_test = np.squeeze(solution[data:data+1,3:6])
t1 = np.linspace(0,8200,data+1)
results.append(sv2coe(r_test, v_test))
# Final form of results in array
results = np.array(results)
# Example of how to plot the relationships between orbital elements and the period
import matplotlib.pyplot as plt
plt.figure(figsize=(11.69, 16.53 ), dpi=600)
x1 = results[:,0]
y1 = t1
plt.subplot(3, 2, 1)
plt.plot(y1,x1, '.')
plt.grid(True)
plt.xlabel("Time (in second)")
plt.ylabel("a (in km)")
plt.title("Variation of Semimajor Axis value for one orbital period")
plt.ylim((8785, 8790))
plt.xticks(np.arange(0, 8200, 1000))
x2 = results[:,1]
y2 = t1
plt.subplot(3, 2, 2)
plt.plot(y2,x2, '.', color='green')
plt.grid(True)
plt.xlabel("Time (in second)")
plt.ylabel("i")
plt.title("Variation of Inclination of orbit for one orbital period")
plt.ylim((150, 155))
plt.xticks(np.arange(0, 8200, 1000))
x3 = results[:,2]
y3 = t1
plt.subplot(3, 2, 3)
plt.plot(y3,x3, '.', color='yellow')
plt.grid(True)
plt.xlabel("Time (in second)")
plt.ylabel(r'$\Omega$' + ' (in degree)')
plt.title("Variation of Right ascencion of the ascending node for one orbital period")
plt.ylim((255, 256))
plt.xticks(np.arange(0, 8200, 1000))
x4 = results[:,3]
y4 = t1
plt.subplot(3, 2, 4)
plt.plot(y4,x4, '.', color='brown')
plt.grid(True)
plt.xlabel("Time (in second)")
plt.ylabel("e")
plt.title("Variation of Eccentricity for one orbital period")
plt.ylim((0, 0.3))
#plt.axis('equal')
plt.xticks(np.arange(0, 8200, 1000))
x5 = results[:,4]
y5 = t1
plt.subplot(3, 2, 5)
plt.plot(y5,x5, '.', color='orange')
plt.grid(True)
plt.xlabel("Time (in second)")
plt.ylabel(r'$\omega$' + ' (in degree)')
plt.title("Variation of Argument of perigee for one orbital period")
plt.ylim((10, 25))
plt.xticks(np.arange(0, 8200, 1000))
x6 = results[:,5]
y6 = t1
plt.subplot(3, 2, 6)
plt.plot(y6,x6, '.', color='pink')
plt.grid(True)
plt.xlabel("Time (in second)")
plt.ylabel(r'$\theta$' + ' (in degree)')
plt.title("Variation of True Anomaly for one orbital period")
#plt.ylim((10, 35))
plt.subplots_adjust(hspace=0.3, wspace=0.5)
plt.suptitle("Variations of Classical Orbital Elements over one orbital period", fontsize=18)
#plt.figure(figsize=(11.69, 16.53), dpi=600)
#plt.savefig('coeSimulation.pdf', dpi=600)
plt.savefig('coeSimulationNew.pdf')
plt.show()
# In[ ]: