From 2b51d10b692a10a6c9a5ff060593ae9e2adf7c46 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Wed, 9 Oct 2024 02:04:54 -0300 Subject: [PATCH 1/6] BUG: fix custom atmosphere max_expected_height --- rocketpy/environment/environment.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rocketpy/environment/environment.py b/rocketpy/environment/environment.py index 4c2c61263..af07f1026 100644 --- a/rocketpy/environment/environment.py +++ b/rocketpy/environment/environment.py @@ -418,7 +418,7 @@ def __initialize_elevation_and_max_height(self, elevation, max_expected_height): """Saves the elevation and the maximum expected height.""" self.elevation = elevation self.set_elevation(elevation) - self._max_expected_height = max_expected_height + self.max_expected_height = max_expected_height def __initialize_date(self, date, timezone): """Saves the date and configure timezone.""" @@ -1390,7 +1390,7 @@ def process_custom_atmosphere( None """ # Initialize an estimate of the maximum expected atmospheric model height - max_expected_height = 1000 + max_expected_height = self.max_expected_height or 1000 # Save pressure profile if pressure is None: From 6fe9b7c231cf1c1371e576bb7a7f3beef6b0ea54 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Wed, 9 Oct 2024 02:04:54 -0300 Subject: [PATCH 2/6] BUG: fix custom atmosphere max_expected_height --- rocketpy/environment/environment.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rocketpy/environment/environment.py b/rocketpy/environment/environment.py index 4c2c61263..af07f1026 100644 --- a/rocketpy/environment/environment.py +++ b/rocketpy/environment/environment.py @@ -418,7 +418,7 @@ def __initialize_elevation_and_max_height(self, elevation, max_expected_height): """Saves the elevation and the maximum expected height.""" self.elevation = elevation self.set_elevation(elevation) - self._max_expected_height = max_expected_height + self.max_expected_height = max_expected_height def __initialize_date(self, date, timezone): """Saves the date and configure timezone.""" @@ -1390,7 +1390,7 @@ def process_custom_atmosphere( None """ # Initialize an estimate of the maximum expected atmospheric model height - max_expected_height = 1000 + max_expected_height = self.max_expected_height or 1000 # Save pressure profile if pressure is None: From 20dd98aeeb7f48a230a500a1085cd457c3cfbe4c Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Wed, 9 Oct 2024 02:04:54 -0300 Subject: [PATCH 3/6] BUG: fix custom atmosphere max_expected_height --- rocketpy/environment/environment.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rocketpy/environment/environment.py b/rocketpy/environment/environment.py index 4c2c61263..af07f1026 100644 --- a/rocketpy/environment/environment.py +++ b/rocketpy/environment/environment.py @@ -418,7 +418,7 @@ def __initialize_elevation_and_max_height(self, elevation, max_expected_height): """Saves the elevation and the maximum expected height.""" self.elevation = elevation self.set_elevation(elevation) - self._max_expected_height = max_expected_height + self.max_expected_height = max_expected_height def __initialize_date(self, date, timezone): """Saves the date and configure timezone.""" @@ -1390,7 +1390,7 @@ def process_custom_atmosphere( None """ # Initialize an estimate of the maximum expected atmospheric model height - max_expected_height = 1000 + max_expected_height = self.max_expected_height or 1000 # Save pressure profile if pressure is None: From 5093a7043536b3a3c76dcdd447a3b68c92388b94 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Wed, 9 Oct 2024 02:04:54 -0300 Subject: [PATCH 4/6] BUG: fix custom atmosphere max_expected_height --- rocketpy/environment/environment.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rocketpy/environment/environment.py b/rocketpy/environment/environment.py index 39ce18532..fd9a37410 100644 --- a/rocketpy/environment/environment.py +++ b/rocketpy/environment/environment.py @@ -419,7 +419,7 @@ def __initialize_elevation_and_max_height(self, elevation, max_expected_height): """Saves the elevation and the maximum expected height.""" self.elevation = elevation self.set_elevation(elevation) - self._max_expected_height = max_expected_height + self.max_expected_height = max_expected_height def __initialize_date(self, date, timezone): """Saves the date and configure timezone.""" @@ -1411,7 +1411,7 @@ def process_custom_atmosphere( None """ # Initialize an estimate of the maximum expected atmospheric model height - max_expected_height = 1000 + max_expected_height = self.max_expected_height or 1000 # Save pressure profile if pressure is None: From e8447061b119ef729d7a16e68b19f6458cedc065 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Wed, 9 Oct 2024 02:27:10 -0300 Subject: [PATCH 5/6] MNT: skip setter validation for the environment attribute --- rocketpy/environment/environment.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/rocketpy/environment/environment.py b/rocketpy/environment/environment.py index af07f1026..5cef60b21 100644 --- a/rocketpy/environment/environment.py +++ b/rocketpy/environment/environment.py @@ -418,7 +418,7 @@ def __initialize_elevation_and_max_height(self, elevation, max_expected_height): """Saves the elevation and the maximum expected height.""" self.elevation = elevation self.set_elevation(elevation) - self.max_expected_height = max_expected_height + self._max_expected_height = max_expected_height def __initialize_date(self, date, timezone): """Saves the date and configure timezone.""" @@ -1313,7 +1313,7 @@ def process_standard_atmosphere(self): self.__set_wind_speed_function(0) # 80k meters is the limit of the standard atmosphere - self.max_expected_height = 80000 + self._max_expected_height = 80000 def process_custom_atmosphere( self, pressure=None, temperature=None, wind_u=0, wind_v=0 @@ -1434,7 +1434,7 @@ def wind_heading_func(h): # TODO: create another custom reset for heading self.__reset_wind_direction_function() self.__reset_wind_speed_function() - self.max_expected_height = max_expected_height + self._max_expected_height = max_expected_height def process_windy_atmosphere( self, model="ECMWF" @@ -1509,7 +1509,7 @@ def process_windy_atmosphere( self.__set_wind_speed_function(data_array[:, (1, 7)]) # Save maximum expected height - self.max_expected_height = max(altitude_array[0], altitude_array[-1]) + self._max_expected_height = max(altitude_array[0], altitude_array[-1]) # Get elevation data from file self.elevation = float(response["header"]["elevation"]) @@ -1647,7 +1647,7 @@ def process_wyoming_sounding(self, file): # pylint: disable=too-many-statements ) # Save maximum expected height - self.max_expected_height = data_array[-1, 1] + self._max_expected_height = data_array[-1, 1] def process_noaaruc_sounding(self, file): # pylint: disable=too-many-statements """Import and process the upper air sounding data from `NOAA @@ -1899,7 +1899,7 @@ def process_forecast_reanalysis( self.__set_wind_speed_function(data_array[:, (1, 7)]) # Save maximum expected height - self.max_expected_height = max(height[0], height[-1]) + self._max_expected_height = max(height[0], height[-1]) # Get elevation data from file if dictionary["surface_geopotential_height"] is not None: @@ -2244,7 +2244,7 @@ def select_ensemble_member(self, member=0): self.__set_wind_speed_function(data_array[:, (1, 7)]) # Save other attributes - self.max_expected_height = max(height[0], height[-1]) + self._max_expected_height = max(height[0], height[-1]) self.ensemble_member = member # Update air density, speed of sound and dynamic viscosity From 7ce1cad005b4afb99d19843896a6369fdaac354a Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Wed, 9 Oct 2024 02:28:15 -0300 Subject: [PATCH 6/6] DEV: updates CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dae262128..1ff387254 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ Attention: The newest changes should be on top --> ### Fixed +- BUG: Fix Environment.max_expected_height for custom atmosphere [#707](https://github.com/RocketPy-Team/RocketPy/pull/707) - BUG: Initialize _Controller Init Parameters [#703](https://github.com/RocketPy-Team/RocketPy/pull/703) - BUG: Rail Buttons Not Accepted in Add Surfaces [#701](https://github.com/RocketPy-Team/RocketPy/pull/701) - BUG: Vector encoding breaks MonteCarlo export. [#704](https://github.com/RocketPy-Team/RocketPy/pull/704)