-
-
Notifications
You must be signed in to change notification settings - Fork 237
ENH: Add JSON export and CSV export support for monte carlo result #916
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
Open
edith1504
wants to merge
9
commits into
RocketPy-Team:develop
Choose a base branch
from
edith1504:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+188
−0
Open
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2168a34
ENH: Add JSON export support for monte carlo result
IPSITA-Nanda 2589fca
Fix lint: removed equality comparison to True
IPSITA-Nanda 894cc83
ENH : add of CSV export feature and previous lint fix
IPSITA-Nanda 841c58e
Merge branch 'develop' into develop
edith1504 9ce41fe
refactor: remove unnecessary try/except in export_json
IPSITA-Nanda a228d59
Merge branch 'develop' of https://github.com/edith1504/RocketPy into …
IPSITA-Nanda 9216cea
style: fix pylint errors in export_json and tests
IPSITA-Nanda a7fa7d4
Merge branch 'develop' into develop
edith1504 d8034e8
Merge branch 'develop' into develop
edith1504 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| {"x_impact": 261.11227152428785, "out_of_rail_velocity": 21.263362678403276, "lateral_surface_wind": 0.0, "impact_velocity": -5.5974307833687975, "apogee_y": 185.02990620611027, "apogee": 4090.397476048397, "max_mach_number": 0.7362805444720003, "out_of_rail_stability_margin": 2.315089166308985, "apogee_x": 222.39281714255011, "t_final": 258.96490133727735, "frontal_surface_wind": 0.0, "apogee_time": 24.189875450232726, "initial_stability_margin": 2.233761459523716, "y_impact": 216.94920645594468, "out_of_rail_time": 0.3526399202369637, "index": 1} | ||
| {"x_impact": 484.2520018225589, "out_of_rail_velocity": 23.043449951089155, "lateral_surface_wind": 0.0, "impact_velocity": -5.638698448227493, "apogee_y": 374.1333818596774, "apogee": 4933.3951884764765, "max_mach_number": 0.8972012428141698, "out_of_rail_stability_margin": 2.3686077590907453, "apogee_x": 421.4330962089096, "t_final": 300.9720229351123, "frontal_surface_wind": 0.0, "apogee_time": 27.281168813699697, "initial_stability_margin": 2.2964923844396727, "y_impact": 429.3662643361925, "out_of_rail_time": 0.32514873530416133, "index": 2} | ||
| {"x_impact": 372.6625337978357, "out_of_rail_velocity": 18.904312773708973, "lateral_surface_wind": 0.0, "impact_velocity": -5.568722088369098, "apogee_y": 224.41013464039185, "apogee": 3401.4185587371117, "max_mach_number": 0.6049423853841714, "out_of_rail_stability_margin": 2.1710531802525574, "apogee_x": 317.7795912292856, "t_final": 229.8195457110126, "frontal_surface_wind": 0.0, "apogee_time": 21.524782290759216, "initial_stability_margin": 2.0781643782173873, "y_impact": 262.9697158122671, "out_of_rail_time": 0.3969987568929141, "index": 3} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder whether we should create a "MonteCarloDataExporter" similarly to what we have recelty done with the Flight class. Needs to think more about it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "x_impact": 372.6625337978357, | ||
| "out_of_rail_velocity": 18.904312773708973, | ||
| "lateral_surface_wind": 0.0, | ||
| "impact_velocity": -5.568722088369098, | ||
| "apogee_y": 224.41013464039185, | ||
| "apogee": 3401.4185587371117, | ||
| "max_mach_number": 0.6049423853841714, | ||
| "out_of_rail_stability_margin": 2.1710531802525574, | ||
| "apogee_x": 317.7795912292856, | ||
| "t_final": 229.8195457110126, | ||
| "frontal_surface_wind": 0.0, | ||
| "apogee_time": 21.524782290759216, | ||
| "initial_stability_margin": 2.0781643782173873, | ||
| "y_impact": 262.9697158122671, | ||
| "out_of_rail_time": 0.3969987568929141, | ||
| "index": 3 | ||
| } | ||
edith1504 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import os | ||
| import json | ||
|
|
||
| def test_json_export(monte_carlo_calisto): | ||
edith1504 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| mc = monte_carlo_calisto | ||
| mc.simulate(3) | ||
|
|
||
| filename = "temp_test_output.json" | ||
edith1504 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| mc.export_json(filename) | ||
|
|
||
| assert os.path.exists(filename) | ||
|
|
||
| with open(filename, "r") as f: | ||
| data = json.load(f) | ||
|
|
||
| # Assert dictionary keys exist | ||
| assert len(data.keys()) > 0 | ||
|
|
||
| # Check that at least one key corresponds to a list of simulation results | ||
| list_keys = [k for k, v in data.items() if isinstance(v, list)] | ||
|
|
||
| # There must be at least 1 Monte Carlo-dependent field | ||
| assert len(list_keys) > 0 | ||
|
|
||
| first_list_key = list_keys[0] | ||
| assert len(data[first_list_key]) == 3 | ||
edith1504 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| os.remove(filename) | ||
edith1504 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
edith1504 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.