Skip to content

Commit 5ff7ca3

Browse files
Merge branch 'develop' of github.com:CLIMADA-project/climada_python into develop
2 parents 05a8dcc + 6cc6e08 commit 5ff7ca3

31 files changed

+2226
-1976
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
-
4848
name: Install CLIMADA
4949
run: |
50-
python -m pip install ".[test]"
50+
python -m pip install "./[dev]"
5151
-
5252
name: Run Unit Tests
5353
run: |

.zenodo.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@
119119
},
120120
{
121121
"name": "Valentin Gebhart"
122+
},
123+
{
124+
"name": "Dahyann Araya"
122125
}
123126
]
124127
}

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@
3636
* Luca Severino
3737
* Samuel Juhel
3838
* Valentin Gebhart
39+
* Dahyann Araya

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Removed:
3939
- 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)
4040
- `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)
4141
- The online documentation has been completely overhauled, now uses PyData theme: [#977](https://github.com/CLIMADA-project/climada_python/pull/977)
42+
- Add `climada.hazard.xarray` module with helper structures for reading Hazard objects from `xarray` data [#1063](https://github.com/CLIMADA-project/climada_python/pull/1063)
4243

4344
### Fixed
4445

@@ -47,6 +48,8 @@ Removed:
4748

4849
### Deprecated
4950

51+
- `Hazard.from_xarray_raster_file`. Use `Hazard.from_xarray_raster` and pass the file path as `data` argument [#1063](https://github.com/CLIMADA-project/climada_python/pull/1063)
52+
5053
### Removed
5154

5255
- `climada.util.interpolation.round_to_sig_digits` [#1012](https://github.com/CLIMADA-project/climada_python/pull/1012)
@@ -102,6 +105,7 @@ Removed:
102105

103106
### Added
104107

108+
- `climada.entity.impact_funcs.trop_cyclone.ImpfSetTropCyclone.get_impf_id_regions_per_countries` function [#1034](https://github.com/CLIMADA-project/climada_python/pull/1034)
105109
- `climada.hazard.tc_tracks.TCTracks.subset_years` function [#1023](https://github.com/CLIMADA-project/climada_python/pull/1023)
106110
- `climada.hazard.tc_tracks.TCTracks.from_FAST` function, add Australia basin (AU) [#993](https://github.com/CLIMADA-project/climada_python/pull/993)
107111
- Add `osm-flex` package to CLIMADA core [#981](https://github.com/CLIMADA-project/climada_python/pull/981)
@@ -221,6 +225,7 @@ CLIMADA tutorials. [#872](https://github.com/CLIMADA-project/climada_python/pull
221225
- `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)
222226
- Split `climada.hazard.trop_cyclone` module into smaller submodules without affecting module usage [#911](https://github.com/CLIMADA-project/climada_python/pull/911)
223227
- `yearly_steps` parameter of `TropCyclone.apply_climate_scenario_knu` has been made explicit [#991](https://github.com/CLIMADA-project/climada_python/pull/991)
228+
- `Hazard.write_hdf5` writes centroids as x,y columns (or as wkb in case of polygons) at a compression level of 9, not as pickled `Shapely` objects anymore, which reduces the size of the files significantly.
224229

225230
### Fixed
226231

climada/engine/unsequa/calc_cost_benefit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ def _map_costben_calc(
398398
ent_future=ent_fut,
399399
save_imp=False,
400400
assign_centroids=False,
401-
**cost_benefit_kwargs
401+
**cost_benefit_kwargs,
402402
)
403403
# Extract from climada.impact the chosen metrics
404404
uncertainty_values.append(

climada/entity/exposures/litpop/litpop.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"""
2020

2121
import logging
22+
import numbers
2223
from pathlib import Path
2324

2425
import geopandas
@@ -820,12 +821,12 @@ def _from_country(
820821
total_value = _get_total_value_per_country(iso3a, fin_mode, reference_year)
821822

822823
# disaggregate total value proportional to LitPop values:
823-
if isinstance(total_value, (float, int)):
824+
if isinstance(total_value, numbers.Number):
824825
litpop_gdf["value"] = (
825826
np.divide(litpop_gdf["value"], litpop_gdf["value"].sum()) * total_value
826827
)
827828
elif total_value is not None:
828-
raise TypeError("total_value must be int or float.")
829+
raise TypeError(f"total_value ({total_value}) must be a number.")
829830

830831
exp = LitPop()
831832
exp.set_gdf(litpop_gdf)

climada/entity/impact_funcs/test/test_tc.py

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def test_default_values_pass(self):
115115
self.assertEqual(impfs.size(), 10)
116116
self.assertEqual(impfs.get_ids()["TC"], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
117117
self.assertEqual(impf_wp4.intensity_unit, "m/s")
118-
self.assertEqual(impf_wp4.name, "North West Pacific (WP4)")
118+
self.assertEqual(impf_wp4.name, "North West Pacific")
119119
self.assertAlmostEqual(v_halfs["WP2"], 188.4, places=7)
120120
self.assertAlmostEqual(v_halfs["ROW"], 110.1, places=7)
121121
self.assertListEqual(list(impf_wp4.intensity), list(np.arange(0, 121, 5)))
@@ -135,7 +135,7 @@ def test_RMSF_pass(self):
135135
self.assertEqual(impfs.size(), 10)
136136
self.assertEqual(impfs.get_ids()["TC"], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
137137
self.assertEqual(impf_na1.intensity_unit, "m/s")
138-
self.assertEqual(impf_na1.name, "Caribbean and Mexico (NA1)")
138+
self.assertEqual(impf_na1.name, "Caribbean and Mexico")
139139
self.assertAlmostEqual(v_halfs["NA1"], 59.6, places=7)
140140
self.assertAlmostEqual(v_halfs["ROW"], 73.4, places=7)
141141
self.assertListEqual(list(impf_na1.intensity), list(np.arange(0, 121, 5)))
@@ -153,7 +153,7 @@ def test_quantile_pass(self):
153153
self.assertEqual(impfs.size(), 10)
154154
self.assertEqual(impfs_p10.size(), 10)
155155
self.assertEqual(impf_si.intensity_unit, "m/s")
156-
self.assertEqual(impf_si_p10.name, "South Indian (SI)")
156+
self.assertEqual(impf_si_p10.name, "South Indian")
157157
self.assertAlmostEqual(impf_si_p10.mdd.max(), 0.99999999880, places=5)
158158
self.assertAlmostEqual(impf_si.calc_mdr(30), 0.01620503041, places=5)
159159
intensity = np.random.randint(26, impf_si.intensity.max())
@@ -168,6 +168,35 @@ def test_get_countries_per_region(self):
168168
self.assertListEqual(out[2], [124, 840])
169169
self.assertListEqual(out[3], ["CAN", "USA"])
170170

171+
def test_get_imf_id_regions_per_countries(self):
172+
"""Test get_impf_id_regions_per_countries()"""
173+
ifs = ImpfSetTropCyclone()
174+
impf_id_reg_id_reg_name = ifs.get_impf_id_regions_per_countries(
175+
countries=["CHE"]
176+
)
177+
178+
# the first element of impf_id_reg_id_reg_name [0] is the impact function id,
179+
# the second [1] is the region id, the third [2] is the region name.
180+
self.assertEqual(impf_id_reg_id_reg_name[0][0], 10)
181+
self.assertEqual(impf_id_reg_id_reg_name[1][0], "ROW")
182+
self.assertEqual(impf_id_reg_id_reg_name[2][0], "Rest of The World")
183+
impf_id_reg_id_reg_name = ifs.get_impf_id_regions_per_countries(countries=[756])
184+
self.assertEqual(impf_id_reg_id_reg_name[0][0], 10)
185+
self.assertEqual(impf_id_reg_id_reg_name[1][0], "ROW")
186+
self.assertEqual(impf_id_reg_id_reg_name[2][0], "Rest of The World")
187+
188+
impf_id_reg_id_reg_name = ifs.get_impf_id_regions_per_countries(
189+
countries=["CHE", 268]
190+
)
191+
# CHE
192+
self.assertEqual(impf_id_reg_id_reg_name[0][0], 10)
193+
self.assertEqual(impf_id_reg_id_reg_name[1][0], "ROW")
194+
self.assertEqual(impf_id_reg_id_reg_name[2][0], "Rest of The World")
195+
# GEO (georgia, 268)
196+
self.assertEqual(impf_id_reg_id_reg_name[0][1], 3)
197+
self.assertEqual(impf_id_reg_id_reg_name[1][1], "NI")
198+
self.assertEqual(impf_id_reg_id_reg_name[2][1], "North Indian")
199+
171200

172201
# Execute Tests
173202
if __name__ == "__main__":

0 commit comments

Comments
 (0)