This script illustrates how to run a Monte Carlo simulation where the Spice is used within the Python setup. Note that the Python Spice setup is separate from the BSK c++ Spice module setup. In this tutorial a very simple simulation is shown to showcase how to correctly perform Python-based Spice function calls with a Basilisk Monte Carlo run.
The script is found in the folder
basilisk/examples and executed by using:
The simulation sets up a simple spacecraft and associated initial conditions. Note that the Basilisk spacecraft
simulation is setup within the class
MySimulation. Here the the code is added to load Spice kernels within
Python to pull the Hubble states from Spice. Thus, this python Spice call is performed within each Monte Carlo
thread. In this simple example the Hubble states are then printed to the terminal.
As this Monte Carlo scenario is setup to run 12 times, by running this script the user should see no errors and the Hubble states printed out 12 times.
In the Controller class MyController there is Spice kernel loading code that is commented out. If the kernels are loaded within the controller class then this results in a Spice kernel loading error.
The user should be careful to load the Spice or use within the Python code within the simulation class.
- class scenarioMonteCarloSpice.MyController¶
- class scenarioMonteCarloSpice.MySimulation¶
This is the main function that is called in this script. It illustrates possible ways to include the Python Spice library in a simulation that uses Monte Carlo runs.