scenarioVisualizeMonteCarlo

Motivation

This script demonstrates how to plot Monte Carlo data using Bokeh. This tool efficiently visualizes large amounts of simulation data typically generated in Monte Carlo sensitivity analysis studies. Running this script creates an interactive HTML view of the simulation data, allowing users to dynamically zoom into the data for more detail.

The following plots illustrate what this particular simulation setup will yield:

attGuidMsg.sigma_BR - Component 1

Bokeh Plot

This plot shows component 1 of the attGuidMsg.sigma_BR variable.

attGuidMsg.sigma_BR - Component 2

Bokeh Plot

This plot shows component 2 of the attGuidMsg.sigma_BR variable.

attGuidMsg.sigma_BR - Component 3

Bokeh Plot

This plot shows component 3 of the attGuidMsg.sigma_BR variable.

attGuidMsg.omega_BR_B - Component 1

Bokeh Plot

This plot shows component 1 of the attGuidMsg.omega_BR_B variable.

attGuidMsg.omega_BR_B - Component 2

Bokeh Plot

This plot shows component 2 of the attGuidMsg.omega_BR_B variable.

attGuidMsg.omega_BR_B - Component 3

Bokeh Plot

This plot shows component 3 of the attGuidMsg.omega_BR_B variable.

Efficient Handling of Large Datasets

This implementation uses Bokeh to efficiently handle and visualize large datasets, including those exceeding one gigabyte in size. Here’s how it achieves this:

  1. Data Loading: The script uses pandas to load data from pickle files, which is an efficient method for handling large datasets.

  2. Dynamic Sampling: While the full dataset is loaded, not all points are plotted at once. The plot is sized by the user’s zoom level and location within the data set.

  3. Efficient Rendering: Bokeh uses HTML5 Canvas for rendering, which is highly efficient for displaying large numbers of data points.

  4. Client-Side Interaction: Most of the interactivity (panning, zooming) happens on the client-side in the browser, reducing the need for constant server communication.

  5. Data Streaming: The plot is updated dynamically as the user interacts with it, loading only the necessary data for the current view.

This approach allows for smooth interaction with large datasets that would be impractical to plot all at once using traditional plotting libraries.

How to Run the Script

Follow these steps to run the script:

  1. First, run the scenarioBskSimAttFeedbackMC.py script to generate the necessary data files:

    python scenarioBskSimAttFeedbackMC.py
    
  2. Run this script from the command line using:

    To generate a static HTML file:

    from scenarioVisualizeMonteCarlo import run
    run(useBokeh_server=False)
    

    To start an interactive Bokeh server:

    from scenarioVisualizeMonteCarlo import run
    run(useBokeh_server=True)
    

    Alternatively, you can run this script directly from the command line:

    # For static HTML generation
    python scenarioVisualizeMonteCarlo.py
    
    # For interactive Bokeh server
    python scenarioVisualizeMonteCarlo.py --bokeh-server
    

    This will process the data created by scenarioBskSimAttFeedbackMC.py and open a browser window showing the interactive plot.

  3. Use the dropdown menus to select different variables and components to plot.

  4. Enter specific run numbers in the text input field to highlight those runs on the plot.

  5. Use the pan, zoom, and reset tools to explore the data in detail.

  6. Use the close button to close the application, then close the browser tab in your browser.

The script will display information about the loaded data, including the number of runs and total data size, at the top of the plot.