From d3499e3784af4e508392064c845e572bf5ef719b Mon Sep 17 00:00:00 2001 From: Xylar Asay-Davis Date: Tue, 22 Nov 2022 10:27:41 +0100 Subject: [PATCH] Fix masking of Hovmoller plots on different meshes We want the more restrictive mask (with shallower bathymetry) for comparing Hovmoller plots on different meshes. --- mpas_analysis/ocean/plot_hovmoller_subtask.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mpas_analysis/ocean/plot_hovmoller_subtask.py b/mpas_analysis/ocean/plot_hovmoller_subtask.py index 1c992e88a..16769e596 100644 --- a/mpas_analysis/ocean/plot_hovmoller_subtask.py +++ b/mpas_analysis/ocean/plot_hovmoller_subtask.py @@ -290,8 +290,6 @@ def run_task(self): # drop any NaN values, because this causes issues with rolling averages mask = field.notnull().all(dim='Time') - field = field.where(mask, drop=True) - z = z.where(mask, drop=True) xLabel = 'Time (years)' yLabel = 'Depth (m)' @@ -324,6 +322,8 @@ def run_task(self): diff = None refTitle = None diffTitle = None + z = z.where(mask, drop=True) + field = field.where(mask, drop=True) else: controlConfig = self.controlConfig dsRef = xr.open_dataset(self.controlFileName) @@ -347,9 +347,12 @@ def run_task(self): # drop any NaN values, because this causes issues with rolling # averages refMask = refField.notnull().all(dim='Time') - assert(np.all(refMask.values == mask.values)) + # if the masks differ, we want only locations where both are valid + mask = np.logical_and(mask, refMask) + z = z.where(mask, drop=True) + field = field.where(mask, drop=True) refField = refField.where(mask, drop=True) - assert(field.shape == refField.shape) + assert (field.shape == refField.shape) # make sure the start and end time sare the same assert(int(field.Time.values[0]) == int(refField.Time.values[0])) assert(int(field.Time.values[-1]) == int(refField.Time.values[-1])) @@ -357,7 +360,7 @@ def run_task(self): # so let's copy them refField['Time'] = field.Time diff = field - refField - assert(field.shape == diff.shape) + assert (field.shape == diff.shape) refTitle = self.controlConfig.get('runs', 'mainRunName') diffTitle = 'Main - Control'