Skip to content

Commit 8008aa7

Browse files
committed
MNT: remove post processing scripts.
1 parent 2a42b26 commit 8008aa7

13 files changed

+3629
-2502
lines changed

docs/notebooks/monte_carlo_analysis/monte_carlo_analysis_outputs/monte_carlo_class_example.inputs.txt

+10-1,000
Large diffs are not rendered by default.

docs/notebooks/monte_carlo_analysis/monte_carlo_analysis_outputs/monte_carlo_class_example.outputs.txt

+10-1,000
Large diffs are not rendered by default.

docs/notebooks/monte_carlo_analysis/monte_carlo_class_usage.ipynb

+3,585-74
Large diffs are not rendered by default.

requirements-optional.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ ipywidgets>=7.6.3
44
jsonpickle
55
timezonefinder
66
imageio
7-
h5py
8-
easygui
7+
h5py

rocketpy/simulation/monte_carlo.py

+23-30
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
import json
1818
import os
1919
import pickle
20+
import warnings
2021
from copy import deepcopy
2122
from pathlib import Path
22-
import warnings
2323
from time import process_time, time
2424

2525
import h5py
@@ -102,7 +102,7 @@ def __init__(
102102
export_list=None,
103103
batch_path=None,
104104
export_sample_time=0.1,
105-
): # pylint: disable=too-many-statements
105+
): # pylint: disable=too-many-statements
106106
"""
107107
Initialize a MonteCarlo object.
108108
@@ -165,7 +165,7 @@ def __init__(
165165

166166
if not os.path.exists(self.batch_path):
167167
os.makedirs(self.batch_path)
168-
168+
169169
self.export_list = self.__check_export_list(export_list)
170170

171171
try:
@@ -191,7 +191,6 @@ def simulate(
191191
light_mode=False,
192192
parallel=False,
193193
n_workers=None,
194-
195194
): # pylint: disable=too-many-statements
196195
"""
197196
Runs the Monte Carlo simulation and saves all data.
@@ -246,7 +245,6 @@ def simulate(
246245
else:
247246
self.__run_in_serial(append, light_mode=light_mode)
248247

249-
250248
def __run_in_serial(self, append, light_mode):
251249
"""
252250
Runs the monte carlo simulation in serial mode.
@@ -468,7 +466,7 @@ def __run_in_parallel(self, append, light_mode, n_workers=None):
468466
print(f"Number of simulations: {self.number_of_simulations}")
469467

470468
# Creates n_workers processes then starts them
471-
for i in range(n_workers - 2): # leave 2 cores for the writer workers
469+
for _ in range(n_workers - 2): # leave 2 cores for the writer workers
472470
p = Process(
473471
target=self.__run_simulation_worker,
474472
args=(
@@ -542,27 +540,24 @@ def __run_in_parallel(self, append, light_mode, n_workers=None):
542540
input_writer_stop_event.set()
543541
results_writer_stop_event.set()
544542

545-
print("Waiting for writer workers to join.")
546-
# join the writer workers
547543
input_writer.join()
548544
results_writer.join()
549545

550546
self.number_of_simulations = sim_counter.get_count()
551547

552548
parallel_end = time()
553549

554-
print("-" * 80 + "\nAll workers joined, simulation complete.")
550+
print("-" * 80 + "\n")
551+
print("All workers joined, simulation complete.")
555552
print(
556553
f"In total, {sim_counter.get_count() - idx_i} simulations were performed."
557554
)
558555
print(
559-
"Simulation took",
560-
parallel_end - parallel_start_time,
561-
"seconds to run.",
556+
f"Simulation took {(parallel_end - parallel_start_time):.2f} seconds to run."
562557
)
563558

564559
finally:
565-
# ensure shared memory is realeased
560+
# ensure shared memory is released
566561
shared_inputs_buffer.close()
567562
shared_results_buffer.close()
568563
shared_inputs_buffer.unlink()
@@ -649,22 +644,14 @@ def __run_simulation_worker(
649644
if sim_idx == -1:
650645
break
651646

652-
env = sto_env.create_object()
653-
rocket = sto_rocket.create_object()
654-
rail_length = sto_flight._randomize_rail_length()
655-
inclination = sto_flight._randomize_inclination()
656-
heading = sto_flight._randomize_heading()
657-
initial_solution = sto_flight.initial_solution
658-
terminate_on_apogee = sto_flight.terminate_on_apogee
659-
660647
monte_carlo_flight = Flight(
661-
rocket=rocket,
662-
environment=env,
663-
rail_length=rail_length,
664-
inclination=inclination,
665-
heading=heading,
666-
initial_solution=initial_solution,
667-
terminate_on_apogee=terminate_on_apogee,
648+
rocket=sto_rocket.create_object(),
649+
environment=sto_env.create_object(),
650+
rail_length=sto_flight._randomize_rail_length(),
651+
inclination=sto_flight._randomize_inclination(),
652+
heading=sto_flight._randomize_heading(),
653+
initial_solution=sto_flight.initial_solution,
654+
terminate_on_apogee=sto_flight.terminate_on_apogee,
668655
)
669656

670657
# Export to file
@@ -793,7 +780,7 @@ def __run_single_simulation(
793780
terminate_on_apogee=self.flight.terminate_on_apogee,
794781
)
795782

796-
self._inputs_dict = dict(
783+
inputs_dict = dict(
797784
item
798785
for d in [
799786
self.environment.last_rnd_dict,
@@ -802,7 +789,13 @@ def __run_single_simulation(
802789
]
803790
for item in d.items()
804791
)
805-
self._inputs_dict["idx"] = sim_idx
792+
inputs_dict["idx"] = sim_idx
793+
794+
inputs_dict = MonteCarlo.prepare_export_data(
795+
inputs_dict, self.export_sample_time, remove_functions=True
796+
)
797+
798+
self._inputs_dict = inputs_dict
806799

807800
# Export inputs and outputs to file
808801
if light_mode:

rocketpy/stochastic/post_processing/__init__.py

Whitespace-only changes.

rocketpy/stochastic/post_processing/scripts/__init__.py

Whitespace-only changes.

rocketpy/stochastic/post_processing/scripts/stochastic_apogee.py

-49
This file was deleted.

rocketpy/stochastic/post_processing/scripts/stochastic_impact_point.py

-83
This file was deleted.

rocketpy/stochastic/post_processing/scripts/stochastic_mach.py

-37
This file was deleted.

rocketpy/stochastic/post_processing/scripts/stochastic_maxQ.py

-42
This file was deleted.

0 commit comments

Comments
 (0)