Skip to content

Commit

Permalink
reconcile bokeh html autogen with sphinx rst docs autogen
Browse files Browse the repository at this point in the history
  • Loading branch information
Natsoulas committed Oct 22, 2024
1 parent 6389d80 commit 86d4adb
Show file tree
Hide file tree
Showing 14 changed files with 540 additions and 316 deletions.
104 changes: 95 additions & 9 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,104 @@
* **Tickets addressed:** bsk-000
* **Review:** By commit <!-- Choose from: "by commit", "by file" -->
* **Merge strategy:** Merge (no squash) <!-- Choose from: "merge (no squash)", "squash and merge" -->
* **Review:** By file
* **Merge strategy:** Merge (no squash)

## Description
<!-- What approach was taken to satisfy the ticket being addressed? What should reviewers be aware of? How are your
commits organized? -->
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

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
<!-- How were the changes validated? Were any automated tests added, updated, removed, or re-baselined? If you didn't
add or update any tests justify this choice. -->
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
<!-- What documentation was invalidated by these changes? Which artifacts should reviewers check for accuracy and
completeness? -->
The following documentation has been affected by these changes and should be reviewed for accuracy and completeness:

1. Docstrings in modified files:
- `AnalysisBaseClass.py`: Updated docstrings for the `MonteCarloPlotter` class and its methods, particularly those related to Bokeh integration and new plotting features
- `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:
- Accuracy and completeness of docstrings in the modified files
- Clarity of explanations for new features and methods
- Consistency between code behavior and documented functionality
- Correct specification of Bokeh and Dask in the optional requirements file

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
<!-- What next steps can we anticipate from here, if any? -->
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

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 comprehensive tutorials and examples showcasing the new Monte Carlo plotting features
- Create video tutorials 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 user feedback and project requirements.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ venv/
build/

# Monte Carlo ignore generated data files and test init file.
examples/MonteCarloExamples/scenario_AttFeedbackMC/
examples/MonteCarloExamples/scenarioBskSimAttFeedbackMC/
src/utilities/tests/__init__.py
examples/montecarlo_test*/
2 changes: 1 addition & 1 deletion docs/source/Support/bskReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ Version 2.1.0 (Nov. 13, 2021)
- Fixed a rare issue where RW data didn't stick
- Fixed an issue subscribing to a C++ wrapped message object from python
- Cleaned up documentation on using datashaders and bokeh to interactively plot large simulation data sets.
The script :ref:`scenarioAnalyzeMonteCarlo` is updated to discuss the particular challenges in running this
The script :ref:`scenarioVisualizeMonteCarlo` is updated to discuss the particular challenges in running this
datashader example of plotting data.
- enable Monte Carlo ``pytest`` test scripts to run on macOS if Python 3.9 or higher is used
- enable opNav scenario ``pytest`` test scripts to be tested by ``pytest`` if the build flag ``--opNav``
Expand Down
2 changes: 1 addition & 1 deletion examples/BskSim/scenarios/scenario_AttFeedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
class scenario_AttFeedback(BSKSim, BSKScenario):
def __init__(self):
super(scenario_AttFeedback, self).__init__()
self.name = 'scenario_AttFeedbackMC'
self.name = 'scenarioBskSimAttFeedbackMC'

# declare additional class variables
self.msgRecList = {}
Expand Down
150 changes: 0 additions & 150 deletions examples/MonteCarloExamples/scenarioAnalyzeMonteCarlo.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@
-----------
1. Ensure you have Basilisk installed with all required dependencies.
2. Run this script directly to execute the Monte Carlo simulations:
python scenario_AttFeedbackMC.py
python scenarioBskSimAttFeedbackMC.py
3. The script will run 20 Monte Carlo simulations by default.
4. Results will be saved in the 'scenario_AttFeedbackMC' directory within the script's location.
4. Results will be saved in the 'scenarioBskSimAttFeedbackMC' directory within the script's location.
Monte Carlo Configuration:
--------------------------
- Simulation Function: Uses `scenario_AttFeedback.scenario_AttFeedback` to set up the base scenario.
- Execution Function: Uses `scenario_AttFeedback.runScenario` to run each simulation.
- Execution Count: Set to 20 simulations.
- Archive Directory: Results are saved in 'scenario_AttFeedbackMC'.
- Archive Directory: Results are saved in 'scenarioBskSimAttFeedbackMC'.
- Seed Dispersion: Enabled to randomize the seed for each module.
- Variable Casting: Downcasts retained numbers to float32 to save storage space.
- Dispersion Magnitude File: Produces a .txt file showing dispersion in standard deviation units.
Expand Down Expand Up @@ -110,9 +110,9 @@ 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(20) # Required: Number of MCs to run
monteCarlo.setExecutionCount(4) # Required: Number of MCs to run

monteCarlo.setArchiveDir(path + "/scenario_AttFeedbackMC") # Optional: If/where to save retained data.
monteCarlo.setArchiveDir(path + "/scenarioBskSimAttFeedbackMC") # 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, automatically sizes for personal computer.
# monteCarlo.setVerbose(True) # Optional: Produce supplemental text output in console describing status
Expand Down
5 changes: 2 additions & 3 deletions examples/MonteCarloExamples/scenarioRerunMonteCarlo.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
This script is a basic demonstration of a script that can be used to rerun a set or subset of Monte Carlo simulations.
.. important::
This script can only be run once there exists data produced by the ``scenario_AttFeedbackMC.py`` script.
This script can only be run once there exists data produced by the ``scenarioBskSimAttFeedbackMC.py`` script.
"""
Expand Down Expand Up @@ -88,7 +88,7 @@ def run(time=None):
# Step 4: Add any additional retention policies desired
retentionPolicy = RetentionPolicy()
retentionPolicy.logRate = int(2E9)
retentionPolicy.addMessageLog("attGuidMsg", ["sigma_BR"])
retentionPolicy.addMessageLog("attGuidMsg", ["sigma_BR"])
monteCarlo.addRetentionPolicy(retentionPolicy)


Expand All @@ -99,4 +99,3 @@ def run(time=None):

if __name__ == "__main__":
run()

Loading

0 comments on commit 86d4adb

Please sign in to comment.