Skip to content
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

Add cli compatibility to scenario_AttFeedbackMC.py #354

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions examples/MonteCarloExamples/scenario_AttFeedbackMC.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import inspect
import os
import sys

import matplotlib.pyplot as plt
import numpy as np
Expand All @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -117,4 +118,9 @@ def displayPlots(data, retentionPolicy):


if __name__ == "__main__":
run(True)
if len(sys.argv) == 1:
run(True)
elif len(sys.argv) == 2:
run(True, int(sys.argv[1]))
elif len(sys.argv) == 3:
run(True, int(sys.argv[1]), int(sys.argv[2]))
Loading