Skip to content

Commit 65e2fe8

Browse files
dbkhoutDaan Buekenhout
andauthored
Spatial aggregation fix (#317)
* Update dimension.py Correct spatial aggregation method to 'mean' for both 'mm/h' and 'mm' precipitation units. * Update test_utils_dimension.py Correct spatial aggregation test. Co-authored-by: Daan Buekenhout <[email protected]>
1 parent 8ece5be commit 65e2fe8

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

pysteps/tests/test_utils_dimension.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def test_aggregate_fields_time(R, metadata, time_window_min, ignore_nan, expecte
150150
{"unit": "mm", "xpixelsize": 1, "ypixelsize": 1},
151151
2,
152152
False,
153-
4 * np.ones((1, 5, 5)),
153+
np.ones((1, 5, 5)),
154154
),
155155
(
156156
np.ones((1, 10, 10)),

pysteps/utils/dimension.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,8 @@ def aggregate_fields_space(R, metadata, space_window, ignore_nan=False):
197197

198198
# specify the operator to be used to aggregate the values
199199
# within the space window
200-
if unit == "mm/h":
200+
if unit == "mm/h" or unit == "mm":
201201
method = "mean"
202-
elif unit == "mm":
203-
method = "sum"
204202
else:
205203
raise ValueError(
206204
"can only aggregate units of 'mm/h' or 'mm' " + "not %s" % unit

0 commit comments

Comments
 (0)