From 9fe3a37c93069156ac45a6f241f5935832ddb21d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Alca=C3=B1iz?= Date: Fri, 14 Mar 2025 18:46:09 +0100 Subject: [PATCH 1/5] wind factor bug corrected the wind factor wasn't applied to the env.wind_velocity properties --- rocketpy/stochastic/stochastic_environment.py | 1 + 1 file changed, 1 insertion(+) diff --git a/rocketpy/stochastic/stochastic_environment.py b/rocketpy/stochastic/stochastic_environment.py index 58afe0fed..e0fc33eec 100644 --- a/rocketpy/stochastic/stochastic_environment.py +++ b/rocketpy/stochastic/stochastic_environment.py @@ -184,5 +184,6 @@ def create_object(self): # get original attribute value and multiply by factor attribute_name = f"_{key.replace('_factor', '')}" value = getattr(self, attribute_name) * value + key = f"{key.replace('_factor', '')}" setattr(self.obj, key, value) return self.obj From f6efa816442a740279ebaf880458049d28799b3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Alca=C3=B1iz?= Date: Sat, 15 Mar 2025 11:46:06 +0100 Subject: [PATCH 2/5] BUG: StochasticModel visualize attributes of a uniform distribution It showed the nominal and the standard deviation values and it doesn't make sense in a uniform distribution. In a np.random.uniform the 'nominal value' is the lower bound of the distribution, and the 'standard deviation' value is the upper bound. Now, a new condition has been added for the uniform distributions where the mean and semi range are calculated and showed. This way the visualize_attribute function will show the whole range where the random values are uniformly taken in --- rocketpy/stochastic/stochastic_model.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/rocketpy/stochastic/stochastic_model.py b/rocketpy/stochastic/stochastic_model.py index c82232fcb..e44e2613d 100644 --- a/rocketpy/stochastic/stochastic_model.py +++ b/rocketpy/stochastic/stochastic_model.py @@ -486,11 +486,20 @@ def format_attribute(attr, value): ) elif isinstance(value, tuple): nominal_value, std_dev, dist_func = value - return ( - f"\t{attr.ljust(max_str_length)} " - f"{nominal_value:.5f} ± " - f"{std_dev:.5f} ({dist_func.__name__})" - ) + if dist_func == np.random.uniform: + mean = (std_dev + nominal_value) / 2 + semi_range = (std_dev - nominal_value) / 2 + return ( + f"\t{attr.ljust(max_str_length)} " + f"{mean:.5f} ± " + f"{semi_range:.5f} ({dist_func.__name__})" + ) + else: + return ( + f"\t{attr.ljust(max_str_length)} " + f"{nominal_value:.5f} ± " + f"{std_dev:.5f} ({dist_func.__name__})" + ) return None attributes = {k: v for k, v in self.__dict__.items() if not k.startswith("_")} From 04337ab79982f28196d4b3950d36407cac6752b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Alca=C3=B1iz?= Date: Sat, 15 Mar 2025 16:11:27 +0100 Subject: [PATCH 3/5] variable names corrections --- rocketpy/stochastic/stochastic_model.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rocketpy/stochastic/stochastic_model.py b/rocketpy/stochastic/stochastic_model.py index e44e2613d..e833e01bf 100644 --- a/rocketpy/stochastic/stochastic_model.py +++ b/rocketpy/stochastic/stochastic_model.py @@ -488,11 +488,11 @@ def format_attribute(attr, value): nominal_value, std_dev, dist_func = value if dist_func == np.random.uniform: mean = (std_dev + nominal_value) / 2 - semi_range = (std_dev - nominal_value) / 2 + half_range = (std_dev - nominal_value) / 2 return ( f"\t{attr.ljust(max_str_length)} " f"{mean:.5f} ± " - f"{semi_range:.5f} ({dist_func.__name__})" + f"{half_range:.5f} ({dist_func.__name__})" ) else: return ( From 18f8323f39798ae90caada573660dcf63b113769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Alca=C3=B1iz?= Date: Sat, 15 Mar 2025 17:46:04 +0100 Subject: [PATCH 4/5] Corrections requested by the pylint test --- rocketpy/stochastic/stochastic_model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rocketpy/stochastic/stochastic_model.py b/rocketpy/stochastic/stochastic_model.py index e833e01bf..39fc478b7 100644 --- a/rocketpy/stochastic/stochastic_model.py +++ b/rocketpy/stochastic/stochastic_model.py @@ -486,7 +486,7 @@ def format_attribute(attr, value): ) elif isinstance(value, tuple): nominal_value, std_dev, dist_func = value - if dist_func == np.random.uniform: + if callable(dist_func) and dist_func.__name__ == "uniform": mean = (std_dev + nominal_value) / 2 half_range = (std_dev - nominal_value) / 2 return ( From 7c68241adf11fe0d8b08b8047eb3c9f511dd242d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Alca=C3=B1iz?= Date: Sat, 22 Mar 2025 10:06:13 +0100 Subject: [PATCH 5/5] ENH: more intuitive uniform distribution display in StochasticModel Co-authored-by: MateusStano <69485049+MateusStano@users.noreply.github.com> --- rocketpy/stochastic/stochastic_model.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/rocketpy/stochastic/stochastic_model.py b/rocketpy/stochastic/stochastic_model.py index b5be5293e..fe47a252a 100644 --- a/rocketpy/stochastic/stochastic_model.py +++ b/rocketpy/stochastic/stochastic_model.py @@ -515,12 +515,11 @@ def format_attribute(attr, value): elif isinstance(value, tuple): nominal_value, std_dev, dist_func = value if callable(dist_func) and dist_func.__name__ == "uniform": - mean = (std_dev + nominal_value) / 2 - half_range = (std_dev - nominal_value) / 2 + lower_bound = nominal_value + upper_bound = std_dev return ( f"\t{attr.ljust(max_str_length)} " - f"{mean:.5f} ± " - f"{half_range:.5f} ({dist_func.__name__})" + f"{lower_bound:.5f}, {upper_bound:.5f} ({dist_func.__name__})" ) else: return (