Skip to content

Commit fdc7dfe

Browse files
committed
Fix index computation
1 parent d962b01 commit fdc7dfe

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

isimip_files_api/netcdf.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from .settings import RESOLUTIONS
44

5+
56
def open_dataset(path):
67
return Dataset(path)
78

@@ -21,11 +22,7 @@ def get_index(path, point):
2122
dx = ds.variables['lon'][1] - ds.variables['lon'][0]
2223
dy = ds.variables['lat'][1] - ds.variables['lat'][0]
2324

24-
ix = int((lon - ds.variables['lon'][0]) / dx)
25-
26-
if dy > 0:
27-
iy = int((lat - ds.variables['lat'][0]) / dy)
28-
else:
29-
iy = int((ds.variables['lat'][0] - lat) / -dy)
25+
ix = round((lon - ds.variables['lon'][0]) / dx)
26+
iy = round((lat - ds.variables['lat'][0]) / dy)
3027

3128
return ix, iy

0 commit comments

Comments
 (0)