Skip to content

Commit 33c5a63

Browse files
authored
Handle exception in rowsize func (#169)
1 parent dbedb78 commit 33c5a63

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

clouddrift/adapters/gdp.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,19 @@ def drogue_presence(lost_time, time) -> bool:
271271

272272

273273
def rowsize(index: int, **kwargs) -> int:
274-
return xr.open_dataset(
275-
os.path.join(kwargs["tmp_path"], kwargs["filename_pattern"].format(id=index)),
276-
decode_cf=False,
277-
decode_times=False,
278-
concat_characters=False,
279-
decode_coords=False,
280-
).dims["obs"]
274+
try:
275+
return xr.open_dataset(
276+
os.path.join(
277+
kwargs["tmp_path"], kwargs["filename_pattern"].format(id=index)
278+
),
279+
decode_cf=False,
280+
decode_times=False,
281+
concat_characters=False,
282+
decode_coords=False,
283+
).dims["obs"]
284+
except Exception as e:
285+
print(
286+
f"Error processing {os.path.join(kwargs['tmp_path'], kwargs['filename_pattern'].format(id=index))}"
287+
)
288+
print(str(e))
289+
return 0

0 commit comments

Comments
 (0)