From 199850e5c3582e063cf2f1f38f765c735367edd6 Mon Sep 17 00:00:00 2001 From: doppler Date: Tue, 16 Apr 2024 09:46:13 +0200 Subject: [PATCH] check for zero size landgrid before calling .min --- opendrift/models/basemodel/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/opendrift/models/basemodel/__init__.py b/opendrift/models/basemodel/__init__.py index 973fc0172..22956a569 100644 --- a/opendrift/models/basemodel/__init__.py +++ b/opendrift/models/basemodel/__init__.py @@ -937,6 +937,10 @@ def closest_ocean_points(self, lon, lat): lat=latgrid, z=0 * longrid, time=land_reader.start_time)[0]['land_binary_mask'] + if landgrid.size == 0: + # Need to catch this before trying .min() on it... + logger.warning('Land grid has zero size, cannot move elements.') + return lon, lat if landgrid.min() == 1 or np.isnan(landgrid.min()): logger.warning('No ocean pixels nearby, cannot move elements.') return lon, lat