Skip to content

Commit 8944221

Browse files
make test_from_shape_zurich_pass pass
1 parent 417af5d commit 8944221

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

climada/entity/exposures/litpop/litpop.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,8 +1285,8 @@ def reproject_input_data(
12851285
... 'height': 1939,
12861286
... 'count': 1,
12871287
... 'crs': CRS.from_epsg(4326),
1288-
... 'transform': Affine(0.00833333333333333, 0.0, -18.175000000000068,
1289-
... 0.0, -0.00833333333333333, 43.79999999999993),
1288+
... 'transform': Affine(30/3600, 0.0, -18.175,
1289+
... 0.0, -30/3600, 43.8),
12901290
... }
12911291
12921292
The meta data with the reference grid used to define the global destination

climada/test/test_litpop_integr.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,24 +169,30 @@ def test_from_shape_zurich_pass(self):
169169
)
170170
self.assertAlmostEqual(ent.value.sum(), 1000.0)
171171
self.assertEqual(ent.value.min(), 0.0)
172+
self.assertAlmostEqual(ent.value.max(), 5.058, places=4)
173+
# Note: up to climada 6.0 this value used to be 5.05792616746308, then 5.058035160766561.
174+
# The discrepancy assumedly caused by rounding differences of the slightly changed
175+
# calculation procedure.
172176
self.assertEqual(ent.region_id.min(), 756)
173177
self.assertEqual(ent.region_id.max(), 756)
174-
self.assertAlmostEqual(ent.latitude.min(), 47.20416666666661)
178+
self.assertAlmostEqual(ent.latitude.min(), 47.2 + 15 / 3600)
175179
# index and coord. of largest value:
176180
self.assertEqual(
177-
ent.gdf.loc[ent.gdf["value"] == ent.gdf["value"].max()].index[0], 482
181+
ent.gdf.loc[ent.gdf["value"] == ent.gdf["value"].max()].index[0], 434
178182
)
183+
# Note: up to climada 6.0 this index used to be 482, because of its then irregular order.
184+
# Specifically: the dataframe started at 36 and then skipped 71, 107, 143, etc.
179185
self.assertAlmostEqual(
180186
ent.gdf.loc[ent.gdf["value"] == ent.gdf["value"].max()].geometry.y.values[
181187
0
182188
],
183-
47.34583333333325,
189+
5681.5 * 30 / 3600,
184190
)
185191
self.assertAlmostEqual(
186192
ent.gdf.loc[ent.gdf["value"] == ent.gdf["value"].max()].geometry.x.values[
187193
0
188194
],
189-
8.529166666666658,
195+
1023.5 * 30 / 3600,
190196
)
191197

192198
def test_from_shape_and_countries_zurich_pass(self):

0 commit comments

Comments
 (0)