From 7f5c242d6f49080f04394e7015ac46dea49b5993 Mon Sep 17 00:00:00 2001 From: Francois Colleoni <110899888+inoelloc@users.noreply.github.com> Date: Mon, 16 Sep 2024 16:17:32 +0200 Subject: [PATCH] FIX: Rounding error with array slice with lat-lon raster (#323) This commit should fix the issue #317 --- smash/core/model/_read_input_data.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/smash/core/model/_read_input_data.py b/smash/core/model/_read_input_data.py index e61047f8..7b612203 100644 --- a/smash/core/model/_read_input_data.py +++ b/smash/core/model/_read_input_data.py @@ -163,8 +163,8 @@ def _read_windowed_raster(path: FilePath, mesh: MeshDT) -> tuple[np.ndarray, dic ys = pyoff - yoff xe = xs + pwin_xsize ye = ys + pwin_ysize - arr_xslice = slice(int(xs * 1 / xres_ratio), int(xe * 1 / xres_ratio)) - arr_yslice = slice(int(ys * 1 / yres_ratio), int(ye * 1 / yres_ratio)) + arr_xslice = slice(int(np.rint(xs * 1 / xres_ratio)), int(np.rint(xe * 1 / xres_ratio))) + arr_yslice = slice(int(np.rint(ys * 1 / yres_ratio)), int(np.rint(ye * 1 / yres_ratio))) # % Reading and writting into buffer ds.read(