speed-up the function to add country borders and coastlines by timschmi95 · Pull Request #1073 · CLIMADA-project/climada_python
Changes proposed in this PR:
- Substantially speeding up plots by directly adding all borders with one call, rather than loop through each geometry object, when adding countries and coastlines in the
u_plot.add_shapesfunction. I've tested the new function in multiple tutorials and my own data (both with standard and projected coordinates) and the plots look equivalent. - Set the default value of the recently implemented mask_distance in hazard plots from 0.01 to 0.03.
This PR fixes #1071
Substantially speeds up hazard.plot_intensity (and other functions that use u_plot.add_shapes). Before the update, adding the country borders took up to 75% of the overall time, which is reduced to <1%, significantly speeding up the overall function.
The change of the default mask_distance is somewhat independent. While testing many plots in the tutorial, we noticed in multiple instances the haz.plot_intensity() with the recently updated raster plotting functionality (PR #1047) showed small white gaps within gridded data, if there are fewer than ~80 regularly spaced gridpoints in one direction. Changing the default from 0.01 to 0.03 allows smooth plots for data with fewer (down to ~30) gridpoints per side, while keeping the default interpolation distance for data with gaps reasonably small.
Of course, users can always adjust the parameter depending on their data, but increasing the default will lead to fewer user seeing gaps in their gridded hazard data plot and needing to dig into the keyword arguments of the haz.plot_intensity() function.
PR Author Checklist
- Read the Contribution Guide
- Correct target branch selected (if unsure, select
develop) - Descriptive pull request title added
- Source branch up-to-date with target branch
- Documentation updated
- Tests updated
- Tests passing
- No new linter issues
- Changelog updated
PR Reviewer Checklist
- Read the Contribution Guide
- CLIMADA Reviewer Checklist passed
- Tests passing
- No new linter issues