Skip to content

Commit cb0a9c2

Browse files
committed
Fix time masking in sea-ice time series
We need to compute the time mask before we can use it as an index.
1 parent fcc4dab commit cb0a9c2

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

mpas_analysis/sea_ice/time_series.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -691,14 +691,19 @@ def _compute_area_vol(self):
691691
mask = dsMesh.latCell < 0
692692

693693
if maxAllowedSeaIceThickness is not None:
694-
mask = np.logical_and(mask,
695-
ds.iceThick <= maxAllowedSeaIceThickness)
694+
mask = np.logical_and(
695+
mask, ds.iceThick <= maxAllowedSeaIceThickness
696+
)
697+
dsForHemisphere = ds
696698
if os.path.exists(outFileNames[hemisphere]):
697699
dsCache = xr.open_dataset(outFileNames[hemisphere])
698700
timeMask = ds.startTime > dsCache.startTime.isel(Time=-1)
699-
ds = ds.isel(Time=timeMask)
701+
timeMask = timeMask.compute()
702+
dsForHemisphere = ds.isel(Time=timeMask)
700703

701-
dsAreaSum = (ds.where(mask) * dsMesh.areaCell).sum('nCells')
704+
dsAreaSum = (
705+
dsForHemisphere.where(mask) * dsMesh.areaCell
706+
).sum('nCells')
702707
dsAreaSum = dsAreaSum.rename(
703708
{'iceConc': 'iceArea',
704709
'iceThick': 'iceVolume',

0 commit comments

Comments
 (0)