Skip to content

Commit ee1c1a4

Browse files
authored
Implement a standard atmosphere up to 100km altitude, raising the ceiling from the current 71km.
1 parent 9a5b4bd commit ee1c1a4

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

mslib/utils/thermolib.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,17 @@ def omega_to_w(omega, p, t):
126126

127127
# Values according to the 1976 U.S. Standard atmosphere [NOAA1976]_.
128128
# List of tuples (height, temperature, pressure, temperature gradient)
129+
# Added a value for 100km roughly based on CIRA
129130
_STANDARD_ATMOSPHERE = [
130131
(0 * units.km, 288.15 * units.K, 101325 * units.Pa, 0.0065 * units.K / units.m),
131132
(11 * units.km, 216.65 * units.K, 22632.1 * units.Pa, 0 * units.K / units.m),
132133
(20 * units.km, 216.65 * units.K, 5474.89 * units.Pa, -0.001 * units.K / units.m),
133134
(32 * units.km, 228.65 * units.K, 868.019 * units.Pa, -0.0028 * units.K / units.m),
134135
(47 * units.km, 270.65 * units.K, 110.906 * units.Pa, 0 * units.K / units.m),
135136
(51 * units.km, 270.65 * units.K, 66.9389 * units.Pa, 0.0028 * units.K / units.m),
136-
(71 * units.km, 214.65 * units.K, 3.95642 * units.Pa, np.nan * units.K / units.m)
137+
(71 * units.km, 214.65 * units.K, 3.95642 * units.Pa, 0.002 * units.K / units.m),
138+
(84.852 * units.km, 186.95 * units.K, 0.3734 * units.Pa, 0 * units.K / units.m),
139+
(100 * units.km, 186.95 * units.K, 0.025641 * units.Pa, np.nan * units.K / units.m),
137140
]
138141
_HEIGHT, _TEMPERATURE, _PRESSURE, _TEMPERATURE_GRADIENT = 0, 1, 2, 3
139142

@@ -235,8 +238,8 @@ def pressure2flightlevel(pressure):
235238
z[indices] = z0 - (Rd * t0) / g * np.log(pressure[indices] / p0)
236239

237240
if np.isnan(z).any():
238-
raise ValueError("flight level to pressure conversion not "
239-
"implemented for z > 71km")
241+
raise ValueError("pressure to flight level conversion not "
242+
"implemented for p < 0.025641 Pa")
240243

241244
return z if is_array else z[0]
242245

@@ -262,7 +265,7 @@ def isa_temperature(height):
262265
return t0 - gamma * (height - z0)
263266

264267
raise ValueError("ISA temperature from flight level not "
265-
"implemented for z > 71km")
268+
"implemented for z > 100 km")
266269

267270

268271
def convert_pressure_to_vertical_axis_measure(vertical_axis, pressure):

tests/_test_utils/test_thermolib.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@
3333

3434

3535
def test_flightlevel2pressure2flightlevel():
36-
fs = (np.arange(1, 71000, 1000.) * units.m).to(units.hft)
36+
fs = (np.arange(1, 95000, 1000.) * units.m).to(units.hft)
3737
ps = thermolib.flightlevel2pressure(fs)
3838
fs_p = thermolib.pressure2flightlevel(ps).magnitude
3939
assert fs.magnitude == pytest.approx(fs_p)
4040

4141

4242
def test_pressure2flightlevel2pressure():
43-
ps = np.arange(5, 105000, 1.)[::-1] * units.Pa
43+
ps = np.arange(1, 105000, 1.)[::-1] * units.Pa
4444
fs = thermolib.pressure2flightlevel(ps)
4545
ps_p = thermolib.flightlevel2pressure(fs).magnitude
4646
assert ps.magnitude == pytest.approx(ps_p)
@@ -54,7 +54,7 @@ def test_flightlevel2pressure():
5454
assert thermolib.flightlevel2pressure(1626.8966 * units.hft).magnitude == pytest.approx(80)
5555
assert thermolib.flightlevel2pressure(1804.2727 * units.hft).magnitude == pytest.approx(40)
5656
with pytest.raises(ValueError):
57-
thermolib.flightlevel2pressure(72000 * units.m)
57+
thermolib.flightlevel2pressure(102000 * units.m)
5858

5959

6060
def test_pressure2flightlevel():
@@ -67,7 +67,7 @@ def test_pressure2flightlevel():
6767
assert thermolib.pressure2flightlevel(80 * units.Pa).magnitude == pytest.approx(1626.8966)
6868
assert thermolib.pressure2flightlevel(40 * units.Pa).magnitude == pytest.approx(1804.2727)
6969
with pytest.raises(ValueError):
70-
thermolib.pressure2flightlevel(3.9 * units.Pa)
70+
thermolib.pressure2flightlevel(0.02 * units.Pa)
7171

7272

7373
def test_isa_temperature():
@@ -81,12 +81,14 @@ def test_isa_temperature():
8181
assert thermolib.isa_temperature(800 * units.hft).magnitude == pytest.approx(221.034)
8282
assert thermolib.isa_temperature(1000 * units.hft).magnitude == pytest.approx(227.13)
8383
with pytest.raises(ValueError):
84-
thermolib.isa_temperature(71001 * units.m)
84+
thermolib.isa_temperature(100001 * units.m)
8585
assert thermolib.isa_temperature(11000 * units.m).magnitude == pytest.approx(216.65)
8686
assert thermolib.isa_temperature(20000 * units.m).magnitude == pytest.approx(216.65)
8787
assert thermolib.isa_temperature(32000 * units.m).magnitude == pytest.approx(228.65)
8888
assert thermolib.isa_temperature(47000 * units.m).magnitude == pytest.approx(270.65)
8989
assert thermolib.isa_temperature(51000 * units.m).magnitude == pytest.approx(270.65)
90+
assert thermolib.isa_temperature(71000 * units.m).magnitude == pytest.approx(214.65)
91+
assert thermolib.isa_temperature(84852 * units.m).magnitude == pytest.approx(186.95)
9092

9193

9294
class TestConverter:

0 commit comments

Comments
 (0)