Skip to content

Commit

Permalink
ENH: add use of natural extrapolation to barometric_height
Browse files Browse the repository at this point in the history
  • Loading branch information
MateusStano authored and Gui-FernandesBR committed Jan 20, 2024
1 parent e787b11 commit 0551317
Showing 1 changed file with 11 additions and 68 deletions.
79 changes: 11 additions & 68 deletions rocketpy/environment/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -1618,23 +1618,13 @@ def process_windy_atmosphere(self, model="ECMWF"):
interpolation="linear",
)
# Linearly extrapolate pressure to ground level
columns = data_array[:, (0, 1)]
pressure_ground = np.array(
[
[
columns[1][0]
+ (-columns[1][1] / (columns[0][1] - columns[1][1]))
* (columns[0][0] - columns[1][0]),
0,
]
]
)
bar_height = np.concatenate((pressure_ground, columns))
bar_height = data_array[:, (0, 1)]
self.barometric_height = Function(

Check warning on line 1622 in rocketpy/environment/environment.py

View check run for this annotation

Codecov / codecov/patch

rocketpy/environment/environment.py#L1621-L1622

Added lines #L1621 - L1622 were not covered by tests
bar_height,
inputs="Pressure (Pa)",
outputs="Height Above Sea Level (m)",
interpolation="linear",
extrapolation="natural",
)
self.temperature = Function(
data_array[:, (1, 2)],
Expand Down Expand Up @@ -1764,23 +1754,13 @@ def process_wyoming_sounding(self, file):
interpolation="linear",
)
# Linearly extrapolate pressure to ground level
columns = data_array[:, (0, 1)]
pressure_ground = np.array(
[
[
columns[1][0]
+ (-columns[1][1] / (columns[0][1] - columns[1][1]))
* (columns[0][0] - columns[1][0]),
0,
]
]
)
bar_height = np.concatenate((pressure_ground, columns))
bar_height = data_array[:, (0, 1)]
self.barometric_height = Function(
bar_height,
inputs="Pressure (Pa)",
outputs="Height Above Sea Level (m)",
interpolation="linear",
extrapolation="natural",
)

# Retrieve temperature from data array
Expand Down Expand Up @@ -1960,29 +1940,12 @@ def process_noaaruc_sounding(self, file):
)
# Converts 10*hPa to Pa and save values
barometric_height_array[:, 0] = 10 * barometric_height_array[:, 0]
# Linearly extrapolate pressure to ground level
pressure_ground = np.array(
[
[
barometric_height_array[1][0]
+ (
-barometric_height_array[1][1]
/ (
barometric_height_array[0][1]
- barometric_height_array[1][1]
)
)
* (barometric_height_array[0][0] - barometric_height_array[1][0]),
0,
]
]
)
bar_height = np.concatenate((pressure_ground, barometric_height_array))
self.barometric_height = Function(

Check warning on line 1943 in rocketpy/environment/environment.py

View check run for this annotation

Codecov / codecov/patch

rocketpy/environment/environment.py#L1942-L1943

Added lines #L1942 - L1943 were not covered by tests
bar_height,
barometric_height_array,
inputs="Pressure (Pa)",
outputs="Height Above Sea Level (m)",
interpolation="linear",
extrapolation="natural",
)

# Convert 10*C to K and save values
Expand Down Expand Up @@ -2354,23 +2317,13 @@ def process_forecast_reanalysis(self, file, dictionary):
interpolation="linear",
)
# Linearly extrapolate pressure to ground level
columns = data_array[:, (0, 1)]
pressure_ground = np.array(
[
[
columns[1][0]
+ (-columns[1][1] / (columns[0][1] - columns[1][1]))
* (columns[0][0] - columns[1][0]),
0,
]
]
)
bar_height = np.concatenate((pressure_ground, columns))
bar_height = data_array[:, (0, 1)]
self.barometric_height = Function(
bar_height,
inputs="Pressure (Pa)",
outputs="Height Above Sea Level (m)",
interpolation="linear",
extrapolation="natural",
)
self.temperature = Function(
data_array[:, (1, 2)],
Expand Down Expand Up @@ -2902,23 +2855,13 @@ def select_ensemble_member(self, member=0):
interpolation="linear",
)
# Linearly extrapolate pressure to ground level
columns = data_array[:, (0, 1)]
pressure_ground = np.array(
[
[
columns[1][0]
+ (-columns[1][1] / (columns[0][1] - columns[1][1]))
* (columns[0][0] - columns[1][0]),
0,
]
]
)
bar_height = np.concatenate((pressure_ground, columns))
bar_height = data_array[:, (0, 1)]
self.barometric_height = Function(

Check warning on line 2859 in rocketpy/environment/environment.py

View check run for this annotation

Codecov / codecov/patch

rocketpy/environment/environment.py#L2858-L2859

Added lines #L2858 - L2859 were not covered by tests
bar_height,
inputs="Pressure (Pa)",
outputs="Height Above Sea Level (m)",
interpolation="linearS",
interpolation="linear",
extrapolation="natural",
)
self.temperature = Function(
data_array[:, (1, 2)],
Expand Down

0 comments on commit 0551317

Please sign in to comment.