Skip to content

Commit 98f62e4

Browse files
committed
Add cli compatibility to scenario_AttFeedbackMC.py
1 parent 0392057 commit 98f62e4

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

examples/MonteCarloExamples/scenario_AttFeedbackMC.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
import inspect
3434
import os
35+
import sys
3536

3637
import matplotlib.pyplot as plt
3738
import numpy as np
@@ -56,7 +57,7 @@
5657
sNavTransName = "sNavTransMsg"
5758
attGuidName = "attGuidMsg"
5859

59-
def run(show_plots):
60+
def run(show_plots, execution_count=4, thread_count=2):
6061
"""This function is called by the py.test environment."""
6162

6263
# A MonteCarlo simulation can be created using the `MonteCarlo` module.
@@ -65,11 +66,11 @@ def run(show_plots):
6566
monteCarlo = Controller()
6667
monteCarlo.setSimulationFunction(scenario_AttFeedback.scenario_AttFeedback) # Required: function that configures the base scenario
6768
monteCarlo.setExecutionFunction(scenario_AttFeedback.runScenario) # Required: function that runs the scenario
68-
monteCarlo.setExecutionCount(4) # Required: Number of MCs to run
69+
monteCarlo.setExecutionCount(execution_count) # Required: Number of MCs to run
6970

7071
monteCarlo.setArchiveDir(path + "/scenario_AttFeedbackMC") # Optional: If/where to save retained data.
7172
monteCarlo.setShouldDisperseSeeds(True) # Optional: Randomize the seed for each module
72-
monteCarlo.setThreadCount(2) # Optional: Number of processes to spawn MCs on
73+
monteCarlo.setThreadCount(thread_count) # Optional: Number of processes to spawn MCs on
7374
monteCarlo.setVerbose(True) # Optional: Produce supplemental text output in console describing status
7475
monteCarlo.setVarCast('float') # Optional: Downcast the retained numbers to float32 to save on storage space
7576
monteCarlo.setDispMagnitudeFile(True) # Optional: Produce a .txt file that shows dispersion in std dev units
@@ -117,4 +118,12 @@ def displayPlots(data, retentionPolicy):
117118

118119

119120
if __name__ == "__main__":
120-
run(True)
121+
if len(sys.argv) == 1:
122+
run(True)
123+
elif len(sys.argv) == 2:
124+
execution_count = int(sys.argv[1])
125+
run(True, execution_count)
126+
elif len(sys.argv) > 3:
127+
execution_count = int(sys.argv[1])
128+
thread_count = int(sys.argv[2])
129+
run(True, execution_count, thread_count)

0 commit comments

Comments
 (0)