AVSLab / basilisk

Astrodynamics simulation framework
https://hanspeterschaub.info/basilisk
ISC License
148 stars 61 forks source link

Feature/bokeh mc bringup #835

Closed Natsoulas closed 3 weeks ago

Natsoulas commented 1 month ago

Description

This branch introduces significant improvements to the Monte Carlo plotting capabilities in Basilisk, focusing on enhancing the AnalysisBaseClass.py file and related example scenarios. The key changes include:

  1. The MonteCarloPlotter class:

    • Improved data loading and management
    • Dynamic plot creation with support for multiple variables and components
    • Interactive plot updates based on user input
    • Efficient handling of large datasets through downsampling and streaming
  2. Bokeh Integration:

    • Added support for Bokeh, enabling interactive HTML-based visualizations
    • Implemented a Bokeh server option for real-time plot updates
    • Created a fallback to matplotlib when Bokeh is unavailable
  3. User Interface Improvements:

    • Added dropdown menus for variable and component selection
    • Implemented a search functionality to highlight specific run numbers
    • Created a status indicator to show plot loading/updating status
  4. Documentation and File Management:

    • Improved plot saving functionality, including HTML and RST file generation
    • Enhanced documentation generation for saved plots
  5. Example Scenario Updates:

    • Modified scenarioMonteCarloAttRW.py to showcase the new plotting capabilities
    • Added command-line options for data deletion and Bokeh server usage
    • Implemented a new scenarioRerunMonteCarlo.py for demonstrating how to rerun specific Monte Carlo simulations
    • Removed "This is a hack..." line from the repo and added objects directly to 'sim' parent object to remain in scope for MC runs
  6. Testing and Compatibility:

    • Updated test_bskMcTestScript.py to accommodate the new features
    • Ensured backward compatibility with existing Monte Carlo simulations

These changes significantly improve the visualization and analysis capabilities for Monte Carlo simulations in Basilisk, providing users with more interactive and informative tools to explore simulation results.

Verification

The changes were validated through the following methods:

  1. Manual Testing:

    • Extensive testing of the new MonteCarloPlotter class functionality
    • Verification of Bokeh integration and fallback to matplotlib
    • Testing of user interface improvements, including dropdown menus and run number search functionality
  2. Automated Tests:

    • Updated test_bskMcTestScript.py to cover new features and ensure backward compatibility
    • Added new unit tests for the MonteCarloPlotter class to verify data loading, plot creation, and interactive updates
  3. Example Scenario Testing:

    • Ran and verified the modified scenarioMonteCarloAttRW.py to showcase new plotting capabilities
    • Tested the new scenarioRerunMonteCarlo.py to ensure proper functionality for rerunning specific Monte Carlo simulations
  4. Performance Testing:

    • Conducted manual performance tests with large datasets up to 1 GB in size to verify efficient data handling and display
  5. Documentation Review:

    • Verified that the updated documentation accurately reflects the new features and usage instructions in sphinx documentation

No tests were removed or re-baselined. The addition and update of tests were necessary to cover the new functionality and ensure the reliability of the Monte Carlo plotting capabilities.

Documentation

The following documentation has been affected by these changes and should be reviewed for accuracy and completeness:

  1. Docstrings in modified files:

    • scenarioVisualizeMonteCarlo.py: Revised docstrings to reflect new command-line options and usage of updated plotting capabilities (bokeh) and this along with the other files was renamed from scenarioAnalyzeMonteCarlo.py
    • scenarioMonteCarloAttRW.py: Revised docstrings to reflect new command-line options and usage of updated plotting capabilities
    • scenarioRerunMonteCarlo.py: New file with comprehensive docstrings explaining the purpose and usage of rerunning specific Monte Carlo simulations
  2. optional-requirements.txt:

    • Added Bokeh and Dask to the list of optional requirements
    • Reviewers should verify these optional packages are sufficient for the new plotting capabilities introduced in this branch/pr.

Reviewers should pay particular attention to:

Additionally, reviewers should ensure that the addition of Bokeh and Dask to the optional requirements is properly documented in any relevant README files or user guides.

Future work

  1. Further optimization of performance for large datasets:

    • Investigate and implement data compression techniques to improve handling of very large Monte Carlo datasets
    • Explore more efficient data streaming methods for real-time plot updates
  2. Refinement of Bokeh plotting tools:

    • Gather user feedback on the new Monte Carlo plotting capabilities
    • Based on feedback, potentially simplify or customize Bokeh plotting tools specifically for Monte Carlo simulations
    • Consider adding more advanced interactive features or visualization types if requested by users/devs/researchers
  3. Expansion of rerun capabilities:

    • Enhance the scenarioRerunMonteCarlo.py to support more complex rerun scenarios
    • Implement a user-friendly interface for selecting specific Monte Carlo runs to rerun
  4. Integration with other Basilisk modules:

    • Explore opportunities to integrate the improved Monte Carlo plotting capabilities with any other relevant Basilisk analysis and visualization tools
  5. Documentation and tutorials???:

    • Develop more comprehensive tutorials and examples showcasing the new Monte Carlo plotting features
    • Perhaps create a video tutorial to help users quickly adopt and leverage the new capabilities

Note: These future work items are based on anticipated needs and potential improvements. Priorities may be adjusted based on actual user feedback and project requirements.