1010# https://raw.githubusercontent.com/MPAS-Dev/MPAS-Analysis/main/LICENSE
1111
1212import numpy as np
13+ import os
1314import xarray as xr
1415
1516from mpas_analysis .shared import AnalysisTask
@@ -692,6 +693,10 @@ def _compute_area_vol(self):
692693 if maxAllowedSeaIceThickness is not None :
693694 mask = np .logical_and (mask ,
694695 ds .iceThick <= maxAllowedSeaIceThickness )
696+ if os .path .exists (outFileNames [hemisphere ]):
697+ dsCache = xr .open_dataset (outFileNames [hemisphere ])
698+ timeMask = ds .startTime > dsCache .startTime .isel (Time = - 1 )
699+ ds = ds .isel (Time = timeMask )
695700
696701 dsAreaSum = (ds .where (mask ) * dsMesh .areaCell ).sum ('nCells' )
697702 dsAreaSum = dsAreaSum .rename (
@@ -703,21 +708,25 @@ def _compute_area_vol(self):
703708 dsAreaSum ['snowDepth' ] = (dsAreaSum .snowVolume /
704709 dsMesh .areaCell .sum ('nCells' ))
705710
706- dsAreaSum ['iceArea' ].attrs ['units' ] = 'm$^2$'
707- dsAreaSum ['iceArea' ].attrs ['description' ] = \
708- f'Total { hemisphere } sea ice area'
709- dsAreaSum ['iceVolume' ].attrs ['units' ] = 'm$^3$'
710- dsAreaSum ['iceVolume' ].attrs ['description' ] = \
711- f'Total { hemisphere } sea ice volume'
712- dsAreaSum ['snowVolume' ].attrs ['units' ] = 'm$^3$'
713- dsAreaSum ['snowVolume' ].attrs ['description' ] = \
714- f'Total { hemisphere } snow volume'
715- dsAreaSum ['iceThickness' ].attrs ['units' ] = 'm'
716- dsAreaSum ['iceThickness' ].attrs ['description' ] = \
717- f'Mean { hemisphere } sea ice thickness'
718- dsAreaSum ['snowDepth' ].attrs ['units' ] = 'm'
719- dsAreaSum ['snowDepth' ].attrs ['description' ] = \
720- f'Mean { hemisphere } snow depth'
711+ if os .path .exists (outFileNames [hemisphere ]):
712+ dsAreaSum = xr .concat ([dsCache , dsAreaSum ], dim = 'Time' )
713+ dsCache .close ()
714+ else :
715+ dsAreaSum ['iceArea' ].attrs ['units' ] = 'm$^2$'
716+ dsAreaSum ['iceArea' ].attrs ['description' ] = \
717+ f'Total { hemisphere } sea ice area'
718+ dsAreaSum ['iceVolume' ].attrs ['units' ] = 'm$^3$'
719+ dsAreaSum ['iceVolume' ].attrs ['description' ] = \
720+ f'Total { hemisphere } sea ice volume'
721+ dsAreaSum ['snowVolume' ].attrs ['units' ] = 'm$^3$'
722+ dsAreaSum ['snowVolume' ].attrs ['description' ] = \
723+ f'Total { hemisphere } snow volume'
724+ dsAreaSum ['iceThickness' ].attrs ['units' ] = 'm'
725+ dsAreaSum ['iceThickness' ].attrs ['description' ] = \
726+ f'Mean { hemisphere } sea ice thickness'
727+ dsAreaSum ['snowDepth' ].attrs ['units' ] = 'm'
728+ dsAreaSum ['snowDepth' ].attrs ['description' ] = \
729+ f'Mean { hemisphere } snow depth'
721730
722731 dsTimeSeries [hemisphere ] = dsAreaSum
723732
0 commit comments