@@ -111,6 +111,10 @@ class Environment:
111
111
Environment.pressure : Function
112
112
Air pressure in Pa as a function of altitude. Can be accessed as regular
113
113
array, or called as a Function. See Function for more information.
114
+ Environment.barometric_height : Function
115
+ Geometric height above sea level in m as a function of pressure. Can be
116
+ accessed as regular array, or called as a Function. See Function for
117
+ more information.
114
118
Environment.temperature : Function
115
119
Air temperature in K as a function of altitude. Can be accessed as
116
120
regular array, or called as a Function. See Function for more
@@ -1315,6 +1319,8 @@ def process_standard_atmosphere(self):
1315
1319
1316
1320
# Save temperature, pressure and wind profiles
1317
1321
self .pressure = self .pressure_ISA
1322
+ self .barometric_height = self .barometric_height_ISA
1323
+
1318
1324
self .temperature = self .temperature_ISA
1319
1325
self .wind_direction = Function (
1320
1326
0 ,
@@ -1433,6 +1439,7 @@ def process_custom_atmosphere(
1433
1439
if pressure is None :
1434
1440
# Use standard atmosphere
1435
1441
self .pressure = self .pressure_ISA
1442
+ self .barometric_height = self .barometric_height_ISA
1436
1443
else :
1437
1444
# Use custom input
1438
1445
self .pressure = Function (
@@ -1441,6 +1448,11 @@ def process_custom_atmosphere(
1441
1448
outputs = "Pressure (Pa)" ,
1442
1449
interpolation = "linear" ,
1443
1450
)
1451
+ self .barometric_height = self .pressure .inverse_function ().set_discrete (
1452
+ 0 , max_expected_height , 100 , extrapolation = "constant"
1453
+ )
1454
+ self .barometric_height .set_inputs ("Pressure (Pa)" )
1455
+ self .barometric_height .set_outputs ("Height Above Sea Level (m)" )
1444
1456
# Check maximum height of custom pressure input
1445
1457
if not callable (self .pressure .source ):
1446
1458
max_expected_height = max (self .pressure [- 1 , 0 ], max_expected_height )
@@ -1605,6 +1617,15 @@ def process_windy_atmosphere(self, model="ECMWF"):
1605
1617
outputs = "Pressure (Pa)" ,
1606
1618
interpolation = "linear" ,
1607
1619
)
1620
+ # Linearly extrapolate pressure to ground level
1621
+ bar_height = data_array [:, (0 , 1 )]
1622
+ self .barometric_height = Function (
1623
+ bar_height ,
1624
+ inputs = "Pressure (Pa)" ,
1625
+ outputs = "Height Above Sea Level (m)" ,
1626
+ interpolation = "linear" ,
1627
+ extrapolation = "natural" ,
1628
+ )
1608
1629
self .temperature = Function (
1609
1630
data_array [:, (1 , 2 )],
1610
1631
inputs = "Height Above Sea Level (m)" ,
@@ -1732,6 +1753,15 @@ def process_wyoming_sounding(self, file):
1732
1753
outputs = "Pressure (Pa)" ,
1733
1754
interpolation = "linear" ,
1734
1755
)
1756
+ # Linearly extrapolate pressure to ground level
1757
+ bar_height = data_array [:, (0 , 1 )]
1758
+ self .barometric_height = Function (
1759
+ bar_height ,
1760
+ inputs = "Pressure (Pa)" ,
1761
+ outputs = "Height Above Sea Level (m)" ,
1762
+ interpolation = "linear" ,
1763
+ extrapolation = "natural" ,
1764
+ )
1735
1765
1736
1766
# Retrieve temperature from data array
1737
1767
data_array [:, 2 ] = data_array [:, 2 ] + 273.15 # Converts C to K
@@ -1845,6 +1875,7 @@ def process_noaaruc_sounding(self, file):
1845
1875
1846
1876
# Extract pressure as a function of height
1847
1877
pressure_array = []
1878
+ barometric_height_array = []
1848
1879
for line in lines :
1849
1880
# Split line into columns
1850
1881
columns = re .split (" +" , line )[1 :]
@@ -1858,7 +1889,9 @@ def process_noaaruc_sounding(self, file):
1858
1889
if max (columns ) != 99999 :
1859
1890
# Save value
1860
1891
pressure_array .append (columns )
1892
+ barometric_height_array .append ([columns [1 ], columns [0 ]])
1861
1893
pressure_array = np .array (pressure_array )
1894
+ barometric_height_array = np .array (barometric_height_array )
1862
1895
1863
1896
# Extract temperature as a function of height
1864
1897
temperature_array = []
@@ -1905,6 +1938,15 @@ def process_noaaruc_sounding(self, file):
1905
1938
outputs = "Pressure (Pa)" ,
1906
1939
interpolation = "linear" ,
1907
1940
)
1941
+ # Converts 10*hPa to Pa and save values
1942
+ barometric_height_array [:, 0 ] = 10 * barometric_height_array [:, 0 ]
1943
+ self .barometric_height = Function (
1944
+ barometric_height_array ,
1945
+ inputs = "Pressure (Pa)" ,
1946
+ outputs = "Height Above Sea Level (m)" ,
1947
+ interpolation = "linear" ,
1948
+ extrapolation = "natural" ,
1949
+ )
1908
1950
1909
1951
# Convert 10*C to K and save values
1910
1952
temperature_array [:, 1 ] = (
@@ -2274,6 +2316,15 @@ def process_forecast_reanalysis(self, file, dictionary):
2274
2316
outputs = "Pressure (Pa)" ,
2275
2317
interpolation = "linear" ,
2276
2318
)
2319
+ # Linearly extrapolate pressure to ground level
2320
+ bar_height = data_array [:, (0 , 1 )]
2321
+ self .barometric_height = Function (
2322
+ bar_height ,
2323
+ inputs = "Pressure (Pa)" ,
2324
+ outputs = "Height Above Sea Level (m)" ,
2325
+ interpolation = "linear" ,
2326
+ extrapolation = "natural" ,
2327
+ )
2277
2328
self .temperature = Function (
2278
2329
data_array [:, (1 , 2 )],
2279
2330
inputs = "Height Above Sea Level (m)" ,
@@ -2803,6 +2854,15 @@ def select_ensemble_member(self, member=0):
2803
2854
outputs = "Pressure (Pa)" ,
2804
2855
interpolation = "linear" ,
2805
2856
)
2857
+ # Linearly extrapolate pressure to ground level
2858
+ bar_height = data_array [:, (0 , 1 )]
2859
+ self .barometric_height = Function (
2860
+ bar_height ,
2861
+ inputs = "Pressure (Pa)" ,
2862
+ outputs = "Height Above Sea Level (m)" ,
2863
+ interpolation = "linear" ,
2864
+ extrapolation = "natural" ,
2865
+ )
2806
2866
self .temperature = Function (
2807
2867
data_array [:, (1 , 2 )],
2808
2868
inputs = "Height Above Sea Level (m)" ,
@@ -2965,7 +3025,12 @@ def pressure_function(h):
2965
3025
outputs = "Pressure (Pa)" ,
2966
3026
)
2967
3027
2968
- return None
3028
+ # Discretize Function to speed up the trajectory simulation.
3029
+ self .barometric_height_ISA = self .pressure_ISA .inverse_function ().set_discrete (
3030
+ pressure [- 1 ], pressure [0 ], 100 , extrapolation = "constant"
3031
+ )
3032
+ self .barometric_height_ISA .set_inputs ("Pressure (Pa)" )
3033
+ self .barometric_height_ISA .set_outputs ("Height Above Sea Level (m)" )
2969
3034
2970
3035
def calculate_density_profile (self ):
2971
3036
"""Compute the density of the atmosphere as a function of
0 commit comments