Skip to content

Commit 4988ef8

Browse files
committed
same bugcatch for slicing error, now in stack.py
1 parent 47101ee commit 4988ef8

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

mintpy/objects/stack.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,17 @@ def read(self, datasetName=None, box=None, squeeze=True, print_msg=True):
270270
box = [0, 0, self.width, self.length]
271271

272272
# read
273-
data = ds[dateFlag,
274-
box[1]:box[3],
275-
box[0]:box[2]]
273+
try:
274+
data = ds[dateFlag,
275+
box[1]:box[3],
276+
box[0]:box[2]]
277+
except:
278+
# for some reason, fails to slice with an array of bools
279+
idx = np.array(list(range(len(dateFlag))))
280+
dateFlag1 = idx[dateFlag]
281+
data = ds[dateFlag1,
282+
box[1]:box[3],
283+
box[0]:box[2]]
276284

277285
if squeeze and any(i == 1 for i in data.shape):
278286
data = np.squeeze(data)

0 commit comments

Comments
 (0)