-
-
Notifications
You must be signed in to change notification settings - Fork 167
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
ENH: disp more results to rocketpy.plots & rocketpy.prints #753
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -327,5 +327,8 @@ | |
"zlabel", | ||
"zlim", | ||
"zorder" | ||
] | ||
], | ||
"files.associations": { | ||
"plyconfig.json": "jsonc" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,7 +149,8 @@ def ellipses( | |
|
||
def all(self, keys=None): | ||
""" | ||
Plot the histograms of the Monte Carlo simulation results. | ||
Plot the histograms with Boxplots & density plots | ||
of the Monte Carlo simulation results. | ||
|
||
Parameters | ||
---------- | ||
|
@@ -175,8 +176,19 @@ def all(self, keys=None): | |
raise ValueError("The 'keys' argument must be a string, list, or tuple.") | ||
|
||
for key in keys: | ||
plt.figure() | ||
plt.hist(self.monte_carlo.results[key]) | ||
plt.title(f"Histogram of {key}") | ||
plt.ylabel("Number of Occurrences") | ||
plt.show() | ||
figure, plt = plt.subplots(3,1,sharex=True,gridspec_kw={'height_ratios':[1,3]}) | ||
|
||
plt[0].boxplot(self.monte_carlo.results[key],vert=False) | ||
plt[0].ytick([]) | ||
|
||
plt[1].hist(self.monte_carlo.results[key]) | ||
plt[1].title(f"Histogram of {key}") | ||
plt[1].ylabel("Number of Occurrences") | ||
|
||
plt[2].hist(self.monte_carlo.results[key], density=True) | ||
plt[2].title(f" Density {key}") | ||
plt[2].ylabel("Probability Density") | ||
kde = kde.gaussian_kde(self.monte_carlo.results[key]) | ||
x_array = np.linspace(min(self.monte_carlo.results[key]), max(self.monte_carlo.results[key]), 100) | ||
plt[2].plot(x_array, kde(x_array), label='KDE') | ||
plt.show() | ||
Comment on lines
+179
to
+194
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. This generates errors when I try to create plot |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import numpy as np | ||
|
||
class _MonteCarloPrints: | ||
"""Class to print the monte carlo analysis results.""" | ||
|
||
def __init__(self, monte_carlo): | ||
self.monte_carlo = monte_carlo | ||
|
||
def all(self): | ||
"""Print the mean and standard deviation of each parameter in the results | ||
dictionary or of the variables passed as argument. | ||
"""Print the mean, standard deviation, and quantiles (0%, 2.5%, 50%, 97.5%, 100%) | ||
of each parameter in the results dictionary or of the variables passed as argument. | ||
|
||
Parameters | ||
---------- | ||
|
@@ -19,12 +21,14 @@ def all(self): | |
""" | ||
print("Monte Carlo Simulation by RocketPy") | ||
print("Data Source: ", self.monte_carlo.filename) | ||
print("Number of simulations: ", self.monte_carlo.num_of_loaded_sims) | ||
print("Number of Simulations: ", self.monte_carlo.num_of_loaded_sims) | ||
print("Results: \n") | ||
print(f"{'Parameter':>25} {'Mean':>15} {'Std. Dev.':>15}") | ||
|
||
print(f"{'Parameter':>25} {'Mean':>15} {'Std. Dev.':>15} {'0% Quant':>15} {'2.5% Quant.':>15} {'50% Quant.':>15} {'97.5% Quant.':>15} {'100% Quant.':>15}") | ||
print("-" * 60) | ||
for key, value in self.monte_carlo.processed_results.items(): | ||
try: | ||
print(f"{key:>25} {value[0]:>15.3f} {value[1]:>15.3f}") | ||
pt = self.monte_carlo.results[key] | ||
print (f"{key:>25} {value[0]:>15.3f} {value[1]:>15.3f} {np.quantile(pt,0):>15.3f} {np.quantile(pt,0.025):>15.3f} {np.quantile(pt,0.5):>15.3f} {np.quantile(pt,0.975):>15.3f} {np.quantile(pt,1):>15.3f}") | ||
except TypeError: | ||
print(f"{key:>25} {str(value[0]):>15} {str(value[1]):>15}") | ||
print (f"{key:>25} {str(value[0]):>15} {str(value[1]):>15} {str(np.quantile(pt,0)):>15} {str(np.quantile(pt,0.025)):>15} {str(np.quantile(pt,0.5)):>15} {str(np.quantile(pt,0.975)):>15} {str(np.quantile(pt,1)):>15}") | ||
Comment on lines
+31
to
+34
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 believe "min" and "max" are way more clear than "0% quantile" and "100% quantile". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to the issue.