Skip to content

Commit 4ff44cd

Browse files
Merge branch 'develop' into feature/density_tracks
2 parents 04e289d + 7459ab8 commit 4ff44cd

File tree

16 files changed

+181
-227
lines changed

16 files changed

+181
-227
lines changed

.github/scripts/prepare_release.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
66
- update version numbers in _version.py and setup.py
77
- purge the "Unreleased" section of CHANGELOG.md and rename it to the new version number
8-
- copy the README.md file to doc/misc/README.md,
9-
but without the badges as they interfere with the sphinx doc builder
108
119
All changes are immediately commited to the repository.
1210
"""
@@ -51,17 +49,6 @@ def bump_version_number(version_number: str, level: str) -> str:
5149
return ".".join([major, minor, patch])
5250

5351

54-
def update_readme(_nvn):
55-
"""align doc/misc/README.md with ./README.md but remove the non-markdown header lines from"""
56-
with open("README.md", "r", encoding="UTF-8") as rmin:
57-
lines = [line for line in rmin.readlines() if not line.startswith("[![")]
58-
while not lines[0].strip():
59-
lines = lines[1:]
60-
with open("doc/misc/README.md", "w", encoding="UTF-8") as rmout:
61-
rmout.writelines(lines)
62-
return GitFile("doc/misc/README.md")
63-
64-
6552
def update_changelog(nvn):
6653
"""Rename the "Unreleased" section, remove unused subsections and the code-freeze date,
6754
set the release date to today"""
@@ -227,7 +214,6 @@ def prepare_new_release(level):
227214
update_setup(new_version_number).gitadd()
228215
update_version(new_version_number).gitadd()
229216
update_changelog(new_version_number).gitadd()
230-
update_readme(new_version_number).gitadd()
231217

232218
Git().commit(new_version_number)
233219

.zenodo.json

Lines changed: 123 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,120 +1,124 @@
11
{
2-
"creators": [
3-
{
4-
"name": "Gabriela Aznar Siguan",
5-
"affiliation": "MeteoSwiss"
6-
},
7-
{
8-
"name": "David N. Bresch",
9-
"affiliation": "ETH Z\u00fcrich"
10-
},
11-
{
12-
"name": "Samuel Eberenz",
13-
"affiliation": "ETH Z\u00fcrich"
14-
},
15-
{
16-
"name": "Jan Hartman",
17-
"affiliation": "CelsiusPro"
18-
},
19-
{
20-
"name": "Marine Perus",
21-
"affiliation": "CelsiusPro"
22-
},
23-
{
24-
"name": "Thomas R\u00f6\u00f6sli"
25-
},
26-
{
27-
"name": "Dario Stocker"
28-
},
29-
{
30-
"name": "Veronica Bozzini"
31-
},
32-
{
33-
"name": "Carmen B. Steinmann"
34-
},
35-
{
36-
"name": "Evelyn M\u00fchlhofer",
37-
"affiliation": "MeteoSwiss"
38-
},
39-
{
40-
"name": "Rachel Bungerer"
41-
},
42-
{
43-
"name": "Inga J. Sauer"
44-
},
45-
{
46-
"name": "Samuel L\u00fcthi",
47-
"affiliation": "ETH Z\u00fcrich"
48-
},
49-
{
50-
"name": "Pui Man (Mannie) Kam",
51-
"affiliation": "ETH Z\u00fcrich"
52-
},
53-
{
54-
"name": "Simona Meiler",
55-
"affiliation": "ETH Z\u00fcrich"
56-
},
57-
{
58-
"name": "Alessio Ciullo",
59-
"affiliation": "ETH Z\u00fcrich"
60-
},
61-
{
62-
"name": "Thomas Vogt",
63-
"affiliation": "Potsdam Institute for Climate Impact Research"
64-
},
65-
{
66-
"name": "Benoit P. Guillod",
67-
"affiliation": "CLIMADA Technologies"
68-
},
69-
{
70-
"name": "Chahan M. Kropf",
71-
"affiliation": "ETH Z\u00fcrich"
72-
},
73-
{
74-
"name": "Emanuel Schmid",
75-
"affiliation": "ETH Z\u00fcrich"
76-
},
77-
{
78-
"name": "Chris Fairless",
79-
"affiliation": "CelsiusPro"
80-
},
81-
{
82-
"name": "Jan W\u00fcthrich"
83-
},
84-
{
85-
"name": "Z\u00e9lie Stalhandske",
86-
"affiliation": "ETH Z\u00fcrich"
87-
},
88-
{
89-
"name": "Yue Yu"
90-
},
91-
{
92-
"name": "Lukas Riedel",
93-
"affiliation": "ETH Z\u00fcrich"
94-
},
95-
{
96-
"name": "Raphael Portmann",
97-
"affiliation": "Agroscope"
98-
},
99-
{
100-
"name": "Nicolas Colombi",
101-
"affiliation": "ETH Z\u00fcrich"
102-
},
103-
{
104-
"name": "Leonie Villiger"
105-
},
106-
{
107-
"name": "Timo Schmid"
108-
},
109-
{
110-
"name": "Luca Severino"
111-
},
112-
{
113-
"name": "Samuel Juhel",
114-
"affiliation": "ETH Z\u00fcrich"
115-
},
116-
{
117-
"name": "Valentin Gebhart"
118-
}
119-
]
120-
}
2+
"title": "CLIMADA Core Python Package",
3+
4+
"description": "CLIMADA (CLIMate ADAptation) is a free and open-source software framework for climate risk assessment and adaptation option appraisal. Designed by a large scientific community, it helps reasearchers, policymakers, and businesses analyse the impacts of natural hazards and explore adaptation strategies.",
5+
6+
"creators": [
7+
{
8+
"name": "Gabriela Aznar Siguan",
9+
"affiliation": "MeteoSwiss"
10+
},
11+
{
12+
"name": "David N. Bresch",
13+
"affiliation": "ETH Z\u00fcrich"
14+
},
15+
{
16+
"name": "Samuel Eberenz",
17+
"affiliation": "ETH Z\u00fcrich"
18+
},
19+
{
20+
"name": "Jan Hartman",
21+
"affiliation": "CelsiusPro"
22+
},
23+
{
24+
"name": "Marine Perus",
25+
"affiliation": "CelsiusPro"
26+
},
27+
{
28+
"name": "Thomas R\u00f6\u00f6sli"
29+
},
30+
{
31+
"name": "Dario Stocker"
32+
},
33+
{
34+
"name": "Veronica Bozzini"
35+
},
36+
{
37+
"name": "Carmen B. Steinmann"
38+
},
39+
{
40+
"name": "Evelyn M\u00fchlhofer",
41+
"affiliation": "MeteoSwiss"
42+
},
43+
{
44+
"name": "Rachel Bungerer"
45+
},
46+
{
47+
"name": "Inga J. Sauer"
48+
},
49+
{
50+
"name": "Samuel L\u00fcthi",
51+
"affiliation": "ETH Z\u00fcrich"
52+
},
53+
{
54+
"name": "Pui Man (Mannie) Kam",
55+
"affiliation": "ETH Z\u00fcrich"
56+
},
57+
{
58+
"name": "Simona Meiler",
59+
"affiliation": "ETH Z\u00fcrich"
60+
},
61+
{
62+
"name": "Alessio Ciullo",
63+
"affiliation": "ETH Z\u00fcrich"
64+
},
65+
{
66+
"name": "Thomas Vogt",
67+
"affiliation": "Potsdam Institute for Climate Impact Research"
68+
},
69+
{
70+
"name": "Benoit P. Guillod",
71+
"affiliation": "CLIMADA Technologies"
72+
},
73+
{
74+
"name": "Chahan M. Kropf",
75+
"affiliation": "ETH Z\u00fcrich"
76+
},
77+
{
78+
"name": "Emanuel Schmid",
79+
"affiliation": "ETH Z\u00fcrich"
80+
},
81+
{
82+
"name": "Chris Fairless",
83+
"affiliation": "CelsiusPro"
84+
},
85+
{
86+
"name": "Jan W\u00fcthrich"
87+
},
88+
{
89+
"name": "Z\u00e9lie Stalhandske",
90+
"affiliation": "ETH Z\u00fcrich"
91+
},
92+
{
93+
"name": "Yue Yu"
94+
},
95+
{
96+
"name": "Lukas Riedel",
97+
"affiliation": "ETH Z\u00fcrich"
98+
},
99+
{
100+
"name": "Raphael Portmann",
101+
"affiliation": "Agroscope"
102+
},
103+
{
104+
"name": "Nicolas Colombi",
105+
"affiliation": "ETH Z\u00fcrich"
106+
},
107+
{
108+
"name": "Leonie Villiger"
109+
},
110+
{
111+
"name": "Timo Schmid"
112+
},
113+
{
114+
"name": "Luca Severino"
115+
},
116+
{
117+
"name": "Samuel Juhel",
118+
"affiliation": "ETH Z\u00fcrich"
119+
},
120+
{
121+
"name": "Valentin Gebhart"
122+
}
123+
]
124+
}

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Code freeze date: YYYY-MM-DD
1616

1717
### Fixed
1818

19+
- bug in `climada.util.coordinates.bounding_box_from_countries` occurring if the country is a polygon and not a multipolygon
20+
[#1018](https://github.com/CLIMADA-project/climada_python/pull/1018)
21+
1922
### Deprecated
2023

2124
### Removed

climada/util/coordinates.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,19 +1854,20 @@ def bounding_box_from_countries(country_names, buffer=1.0):
18541854
"""
18551855

18561856
country_geometry = get_country_geometries(country_names).geometry
1857-
longitudes, latitudes = [], []
1858-
for multipolygon in country_geometry:
1859-
if isinstance(multipolygon, Polygon): # if entry is polygon
1860-
for coord in polygon.exterior.coords: # Extract exterior coordinates
1861-
longitudes.append(coord[0])
1862-
latitudes.append(coord[1])
1863-
else: # if entry is multipolygon
1864-
for polygon in multipolygon.geoms:
1865-
for coord in polygon.exterior.coords: # Extract exterior coordinates
1866-
longitudes.append(coord[0])
1867-
latitudes.append(coord[1])
1857+
generator_country_geometry = (
1858+
poly if isinstance(poly, MultiPolygon) else MultiPolygon([poly])
1859+
for poly in country_geometry
1860+
)
1861+
lon, lat = np.concatenate(
1862+
[
1863+
np.array(pg.exterior.coords).T
1864+
for poly in generator_country_geometry
1865+
for pg in poly.geoms
1866+
],
1867+
axis=1,
1868+
)
18681869

1869-
return latlon_bounds(np.array(latitudes), np.array(longitudes), buffer=buffer)
1870+
return latlon_bounds(lat, lon, buffer=buffer)
18701871

18711872

18721873
def bounding_box_from_cardinal_bounds(*, northern, eastern, western, southern):
@@ -1887,12 +1888,13 @@ def bounding_box_from_cardinal_bounds(*, northern, eastern, western, southern):
18871888
Returns
18881889
-------
18891890
tuple
1890-
The resulting normalized bounding box (min_lon, min_lat, max_lon, max_lat) with -180 <= min_lon < max_lon < 540
1891+
The resulting normalized bounding box (min_lon, min_lat, max_lon, max_lat)
1892+
with -180 <= min_lon < max_lon < 540
18911893
18921894
"""
18931895

18941896
# latitude bounds check
1895-
if not ((90 >= northern > southern >= -90)):
1897+
if not 90 >= northern > southern >= -90:
18961898
raise ValueError(
18971899
"Given northern bound is below given southern bound or out of bounds"
18981900
)

climada/util/test/test_coordinates.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2330,6 +2330,7 @@ def test_bounding_box_global(self):
23302330

23312331
def test_bounding_box_from_countries(self):
23322332
"""Test for a list of ISO country codes."""
2333+
# Italy is a multipolygon geometry
23332334
result = u_coord.bounding_box_from_countries(
23342335
["ITA"], buffer=1.0
23352336
) # Testing with Italy (ITA)
@@ -2339,7 +2340,21 @@ def test_bounding_box_from_countries(self):
23392340
34.48924388200004,
23402341
19.517425977000073,
23412342
48.08521494500006,
2342-
] # Italy's bounding box
2343+
] # Italy's bounding box with 1 degree buffer
2344+
np.testing.assert_array_almost_equal(result, expected)
2345+
2346+
# Switzerland is a polygon geometry
2347+
result = u_coord.bounding_box_from_countries(
2348+
["CHE"], buffer=0.0
2349+
) # Testing with Switzerland (CHE)
2350+
# Real expected bounds for Switzerland (calculated or manually known)
2351+
expected = [
2352+
5.954809204000128,
2353+
45.82071848599999,
2354+
10.466626831000013,
2355+
47.801166077000076,
2356+
] # CHE's bounding box with 0 degree buffer
2357+
np.testing.assert_array_almost_equal(result, expected)
23432358

23442359
# invalid input
23452360
with self.assertRaises(ValueError):

doc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"sphinx.ext.viewcode",
4141
"sphinx.ext.napoleon",
4242
"sphinx.ext.ifconfig",
43+
"sphinx_mdinclude",
4344
"myst_nb",
4445
"sphinx_markdown_tables",
4546
"readthedocs_ext.readthedocs",

doc/misc/AUTHORS.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

doc/misc/AUTHORS.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CLIMADA List of Authors
2+
=======================
3+
4+
.. mdinclude:: ../../AUTHORS.md
5+
:start-line: 1

doc/misc/CHANGELOG.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

doc/misc/CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Changelog
2+
=========
3+
4+
.. mdinclude:: ../../CHANGELOG.md
5+
:start-line: 1

0 commit comments

Comments
 (0)