Skip to content

Commit

Permalink
Merge pull request #927 from xylar/fix_hovmoller_masking
Browse files Browse the repository at this point in the history
Fix masking of Hovmoller plots on different meshes
  • Loading branch information
xylar authored Nov 30, 2022
2 parents c19ec71 + d3499e3 commit 84f2d89
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions mpas_analysis/ocean/plot_hovmoller_subtask.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)'
Expand Down Expand Up @@ -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)
Expand All @@ -347,17 +347,20 @@ 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]))
# we're seeing issues with slightly different times between runs
# 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'

Expand Down

0 comments on commit 84f2d89

Please sign in to comment.