This script is a basic demonstration of a script that can be used to plot Monte Carlo data with bokeh and datashaders. These tools are very efficient to plot large amounts of simulation data that is likely to occur with Monte Carlo sensitivity analysis studies. For example, running this script will create an HTML interactive view of the simulation data. Instead of seeing a fixed resolution, the user can zoom into the data dynamically to see more detail. This process recreates a newly render view of the simulation data.
The following two plots illustrate what this particular simulation setup will yield.
The next plot illustrates the output if you run
scenario_AttFeedbackMC.py with more simulation cases,
40 in this plot.
Configuring a Python Environment For this Script¶
Running this script is different from running other BSK scripts. There are very particular python package requirements that must be carefully followed. It is recommended the user create a virtual python environment as discussed in the installation setup. This environment might have to be specific to running this script because of these dependency challenges.
The setup steps are as follows:
The datashaders etc. require that this script be run with Python 3.7, not higher
Create dedicated virtual environment and compile Basilisk for this environment
Install this particular version of
panelpackage first. It must be done alone as it upgrades
bokehto a version that is too new:
pip3 install --upgrade panel==0.9.7
Next, install the following particular python package versions:
pip3 install --upgrade bokeh==1.2.0 holoviews==1.12.3 param==1.9.3 hvplot==0.6.0
How to Run the Script¶
Read all three steps before advancing.
The next steps outline how to run this script.
This script can only be run once there exists data produced by the
At the bottom of this script, comment out the name guard and associated
run()statement, and un-comment the following
run()statement before this script can run. These lines are provided in their commented/uncommented form to ensure that the sphinx documentation generation process does not run this script automatically.
This script must be called from command line using:
/$path2bin/bokeh serve --show /$path2script/scenarioAnalyzeMonteCarlo.py
This will process the data created with
scenario_AttFeedbackMC.py and open a browser window showing
Figure 1 above. To end the script you need to press the typical key strokes to interrupt a process as the
bokeh server will keep running until stopped.
This is the function to populate with all of the plots to be generated using datashaders and bokeh. Each variable requires a call to
pull_and_format_df()to ensure the dataframe will be compatible with the developed datashader utilities.
dataDir – (str) directory containing all of the dataframes created from the Monte Carlo run
Returns: List of DS_Plots
This script is meant to be configured based on the user’s needs. It can be configured using the following three booleans:
show_all_data = Trueto get a broad view of the data and find a time window to investigate closer.
Once the data is characterized, the user can set
show_extreme_data = Trueto look at specific run cases within the window.
Finally, the user can set
show_optional_data = Trueto look at any extra data to determine why the extrema cases exist.
show_all_data – plot all MC runs for the plots specified in the plotSuite method
show_extreme_data – call plotSuite method for user-defined number of extrema MC runs
optional_plots – plots additional user-defined plots