RocketPy icon indicating copy to clipboard operation
RocketPy copied to clipboard

ENH: Simulation Save and Load in JSON Files

Open phmbressan opened this issue 5 months ago • 1 comments

Pull request type

  • [X] Code changes (bugfix, features)

Checklist

  • [X] Tests for the changes have been added (if needed)
  • [ ] Docs have been reviewed and added / updated
  • [X] Lint (black rocketpy/ tests/) has passed locally
  • [X] All tests (pytest tests -m slow --runslow) have passed locally
  • [ ] CHANGELOG.md has been updated (if relevant)

New behavior

This PR improves rocketpy encoding and introduces decoding functionalities. The way this works is:

  • If the is a to_dict or from_dict method, they are used to perform the (de)encoding;
  • Otherwise, a default encoding of all vars() and constructor based decoding is done.

Breaking change

  • [ ] Yes
  • [X] No

Additional information

PR #679 should be merged first.

Here are some of the steps that could be improved:

  • [ ] Verify why the test for hybrid motor flight requires higher tolerances;
  • [ ] Test if all of the atmospheric models of Environments can be decoded without requiring re-read of files or API;
  • [ ] Evaluate whether we should encode outputs or only the minimum required information to decode the class from its init;
  • [ ] (Optional) Expand implementation to AirBrakes + Controllers and new classes.

Some important remarks:

  • The simple getting started simulation is essentially identical comparing the store & load, the only difference is the random lag and noise from Parachute class. I could not found a simple solution to reset those and always get the same results.

phmbressan avatar Sep 22 '24 15:09 phmbressan