Skip to content

Commit ea53268

Browse files
Merge branch 'develop' into remove-pandas-datareader
2 parents 6d62771 + eda7e40 commit ea53268

File tree

7 files changed

+38
-7
lines changed

7 files changed

+38
-7
lines changed

.github/CODEOWNERS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This is a comment.
2+
# Each line is a file pattern followed by one or more owners.
3+
4+
# These owners will be the default owners for everything in
5+
# the repo. Unless a later match takes precedence, they will
6+
# be requested for review when someone opens a pull request.
7+
* @emanuel-schmid @chahank @peanutfun

.github/workflows/pull-request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
ref: ${{ github.event.pull_request.head.sha }}
1717
-
1818
name: Checkout target commit
19-
run: git -c protocol.version=2 fetch --no-tags --prune --no-recurse-submodules --depth=1 origin ${{ github.event.pull_request.base.ref }}
19+
run: git -c protocol.version=2 fetch --no-tags --prune --no-recurse-submodules --depth=50 origin ${{ github.event.pull_request.base.ref }}
2020
-
2121
name: Set up Python 3.11
2222
uses: actions/setup-python@v5

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Removed:
2222
- World Bank indicator data is now downloaded directly from their API via the function `download_world_bank_indicator`, instead of relying on the `pandas-datareader` package [#1033](https://github.com/CLIMADA-project/climada_python/pull/1033)
2323

2424
### Fixed
25+
- NaN plotting issues in `geo_im_from_array`[#1038](https://github.com/CLIMADA-project/climada_python/pull/1038)
2526

2627
### Deprecated
2728

@@ -195,6 +196,7 @@ CLIMADA tutorials. [#872](https://github.com/CLIMADA-project/climada_python/pull
195196
- `Impact.from_hdf5` now calls `str` on `event_name` data that is not strings, and issue a warning then [#894](https://github.com/CLIMADA-project/climada_python/pull/894)
196197
- `Impact.write_hdf5` now throws an error if `event_name` is does not contain strings exclusively [#894](https://github.com/CLIMADA-project/climada_python/pull/894)
197198
- Split `climada.hazard.trop_cyclone` module into smaller submodules without affecting module usage [#911](https://github.com/CLIMADA-project/climada_python/pull/911)
199+
- `yearly_steps` parameter of `TropCyclone.apply_climate_scenario_knu` has been made explicit [#991](https://github.com/CLIMADA-project/climada_python/pull/991)
198200

199201
### Fixed
200202

climada/hazard/trop_cyclone/trop_cyclone.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def apply_climate_scenario_knu(
391391
percentile: str = "50",
392392
scenario: str = "4.5",
393393
target_year: int = 2050,
394-
**kwargs,
394+
yearly_steps: int = 5,
395395
):
396396
"""
397397
From current TC hazard instance, return new hazard set with future events
@@ -437,6 +437,9 @@ def apply_climate_scenario_knu(
437437
438438
target_year : int
439439
future year to be simulated, between 2000 and 2100. Default: 2050.
440+
yearly_steps : int
441+
yearly resolution at which projections are provided. Default is 5 years.
442+
440443
Returns
441444
-------
442445
haz_cc : climada.hazard.TropCyclone
@@ -465,11 +468,11 @@ def apply_climate_scenario_knu(
465468
for basin in np.unique(tc_cc.basin):
466469
scale_year_rcp_05, scale_year_rcp_45 = [
467470
get_knutson_scaling_factor(
468-
percentile=percentile,
469471
variable=variable,
472+
percentile=percentile,
470473
basin=basin,
471474
baseline=(np.min(years), np.max(years)),
472-
**kwargs,
475+
yearly_steps=yearly_steps,
473476
).loc[target_year, scenario]
474477
for variable in ["cat05", "cat45"]
475478
]

climada/util/plot.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import cartopy.crs as ccrs
3838
import geopandas as gpd
3939
import matplotlib as mpl
40+
import matplotlib.patches as mpatches
4041
import matplotlib.pyplot as plt
4142
import numpy as np
4243
import requests
@@ -374,6 +375,11 @@ def geo_im_from_array(
374375
-------
375376
cartopy.mpl.geoaxes.GeoAxesSubplot
376377
378+
Notes
379+
-----
380+
Data points with NaN or inf are plotted in gray. White regions correspond to
381+
regions outside the convex hull of the given coordinates.
382+
377383
Raises
378384
------
379385
ValueError
@@ -420,8 +426,7 @@ def geo_im_from_array(
420426

421427
# prepare colormap
422428
cmap = plt.get_cmap(kwargs.pop("cmap", CMAP_RASTER))
423-
cmap.set_bad("gainsboro") # For NaNs and infs
424-
cmap.set_under("white", alpha=0) # For values below vmin
429+
cmap.set_under("white") # For values below vmin
425430

426431
# Generate each subplot
427432
for array_im, axis, tit, name in zip(
@@ -470,6 +475,17 @@ def geo_im_from_array(
470475
cmap=cmap,
471476
**kwargs,
472477
)
478+
# handle NaNs in griddata
479+
color_nan = "gainsboro"
480+
if np.any(np.isnan(x) for x in grid_im):
481+
no_data_patch = mpatches.Patch(
482+
facecolor=color_nan, edgecolor="black", label="NaN"
483+
)
484+
axis.legend(
485+
handles=[no_data_patch] + axis.get_legend_handles_labels()[0],
486+
loc="lower right",
487+
)
488+
axis.set_facecolor(color_nan)
473489
cbar = plt.colorbar(img, cax=cbax, orientation="vertical")
474490
cbar.set_label(name)
475491
axis.set_title("\n".join(wrap(tit)))

doc/index.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Welcome to CLIMADA!
66
:align: center
77
:alt: CLIMADA Logo
88

9-
CLIMADA stands for CLIMate ADAptation and is a probabilistic natural catastrophe impact model, that also calculates averted damage (benefit) thanks to adaptation measures of any kind (from grey to green infrastructure, behavioural, etc.).
9+
`CLIMADA <https://climada.ethz.ch/>`_ stands for CLIMate ADAptation and is a probabilistic natural catastrophe impact model, that also calculates averted damage (benefit) thanks to adaptation measures of any kind (from grey to green infrastructure, behavioural, etc.).
1010

1111
CLIMADA is primarily developed and maintained by the `Weather and Climate Risks Group <https://wcr.ethz.ch/>`_ at `ETH Zürich <https://ethz.ch/en.html>`_.
1212

@@ -22,6 +22,7 @@ Jump right in:
2222
* :doc:`Overview <tutorial/1_main_climada>`
2323
* `GitHub Repository <https://github.com/CLIMADA-project/climada_python>`_
2424
* :doc:`Module Reference <climada/climada>`
25+
* `CLIMADA Webpage <https://climada.ethz.ch/>`_
2526

2627
.. ifconfig:: readthedocs
2728

@@ -50,6 +51,7 @@ Jump right in:
5051
.. toctree::
5152
:hidden:
5253

54+
CLIMADA Webpage <https://climada.ethz.ch/>
5355
GitHub Repositories <https://github.com/CLIMADA-project>
5456
CLIMADA Petals <https://climada-petals.readthedocs.io/en/stable/>
5557
Weather and Climate Risks Group <https://wcr.ethz.ch/>

requirements/env_climada.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ dependencies:
3434
- seaborn>=0.13
3535
- scikit-learn>=1.6
3636
- scipy>=1.14,<1.15 # 1.15 is not compatible with climada_petals, climada_petals.engine.test.test_supplychain fails with "'Series' has no attribute 'nonzero'"
37+
- shapely<2.1 # in 2.1 'shapely.ops' has no attribute 'cascaded_union' anymore, which is used in black_marble
3738
- sparse>=0.15
3839
- statsmodels>=0.14
3940
- tabulate>=0.9

0 commit comments

Comments
 (0)