Debian Codegraph @

tests/tests_earth/tests_atmosphere/test_jacchia77.py

raw symbols SCIP
1 from astropyscip-python python astropy 7.2.0 astropy/__init__: import units as u
2 from astropy.tests.helperscip-python python astropy 7.2.0 `astropy.tests.helper`/__init__: import assert_quantity_allclose
3 import numpyscip-python python numpy 2.4.6 numpy/__init__: as np
4 import pytestscip-python python pytest 9.0.3 pytest/__init__:
5
6 from boinor.earth.atmosphere.jacchiascip-python python boinor 0.19.0 `boinor.earth.atmosphere.jacchia`/__init__: import Jacchia77
7
8 # SOLUTIONS DIRECTLY TAKEN FROM JACCHIA77 REPORT AND
9 # https://git.mysmce.com/ccmc-share/modelwebarchive/-/raw/main/Jacchi-Reference-Atmosphere/t1000.out
10 jacchia77_solutionsscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/jacchia77_solutions. = {
11 90
12 * u.kmscip-python python boinor 0.19.0 `astropy.units.core`/km#: [
13 188.0,
14 19.746,
15 19.170,
16 17.390,
17 17.824,
18 14.573,
19 -9.9000,
20 19.854,
21 28.91,
22 -0.732,
23 -5.465,
24 ],
25 100
26 * u.kmscip-python python boinor 0.19.0 `astropy.units.core`/km#: [
27 193.7,
28 18.971,
29 18.323,
30 17.665,
31 17.049,
32 13.798,
33 -9.9000,
34 19.081,
35 28.36,
36 -1.492,
37 -6.247,
38 ],
39 120
40 * u.kmscip-python python boinor 0.19.0 `astropy.units.core`/km#: [
41 350.5,
42 17.578,
43 16.637,
44 16.985,
45 15.172,
46 13.476,
47 -9.9000,
48 17.716,
49 26.15,
50 -2.599,
51 -7.646,
52 ],
53 150
54 * u.kmscip-python python boinor 0.19.0 `astropy.units.core`/km#: [
55 669.8,
56 16.476,
57 15.412,
58 16.238,
59 13.720,
60 13.184,
61 11.756,
62 16.698,
63 24.06,
64 -3.336,
65 -8.701,
66 ],
67 200
68 * u.kmscip-python python boinor 0.19.0 `astropy.units.core`/km#: [
69 884.4,
70 15.501,
71 14.315,
72 15.629,
73 12.381,
74 12.987,
75 11.392,
76 15.883,
77 21.40,
78 -4.030,
79 -9.566,
80 ],
81 300
82 * u.kmscip-python python boinor 0.19.0 `astropy.units.core`/km#: [
83 975.1,
84 14.049,
85 12.663,
86 14.781,
87 10.328,
88 12.760,
89 11.199,
90 14.862,
91 17.85,
92 -5.009,
93 -10.667,
94 ],
95 400
96 * u.kmscip-python python boinor 0.19.0 `astropy.units.core`/km#: [
97 991.7,
98 12.733,
99 11.161,
100 14.027,
101 8.455,
102 12.568,
103 11.129,
104 14.064,
105 16.18,
106 -5.800,
107 -11.507,
108 ],
109 500
110 * u.kmscip-python python boinor 0.19.0 `astropy.units.core`/km#: [
111 996.4,
112 11.472,
113 9.722,
114 13.306,
115 6.658,
116 12.387,
117 11.079,
118 13.363,
119 14.81,
120 -6.498,
121 -12.246,
122 ],
123 560
124 * u.kmscip-python python boinor 0.19.0 `astropy.units.core`/km#: [
125 997.64,
126 10.7357,
127 8.8803,
128 12.8850,
129 5.6083,
130 12.2814,
131 11.0517,
132 12.9892,
133 13.543,
134 -6.872,
135 -12.659,
136 ],
137 800
138 * u.kmscip-python python boinor 0.19.0 `astropy.units.core`/km#: [
139 999.33,
140 7.9200,
141 5.6641,
142 11.2766,
143 1.5933,
144 11.8788,
145 10.9493,
146 12.0147,
147 5.939,
148 -7.845,
149 -13.991,
150 ],
151 1000
152 * u.kmscip-python python boinor 0.19.0 `astropy.units.core`/km#: [
153 999.69,
154 5.7162,
155 3.1468,
156 10.0178,
157 -1.5493,
158 11.5638,
159 10.8698,
160 11.6540,
161 3.788,
162 -8.206,
163 -14.547,
164 ],
165 1500
166 * u.kmscip-python python boinor 0.19.0 `astropy.units.core`/km#: [
167 999.92,
168 0.6993,
169 -2.5839,
170 7.1525,
171 -8.7035,
172 10.8469,
173 10.6890,
174 11.0762,
175 2.776,
176 -8.783,
177 -15.260,
178 ],
179 2000
180 * u.kmscip-python python boinor 0.19.0 `astropy.units.core`/km#: [
181 999.97,
182 -3.7167,
183 -7.6281,
184 4.6303,
185 -9.9000,
186 10.2160,
187 10.5301,
188 10.7018,
189 1.986,
190 -9.158,
191 -15.780,
192 ],
193 2400
194 * u.kmscip-python python boinor 0.19.0 `astropy.units.core`/km#: [
195 999.98,
196 -6.8863,
197 -9.9000,
198 2.8201,
199 -9.9000,
200 9.7631,
201 10.4160,
202 10.5032,
203 1.553,
204 -9.357,
205 -16.148,
206 ],
207 }
208
209
210 @pytestscip-python python pytest 9.0.3 pytest/__init__:.mark.parametrize("z", jacchia77_solutionsscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/jacchia77_solutions..keysscip-python python python-stdlib 3.11 builtins/dict#keys().())
211 def test_jacchia77scip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_jacchia77().(zscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_jacchia77().(z)):
212 # Z, T, CN2, CO2, CO, CAr, CHe, CH, CM, WM)
213 expected_CN2 = jacchia77_solutionsscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/jacchia77_solutions.[zscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_jacchia77().(z)][1] << (u.mscip-python python boinor 0.19.0 `astropy.units.core`/km#**-3)
214 expected_CO2 = jacchia77_solutionsscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/jacchia77_solutions.[zscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_jacchia77().(z)][2] << (u.mscip-python python boinor 0.19.0 `astropy.units.core`/km#**-3)
215 expected_CO = jacchia77_solutionsscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/jacchia77_solutions.[zscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_jacchia77().(z)][3] << (u.mscip-python python boinor 0.19.0 `astropy.units.core`/km#**-3)
216 expected_CAr = jacchia77_solutionsscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/jacchia77_solutions.[zscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_jacchia77().(z)][4] << (u.mscip-python python boinor 0.19.0 `astropy.units.core`/km#**-3)
217 expected_CHe = jacchia77_solutionsscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/jacchia77_solutions.[zscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_jacchia77().(z)][5] << (u.mscip-python python boinor 0.19.0 `astropy.units.core`/km#**-3)
218 expected_CH = jacchia77_solutionsscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/jacchia77_solutions.[zscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_jacchia77().(z)][6] << (u.mscip-python python boinor 0.19.0 `astropy.units.core`/km#**-3)
219 expected_CM = jacchia77_solutionsscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/jacchia77_solutions.[zscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_jacchia77().(z)][7] << (u.mscip-python python boinor 0.19.0 `astropy.units.core`/km#**-3)
220 expected_WM = jacchia77_solutionsscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/jacchia77_solutions.[zscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_jacchia77().(z)][8] << (u.kgscip-python python boinor 0.19.0 `astropy.units.core`/km# / u.kmolscip-python python boinor 0.19.0 `astropy.units.core`/km#)
221
222 properties = Jacchia77(1000 * u.Kscip-python python boinor 0.19.0 `astropy.units.core`/rad#).altitude_profile(zscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_jacchia77().(z))
223
224 for i in rangescip-python python python-stdlib 3.11 builtins/range#(2, len(properties) - 1):
225 if properties[i].value > 1.26e-10:
226 properties[i] = np.log10(properties[i].value) * properties[i].unit
227 else:
228 properties[i] = -9.9 * properties[i].unit
229
230 Z, T, CN2, CO2, CO, CAr, CHe, CH, CM, WM = properties
231
232 assert_quantity_allclose(CN2, expected_CN2, rtol=1e-4)
233 assert_quantity_allclose(CO2, expected_CO2, rtol=1e-4)
234 assert_quantity_allclose(CO, expected_CO, rtol=1e-4)
235 assert_quantity_allclose(CAr, expected_CAr, rtol=1e-4)
236 assert_quantity_allclose(CHe, expected_CHe, rtol=1e-4)
237 assert_quantity_allclose(CH, expected_CH, rtol=1e-3)
238 assert_quantity_allclose(CM, expected_CM, rtol=1e-4)
239 assert_quantity_allclose(WM, expected_WM, rtol=1e-3)
240
241
242 @pytestscip-python python pytest 9.0.3 pytest/__init__:.mark.parametrize("z", jacchia77_solutionsscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/jacchia77_solutions..keysscip-python python python-stdlib 3.11 builtins/dict#keys().())
243 def test_tempertaurescip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_tempertaure().(zscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_tempertaure().(z)):
244 expected_T = jacchia77_solutionsscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/jacchia77_solutions.[zscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_tempertaure().(z)][0] * u.Kscip-python python boinor 0.19.0 `astropy.units.core`/rad#
245 T = Jacchia77(1000 * u.Kscip-python python boinor 0.19.0 `astropy.units.core`/rad#).temperature(zscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_tempertaure().(z))
246
247 assert_quantity_allclose(T, expected_T, rtol=1e-4)
248
249
250 @pytestscip-python python pytest 9.0.3 pytest/__init__:.mark.parametrize("z", jacchia77_solutionsscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/jacchia77_solutions..keysscip-python python python-stdlib 3.11 builtins/dict#keys().())
251 def test_pressurescip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_pressure().(zscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_pressure().(z)):
252 expected_p = jacchia77_solutionsscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/jacchia77_solutions.[zscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_pressure().(z)][9] * (u.Nscip-python python boinor 0.19.0 `astropy.units.core`/km# * u.mscip-python python boinor 0.19.0 `astropy.units.core`/km#**-2)
253 pressure = Jacchia77(1000 * u.Kscip-python python boinor 0.19.0 `astropy.units.core`/rad#).pressure(zscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_pressure().(z))
254 p = np.log10(pressure.value) * pressure.unit
255
256 assert_quantity_allclose(p, expected_p, rtol=1e-3)
257
258
259 @pytestscip-python python pytest 9.0.3 pytest/__init__:.mark.parametrize("z", jacchia77_solutionsscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/jacchia77_solutions..keysscip-python python python-stdlib 3.11 builtins/dict#keys().())
260 def test_densityscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_density().(zscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_density().(z)):
261 expected_rho = jacchia77_solutionsscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/jacchia77_solutions.[zscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_density().(z)][10] << (u.kgscip-python python boinor 0.19.0 `astropy.units.core`/km# / u.mscip-python python boinor 0.19.0 `astropy.units.core`/km#**3)
262 density = Jacchia77(1000 * u.Kscip-python python boinor 0.19.0 `astropy.units.core`/rad#).density(zscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_density().(z))
263 rho = np.log10(density.value) << density.unit
264
265 assert_quantity_allclose(rho, expected_rho, rtol=1e-2)
266
267
268 # @pytest.mark.parametrize("z", jacchia77_solutions.keys())
269 @pytestscip-python python pytest 9.0.3 pytest/__init__:.mark.xfail(
270 reason="This is basically just a template and need to be expanded later; fails on circleci but not locally!?"
271 )
272 def test_H_correctionscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_H_correction().(zscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_H_correction().(z)):
273 Jacchia77(1000 * u.Kscip-python python boinor 0.19.0 `astropy.units.core`/rad#)._H_correction(200)
274 # TODO: at the moment it is only checked whether the call does work (it didn't before)
275 # later one has to check the results as well
276
277
278 # @pytest.mark.parametrize("z", jacchia77_solutions.keys())
279 @pytestscip-python python pytest 9.0.3 pytest/__init__:.mark.xfail(
280 reason="This is basically just a template and need to be expanded later; fails on circleci but not locally!?"
281 )
282 def test_O_and_O2_correctionscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_O_and_O2_correction().(zscip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_O_and_O2_correction().(z)):
283 Jacchia77(1000 * u.Kscip-python python boinor 0.19.0 `astropy.units.core`/rad#)._O_and_O2_correction(200)
284 # TODO: at the moment it is only checked whether the call does work (it didn't before)
285 # later one has to check the results as well
286
287
288 def test_outside_upper_limit_coesa76scip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_outside_upper_limit_coesa76().():
289 with pytestscip-python python pytest 9.0.3 pytest/__init__:.raises(ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError#) as excinfo:
290 alt = 2501.0 * u.kmscip-python python boinor 0.19.0 `astropy.units.core`/km#
291 Texo = 1000 * u.Kscip-python python boinor 0.19.0 `astropy.units.core`/rad#
292 Jacchia77(Texo).altitude_profile(alt)
293 assert (
294 "ValueError: Jacchia77 has been implemented in range 90km - 2500km."
295 in excinfo.exconly()
296 )
297
298
299 def test_outside_lower_limit_coesa76scip-python python boinor 0.19.0 `tests.tests_earth.tests_atmosphere.test_jacchia77`/test_outside_lower_limit_coesa76().():
300 with pytestscip-python python pytest 9.0.3 pytest/__init__:.raises(ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError#) as excinfo:
301 alt = 89.0 * u.kmscip-python python boinor 0.19.0 `astropy.units.core`/km#
302 Texo = 1000 * u.Kscip-python python boinor 0.19.0 `astropy.units.core`/rad#
303 Jacchia77(Texo).altitude_profile(alt)
304 assert (
305 "ValueError: Jacchia77 has been implemented in range 90km - 2500km."
306 in excinfo.exconly()
307 )