Skip to content

Commit d9c00bd

Browse files
committed
Fix indexing
1 parent a6146a8 commit d9c00bd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pysteps/utils/dimension.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,9 @@ def clip_domain(R, metadata, extent=None):
249249
if len(R.shape) < 2:
250250
raise ValueError("The number of dimension must be > 1")
251251
if len(R.shape) == 2:
252-
R = R[None, None, :]
252+
R = R[None, None, :, :]
253253
if len(R.shape) == 3:
254-
R = R[None, :]
254+
R = R[None, :, :, :]
255255
if len(R.shape) > 4:
256256
raise ValueError("The number of dimension must be <= 4")
257257

@@ -298,8 +298,8 @@ def clip_domain(R, metadata, extent=None):
298298
idx_x_ = np.where(np.logical_and(x_coord_ < right, x_coord_ > left))[0]
299299

300300
# compose the new array
301-
R_[:, :, idx_y_[0]:idx_y_[-1], idx_x_[0]:idx_x_[-1]] = \
302-
R[:, :, idx_y[0]:idx_y[-1], idx_x[0]:idx_x[-1]]
301+
R_[:, :, idx_y_[0]:(idx_y_[-1] + 1), idx_x_[0]:(idx_x_[-1] + 1)] = \
302+
R[:, :, idx_y[0]:(idx_y[-1] + 1), idx_x[0]:(idx_x[-1] + 1)]
303303

304304
# update coordinates
305305
metadata["y1"] = bottom_

0 commit comments

Comments
 (0)