Is your feature request related to a problem? Please describe.
Exporting rocketpy classes to a json file is something that the user currently cannot do so easily.
The get_instance_attributes (see below) function already made an important advance to export all the attributes of an instance to a dictionary, but that doesn't mean we can always save these dictionaries to json files.
Exporting objects as json files might be the easiest way of saving a rocketpy simulation without having to plot tons of data and plots.
|
def get_instance_attributes(instance): |
Describe the solution you'd like
- Add
to_json, to_serializable or __json__ methods to the important classes of RocketPy, allowing the
- Alternatively, the
jsonpickle package can be used to perform a quick encode/decode with any of the rocketpy classes, as already done in the EnvironmentAnalysis class.
|
def save(self, filename="env_analysis_dict"): |
Additional context
As far as I know there's no convention on Python regarding the name of the method
Is your feature request related to a problem? Please describe.
Exporting rocketpy classes to a json file is something that the user currently cannot do so easily.
The
get_instance_attributes(see below) function already made an important advance to export all the attributes of an instance to a dictionary, but that doesn't mean we can always save these dictionaries to json files.Exporting objects as json files might be the easiest way of saving a rocketpy simulation without having to plot tons of data and plots.
RocketPy/rocketpy/utilities.py
Line 642 in 14dd0f6
Describe the solution you'd like
to_json,to_serializableor__json__methods to the important classes of RocketPy, allowing thejsonpicklepackage can be used to perform a quick encode/decode with any of the rocketpy classes, as already done in the EnvironmentAnalysis class.RocketPy/rocketpy/environment/environment_analysis.py
Line 2899 in 14dd0f6
Additional context
As far as I know there's no convention on Python regarding the name of the method