-
-
Notifications
You must be signed in to change notification settings - Fork 193
ENH: Compare trajectories method #227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Compare trajectories method #227
Conversation
@MateusStano @FranzYuri , could one of your review/approve/merge this one? |
Hey, nice one! Just wondering is there a reason for the function to receive the trajectories instead of receiving the Flight objects right away? |
I altered the code so that it receives Flight objects instead. I also solved some TODOs while at it. Here is a preview
Tell me what you think, I can commit it right away |
Don't forget to make the method documentation compliant to our docs style (Numpy-style docstrings). |
@MateusStano implementation seems like a welcome improvement! |
Definitely! This commit will help us a lot |
I would add that support for non Flight objects may also be very interesting for use cases such as comparing openRocket flights to RocketPy, or comparing real flight data. |
I guess those are different paradigms... One is to combine different flight phases of a non-conventional flights, for instance, deployable payloads and milti-stage rockets. The other is to plot two (or more) series and compare one against each other. Perhaps they can be treated by the same methods when plotting 3D trajectory, but the idea is a bit different. |
I see. I think we are getting a little bit confused here. @MateusStano's function is called I guess we need a class method in the Flight class called |
I would recommend proceeding by separating Stano's function into 2 other functions, one takes lists as input, and orher takes flights. We can setup a manner that the second opens the flight object, take the lists and call the first function. |
Please describe this |
I don't know if I understood the But I think having two different functions here is useful. One for comparing Flight objects and one for comparing trajectories in general. I commited the two functions @Gui-FernandesBR check if they are doing what you needed |
Everything looks great now. @MateusStano thank you so much for your addition, I've made some quick adjustments and believe we can proceed. Would you re-review/approve/merge please? @giovaniceotto , I'm still open if you want to discuss the mergeFlights idea that you mentioned, but I think the current contribution already achieved its porpouse. Indeed, I've already done a quick deployable payload simulation, and there's something that is really bothering me which is the idea of `finishing a "first-stage" flight -> save the final state vector -> Start a new Flight object again". I'm thinking of somehow utilize a "modifyRocket" inside the Flight Class. This way you still keep in the same flight, but with a different rocket. |
This PR is named COMBINE flights, but it is implementing a COMPARE flights. Is this correct? The |
Pull request type
Pull request checklist
Code base additions (for bug fixes / features):
black rocketpy
) has passed locally and any fixes were madepytest --runslow
) have passed locallyWhat is the current behavior?
There's no pre-build method to allow us easily create plots for combined trajectories, e.g. multi-stage rockets.
What is the new behavior?
I've used some code examples to implement an auxiliary function at utilities, which will allow us to create useful plots for some applications.
A simple function to plot the diffferent flight trajectories at the same matplotlib figure.
Expected behavior:
Code example:
trajectory1 = (RocketFlight1.x[:,1], RocketFlight1.y[:,1], RocketFlight1.z[:,1]-RocketFlight1.env.elevation)
trajectory2 = (RocketFlight2.x[:,1], RocketFlight2.y[:,1], RocketFlight2.z[:,1]-RocketFlight2.env.elevation)
trajectory3 = (PayloadFlight.x[:,1], PayloadFlight.y[:,1], PayloadFlight.z[:,1]-PayloadFlight.env.elevation)
combineTrajectories(trajectory1, trajectory2, trajectory3)
Result:
Does this introduce a breaking change?
Other information
This is a part of "complex_simulations", which will give use some work with new simulations examples, such as deployable payloads flights and others.