From 0f875683129161376cff30a3f8dfc4a3c5615ad1 Mon Sep 17 00:00:00 2001 From: sloosvel Date: Thu, 23 Jul 2020 14:14:43 +0200 Subject: [PATCH] Use masked array routines --- earthdiagnostics/ocean/regionmean.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/earthdiagnostics/ocean/regionmean.py b/earthdiagnostics/ocean/regionmean.py index b1a48300..c3850228 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) -- GitLab