File: test_gabbard.py

package info (click to toggle)
poliastro 0.17.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 7,136 kB
  • sloc: python: 17,039; makefile: 172
file content (233 lines) | stat: -rw-r--r-- 6,235 bytes parent folder | download
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
import pytest
from astropy import units as u
from matplotlib import pyplot as plt

from poliastro.bodies import Earth
from poliastro.examples import iss
from poliastro.plotting.gabbard import GabbardPlotter
from poliastro.twobody import Orbit


def test_axes_labels_and_title():
    ax = plt.gca()
    gbp = GabbardPlotter(ax=ax)
    ss = iss
    gbp.plot_orbits([ss])

    assert ax.get_xlabel() == "Period (min)"
    assert ax.get_ylabel() == "Altitude (km)"


def test_legend():
    ax = plt.gca()
    gbp = GabbardPlotter(ax=ax)
    ss = iss
    gbp.plot_orbits([ss], label="ISS")
    legend = plt.gca().get_legend()

    ss.epoch.out_subfmt = "date_hm"
    label = f"{ss.epoch.iso} (ISS)"

    assert legend.get_title().get_text() == label


@pytest.mark.mpl_image_compare
def test_static_gabbard_plotting():
    fig, ax = plt.subplots()
    plotter = GabbardPlotter(ax=ax)
    plotter.plot_orbits(debris_orbits_list, label="COSMOS 1408 DEB")

    return fig


@pytest.mark.parametrize(
    "dark, expected_color",
    [(True, (0.0, 0.0, 0.0, 1.0)), (False, (1.0, 1.0, 1.0, 1))],
)
def test_dark_mode_plots_dark_plot(dark, expected_color):
    gbp = GabbardPlotter(dark=dark)
    assert gbp._ax.get_facecolor() == expected_color


debris_orbits_list = []

debris_orbits_list.append(
    Orbit.from_classical(
        attractor=Earth,
        a=6828.193338988509 * u.km,
        ecc=0.0062140354170737815 * u.one,
        inc=82.69387440482602 * u.deg,
        raan=37.33894561668519 * u.deg,
        argp=200.62393574484153 * u.deg,
        nu=-117.55203086408737 * u.deg,
    )
)

debris_orbits_list.append(
    Orbit.from_classical(
        attractor=Earth,
        a=6821.922877133498 * u.km,
        ecc=0.0023241234515223646 * u.one,
        inc=82.65684766470754 * u.deg,
        raan=36.3401421924121 * u.deg,
        argp=125.29597430617513 * u.deg,
        nu=-151.64963315597913 * u.deg,
    )
)

debris_orbits_list.append(
    Orbit.from_classical(
        attractor=Earth,
        a=6836.825166360441 * u.km,
        ecc=0.004635589373624103 * u.one,
        inc=82.69764910622918 * u.deg,
        raan=36.757861621556614 * u.deg,
        argp=44.219092511353594 * u.deg,
        nu=133.63349740950568 * u.deg,
    )
)

debris_orbits_list.append(
    Orbit.from_classical(
        attractor=Earth,
        a=7117.414488497581 * u.km,
        ecc=0.04540691741651712 * u.one,
        inc=83.07451144780156 * u.deg,
        raan=52.87995597314799 * u.deg,
        argp=190.63045916106168 * u.deg,
        nu=41.306044841636634 * u.deg,
    )
)

debris_orbits_list.append(
    Orbit.from_classical(
        attractor=Earth,
        a=6917.149445506758 * u.km,
        ecc=0.014811336719791061 * u.one,
        inc=82.6218902660939 * u.deg,
        raan=39.58175296436131 * u.deg,
        argp=106.71561062464224 * u.deg,
        nu=-62.66454424955413 * u.deg,
    )
)

debris_orbits_list.append(
    Orbit.from_classical(
        attractor=Earth,
        a=6910.923895002164 * u.km,
        ecc=0.016808366674815105 * u.one,
        inc=82.35369942440258 * u.deg,
        raan=35.60505049154483 * u.deg,
        argp=184.42211913686066 * u.deg,
        nu=45.95875318418421 * u.deg,
    )
)

debris_orbits_list.append(
    Orbit.from_classical(
        attractor=Earth,
        a=6677.880585440615 * u.km,
        ecc=0.0014802577911015675 * u.one,
        inc=82.17121703030627 * u.deg,
        raan=25.699484007134643 * u.deg,
        argp=204.23415215165576 * u.deg,
        nu=-24.40253410856961 * u.deg,
    )
)

debris_orbits_list.append(
    Orbit.from_classical(
        attractor=Earth,
        a=6961.126175813936 * u.km,
        ecc=0.025433234625720075 * u.one,
        inc=82.56625734212793 * u.deg,
        raan=40.073969157354824 * u.deg,
        argp=188.205744852877 * u.deg,
        nu=152.76011672297756 * u.deg,
    )
)

debris_orbits_list.append(
    Orbit.from_classical(
        attractor=Earth,
        a=6883.993995695628 * u.km,
        ecc=0.008022496129527943 * u.one,
        inc=83.2763699331857 * u.deg,
        raan=47.55215625476586 * u.deg,
        argp=114.15854367766484 * u.deg,
        nu=-31.793479924939778 * u.deg,
    )
)

debris_orbits_list.append(
    Orbit.from_classical(
        attractor=Earth,
        a=6798.16535966413 * u.km,
        ecc=0.006497072501655168 * u.one,
        inc=82.61152388022165 * u.deg,
        raan=34.66534775192231 * u.deg,
        argp=349.72219499585407 * u.deg,
        nu=90.16499314429353 * u.deg,
    )
)

debris_orbits_list.append(
    Orbit.from_classical(
        attractor=Earth,
        a=6854.939735394475 * u.km,
        ecc=0.006324699282668879 * u.one,
        inc=82.67294675705102 * u.deg,
        raan=37.411303678153935 * u.deg,
        argp=69.71516857133007 * u.deg,
        nu=-29.51423158409656 * u.deg,
    )
)
debris_orbits_list.append(
    Orbit.from_classical(
        attractor=Earth,
        a=6884.147529089194 * u.km,
        ecc=0.01552728578907267 * u.one,
        inc=82.4114164903979 * u.deg,
        raan=35.234082427651664 * u.deg,
        argp=186.60344739193755 * u.deg,
        nu=-146.9445890288543 * u.deg,
    )
)
debris_orbits_list.append(
    Orbit.from_classical(
        attractor=Earth,
        a=6846.946980540078 * u.km,
        ecc=0.0029371405696242913 * u.one,
        inc=82.6314212152875 * u.deg,
        raan=36.88448947562918 * u.deg,
        argp=134.53438085198738 * u.deg,
        nu=-69.91109773157386 * u.deg,
    )
)
debris_orbits_list.append(
    Orbit.from_classical(
        attractor=Earth,
        a=6914.901161035591 * u.km,
        ecc=0.010664583104155329 * u.one,
        inc=82.31703307692484 * u.deg,
        raan=34.654644407052835 * u.deg,
        argp=144.83292617925179 * u.deg,
        nu=-133.54025144695484 * u.deg,
    )
)
debris_orbits_list.append(
    Orbit.from_classical(
        attractor=Earth,
        a=7040.971575280624 * u.km,
        ecc=0.0333018067425175 * u.one,
        inc=82.50417227979605 * u.deg,
        raan=44.11015739081946 * u.deg,
        argp=133.5425169343891 * u.deg,
        nu=-42.74160359135228 * u.deg,
    )
)
"""Orbit List of COSMOS 1408 Debris Orbits Example

COSMOS 1408 Debris Data Taken from https://celestrak.com/NORAD/

"""