diff --git a/earthdiagnostics/ocean/regionmean.py b/earthdiagnostics/ocean/regionmean.py index b1a48300defc7f6ba029cbe076a45d29436c81bd..c38502286ef8d8b3e01a4b051c85c3cf168b2561 100644 --- a/earthdiagnostics/ocean/regionmean.py +++ b/earthdiagnostics/ocean/regionmean.py @@ -216,6 +216,20 @@ class RegionMean(Diagnostic): ) e3 = e3.extract(depth_constraint) data = data.extract(depth_constraint) + if self.box.min_depth is -1 and self.box.max_depth is not -1: + self.box.min_depth = 0 + depth_constraint = iris.Constraint( + depth=lambda c: self.box.min_depth <= c <= self.box.max_depth + ) + e3 = e3.extract(depth_constraint) + data = data.extract(depth_constraint) + if self.box.min_depth is not -1 and self.box.max_depth is -1: + self.box.max_depth = 6000 + depth_constraint = iris.Constraint( + depth=lambda c: self.box.min_depth <= c <= self.box.max_depth + ) + e3 = e3.extract(depth_constraint) + data = data.extract(depth_constraint) volcello = areacello * e3.data.astype(np.float32) mean = regmean.compute_regmean_3d(data.data, masks, volcello) self._save_result_2d("mean", mean, data)