Repository navigation
ENH: Save Monte Carlo outputs to .csv and .json formats #242
Description
Is your feature request related to a problem? Please describe.
Currently, the MonteCarlo class saves simulation outputs (results, inputs, and errors) primarily to .txt files. While this works for internal storage, it makes post-processing difficult for users who want to analyze their data in external tools like Excel, MATLAB, or generic Python scripts without loading RocketPy.
As discussed in PR #229, users need a way to easily export their dispersion results to standard data exchange formats to perform comparative analysis between different rocket configurations.
Describe the solution you'd like
I would like to implement a method (or extend the existing functionality) in the MonteCarlo class to export results to .csv and .json files.
The goal is to allow the user to choose the output format easily.
Implementation Details
The changes should likely be made in rocketpy/simulation/monte_carlo.py.
-
New Methods: We need methods to handle the export logic. For example:
export_results_to_csv(filename)export_results_to_json(filename)- Alternatively, a single unified method:
export_data(filename, format="csv").
-
Data to Export: The export should include the data currently stored in the
self.resultsdictionary (e.g., apogee, max_mach, impact coordinates). -
JSON Structure: Should map keys (variable names) to lists of values.
-
CSV Structure: Should have headers (variable names) and rows corresponding to each simulation iteration.
Proposed Usage
# After running the simulation
analysis = MonteCarlo(filename="my_flight_data", ...)
analysis.simulate(number_of_simulations=1000)
# The user should be able to do this:
analysis.export_results("simulation_data.csv", format="csv")
analysis.export_results("simulation_data.json", format="json")Acceptance Criteria
- Implement export functionality for
.csv. - Implement export functionality for
.json. - Ensure that
export_listand customdata_collectorvariables are included in the export. - Add unit tests in
tests/ensuring the files are created and contain correct data. - Update the documentation to include examples of how to export data.
Additional Context
Please avoid using heavy dependencies (like pandas) inside the class methods if possible, unless the team decides it is a required dependency. Using Python's built-in csv and json libraries is preferred for lightweight implementation.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsBacklog
Activity
Gui-FernandesBR commentedon Apr 17, 2023
Perhaps they [the outputs from the Monte Carlo simlations] should be exported to ;json files instead of .txt (current) or .csv (proposed)
[-]ENH: Automate dispersion Outputs extraction to .csv [/-][+]ENH: Save dispersion outputs in different file formats[/+]9 remaining items
Gui-FernandesBR commentedon Nov 29, 2025
@ViniciusCMB, I just have updated this issue description. I believe it is cristal clear defined now, but you are totally free to ask me any question if you need.
Thank you in advance for your contribution!!
[-]ENH: Save dispersion outputs in different file formats[/-][+]ENH: Save Monte Carlo outputs to .csv and .json formats[/+]GMinoruy commentedon Dec 4, 2025
Hey, I am that user on Discord that asked where to be assigned issues, this is the one I was considering for the selective process can I work on it?
Gui-FernandesBR commentedon Dec 4, 2025
@GMinoruy absolutely!!
ENH: trying to add Monte Carlo output to csv and json see issue Rocke…
ENH: trying to add Monte Carlo output to csv and json see issue Rocke…
ENH: trying to add Monte Carlo output to csv and json see issue Rocke…
ENH: trying to add Monte Carlo output to csv and json see issue Rocke…