Skip to content

Commit 658ac44

Browse files
committed
BUG #1106: wrong dataset created from nc file with decreasing lat and bounds
We did not handle correctly a nc file which specifies bounds and has decreasing latitude or longitude.
1 parent 5ea46aa commit 658ac44

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

Packages/vcs/Lib/vcs2vtk.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,22 @@ def genGrid(data1, data2, gm, deep=True, grid=None, geo=None):
344344
try:
345345
blat = lat.getBounds()
346346
blon = lon.getBounds()
347-
lat2[:len(lat)] = blat[:, 0]
348-
lat2[len(lat)] = blat[-1, 1]
349-
lon2[:len(lon)] = blon[:, 0]
350-
lon2[len(lon)] = blon[-1, 1]
347+
if (lat[0] < lat[-1]):
348+
# latitude is increasing
349+
lat2[:len(lat)] = blat[:, 0]
350+
lat2[len(lat)] = blat[-1, 1]
351+
else:
352+
# latitude is decreasing
353+
lat2[:len(lat)] = blat[:, 1]
354+
lat2[len(lat)] = blat[-1, 0]
355+
if (lon[0] < lon[-1]):
356+
# longitude is incresing
357+
lon2[:len(lon)] = blon[:, 0]
358+
lon2[len(lon)] = blon[-1, 1]
359+
else:
360+
# longitude is decreasing
361+
lon2[:len(lon)] = blon[:, 1]
362+
lon2[len(lon)] = blon[-1, 0]
351363
xm = blon[0][0]
352364
xM = blon[-1][1]
353365
ym = blat[0][0]

0 commit comments

Comments
 (0)