From f7503f292f7c10e3a27623c8c7da9d63e39cfd54 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Mon, 12 Sep 2022 08:59:16 +0200 Subject: [PATCH 1/7] ENH: Adding combine_trajectories function --- rocketpy/utilities.py | 62 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/rocketpy/utilities.py b/rocketpy/utilities.py index dc847ea3c..100fe8637 100644 --- a/rocketpy/utilities.py +++ b/rocketpy/utilities.py @@ -4,12 +4,15 @@ __license__ = "MIT" import numpy as np +import matplotlib.pyplot as plt from scipy.integrate import solve_ivp from .Environment import Environment from .Function import Function +# Parachutes related functions + # TODO: Needs tests def compute_CdS_from_drop_test( terminal_velocity, rocket_mass, air_density=1.225, g=9.80665 @@ -42,7 +45,6 @@ def compute_CdS_from_drop_test( # TODO: Needs tests - def calculateEquilibriumAltitude( rocket_mass, CdS, @@ -197,3 +199,61 @@ def du(z, u): velocityFunction() return altitudeFunction, velocityFunction, final_sol + + + +def combineTrajectories(traj1, traj2=None, traj3=None, traj4=None, traj5=None): + """Returns a trajectory that is the combination of the trajectories passed + All components of the trajectory (x, y, z) must be at the same length. + Minimum of 1 trajectory is required. + Current a maximum of 5 trajectories can be combined. + This function was created based two source-codes: + - + - + + """ + # TODO: Add a check to make sure that the components (x, y, z) of trajectories are the same length + # TODO: Allow the user to catch different planes (xy, yz, xz) from the main plot + # TODO: Allow the user to input a name + # TODO: Allow the user to set the colors + # TODO: Make the legend optional + # TODO: Allow the user to set the line style + # TODO: Make it more general, so that it can be used for any number of trajectories + + # Decompose the trajectories into x, y, z components + x1, y1, z1 = traj1 + x2, y2, z2 = traj2 if traj2 else (0, 0, 0) + x3, y3, z3 = traj3 if traj3 else (0, 0, 0) + x4, y4, z4 = traj4 if traj4 else (0, 0, 0) + x5, y5, z5 = traj5 if traj5 else (0, 0, 0) + + # Find max/min values for each component + maxZ = max(*z1, *z2, *z3, *z4, *z5) + maxX = max(*x1, *x2, *x3, *x4, *x5) + minX = min(*x1, *x2, *x3, *x4, *x5) + minY = min(*y1, *y2, *y3, *y4, *y5) + maxY = max(*y1, *y2, *y3, *y4, *y5) + maxXY = max(maxX, maxY) + minXY = min(minX, minY) + + # Create the figure + fig1 = plt.figure(figsize=(9, 9)) + ax1 = plt.subplot(111, projection="3d") + ax1.plot(x1, y1, z1, linewidth='2', label="Trajectory 1") + ax1.plot(x2, y2, z2, linewidth='2', label="Trajectory 2") if traj2 else None + ax1.plot(x3, y3, z3, linewidth='2', label="Trajectory 3") if traj3 else None + ax1.plot(x4, y4, z4, linewidth='2', label="Trajectory 4") if traj4 else None + ax1.plot(x5, y5, z5, linewidth='2', label="Trajectory 5") if traj5 else None + ax1.scatter(0, 0, 0) + ax1.set_xlabel("X - East (m)") + ax1.set_ylabel("Y - North (m)") + ax1.set_zlabel("Z - Altitude Above Ground Level (m)") + ax1.set_title("Flight Trajectory") + ax1.set_zlim3d([0, maxZ]) + ax1.set_ylim3d([minXY, maxXY]) + ax1.set_xlim3d([minXY, maxXY]) + ax1.view_init(15, 45) + plt.legend() + plt.show() + + return None \ No newline at end of file From 18a1537ce6ac4dffdd1bd0e7e0af74e2292c0403 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Mon, 12 Sep 2022 09:03:32 +0200 Subject: [PATCH 2/7] ENH: Improve TODOs at function --- rocketpy/utilities.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/rocketpy/utilities.py b/rocketpy/utilities.py index 100fe8637..4d4549491 100644 --- a/rocketpy/utilities.py +++ b/rocketpy/utilities.py @@ -200,16 +200,19 @@ def du(z, u): return altitudeFunction, velocityFunction, final_sol - +# TODO: Needs tests def combineTrajectories(traj1, traj2=None, traj3=None, traj4=None, traj5=None): """Returns a trajectory that is the combination of the trajectories passed All components of the trajectory (x, y, z) must be at the same length. Minimum of 1 trajectory is required. Current a maximum of 5 trajectories can be combined. + The trajectories must be in the same reference frame. + The z coordinate must be referenced to the ground or to the sea level, but + it is important that all trajectories are passed in the same reference. This function was created based two source-codes: - - - - + - Mateus Stano: https://github.com/RocketPy-Team/Hackathon_2020/pull/123/files#diff-8f0a881d1355d1748074d56ed43129d46db5b755acaa753e3c49143a1c800386 + - Dyllon Preston: https://github.com/Dyllon-P/MBS-Template/blob/main/MBS.py """ # TODO: Add a check to make sure that the components (x, y, z) of trajectories are the same length @@ -219,6 +222,7 @@ def combineTrajectories(traj1, traj2=None, traj3=None, traj4=None, traj5=None): # TODO: Make the legend optional # TODO: Allow the user to set the line style # TODO: Make it more general, so that it can be used for any number of trajectories + # TODO: Improve docs # Decompose the trajectories into x, y, z components x1, y1, z1 = traj1 @@ -247,7 +251,7 @@ def combineTrajectories(traj1, traj2=None, traj3=None, traj4=None, traj5=None): ax1.scatter(0, 0, 0) ax1.set_xlabel("X - East (m)") ax1.set_ylabel("Y - North (m)") - ax1.set_zlabel("Z - Altitude Above Ground Level (m)") + ax1.set_zlabel("Z - Altitude (m)") ax1.set_title("Flight Trajectory") ax1.set_zlim3d([0, maxZ]) ax1.set_ylim3d([minXY, maxXY]) From d3c0ee9a52c214df6ea43cc67789e64703827195 Mon Sep 17 00:00:00 2001 From: Lint Action Date: Mon, 12 Sep 2022 07:14:47 +0000 Subject: [PATCH 3/7] Fix code style issues with Black --- rocketpy/utilities.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/rocketpy/utilities.py b/rocketpy/utilities.py index 4d4549491..4a4c810be 100644 --- a/rocketpy/utilities.py +++ b/rocketpy/utilities.py @@ -45,6 +45,7 @@ def compute_CdS_from_drop_test( # TODO: Needs tests + def calculateEquilibriumAltitude( rocket_mass, CdS, @@ -200,8 +201,10 @@ def du(z, u): return altitudeFunction, velocityFunction, final_sol + # TODO: Needs tests + def combineTrajectories(traj1, traj2=None, traj3=None, traj4=None, traj5=None): """Returns a trajectory that is the combination of the trajectories passed All components of the trajectory (x, y, z) must be at the same length. @@ -216,7 +219,7 @@ def combineTrajectories(traj1, traj2=None, traj3=None, traj4=None, traj5=None): """ # TODO: Add a check to make sure that the components (x, y, z) of trajectories are the same length - # TODO: Allow the user to catch different planes (xy, yz, xz) from the main plot + # TODO: Allow the user to catch different planes (xy, yz, xz) from the main plot # TODO: Allow the user to input a name # TODO: Allow the user to set the colors # TODO: Make the legend optional @@ -230,7 +233,7 @@ def combineTrajectories(traj1, traj2=None, traj3=None, traj4=None, traj5=None): x3, y3, z3 = traj3 if traj3 else (0, 0, 0) x4, y4, z4 = traj4 if traj4 else (0, 0, 0) x5, y5, z5 = traj5 if traj5 else (0, 0, 0) - + # Find max/min values for each component maxZ = max(*z1, *z2, *z3, *z4, *z5) maxX = max(*x1, *x2, *x3, *x4, *x5) @@ -239,15 +242,15 @@ def combineTrajectories(traj1, traj2=None, traj3=None, traj4=None, traj5=None): maxY = max(*y1, *y2, *y3, *y4, *y5) maxXY = max(maxX, maxY) minXY = min(minX, minY) - + # Create the figure fig1 = plt.figure(figsize=(9, 9)) ax1 = plt.subplot(111, projection="3d") - ax1.plot(x1, y1, z1, linewidth='2', label="Trajectory 1") - ax1.plot(x2, y2, z2, linewidth='2', label="Trajectory 2") if traj2 else None - ax1.plot(x3, y3, z3, linewidth='2', label="Trajectory 3") if traj3 else None - ax1.plot(x4, y4, z4, linewidth='2', label="Trajectory 4") if traj4 else None - ax1.plot(x5, y5, z5, linewidth='2', label="Trajectory 5") if traj5 else None + ax1.plot(x1, y1, z1, linewidth="2", label="Trajectory 1") + ax1.plot(x2, y2, z2, linewidth="2", label="Trajectory 2") if traj2 else None + ax1.plot(x3, y3, z3, linewidth="2", label="Trajectory 3") if traj3 else None + ax1.plot(x4, y4, z4, linewidth="2", label="Trajectory 4") if traj4 else None + ax1.plot(x5, y5, z5, linewidth="2", label="Trajectory 5") if traj5 else None ax1.scatter(0, 0, 0) ax1.set_xlabel("X - East (m)") ax1.set_ylabel("Y - North (m)") @@ -260,4 +263,4 @@ def combineTrajectories(traj1, traj2=None, traj3=None, traj4=None, traj5=None): plt.legend() plt.show() - return None \ No newline at end of file + return None From ff3f7a510a60b84c0cd0cfa8f012cd26e70521df Mon Sep 17 00:00:00 2001 From: MateusStano Date: Tue, 13 Sep 2022 11:25:54 -0300 Subject: [PATCH 4/7] ENH: added compareFlightTrajectories and improved compareTrajectories --- rocketpy/utilities.py | 183 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 150 insertions(+), 33 deletions(-) diff --git a/rocketpy/utilities.py b/rocketpy/utilities.py index 4a4c810be..6a9479f2a 100644 --- a/rocketpy/utilities.py +++ b/rocketpy/utilities.py @@ -205,52 +205,168 @@ def du(z, u): # TODO: Needs tests -def combineTrajectories(traj1, traj2=None, traj3=None, traj4=None, traj5=None): - """Returns a trajectory that is the combination of the trajectories passed - All components of the trajectory (x, y, z) must be at the same length. - Minimum of 1 trajectory is required. - Current a maximum of 5 trajectories can be combined. - The trajectories must be in the same reference frame. - The z coordinate must be referenced to the ground or to the sea level, but - it is important that all trajectories are passed in the same reference. +def compareTrajectories( + trajectory_list, + names=None, + legend=True, +): + """Creates a trajectory plot that is the combination of the trajectories passed. This function was created based two source-codes: - Mateus Stano: https://github.com/RocketPy-Team/Hackathon_2020/pull/123/files#diff-8f0a881d1355d1748074d56ed43129d46db5b755acaa753e3c49143a1c800386 - Dyllon Preston: https://github.com/Dyllon-P/MBS-Template/blob/main/MBS.py + Parameters + ---------- + trajectory_list : list, array + List of trajectories. Must be in the form of [trajectory_1,trajectory_2,...,trajectory_n] + where trajectory_n is a list with the arrays regarding positions in x, y and z [x, y, z]. + The trajectories must be in the same reference frame. The z coordinate must be referenced + to the ground or to the sea level, but it is important that all trajectories are passed + in the same reference. + names : list, optional + List of strings with the name of each trajectory inputed. The names must be in + the same order as the trajectories in trajectory_list + legend : boolean, optional + Whether legend will or will not be included. Default is True + + Returns + ------- + None + """ - # TODO: Add a check to make sure that the components (x, y, z) of trajectories are the same length # TODO: Allow the user to catch different planes (xy, yz, xz) from the main plot - # TODO: Allow the user to input a name # TODO: Allow the user to set the colors - # TODO: Make the legend optional # TODO: Allow the user to set the line style - # TODO: Make it more general, so that it can be used for any number of trajectories # TODO: Improve docs - # Decompose the trajectories into x, y, z components - x1, y1, z1 = traj1 - x2, y2, z2 = traj2 if traj2 else (0, 0, 0) - x3, y3, z3 = traj3 if traj3 else (0, 0, 0) - x4, y4, z4 = traj4 if traj4 else (0, 0, 0) - x5, y5, z5 = traj5 if traj5 else (0, 0, 0) - - # Find max/min values for each component - maxZ = max(*z1, *z2, *z3, *z4, *z5) - maxX = max(*x1, *x2, *x3, *x4, *x5) - minX = min(*x1, *x2, *x3, *x4, *x5) - minY = min(*y1, *y2, *y3, *y4, *y5) - maxY = max(*y1, *y2, *y3, *y4, *y5) - maxXY = max(maxX, maxY) - minXY = min(minX, minY) + # Initialize variables + maxZ = 0 + maxX = 0 + minX = 0 + minY = 0 + maxY = 0 + maxXY = 0 + minXY = 0 + counter = 0 + name = ( + [("Trajectory " + str(i + 1)) for i in range(len(trajectory_list))] + if name == None + else name + ) # Create the figure fig1 = plt.figure(figsize=(9, 9)) ax1 = plt.subplot(111, projection="3d") - ax1.plot(x1, y1, z1, linewidth="2", label="Trajectory 1") - ax1.plot(x2, y2, z2, linewidth="2", label="Trajectory 2") if traj2 else None - ax1.plot(x3, y3, z3, linewidth="2", label="Trajectory 3") if traj3 else None - ax1.plot(x4, y4, z4, linewidth="2", label="Trajectory 4") if traj4 else None - ax1.plot(x5, y5, z5, linewidth="2", label="Trajectory 5") if traj5 else None + + # Iterate through trajectories + for trajectory in trajectory_list: + + x, y, z = trajectory + + # Find max/min values for each component + maxZ = max(z) if max(z) > maxZ else maxZ + maxX = max(x) if max(x) > maxX else maxX + minX = min(x) if min(x) > minX else minX + minY = min(x) if min(x) > minX else minX + maxY = max(y) if max(y) > maxY else maxY + maxXY = max(maxX, maxY) if max(maxX, maxY) > maxXY else maxXY + minXY = min(minX, minY) if min(minX, minY) > minXY else minXY + + # Plot Trajectory + ax1.plot(x, y, z, linewidth="2", label=name[counter]) + counter += 1 + + # Plot settings + ax1.scatter(0, 0, 0) + ax1.set_xlabel("X - East (m)") + ax1.set_ylabel("Y - North (m)") + ax1.set_zlabel("Z - Altitude (m)") + ax1.set_title("Flight Trajectory") + ax1.set_zlim3d([0, maxZ]) + ax1.set_ylim3d([minXY, maxXY]) + ax1.set_xlim3d([minXY, maxXY]) + ax1.view_init(15, 45) + if legend: + plt.legend() + plt.show() + + return None + + +def compareFlightTrajectories( + flight_list, + name=None, + legend=True, +): + """Creates a trajectory plot that is the combination of the trajectories of the Flight + objects passed. + + Parameters + ---------- + flight_list : list, array + List of FLight objects. The flights must be in the same reference frame. + names : list, optional + List of strings with the name of each trajectory inputed. The names must be in + the same order as the trajectories in flight_list + legend : boolean, optional + Whether legend will or will not be included. Default is True + + Returns + ------- + None + + """ + # TODO: Allow the user to catch different planes (xy, yz, xz) from the main plot + # TODO: Allow the user to set the colors + # TODO: Make the legend optional + # TODO: Allow the user to set the line style + # TODO: Improve docs + + # Initialize variables + maxZ = 0 + maxX = 0 + minX = 0 + minY = 0 + maxY = 0 + maxXY = 0 + minXY = 0 + counter = 0 + name = ( + [("Trajectory " + str(i + 1)) for i in range(len(flight_list))] + if name == None + else name + ) + + # Initialize Figure + fig1 = plt.figure(figsize=(9, 9)) + ax1 = plt.subplot(111, projection="3d") + + # Iterate through Flight objects + for flight in flight_list: + + # Check post process + if flight.postProcessed is False: + flight.postProcess() + + # Get trajectories + x = flight.x[:, 1] + y = flight.y[:, 1] + z = flight.z[:, 1] - flight.env.elevation + + # Find max/min values for each component + maxZ = max(z) if max(z) > maxZ else maxZ + maxX = max(x) if max(x) > maxX else maxX + minX = min(x) if min(x) > minX else minX + minY = min(x) if min(x) > minX else minX + maxY = max(y) if max(y) > maxY else maxY + maxXY = max(maxX, maxY) if max(maxX, maxY) > maxXY else maxXY + minXY = min(minX, minY) if min(minX, minY) > minXY else minXY + + # Plot Trajectory + ax1.plot(x, y, z, linewidth="2", label=name[counter]) + counter += 1 + + # Plot settings ax1.scatter(0, 0, 0) ax1.set_xlabel("X - East (m)") ax1.set_ylabel("Y - North (m)") @@ -260,7 +376,8 @@ def combineTrajectories(traj1, traj2=None, traj3=None, traj4=None, traj5=None): ax1.set_ylim3d([minXY, maxXY]) ax1.set_xlim3d([minXY, maxXY]) ax1.view_init(15, 45) - plt.legend() + if legend: + plt.legend() plt.show() return None From 7253b626a3358a5db609673698dd165a29c10048 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Tue, 13 Sep 2022 17:54:45 +0200 Subject: [PATCH 5/7] ENH: Refactor compare functions --- rocketpy/utilities.py | 118 ++++++++++++------------------------------ 1 file changed, 34 insertions(+), 84 deletions(-) diff --git a/rocketpy/utilities.py b/rocketpy/utilities.py index 6a9479f2a..d0b8a436c 100644 --- a/rocketpy/utilities.py +++ b/rocketpy/utilities.py @@ -3,14 +3,13 @@ __copyright__ = "Copyright 20XX, RocketPy Team" __license__ = "MIT" -import numpy as np import matplotlib.pyplot as plt +import numpy as np from scipy.integrate import solve_ivp from .Environment import Environment from .Function import Function - # Parachutes related functions # TODO: Needs tests @@ -210,48 +209,42 @@ def compareTrajectories( names=None, legend=True, ): - """Creates a trajectory plot that is the combination of the trajectories passed. + """Creates a trajectory plot combining the trajectories listed. This function was created based two source-codes: - - Mateus Stano: https://github.com/RocketPy-Team/Hackathon_2020/pull/123/files#diff-8f0a881d1355d1748074d56ed43129d46db5b755acaa753e3c49143a1c800386 + - Mateus Stano: https://github.com/RocketPy-Team/Hackathon_2020/pull/123 - Dyllon Preston: https://github.com/Dyllon-P/MBS-Template/blob/main/MBS.py Parameters ---------- trajectory_list : list, array - List of trajectories. Must be in the form of [trajectory_1,trajectory_2,...,trajectory_n] - where trajectory_n is a list with the arrays regarding positions in x, y and z [x, y, z]. + List of trajectories. Must be in the form of [trajectory_1, trajectory_2, ..., trajectory_n] + where each element is a list with the arrays regarding positions in x, y and z [x, y, z]. The trajectories must be in the same reference frame. The z coordinate must be referenced to the ground or to the sea level, but it is important that all trajectories are passed in the same reference. names : list, optional - List of strings with the name of each trajectory inputed. The names must be in - the same order as the trajectories in trajectory_list + List of strings with the name of each trajectory inputted. The names must be in + the same order as the trajectories in trajectory_list. If no names are passed, the + trajectories will be named as "Trajectory 1", "Trajectory 2", ..., "Trajectory n". legend : boolean, optional - Whether legend will or will not be included. Default is True + Whether legend will or will not be plotted. Default is True Returns ------- None """ - # TODO: Allow the user to catch different planes (xy, yz, xz) from the main plot - # TODO: Allow the user to set the colors + # TODO: Allow the user to catch different planes (xy, yz, xz) from the main plot (this can be done in a separate function) + # TODO: Allow the user to set the colors or color style # TODO: Allow the user to set the line style - # TODO: Improve docs # Initialize variables - maxZ = 0 - maxX = 0 - minX = 0 - minY = 0 - maxY = 0 - maxXY = 0 - minXY = 0 - counter = 0 - name = ( + maxX, maxY, maxZ, minX, minY, minZ, maxXY, minXY = 0, 0, 0, 0, 0, 0, 0, 0 + + names = ( [("Trajectory " + str(i + 1)) for i in range(len(trajectory_list))] - if name == None - else name + if names == None + else names ) # Create the figure @@ -259,30 +252,30 @@ def compareTrajectories( ax1 = plt.subplot(111, projection="3d") # Iterate through trajectories - for trajectory in trajectory_list: + for i, trajectory in enumerate(trajectory_list): x, y, z = trajectory # Find max/min values for each component - maxZ = max(z) if max(z) > maxZ else maxZ maxX = max(x) if max(x) > maxX else maxX + maxY = max(y) if max(y) > maxY else maxY + maxZ = max(z) if max(z) > maxZ else maxZ minX = min(x) if min(x) > minX else minX minY = min(x) if min(x) > minX else minX - maxY = max(y) if max(y) > maxY else maxY + minY = min(z) if min(z) > minZ else minZ maxXY = max(maxX, maxY) if max(maxX, maxY) > maxXY else maxXY minXY = min(minX, minY) if min(minX, minY) > minXY else minXY - # Plot Trajectory - ax1.plot(x, y, z, linewidth="2", label=name[counter]) - counter += 1 + # Add Trajectory as a plot in main figure + ax1.plot(x, y, z, linewidth="2", label=names[i]) # Plot settings ax1.scatter(0, 0, 0) ax1.set_xlabel("X - East (m)") ax1.set_ylabel("Y - North (m)") ax1.set_zlabel("Z - Altitude (m)") - ax1.set_title("Flight Trajectory") - ax1.set_zlim3d([0, maxZ]) + ax1.set_title("Flight Trajectories Combined") + ax1.set_zlim3d([minZ, maxZ]) ax1.set_ylim3d([minXY, maxXY]) ax1.set_xlim3d([minXY, maxXY]) ax1.view_init(15, 45) @@ -295,18 +288,18 @@ def compareTrajectories( def compareFlightTrajectories( flight_list, - name=None, + names=None, legend=True, ): - """Creates a trajectory plot that is the combination of the trajectories of the Flight - objects passed. + """Creates a trajectory plot that is the combination of the trajectories of + the Flight objects passed via a Python list. Parameters ---------- flight_list : list, array List of FLight objects. The flights must be in the same reference frame. names : list, optional - List of strings with the name of each trajectory inputed. The names must be in + List of strings with the name of each trajectory inputted. The names must be in the same order as the trajectories in flight_list legend : boolean, optional Whether legend will or will not be included. Default is True @@ -317,31 +310,11 @@ def compareFlightTrajectories( """ # TODO: Allow the user to catch different planes (xy, yz, xz) from the main plot - # TODO: Allow the user to set the colors - # TODO: Make the legend optional + # TODO: Allow the user to set the colors or color style # TODO: Allow the user to set the line style - # TODO: Improve docs - - # Initialize variables - maxZ = 0 - maxX = 0 - minX = 0 - minY = 0 - maxY = 0 - maxXY = 0 - minXY = 0 - counter = 0 - name = ( - [("Trajectory " + str(i + 1)) for i in range(len(flight_list))] - if name == None - else name - ) - # Initialize Figure - fig1 = plt.figure(figsize=(9, 9)) - ax1 = plt.subplot(111, projection="3d") - - # Iterate through Flight objects + # Iterate through Flight objects and create a list of trajectories + trajectory_list = [] for flight in flight_list: # Check post process @@ -352,32 +325,9 @@ def compareFlightTrajectories( x = flight.x[:, 1] y = flight.y[:, 1] z = flight.z[:, 1] - flight.env.elevation + trajectory_list.append([x, y, z]) - # Find max/min values for each component - maxZ = max(z) if max(z) > maxZ else maxZ - maxX = max(x) if max(x) > maxX else maxX - minX = min(x) if min(x) > minX else minX - minY = min(x) if min(x) > minX else minX - maxY = max(y) if max(y) > maxY else maxY - maxXY = max(maxX, maxY) if max(maxX, maxY) > maxXY else maxXY - minXY = min(minX, minY) if min(minX, minY) > minXY else minXY - - # Plot Trajectory - ax1.plot(x, y, z, linewidth="2", label=name[counter]) - counter += 1 - - # Plot settings - ax1.scatter(0, 0, 0) - ax1.set_xlabel("X - East (m)") - ax1.set_ylabel("Y - North (m)") - ax1.set_zlabel("Z - Altitude (m)") - ax1.set_title("Flight Trajectory") - ax1.set_zlim3d([0, maxZ]) - ax1.set_ylim3d([minXY, maxXY]) - ax1.set_xlim3d([minXY, maxXY]) - ax1.view_init(15, 45) - if legend: - plt.legend() - plt.show() + # Call compareTrajectories function to do the hard work + compareTrajectories(trajectory_list, names, legend) return None From 6de473b954e92eb81b25b8bc048dde626f6837e8 Mon Sep 17 00:00:00 2001 From: Lint Action Date: Tue, 13 Sep 2022 15:55:28 +0000 Subject: [PATCH 6/7] Fix code style issues with Black --- rocketpy/utilities.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rocketpy/utilities.py b/rocketpy/utilities.py index d0b8a436c..76bdcc8e6 100644 --- a/rocketpy/utilities.py +++ b/rocketpy/utilities.py @@ -327,7 +327,7 @@ def compareFlightTrajectories( z = flight.z[:, 1] - flight.env.elevation trajectory_list.append([x, y, z]) - # Call compareTrajectories function to do the hard work + # Call compareTrajectories function to do the hard work compareTrajectories(trajectory_list, names, legend) return None From 5584a3e45fb567f380da5bf31b3c527a6dda2678 Mon Sep 17 00:00:00 2001 From: MateusStano Date: Tue, 13 Sep 2022 16:14:01 -0300 Subject: [PATCH 7/7] BUG: fix minZ --- rocketpy/utilities.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rocketpy/utilities.py b/rocketpy/utilities.py index 76bdcc8e6..f653a370c 100644 --- a/rocketpy/utilities.py +++ b/rocketpy/utilities.py @@ -262,7 +262,7 @@ def compareTrajectories( maxZ = max(z) if max(z) > maxZ else maxZ minX = min(x) if min(x) > minX else minX minY = min(x) if min(x) > minX else minX - minY = min(z) if min(z) > minZ else minZ + minZ = min(z) if min(z) > minZ else minZ maxXY = max(maxX, maxY) if max(maxX, maxY) > maxXY else maxXY minXY = min(minX, minY) if min(minX, minY) > minXY else minXY