From 98f62e4b945c01440d0a469b7b9c36bb6269e3bb Mon Sep 17 00:00:00 2001 From: Bryson Smith Date: Wed, 16 Oct 2024 14:02:10 -0600 Subject: [PATCH] Add cli compatibility to scenario_AttFeedbackMC.py --- .../scenario_AttFeedbackMC.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/examples/MonteCarloExamples/scenario_AttFeedbackMC.py b/examples/MonteCarloExamples/scenario_AttFeedbackMC.py index b9e5156ee2..b591c24260 100644 --- a/examples/MonteCarloExamples/scenario_AttFeedbackMC.py +++ b/examples/MonteCarloExamples/scenario_AttFeedbackMC.py @@ -32,6 +32,7 @@ import inspect import os +import sys import matplotlib.pyplot as plt import numpy as np @@ -56,7 +57,7 @@ sNavTransName = "sNavTransMsg" attGuidName = "attGuidMsg" -def run(show_plots): +def run(show_plots, execution_count=4, thread_count=2): """This function is called by the py.test environment.""" # A MonteCarlo simulation can be created using the `MonteCarlo` module. @@ -65,11 +66,11 @@ def run(show_plots): monteCarlo = Controller() monteCarlo.setSimulationFunction(scenario_AttFeedback.scenario_AttFeedback) # Required: function that configures the base scenario monteCarlo.setExecutionFunction(scenario_AttFeedback.runScenario) # Required: function that runs the scenario - monteCarlo.setExecutionCount(4) # Required: Number of MCs to run + monteCarlo.setExecutionCount(execution_count) # Required: Number of MCs to run monteCarlo.setArchiveDir(path + "/scenario_AttFeedbackMC") # Optional: If/where to save retained data. monteCarlo.setShouldDisperseSeeds(True) # Optional: Randomize the seed for each module - monteCarlo.setThreadCount(2) # Optional: Number of processes to spawn MCs on + monteCarlo.setThreadCount(thread_count) # Optional: Number of processes to spawn MCs on monteCarlo.setVerbose(True) # Optional: Produce supplemental text output in console describing status monteCarlo.setVarCast('float') # Optional: Downcast the retained numbers to float32 to save on storage space monteCarlo.setDispMagnitudeFile(True) # Optional: Produce a .txt file that shows dispersion in std dev units @@ -117,4 +118,12 @@ def displayPlots(data, retentionPolicy): if __name__ == "__main__": - run(True) + if len(sys.argv) == 1: + run(True) + elif len(sys.argv) == 2: + execution_count = int(sys.argv[1]) + run(True, execution_count) + elif len(sys.argv) > 3: + execution_count = int(sys.argv[1]) + thread_count = int(sys.argv[2]) + run(True, execution_count, thread_count)