Skip to content

Commit 0f80516

Browse files
Merge pull request #549 from RocketPy-Team/enh/dispersion-renaming
MNT: Dispersion Renaming
2 parents b16e329 + f234624 commit 0f80516

36 files changed

+549
-575
lines changed

docs/notebooks/dispersion_analysis/dispersion_analysis.ipynb renamed to docs/notebooks/monte_carlo_analysis/monte_carlo_analysis.ipynb

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"!git clone https://github.com/RocketPy-Team/RocketPy.git\n",
4141
"import os\n",
4242
"\n",
43-
"os.chdir(\"RocketPy/docs/notebooks/dispersion_analysis\")"
43+
"os.chdir(\"RocketPy/docs/notebooks/monte_carlo_analysis\")"
4444
]
4545
},
4646
{
@@ -382,7 +382,7 @@
382382
],
383383
"source": [
384384
"# Basic analysis info\n",
385-
"filename = \"dispersion_analysis_outputs/valetudo_rocket_v0\"\n",
385+
"filename = \"monte_carlo_analysis_outputs/valetudo_rocket_v0\"\n",
386386
"number_of_simulations = 100\n",
387387
"\n",
388388
"# Create data files for inputs, outputs and error logging\n",
@@ -402,7 +402,7 @@
402402
"Env.max_expected_height = 1500\n",
403403
"Env.set_atmospheric_model(\n",
404404
" type=\"Ensemble\",\n",
405-
" file=\"dispersion_analysis_inputs/LASC2019_reanalysis.nc\",\n",
405+
" file=\"monte_carlo_analysis_inputs/LASC2019_reanalysis.nc\",\n",
406406
" dictionary=\"ECMWF\",\n",
407407
")\n",
408408
"\n",
@@ -426,7 +426,7 @@
426426
"\n",
427427
" # Create motor\n",
428428
" Keron = SolidMotor(\n",
429-
" thrust_source=\"dispersion_analysis_inputs/thrustCurve.csv\",\n",
429+
" thrust_source=\"monte_carlo_analysis_inputs/thrustCurve.csv\",\n",
430430
" burn_time=5.274,\n",
431431
" reshape_thrust_curve=(setting[\"burn_time\"], setting[\"impulse\"]),\n",
432432
" nozzle_radius=setting[\"nozzle_radius\"],\n",
@@ -458,8 +458,8 @@
458458
" setting[\"rocket_inertia_11\"],\n",
459459
" setting[\"rocket_inertia_33\"],\n",
460460
" ),\n",
461-
" power_off_drag=\"dispersion_analysis_inputs/Cd_PowerOff.csv\",\n",
462-
" power_on_drag=\"dispersion_analysis_inputs/Cd_PowerOn.csv\",\n",
461+
" power_off_drag=\"monte_carlo_analysis_inputs/Cd_PowerOff.csv\",\n",
462+
" power_on_drag=\"monte_carlo_analysis_inputs/Cd_PowerOn.csv\",\n",
463463
" center_of_mass_without_motor=0,\n",
464464
" coordinate_system_orientation=\"tail_to_nose\",\n",
465465
" )\n",
@@ -572,7 +572,7 @@
572572
}
573573
],
574574
"source": [
575-
"filename = \"dispersion_analysis_outputs/valetudo_rocket_v0\"\n",
575+
"filename = \"monte_carlo_analysis_outputs/valetudo_rocket_v0\"\n",
576576
"\n",
577577
"# Initialize variable to store all results\n",
578578
"dispersion_general_results = []\n",
@@ -12892,9 +12892,7 @@
1289212892
")\n",
1289312893
"\n",
1289412894
"plt.figure()\n",
12895-
"plt.hist(\n",
12896-
" dispersion_results[\"initial_static_margin\"], label=\"Initial\", bins=int(N**0.5)\n",
12897-
")\n",
12895+
"plt.hist(dispersion_results[\"initial_static_margin\"], label=\"Initial\", bins=int(N**0.5))\n",
1289812896
"plt.hist(\n",
1289912897
" dispersion_results[\"out_of_rail_static_margin\"],\n",
1290012898
" label=\"Out of Rail\",\n",
@@ -20354,7 +20352,7 @@
2035420352
"from matplotlib.patches import Ellipse\n",
2035520353
"\n",
2035620354
"# Import background map\n",
20357-
"img = imread(\"dispersion_analysis_inputs/Valetudo_basemap_final.jpg\")\n",
20355+
"img = imread(\"monte_carlo_analysis_inputs/Valetudo_basemap_final.jpg\")\n",
2035820356
"\n",
2035920357
"# Retrieve dispersion data por apogee and impact XY position\n",
2036020358
"apogee_x = np.array(dispersion_results[\"apogee_x\"])\n",

docs/notebooks/dispersion_analysis/dispersion_class_usage.ipynb renamed to docs/notebooks/monte_carlo_analysis/monte_carlo_class_usage.ipynb

Lines changed: 79 additions & 87 deletions
Large diffs are not rendered by default.

docs/notebooks/dispersion_analysis/parachute_drop_from_helicopter.ipynb renamed to docs/notebooks/monte_carlo_analysis/parachute_drop_from_helicopter.ipynb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"!git clone https://github.com/giovaniceotto/RocketPy.git\n",
3535
"import os\n",
3636
"\n",
37-
"os.chdir(\"RocketPy/docs/notebooks/dispersion_analysis\")"
37+
"os.chdir(\"RocketPy/docs/notebooks/monte_carlo_analysis\")"
3838
]
3939
},
4040
{
@@ -391,7 +391,7 @@
391391
"outputs": [],
392392
"source": [
393393
"# Basic analysis info\n",
394-
"filename = \"dispersion_analysis_outputs/parachute_drop_from_helicopter\"\n",
394+
"filename = \"monte_carlo_analysis_outputs/parachute_drop_from_helicopter\"\n",
395395
"number_of_simulations = 4000\n",
396396
"\n",
397397
"# Create data files for inputs, outputs and error logging\n",
@@ -413,7 +413,7 @@
413413
"Env.maxExpectedHeight = 1500\n",
414414
"Env.setAtmosphericModel(\n",
415415
" type=\"Ensemble\",\n",
416-
" file=\"dispersion_analysis_inputs/LASC2019_reanalysis.nc\",\n",
416+
" file=\"monte_carlo_analysis_inputs/LASC2019_reanalysis.nc\",\n",
417417
" dictionary=\"ECMWF\",\n",
418418
")\n",
419419
"\n",
@@ -436,7 +436,7 @@
436436
"\n",
437437
" # Create motor\n",
438438
" Keron = SolidMotor(\n",
439-
" thrustSource=\"dispersion_analysis_inputs/thrustCurve.csv\",\n",
439+
" thrustSource=\"monte_carlo_analysis_inputs/thrustCurve.csv\",\n",
440440
" burn_time=5.274,\n",
441441
" reshapeThrustCurve=(setting[\"burn_time\"], setting[\"impulse\"]),\n",
442442
" nozzle_radius=setting[\"nozzle_radius\"],\n",
@@ -459,8 +459,8 @@
459459
" mass=setting[\"rocketMass\"],\n",
460460
" inertiaI=setting[\"inertiaI\"],\n",
461461
" inertiaZ=setting[\"inertiaZ\"],\n",
462-
" powerOffDrag=\"dispersion_analysis_inputs/Cd_PowerOff.csv\",\n",
463-
" powerOnDrag=\"dispersion_analysis_inputs/Cd_PowerOn.csv\",\n",
462+
" powerOffDrag=\"monte_carlo_analysis_inputs/Cd_PowerOff.csv\",\n",
463+
" powerOnDrag=\"monte_carlo_analysis_inputs/Cd_PowerOn.csv\",\n",
464464
" centerOfDryMassPosition=0,\n",
465465
" coordinateSystemOrientation=\"tailToNose\",\n",
466466
" )\n",
@@ -581,7 +581,7 @@
581581
},
582582
"outputs": [],
583583
"source": [
584-
"filename = \"dispersion_analysis_outputs/parachute_drop_from_helicopter\"\n",
584+
"filename = \"monte_carlo_analysis_outputs/parachute_drop_from_helicopter\"\n",
585585
"\n",
586586
"# Initialize variable to store all results\n",
587587
"dispersion_general_results = []\n",
@@ -1165,7 +1165,7 @@
11651165
"from matplotlib.patches import Ellipse\n",
11661166
"\n",
11671167
"# Import background map\n",
1168-
"img = imread(\"dispersion_analysis_inputs/Valetudo_basemap_final.jpg\")\n",
1168+
"img = imread(\"monte_carlo_analysis_inputs/Valetudo_basemap_final.jpg\")\n",
11691169
"\n",
11701170
"# Retrieve dispersion data por apogee and impact XY position\n",
11711171
"apogeeX = np.array(dispersion_results[\"apogeeX\"])\n",

docs/user/first_simulation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ analysis. Here we will show some examples, but much more can be done!
661661
.. seealso::
662662
*RocketPy* can be used to perform a Monte Carlo Dispersion Analysis.
663663
See
664-
`Monte Carlo Simulations <https://colab.research.google.com/github/RocketPy-Team/rocketpy/blob/master/docs/notebooks/dispersion_analysis/dispersion_analysis.html>`_
664+
`Monte Carlo Simulations <https://colab.research.google.com/github/RocketPy-Team/rocketpy/blob/master/docs/notebooks/monte_carlo_analysis/monte_carlo_analysis.html>`_
665665
for more information.
666666

667667
Apogee as a Function of Mass

docs/user/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ RocketPy's User Guide
2929
:maxdepth: 2
3030
:caption: Dispersion Analysis
3131

32-
../notebooks/dispersion_analysis/dispersion_analysis.ipynb
33-
../notebooks/dispersion_analysis/parachute_drop_from_helicopter.ipynb
32+
../notebooks/monte_carlo_analysis/monte_carlo_analysis.ipynb
33+
../notebooks/monte_carlo_analysis/parachute_drop_from_helicopter.ipynb
3434

3535
.. toctree::
3636
:maxdepth: 2

rocketpy/__init__.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
funcify_method,
66
reset_funcified_methods,
77
)
8-
from .monte_carlo import (
9-
McEllipticalFins,
10-
McEnvironment,
11-
McFlight,
12-
McNoseCone,
13-
McParachute,
14-
McRocket,
15-
McSolidMotor,
16-
McTail,
17-
McTrapezoidalFins,
8+
from .stochastic import (
9+
StochasticEllipticalFins,
10+
StochasticEnvironment,
11+
StochasticFlight,
12+
StochasticNoseCone,
13+
StochasticParachute,
14+
StochasticRocket,
15+
StochasticSolidMotor,
16+
StochasticTail,
17+
StochasticTrapezoidalFins,
1818
)
1919
from .motors import (
2020
CylindricalTank,
@@ -45,5 +45,5 @@
4545
Tail,
4646
TrapezoidalFins,
4747
)
48-
from .simulation import Flight, Dispersion
48+
from .simulation import Flight, MonteCarlo
4949
from .plots.compare import Compare, CompareFlights

rocketpy/monte_carlo/__init__.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

rocketpy/plots/dispersion_plots.py renamed to rocketpy/plots/monte_carlo_plots.py

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
1-
__author__ = (
2-
"Mateus Stano Junqueira, Guilherme Fernandes Alves, Bruno Abdulklech Sorban"
3-
)
4-
__copyright__ = "Copyright 20XX, RocketPy Team"
5-
__license__ = "MIT"
6-
7-
81
import matplotlib.pyplot as plt
92

10-
from ..tools import generate_dispersion_ellipses
3+
from ..tools import generate_monte_carlo_ellipses
114

125

13-
class _DispersionPlots:
14-
"""Class to plot the dispersion results of the dispersion analysis."""
6+
class _MonteCarloPlots:
7+
"""Class to plot the monte carlo analysis results."""
158

16-
def __init__(self, dispersion):
17-
self.dispersion = dispersion
18-
return None
9+
def __init__(self, monte_carlo):
10+
self.monte_carlo = monte_carlo
1911

2012
def ellipses(
2113
self,
@@ -36,7 +28,7 @@ def ellipses(
3628
The path to the image to be used as the background
3729
actual_landing_point : tuple, optional
3830
A tuple containing the actual landing point of the rocket, if known.
39-
Useful when comparing the dispersion results with the actual landing.
31+
Useful when comparing the Monte Carlo results with the actual landing.
4032
Must be given in tuple format, such as (x, y) in meters.
4133
By default None.
4234
perimeterSize : int, optional
@@ -76,7 +68,7 @@ def ellipses(
7668
apogeeY,
7769
impactX,
7870
impactY,
79-
) = generate_dispersion_ellipses(self.dispersion.results)
71+
) = generate_monte_carlo_ellipses(self.monte_carlo.results)
8072

8173
# Create plot figure
8274
plt.figure(num=None, figsize=(8, 6), dpi=150, facecolor="w", edgecolor="k")
@@ -117,7 +109,8 @@ def ellipses(
117109

118110
# Add title and labels to plot
119111
ax.set_title(
120-
"1$\\sigma$, 2$\\sigma$ and 3$\\sigma$ Dispersion Ellipses: Apogee and Landing Points"
112+
"1$\\sigma$, 2$\\sigma$ and 3$\\sigma$ "
113+
+ "Monte Carlo Ellipses: Apogee and Landing Points"
121114
)
122115
ax.set_ylabel("North (m)")
123116
ax.set_xlabel("East (m)")
@@ -146,16 +139,15 @@ def ellipses(
146139
# Save plot and show result
147140
if save:
148141
plt.savefig(
149-
str(self.dispersion.filename) + ".png",
142+
str(self.monte_carlo.filename) + ".png",
150143
bbox_inches="tight",
151144
pad_inches=0,
152145
)
153146
else:
154147
plt.show()
155-
return None
156148

157149
def all_results(self, keys=None):
158-
"""Plot the results of the dispersion analysis.
150+
"""Plot the results of the Monte Carlo analysis.
159151
160152
Parameters
161153
----------
@@ -169,11 +161,11 @@ def all_results(self, keys=None):
169161
"""
170162

171163
if keys is None:
172-
keys = self.dispersion.results.keys()
164+
keys = self.monte_carlo.results.keys()
173165
elif isinstance(keys, str):
174166
keys = [keys]
175167
elif isinstance(keys, (list, tuple)):
176-
keys = list(set(keys).intersection(self.dispersion.results.keys()))
168+
keys = list(set(keys).intersection(self.monte_carlo.results.keys()))
177169
if len(keys) == 0:
178170
raise ValueError(
179171
"The selected 'keys' are not available in the results. "
@@ -187,10 +179,8 @@ def all_results(self, keys=None):
187179
for key in keys:
188180
plt.figure()
189181
plt.hist(
190-
self.dispersion.results[key],
182+
self.monte_carlo.results[key],
191183
)
192184
plt.title("Histogram of " + key)
193185
plt.ylabel("Number of Occurrences")
194186
plt.show()
195-
196-
return None
Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
__author__ = "Guilherme Fernandes Alves"
2-
__copyright__ = "Copyright 20XX, RocketPy Team"
3-
__license__ = "MIT"
1+
class _MonteCarloPrints:
2+
"""Class to print the monte carlo analysis results."""
43

5-
6-
class _DispersionPrints:
7-
"""Class to print the dispersion results of the dispersion analysis."""
8-
9-
def __init__(self, dispersion):
10-
self.dispersion = dispersion
4+
def __init__(self, monte_carlo):
5+
self.monte_carlo = monte_carlo
116
return None
127

138
def all_results(self):
@@ -24,12 +19,12 @@ def all_results(self):
2419
2520
"""
2621
print("Monte Carlo Simulation by RocketPy")
27-
print("Data Source: ", self.dispersion.filename)
28-
print("Number of simulations: ", self.dispersion.num_of_loaded_sims)
22+
print("Data Source: ", self.monte_carlo.filename)
23+
print("Number of simulations: ", self.monte_carlo.num_of_loaded_sims)
2924
print("Results: \n")
3025
print("{:>25} {:>15} {:>15}".format("Parameter", "Mean", "Std. Dev."))
3126
print("-" * 60)
32-
for key, value in self.dispersion.processed_results.items():
27+
for key, value in self.monte_carlo.processed_results.items():
3328
print("{:>25} {:>15.3f} {:>15.3f}".format(key, value[0], value[1]))
3429

3530
return None

rocketpy/simulation/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from .dispersion import Dispersion
1+
from .monte_carlo import MonteCarlo
22
from .flight import Flight
33
from .flight_data_importer import FlightDataImporter

0 commit comments

Comments
 (0)