Skip to content

Commit f6ceac0

Browse files
Merge branch 'develop' into feature/get-region-per-country
2 parents 215aece + 1d266b6 commit f6ceac0

File tree

136 files changed

+5513
-1590
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+5513
-1590
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

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,3 +183,5 @@ results/
183183
!.pylintrc
184184
!.readthedocs.yml
185185
!.github
186+
climada_petals/
187+
climada_python/

.readthedocs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ python:
2525

2626
formats:
2727
- pdf
28+
29+
sphinx:
30+
configuration: doc/conf.py

CHANGELOG.md

Lines changed: 106 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,36 @@ Code freeze date: YYYY-MM-DD
1010

1111
### Dependency Changes
1212

13+
Removed:
14+
15+
- `pandas-datareader`
16+
- `intensity_thres` of `Hazard`, `StormEurope`, and `TropCyclones` object [#1065](https://github.com/CLIMADA-project/climada_python/pull/1065)
17+
- Deprecated method `climada.hazard.trop_cyclone.trop_cyclone.TropCyclone.set_from_tracks` [#1065](https://github.com/CLIMADA-project/climada_python/pull/1065)
18+
1319
### Added
20+
- Added optional parameter to `geo_im_from_array`, `plot_from_gdf`, `plot_rp_imp`, `plot_rp_intensity`,
21+
`plot_intensity`, `plot_fraction`, `_event_plot` to mask plotting when regions are too far from data points [#1047](https://github.com/CLIMADA-project/climada_python/pull/1047). To recreate previous plots (no masking), the parameter can be set to None.
1422
- Added instructions to install Climada petals on Euler cluster in `doc.guide.Guide_Euler.ipynb` [#1029](https://github.com/CLIMADA-project/climada_python/pull/1029)
1523

24+
- `ImpactFunc` and `ImpactFuncSet` now support equality comparisons via `==` [#1027](https://github.com/CLIMADA-project/climada_python/pull/1027)
25+
1626
### Changed
27+
- Changed the default mask_distance in `util.plot.geo_im_from_array` to 0.03 to avoid white gaps in gridded hazard data with comparably low resolution (>80 centroids per axis) [#1073](https://github.com/CLIMADA-project/climada_python/pull/1073)
28+
- Increased speed of `util.plot.add_shapes` by avoiding for loops, substantially speeding up `Hazard.plot_intensity` and other functions. [#1073](https://github.com/CLIMADA-project/climada_python/pull/1073)
1729
- `Hazard.local_exceedance_intensity`, `Hazard.local_return_period` and `Impact.local_exceedance_impact`, `Impact.local_return_period`, using the `climada.util.interpolation` module: New default (no binning), binning on decimals, and faster implementation [#1012](https://github.com/CLIMADA-project/climada_python/pull/1012)
30+
- 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)
31+
- `Exposures.write_hdf5` pickles geometry data in WKB format, which is faster and more sustainable. [#1051](https://github.com/CLIMADA-project/climada_python/pull/1051)
32+
- The online documentation has been completely overhauled, now uses PyData theme: [#977](https://github.com/CLIMADA-project/climada_python/pull/977)
33+
1834
### Fixed
1935

36+
- NaN plotting issues in `geo_im_from_array`[#1038](https://github.com/CLIMADA-project/climada_python/pull/1038)
37+
- Broken ECMWF links in pydoc of `climada.hazard.storm_europe` relocated. [#944](https://github.com/CLIMADA-project/climada_python/pull/944)
38+
2039
### Deprecated
2140

2241
### Removed
42+
2343
- `climada.util.interpolation.round_to_sig_digits` [#1012](https://github.com/CLIMADA-project/climada_python/pull/1012)
2444

2545
## 6.0.1
@@ -43,27 +63,27 @@ Added:
4363

4464
Updated:
4565

46-
- `cartopy` >=0.23 → >=0.24
47-
- `cfgrib` >=0.9.9,<0.9.10 &rarr; >=0.9
48-
- `dask` >=2024.2,<2024.3 &rarr; >=2025.2
49-
- `eccodes` >=2.27,<2.28 &rarr; >=2.40
50-
- `gdal` >=3.6 &rarr; >=3.10
51-
- `geopandas` >=0.14 &rarr; >=0.14,<1.0
52-
- `h5py` >=3.8 &rarr; >=3.12
53-
- `haversine` >=2.8 &rarr; >=2.9
54-
- `matplotlib-base` >=3.9 &rarr; >=3.10
55-
- `netcdf4` >=1.6 &rarr; >=1.7
56-
- `numba` >=0.60 &rarr; >=0.61
57-
- `pillow` =9.4 &rarr; =11.1
58-
- `pyproj` >=3.5 &rarr; >=3.7
59-
- `pytables` >=3.7 &rarr; >=3.10
60-
- `python` =3.9 &rarr; =3.11
61-
- `rasterio` >=1.3 &rarr; >=1.4
62-
- `scikit-learn` >=1.5 &rarr; >=1.6
63-
- `scipy` >=1.13 &rarr; >=1.14,<1.15
64-
- `tqdm` >=4.66 &rarr; >=4.67
65-
- `xarray` >=2024.6 &rarr; >=2025.1
66-
- `xlsxwriter` >=3.1 &rarr; >=3.2
66+
- `cartopy` >=0.23 >=0.24
67+
- `cfgrib` >=0.9.9,<0.9.10 >=0.9
68+
- `dask` >=2024.2,<2024.3 >=2025.2
69+
- `eccodes` >=2.27,<2.28 >=2.40
70+
- `gdal` >=3.6 >=3.10
71+
- `geopandas` >=0.14 >=0.14,<1.0
72+
- `h5py` >=3.8 >=3.12
73+
- `haversine` >=2.8 >=2.9
74+
- `matplotlib-base` >=3.9 >=3.10
75+
- `netcdf4` >=1.6 >=1.7
76+
- `numba` >=0.60 >=0.61
77+
- `pillow` =9.4 =11.1
78+
- `pyproj` >=3.5 >=3.7
79+
- `pytables` >=3.7 >=3.10
80+
- `python` =3.9 =3.11
81+
- `rasterio` >=1.3 >=1.4
82+
- `scikit-learn` >=1.5 >=1.6
83+
- `scipy` >=1.13 >=1.14,<1.15
84+
- `tqdm` >=4.66 >=4.67
85+
- `xarray` >=2024.6 >=2025.1
86+
- `xlsxwriter` >=3.1 >=3.2
6787

6888
Removed:
6989

@@ -75,7 +95,7 @@ Removed:
7595
- `climada.hazard.tc_tracks.TCTracks.subset_years` function [#1023](https://github.com/CLIMADA-project/climada_python/pull/1023)
7696
- `climada.hazard.tc_tracks.TCTracks.from_FAST` function, add Australia basin (AU) [#993](https://github.com/CLIMADA-project/climada_python/pull/993)
7797
- Add `osm-flex` package to CLIMADA core [#981](https://github.com/CLIMADA-project/climada_python/pull/981)
78-
- `doc.tutorial.climada_entity_Exposures_osm.ipynb` tutorial explaining how to use `osm-flex`with CLIMADA
98+
- `doc.tutorial.climada_entity_Exposures_osm.ipynb` tutorial explaining how to use `osm-flex` with CLIMADA
7999
- `climada.util.coordinates.bounding_box_global` function [#980](https://github.com/CLIMADA-project/climada_python/pull/980)
80100
- `climada.util.coordinates.bounding_box_from_countries` function [#980](https://github.com/CLIMADA-project/climada_python/pull/980)
81101
- `climada.util.coordinates.bounding_box_from_cardinal_bounds` function [#980](https://github.com/CLIMADA-project/climada_python/pull/980)
@@ -107,8 +127,8 @@ Removed:
107127
- the _geometry_ column of the inherent `GeoDataFrame` is set up at initialization
108128
- latitude and longitude column are no longer present there (the according arrays can be retrieved as properties of the Exposures object: `exp.latitude` instead of `exp.gdf.latitude.values`).
109129
- `Exposures.gdf` has been renamed to `Exposures.data` (it still works though, as it is a property now pointing to the latter)
110-
- the `check` method does not add a default "IMPF_" column to the GeoDataFrame anymore
111-
- Updated IBTrACS version from v4.0 to v4.1 ([#976](https://github.com/CLIMADA-project/climada_python/pull/976)
130+
- the `check` method does not add a default `'IMPF_'` column to the GeoDataFrame anymore
131+
- Updated IBTrACS version from v4.0 to v4.1 [#976](https://github.com/CLIMADA-project/climada_python/pull/976)
112132
- Fix xarray future warning in TCTracks for .dims to .sizes
113133
- Fix hazard.concatenate type test for pathos pools
114134

@@ -142,20 +162,20 @@ Added:
142162

143163
Updated:
144164

145-
- `bottleneck` >=1.3 &rarr; >=1.4
146-
- `cartopy` >=0.22 &rarr; >=0.23
147-
- `contextily` >=1.5 &rarr; >=1.6
148-
- `dask` >=2024.1,<2024.3 &rarr; >=2024.2,<2024.3
149-
- `matplotlib-base` >=3.8 &rarr; >=3.9
150-
- `numba` >=0.59 &rarr; >=0.60
151-
- `numexpr` >=2.9 &rarr; >=2.10
152-
- `pint` >=0.23 &rarr; >=0.24
153-
- `pycountry` >=22.3 &rarr; >=24.6
154-
- `requests` >=2.31 &rarr; >=2.32
155-
- `salib` >=1.4 &rarr; >=1.5
156-
- `scikit-learn` >=1.4 &rarr; >=1.5
157-
- `scipy` >=1.12 &rarr; >=1.13
158-
- `xarray` >=2024.2 &rarr; >=2024.6
165+
- `bottleneck` >=1.3 >=1.4
166+
- `cartopy` >=0.22 >=0.23
167+
- `contextily` >=1.5 >=1.6
168+
- `dask` >=2024.1,<2024.3 >=2024.2,<2024.3
169+
- `matplotlib-base` >=3.8 >=3.9
170+
- `numba` >=0.59 >=0.60
171+
- `numexpr` >=2.9 >=2.10
172+
- `pint` >=0.23 >=0.24
173+
- `pycountry` >=22.3 >=24.6
174+
- `requests` >=2.31 >=2.32
175+
- `salib` >=1.4 >=1.5
176+
- `scikit-learn` >=1.4 >=1.5
177+
- `scipy` >=1.12 >=1.13
178+
- `xarray` >=2024.2 >=2024.6
159179

160180
### Added
161181

@@ -190,6 +210,7 @@ CLIMADA tutorials. [#872](https://github.com/CLIMADA-project/climada_python/pull
190210
- `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)
191211
- `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)
192212
- Split `climada.hazard.trop_cyclone` module into smaller submodules without affecting module usage [#911](https://github.com/CLIMADA-project/climada_python/pull/911)
213+
- `yearly_steps` parameter of `TropCyclone.apply_climate_scenario_knu` has been made explicit [#991](https://github.com/CLIMADA-project/climada_python/pull/991)
193214

194215
### Fixed
195216

@@ -260,17 +281,17 @@ Added:
260281

261282
Updated:
262283

263-
- `contextily` >=1.3 &rarr; >=1.5
264-
- `dask` >=2023 &rarr; >=2024
265-
- `numba` >=0.57 &rarr; >=0.59
266-
- `pandas` >=2.1 &rarr; >=2.1,<2.2
267-
- `pint` >=0.22 &rarr; >=0.23
268-
- `scikit-learn` >=1.3 &rarr; >=1.4
269-
- `scipy` >=1.11 &rarr; >=1.12
270-
- `sparse` >=0.14 &rarr; >=0.15
271-
- `xarray` >=2023.8 &rarr; >=2024.1
272-
- `overpy` =0.6 &rarr; =0.7
273-
- `peewee` =3.16.3 &rarr; =3.17.1
284+
- `contextily` >=1.3 >=1.5
285+
- `dask` >=2023 >=2024
286+
- `numba` >=0.57 >=0.59
287+
- `pandas` >=2.1 >=2.1,<2.2
288+
- `pint` >=0.22 >=0.23
289+
- `scikit-learn` >=1.3 >=1.4
290+
- `scipy` >=1.11 >=1.12
291+
- `sparse` >=0.14 >=0.15
292+
- `xarray` >=2023.8 >=2024.1
293+
- `overpy` =0.6 =0.7
294+
- `peewee` =3.16.3 =3.17.1
274295

275296
Removed:
276297

@@ -279,7 +300,7 @@ Removed:
279300
### Added
280301

281302
- Convenience method `api_client.Client.get_dataset_file`, combining `get_dataset_info` and `download_dataset`, returning a single file objet. [#821](https://github.com/CLIMADA-project/climada_python/pull/821)
282-
- Read and Write methods to and from csv files for the `DiscRates` class. [#818](ttps://github.com/CLIMADA-project/climada_python/pull/818)
303+
- Read and Write methods to and from csv files for the `DiscRates` class. [#818](https://github.com/CLIMADA-project/climada_python/pull/818)
283304
- Add `CalcDeltaClimate` to unsequa module to allow uncertainty and sensitivity analysis of impact change calculations [#844](https://github.com/CLIMADA-project/climada_python/pull/844)
284305
- Add function `safe_divide` in util which handles division by zero and NaN values in the numerator or denominator [#844](https://github.com/CLIMADA-project/climada_python/pull/844)
285306
- Add reset_frequency option for the impact.select() function. [#847](https://github.com/CLIMADA-project/climada_python/pull/847)
@@ -313,13 +334,13 @@ Release date: 2023-09-27
313334

314335
Added:
315336

316-
- `matplotlib-base` None &rarr; >=3.8
337+
- `matplotlib-base` None >=3.8
317338

318339
Changed:
319340

320-
- `geopandas` >=0.13 &rarr; >=0.14
321-
- `pandas` >=1.5,<2.0 &rarr; >=2.1
322-
- `salib` >=1.3.0 &rarr; >=1.4.7
341+
- `geopandas` >=0.13 >=0.14
342+
- `pandas` >=1.5,<2.0 >=2.1
343+
- `salib` >=1.3.0 >=1.4.7
323344

324345
Removed:
325346

@@ -348,37 +369,37 @@ Added:
348369

349370
Changed:
350371

351-
- `cartopy` >=0.20.0,<0.20.3 &rarr; >=0.21
352-
- `cfgrib` >=0.9.7,<0.9.10 &rarr; =0.9.9
353-
- `contextily` >=1.0 &rarr; >=1.3
354-
- `dask` >=2.25 &rarr; >=2023
355-
- `eccodes` [auto] &rarr; =2.27
356-
- `gdal` !=3.4.1 &rarr; >=3.6
357-
- `geopandas` >=0.8 &rarr; >=0.13
358-
- `h5py` >=2.10 &rarr; >=3.8
359-
- `haversine` >=2.3 &rarr; >=2.8
360-
- `matplotlib` >=3.2,< 3.6 &rarr; >=3.7
361-
- `netcdf4` >=1.5 &rarr; >=1.6
362-
- `numba` >=0.51,!=0.55.0 &rarr; >=0.57
363-
- `openpyxl` >=3.0 &rarr; >=3.1
364-
- `pandas-datareader` >=0.9 &rarr; >=0.10
365-
- `pathos` >=0.2 &rarr; >=0.3
366-
- `pint` >=0.15 &rarr; >=0.22
367-
- `proj` !=9.0.0 &rarr; >=9.1
368-
- `pycountry` >=20.7 &rarr; >=22.3
369-
- `pytables` >=3.6 &rarr; >=3.7
370-
- `rasterio` >=1.2.7,<1.3 &rarr; >=1.3
371-
- `requests` >=2.24 &rarr; >=2.31
372-
- `salib` >=1.3.0 &rarr; >=1.4
373-
- `scikit-learn` >=1.0 &rarr; >=1.2
374-
- `scipy` >=1.6 &rarr; >=1.10
375-
- `sparse` >=0.13 &rarr; >=0.14
376-
- `statsmodels` >=0.11 &rarr; >=0.14
377-
- `tabulate` >=0.8 &rarr; >=0.9
378-
- `tqdm` >=4.48 &rarr; >=4.65
379-
- `xarray` >=0.13 &rarr; >=2023.5
380-
- `xlrd` >=1.2 &rarr; >=2.0
381-
- `xlsxwriter` >=1.3 &rarr; >=3.1
372+
- `cartopy` >=0.20.0,<0.20.3 >=0.21
373+
- `cfgrib` >=0.9.7,<0.9.10 =0.9.9
374+
- `contextily` >=1.0 >=1.3
375+
- `dask` >=2.25 >=2023
376+
- `eccodes` [auto] =2.27
377+
- `gdal` !=3.4.1 >=3.6
378+
- `geopandas` >=0.8 >=0.13
379+
- `h5py` >=2.10 >=3.8
380+
- `haversine` >=2.3 >=2.8
381+
- `matplotlib` >=3.2,< 3.6 >=3.7
382+
- `netcdf4` >=1.5 >=1.6
383+
- `numba` >=0.51,!=0.55.0 >=0.57
384+
- `openpyxl` >=3.0 >=3.1
385+
- `pandas-datareader` >=0.9 >=0.10
386+
- `pathos` >=0.2 >=0.3
387+
- `pint` >=0.15 >=0.22
388+
- `proj` !=9.0.0 >=9.1
389+
- `pycountry` >=20.7 >=22.3
390+
- `pytables` >=3.6 >=3.7
391+
- `rasterio` >=1.2.7,<1.3 >=1.3
392+
- `requests` >=2.24 >=2.31
393+
- `salib` >=1.3.0 >=1.4
394+
- `scikit-learn` >=1.0 >=1.2
395+
- `scipy` >=1.6 >=1.10
396+
- `sparse` >=0.13 >=0.14
397+
- `statsmodels` >=0.11 >=0.14
398+
- `tabulate` >=0.8 >=0.9
399+
- `tqdm` >=4.48 >=4.65
400+
- `xarray` >=0.13 >=2023.5
401+
- `xlrd` >=1.2 >=2.0
402+
- `xlsxwriter` >=1.3 >=3.1
382403

383404
Removed:
384405

CONTRIBUTING.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ For orientation, these are some categories of possible contributions we can thin
1212
* **New Modules and Utility Functions:** Did you create a function or an entire module you find useful for your work? Maybe you are not the only one! Feel free to simply raise a pull request for functions that improve, e.g., plotting or data handling. As an entire module has to be carefully integrated into the framework, it might help if you talk to us first so we can design the module and plan the next steps. You can do that by raising an issue or starting a [discussion](https://github.com/CLIMADA-project/climada_python/discussions) on GitHub.
1313

1414
A good place to start a personal discussion is our monthly CLIMADA developers call.
15-
Please contact the [lead developers](https://wcr.ethz.ch/research/climada.html) if you want to join.
15+
Please contact the [lead developers](https://climada.ethz.ch/team/) if you want to join.
1616

1717
## Why Should You Contribute?
1818

19-
* You will be listed as author of the CLIMADA repository in the [AUTHORS](AUTHORS.md) file.
19+
* You will be listed as author of the CLIMADA repository in the [AUTHORS][authors] file.
2020
* You will improve the quality of the CLIMADA software for you and for everybody else using it.
2121
* You will gain insights into scientific software development.
2222

@@ -40,7 +40,7 @@ To contribute follow these steps:
4040
```bash
4141
pylint
4242
```
43-
6. Add your name to the [AUTHORS](AUTHORS.md) file.
43+
6. Add your name to the [AUTHORS][authors] file.
4444
7. Push your updates to the remote repository:
4545
4646
```bash
@@ -83,4 +83,5 @@ It also contains a checklist for both pull request authors and reviewers to guid
8383
8484
[docs]: https://climada-python.readthedocs.io/en/latest/
8585
[devguide]: https://climada-python.readthedocs.io/en/latest/#developer-guide
86-
[testing]: https://climada-python.readthedocs.io/en/latest/guide/Guide_Testing.html
86+
[testing]: https://climada-python.readthedocs.io/en/latest/development/Guide_Testing.html
87+
[authors]: https://github.com/CLIMADA-project/climada_python/blob/main/AUTHORS.md

climada/engine/cost_benefit.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,9 +1079,7 @@ def _calc_impact_measures(
10791079
# compute impact for each measure
10801080
for measure in meas_set.get_measure(hazard.haz_type):
10811081
LOGGER.debug("%s impact of measure %s.", when, measure.name)
1082-
imp_tmp, risk_transf = measure.calc_impact(
1083-
exposures, imp_fun_set, hazard, assign_centroids=False
1084-
)
1082+
imp_tmp, risk_transf = measure.calc_impact(exposures, imp_fun_set, hazard)
10851083
impact_meas[measure.name] = dict()
10861084
impact_meas[measure.name]["cost"] = (
10871085
measure.cost,

climada/engine/impact.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,6 +1178,7 @@ def plot_rp_imp(
11781178
return_periods=(25, 50, 100, 250),
11791179
log10_scale=True,
11801180
axis=None,
1181+
mask_distance=0.03,
11811182
kwargs_local_exceedance_impact=None,
11821183
**kwargs,
11831184
):
@@ -1194,6 +1195,11 @@ def plot_rp_imp(
11941195
plot impact as log10(impact). Default: True
11951196
smooth : bool, optional
11961197
smooth plot to plot.RESOLUTIONxplot.RESOLUTION. Default: True
1198+
mask_distance: float, optional
1199+
Only regions are plotted that are closer to any of the data points than this distance,
1200+
relative to overall plot size. For instance, to only plot values
1201+
at the centroids, use mask_distance=0.03. If None, the plot is not masked.
1202+
Default is 0.03.
11971203
kwargs_local_exceedance_impact: dict
11981204
Dictionary of keyword arguments for the method impact.local_exceedance_impact.
11991205
kwargs : dict, optional
@@ -1242,7 +1248,12 @@ def plot_rp_imp(
12421248
)
12431249

12441250
axis = u_plot.plot_from_gdf(
1245-
impacts_stats, title, column_labels, axis=axis, **kwargs
1251+
impacts_stats,
1252+
title,
1253+
column_labels,
1254+
axis=axis,
1255+
mask_distance=mask_distance,
1256+
**kwargs,
12461257
)
12471258
return axis, impacts_stats_vals
12481259

0 commit comments

Comments
 (0)