From f06a142d78ab27f276fbfeb061310cb2654721e8 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Fri, 8 Sep 2023 22:23:49 -0300 Subject: [PATCH 1/4] FIX: absolute value of the rail button forces --- rocketpy/Flight.py | 8 ++++---- rocketpy/Function.py | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/rocketpy/Flight.py b/rocketpy/Flight.py index e6f805267..4f04d3a80 100644 --- a/rocketpy/Flight.py +++ b/rocketpy/Flight.py @@ -2623,22 +2623,22 @@ def rail_button2_shear_force(self): @property def max_rail_button1_normal_force(self): """Maximum upper rail button normal force, in Newtons.""" - return self.rail_button1_normal_force.max + return self.rail_button1_normal_force.max_absolute @property def max_rail_button1_shear_force(self): """Maximum upper rail button shear force, in Newtons.""" - return self.rail_button1_shear_force.max + return self.rail_button1_shear_force.max_absolute @property def max_rail_button2_normal_force(self): """Maximum lower rail button normal force, in Newtons.""" - return self.rail_button2_normal_force.max + return self.rail_button2_normal_force.max_absolute @property def max_rail_button2_shear_force(self): """Maximum lower rail button shear force, in Newtons.""" - return self.rail_button2_shear_force.max + return self.rail_button2_shear_force.max_absolute @funcify_method( "Time (s)", "Horizontal Distance to Launch Point (m)", "spline", "constant" diff --git a/rocketpy/Function.py b/rocketpy/Function.py index 854ac1dd9..587cefbf3 100644 --- a/rocketpy/Function.py +++ b/rocketpy/Function.py @@ -264,6 +264,28 @@ def max(self): """ return self.y_array.max() + @cached_property + def min_absolute(self): + """Get the minimum absolute value of the Function y_array. + + Returns + ------- + minimum: float. + The minimum absolute value of the Function y_array. + """ + return np.abs(self.y_array).min() + + @cached_property + def max_absolute(self): + """Get the maximum absolute value of the Function y_array. + + Returns + ------- + maximum: float. + The maximum absolute value of the Function y_array. + """ + return np.abs(self.y_array).max() + def set_interpolation(self, method="spline"): """Set interpolation method and process data is method requires. From 279574f65c002c12e7686d36f8d1e292ef235194 Mon Sep 17 00:00:00 2001 From: Lint Action Date: Sat, 9 Sep 2023 01:30:02 +0000 Subject: [PATCH 2/4] Fix code style issues with Black --- rocketpy/Function.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rocketpy/Function.py b/rocketpy/Function.py index 587cefbf3..e5cab3621 100644 --- a/rocketpy/Function.py +++ b/rocketpy/Function.py @@ -272,7 +272,7 @@ def min_absolute(self): ------- minimum: float. The minimum absolute value of the Function y_array. - """ + """ return np.abs(self.y_array).min() @cached_property @@ -283,7 +283,7 @@ def max_absolute(self): ------- maximum: float. The maximum absolute value of the Function y_array. - """ + """ return np.abs(self.y_array).max() def set_interpolation(self, method="spline"): From b3a59844c54536a1bf3f8771e6f576e972074690 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Fri, 15 Sep 2023 17:06:22 -0300 Subject: [PATCH 3/4] MAINT: drop Function.max_absolute properties --- rocketpy/Flight.py | 8 ++++---- rocketpy/Function.py | 22 ---------------------- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/rocketpy/Flight.py b/rocketpy/Flight.py index 4f04d3a80..fc66eac8b 100644 --- a/rocketpy/Flight.py +++ b/rocketpy/Flight.py @@ -2623,22 +2623,22 @@ def rail_button2_shear_force(self): @property def max_rail_button1_normal_force(self): """Maximum upper rail button normal force, in Newtons.""" - return self.rail_button1_normal_force.max_absolute + return np.abs(self.rail_button1_normal_force).max() @property def max_rail_button1_shear_force(self): """Maximum upper rail button shear force, in Newtons.""" - return self.rail_button1_shear_force.max_absolute + return np.abs(self.rail_button1_shear_force).max() @property def max_rail_button2_normal_force(self): """Maximum lower rail button normal force, in Newtons.""" - return self.rail_button2_normal_force.max_absolute + return np.abs(self.rail_button2_normal_force).max() @property def max_rail_button2_shear_force(self): """Maximum lower rail button shear force, in Newtons.""" - return self.rail_button2_shear_force.max_absolute + return np.abs(self.rail_button2_shear_force).max() @funcify_method( "Time (s)", "Horizontal Distance to Launch Point (m)", "spline", "constant" diff --git a/rocketpy/Function.py b/rocketpy/Function.py index e5cab3621..854ac1dd9 100644 --- a/rocketpy/Function.py +++ b/rocketpy/Function.py @@ -264,28 +264,6 @@ def max(self): """ return self.y_array.max() - @cached_property - def min_absolute(self): - """Get the minimum absolute value of the Function y_array. - - Returns - ------- - minimum: float. - The minimum absolute value of the Function y_array. - """ - return np.abs(self.y_array).min() - - @cached_property - def max_absolute(self): - """Get the maximum absolute value of the Function y_array. - - Returns - ------- - maximum: float. - The maximum absolute value of the Function y_array. - """ - return np.abs(self.y_array).max() - def set_interpolation(self, method="spline"): """Set interpolation method and process data is method requires. From 768595554cc4b1c26624d7041893a250d9c88bd0 Mon Sep 17 00:00:00 2001 From: Pedro Bressan Date: Fri, 15 Sep 2023 20:12:24 -0300 Subject: [PATCH 4/4] FIX: consider only rail button force at max calc. --- rocketpy/Flight.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rocketpy/Flight.py b/rocketpy/Flight.py index fc66eac8b..a5e172c67 100644 --- a/rocketpy/Flight.py +++ b/rocketpy/Flight.py @@ -2623,22 +2623,22 @@ def rail_button2_shear_force(self): @property def max_rail_button1_normal_force(self): """Maximum upper rail button normal force, in Newtons.""" - return np.abs(self.rail_button1_normal_force).max() + return np.abs(self.rail_button1_normal_force.y_array).max() @property def max_rail_button1_shear_force(self): """Maximum upper rail button shear force, in Newtons.""" - return np.abs(self.rail_button1_shear_force).max() + return np.abs(self.rail_button1_shear_force.y_array).max() @property def max_rail_button2_normal_force(self): """Maximum lower rail button normal force, in Newtons.""" - return np.abs(self.rail_button2_normal_force).max() + return np.abs(self.rail_button2_normal_force.y_array).max() @property def max_rail_button2_shear_force(self): """Maximum lower rail button shear force, in Newtons.""" - return np.abs(self.rail_button2_shear_force).max() + return np.abs(self.rail_button2_shear_force.y_array).max() @funcify_method( "Time (s)", "Horizontal Distance to Launch Point (m)", "spline", "constant"