Commit a25fd25
authored
Enh/automatically download images (#896)
* ENH: Add contextily as a dependency for Monte Carlo simulations in pyproject.toml and requirements-optional.txt
* ENH: Add background map functionality to Monte Carlo plots
- Introduced a new method `_get_background_map` to fetch and display background maps using contextily.
- Added support for various map types: "satellite", "street", "terrain", and custom contextily providers.
- Updated `ellipses` and comparison methods to integrate background maps, enhancing visualization capabilities.
- Included error handling and warnings for missing dependencies and attributes.
- See issue #890
* DOC: Enhance documentation for _get_background_map method in Monte Carlo plots
- Added detailed docstring for the _get_background_map method, outlining parameters, return values, and background map options.
- Clarified usage of background types including "satellite", "street", "terrain", and contextily providers.
* MNT: Move imageio import to conditional block in _MonteCarloPlots class
- Moved the import of imageio to be conditional upon the presence of an image, improving dependency management.
- This change ensures that imageio is only imported when necessary, optimizing performance and reducing unnecessary imports.
* TST: Add unit tests for ellipses background functionality in Monte Carlo plots
- Introduced a new test file to validate the behavior of the `ellipses` method with various background options including None, satellite, street, terrain, and custom providers.
- Implemented tests to ensure proper error handling when the MonteCarlo object lacks necessary attributes.
- Added checks for warnings when contextily is not installed and verified that images take precedence over backgrounds.
* TST: Add integration test for Monte Carlo background map options at Kennedy Space Center
- Introduced a new test script to visualize and validate various background map options for Monte Carlo simulations at Kennedy Space Center.
- The script generates simulated data and tests background options including None, satellite, street, terrain, and custom providers, saving the results as images.
* DOC: Updated CHANGELOG.md
* STY: Reformat with black
* MNT: Fix wrong usage for set_aspect in _MonteCarloPlots.ellipses_comparison
* MNT: Refactor _get_background_map in _MonteCarloPlots class
- Removed unnecessary else statements and improved indentation issues.
* MNT: Move mercator_to_wgs84 from_MonteCarloPlots class to tools
- Removed the local definition of mercator_to_wgs84 and replaced it with an import from tools.
- Updated calls to mercator_to_wgs84 to include the earth_radius parameter for improved accuracy.
* MNT: Decompose _get_background_map and move utilities to tools.py
- Refactors `_get_background_map` into modular functions and extracts shared utility logic into `tools.py`. This significantly improves maintainability and separation of concerns.
* BUG: Fix map alignment by enforcing standard Earth radius in plots
- Previously, `_get_environment_coordinates` retrieved the Earth radius
directly from the environment object. When simulations utilized a
custom or local Earth radius for high-precision physics, this value was
incorrectly applied to the map projection calculations.
- Since background map providers (like Contextily) rely on the standard
Web Mercator projection (based on ~6,378,137m), using a non-standard
radius caused the background map to be shifted or scaled incorrectly
relative to the scatter plot data.
- This change forces the plotting module to use the standard WGS84 radius.
This ensures visual accuracy for map overlays without affecting the
physical integrity of the simulation data itself.
* TST: Add Kennedy Space Center environment fixture
- Add example_kennedy_env fixture to replace create_kennedy_environment helper function in tests. This follows the same pattern as other environment fixtures and improves test consistency.
- Make test_all_background_options() a a parametrized test.
- Remove main from test
* ENH: Improve error handling and documentation for automatically download background
- Enhanced error messages for missing or invalid map providers, providing clearer guidance on potential issues.
- Removed warnings for missing contextily library and replaced them with exceptions to enforce required dependencies.
- Updated docstring to include raised exceptions and clarify the function's behavior when fetching background maps.
* TST: Enhance Monte Carlo background map unit tests
- Refactored tests to improve error handling for missing environment attributes and invalid map providers.
- Replaced warnings with exceptions for missing dependencies, ensuring stricter validation.
- Added assertions to verify error messages for better clarity on issues encountered during background map fetching.
- Introduced new tests for handling network errors and invalid map provider scenarios.
* TST: Refactor Monte Carlo plot tests with mock class
- Introduced a MockMonteCarlo class to simulate Monte Carlo data for testing background map options without real simulations.
- Updated tests to utilize the MockMonteCarlo, improving clarity and maintainability.
- Simplified environment handling in tests by creating a SimpleEnvironment class for latitude and longitude attributes.
- Enhanced error handling and assertions in tests for various background map scenarios.
* DOC: Add background map options to documentation
- Updated the user documentation for the Monte Carlo simulations to include details on the new ``background`` parameter for displaying various map types.
- Provided examples for using satellite, street, and terrain maps, along with instructions for listing available providers.
* DOC: Update Monte Carlo analysis notebook with background parameter
* REV: Remove background documents form mrs.rst
* TST: Refactor Monte Carlo plot tests to remove cleanup function
- Since we switched to MockMonteCarlo for testing. Since it does not inherit MonteCarlo.__init__(), no files that need cleanup are produced.
- Removed the `_post_test_file_cleanup` function to streamline test cases.
- Updated tests to directly handle file cleanup for test_ellipses_background_save.
* TST: Enhance Monte Carlo plot tests with file cleanup
- Added file cleanup functionality to the Monte Carlo plot tests to ensure generated files are removed after execution.
* DOC: Update docstring for background map provider resolution
- Enhanced the docstring for the background map provider function to include details on potential ValueError exceptions.
* ENH: Improve error handling in Monte Carlo background map fetching
- Enhanced exception handling for various error scenarios when fetching background map tiles, including invalid coordinates, network issues, and image data errors.
- Added detailed error messages to guide users on potential causes and solutions for encountered issues.
* TST: Parameterize tests for bounds2img failure scenarios
- Introduced parameterized tests to cover various exception types raised during background map fetching, including ValueError, ConnectionError, and RuntimeError.
- Enhanced assertions to verify specific error messages, improving clarity on the nature of failures encountered.
- Updated the test for bounds2img to handle different network and image data errors, ensuring comprehensive coverage of edge cases.
* TST: Parameterize background map option tests in Monte Carlo plots
- Introduced parameterization for the `test_all_background_options` function to streamline testing of various background map options.
- Enhanced the test structure by removing hardcoded background options and utilizing pytest's parameterization feature for improved clarity and maintainability.
- Updated docstring to reflect new parameters and their usage in the test.
* MNT: Formatting monte_carlo_class_usage.ipynb with ruff
* TST: Refactor imports in Monte Carlo plot tests for consistency
- Moved import statements for numpy and rocketpy.tools to the top of the test functions to adhere to best practices and improve readability.
- Added pylint disable comments for imports outside of the top-level to maintain code quality standards.
* TST: Skip tests requiring contextily in Monte Carlo plot tests
- Added pytest.importorskip for contextily in both integration and unit test files to ensure tests are only run if the required library is installed.
* TST: Update contextily import in Monte Carlo plot tests
- Replaced direct import of contextily with pytest.importorskip to ensure tests are skipped if the library is not available, enhancing test robustness.
* Update contextily dependency in pyproject.toml and requirements-optional.txt
- Modified contextily dependency in pyproject.toml to conditionally require it for Python versions below 3.14.
* DOC: Update monte_carlo_class_usage.ipynb to note about contextily issue on python 3.141 parent eaa9181 commit a25fd25
File tree
8 files changed
+1471
-93
lines changed- docs/notebooks/monte_carlo_analysis
- rocketpy
- plots
- tests
- fixtures/environment
- integration/simulation
- unit/simulation
8 files changed
+1471
-93
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
Lines changed: 516 additions & 87 deletions
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
7 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
8 | 15 | | |
9 | 16 | | |
10 | 17 | | |
| |||
14 | 21 | | |
15 | 22 | | |
16 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
17 | 207 | | |
18 | 208 | | |
19 | 209 | | |
20 | 210 | | |
| 211 | + | |
21 | 212 | | |
22 | 213 | | |
23 | 214 | | |
| |||
31 | 222 | | |
32 | 223 | | |
33 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
34 | 233 | | |
35 | 234 | | |
36 | 235 | | |
| |||
48 | 247 | | |
49 | 248 | | |
50 | 249 | | |
51 | | - | |
52 | | - | |
53 | 250 | | |
54 | 251 | | |
| 252 | + | |
55 | 253 | | |
56 | 254 | | |
57 | 255 | | |
58 | 256 | | |
59 | 257 | | |
60 | 258 | | |
61 | 259 | | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
62 | 264 | | |
63 | 265 | | |
64 | 266 | | |
| |||
132 | 334 | | |
133 | 335 | | |
134 | 336 | | |
135 | | - | |
136 | 337 | | |
137 | 338 | | |
138 | 339 | | |
| |||
150 | 351 | | |
151 | 352 | | |
152 | 353 | | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
153 | 357 | | |
154 | 358 | | |
155 | 359 | | |
156 | 360 | | |
| 361 | + | |
| 362 | + | |
157 | 363 | | |
158 | 364 | | |
159 | 365 | | |
| |||
294 | 500 | | |
295 | 501 | | |
296 | 502 | | |
| 503 | + | |
297 | 504 | | |
298 | 505 | | |
299 | 506 | | |
| |||
308 | 515 | | |
309 | 516 | | |
310 | 517 | | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
311 | 525 | | |
312 | 526 | | |
313 | 527 | | |
| |||
322 | 536 | | |
323 | 537 | | |
324 | 538 | | |
325 | | - | |
326 | 539 | | |
327 | 540 | | |
328 | 541 | | |
| 542 | + | |
329 | 543 | | |
330 | 544 | | |
331 | 545 | | |
332 | 546 | | |
333 | 547 | | |
334 | 548 | | |
335 | 549 | | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
336 | 554 | | |
337 | 555 | | |
338 | 556 | | |
| |||
453 | 671 | | |
454 | 672 | | |
455 | 673 | | |
| 674 | + | |
| 675 | + | |
456 | 676 | | |
457 | 677 | | |
458 | 678 | | |
459 | 679 | | |
460 | 680 | | |
| 681 | + | |
461 | 682 | | |
462 | 683 | | |
463 | 684 | | |
| |||
0 commit comments