Repository navigation
Expand file tree
/
Copy pathpopulationPlots.py
More file actions
executable file
·149 lines (120 loc) · 5.35 KB
/
Copy pathpopulationPlots.py
File metadata and controls
executable file
·149 lines (120 loc) · 5.35 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
'''
Copyright (c) 2014, K. Kumar (me@kartikkumar.com)
All rights reserved.
'''
###################################################################################################
# Set up input deck
###################################################################################################
# Set path to TLE catalog file.
tleCatalogFilePath = ""
# Set number of lines per entry in TLE catalog (2 or 3).
tleEntryNumberOfLines = 3
# Set path to output directory.
outputPath = "."
# Set figure DPI.
figureDPI = 300
# Set font size for axes labels.
fontSize = 24
###################################################################################################
'''
DO NOT EDIT PARAMETERS BEYOND THIS POINT!!!
'''
###################################################################################################
# Set up modules and packages
###################################################################################################
from sgp4.earth_gravity import wgs72
from sgp4.io import twoline2rv
from sgp4.propagation import getgravconst
from matplotlib import rcParams
import matplotlib.pyplot as plt
import numpy as np
from twoBodyMethods import convertMeanMotionToSemiMajorAxis
###################################################################################################
###################################################################################################
# Read and store TLE catalog
###################################################################################################
# Read in catalog and store lines in list.
fileHandle = open(tleCatalogFilePath)
catalogLines = fileHandle.readlines()
fileHandle.close()
# Strip newline and return carriage characters.
for i in xrange(len(catalogLines)):
catalogLines[i] = catalogLines[i].strip('\r\n')
# Parse TLE entries and store debris objects.
debrisObjects = []
for tleEntry in xrange(0,len(catalogLines),tleEntryNumberOfLines):
debrisObjects.append(twoline2rv(catalogLines[tleEntry+1], catalogLines[tleEntry+2], wgs72))
# Sort list of debris objects based on inclination.
inclinationSortedObjects = sorted(debrisObjects, key=lambda x: x.inclo, reverse=False)
inclinations = []
raan = []
ecc = []
aop = []
for i in xrange(len(inclinationSortedObjects)-1):
inclinations.append(inclinationSortedObjects[i].inclo)
raan.append(inclinationSortedObjects[i].nodeo)
ecc.append(inclinationSortedObjects[i].ecco)
aop.append(inclinationSortedObjects[i].argpo)
###################################################################################################
###################################################################################################
# Generate plots
###################################################################################################
# Set font size for plot labels.
rcParams.update({'font.size': fontSize})
# Plot distribution of eccentricity [-] against semi-major axis [km].
figure = plt.figure()
axis = figure.add_subplot(111)
plt.xlabel("Semi-major axis [km]")
plt.ylabel("Eccentricity [-]")
plt.ticklabel_format(style='sci', axis='x', scilimits=(0,0))
plt.plot([convertMeanMotionToSemiMajorAxis(debrisObject.no/60.0, getgravconst('wgs72')[1]) \
for debrisObject in debrisObjects], \
[debrisObject.ecco for debrisObject in debrisObjects], \
marker='o', markersize=5, linestyle='none')
axis.set_xlim(xmax=5.0e4)
figure.set_tight_layout(True)
plt.savefig(outputPath + "/figure1_debrisPopulation_eccentricityVsSemiMajorAxis.pdf", \
dpi = figureDPI)
plt.close()
# Plot components of eccentricity vector [-].
figure = plt.figure()
axis = figure.add_subplot(111)
plt.xlabel("$e \cos{\omega}$ [-]")
plt.ylabel("$e \sin{\omega}$ [-]")
plt.plot(ecc*np.cos(aop),ecc*np.sin(aop), marker='o', markersize=5, linestyle='none')
plt.axis('equal')
axis.set_xlim(xmin=-1.0, xmax=1.0)
axis.set_ylim(ymin=-1.0, ymax=1.0)
figure.set_tight_layout(True)
plt.savefig(outputPath + "/figure2_debrisPopulation_eccentricityVector.pdf", dpi = figureDPI)
plt.savefig(outputPath + "/figure2_debrisPopulation_eccentricityVector.pdf", dpi = figureDPI)
plt.close()
# Plot distribution of inclination [deg] against semi-major axis [km].
figure = plt.figure()
axis = figure.add_subplot(111)
plt.xlabel("Semi-major axis [km]")
plt.ylabel("Inclination [deg]")
plt.ticklabel_format(style='sci', axis='x', scilimits=(0,0))
plt.plot([convertMeanMotionToSemiMajorAxis(debrisObject.no/60.0, getgravconst('wgs72')[1]) \
for debrisObject in debrisObjects], \
[np.rad2deg(debrisObject.inclo) for debrisObject in debrisObjects], \
marker='o', markersize=5, linestyle='none')
axis.set_xlim(xmax=5.0e4)
figure.set_tight_layout(True)
plt.savefig(outputPath + "/figure3_debrisPopulation_inclinationVsSemiMajorAxis.pdf", \
dpi = figureDPI)
plt.close()
# Plot components of inclination vector [deg].
figure = plt.figure()
axis = figure.add_subplot(111)
plt.xlabel("$i \cos{\Omega}$ [rad]")
plt.ylabel("$i \sin{\Omega}$ [rad]")
plt.plot(np.rad2deg(inclinations)*np.cos(raan),np.rad2deg(inclinations)*np.sin(raan), \
marker='o', markersize=5, linestyle='none')
plt.axis('equal')
axis.set_xlim(xmin=-180.0, xmax=180.0)
axis.set_ylim(ymin=-180.0, ymax=180.0)
figure.set_tight_layout(True)
plt.savefig(outputPath + "/figure4_debrisPopulation_inclinationVector.pdf", dpi = figureDPI)
plt.close()
###################################################################################################