Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions mpas_analysis/ocean/time_series_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,29 @@ def run_task(self):

outFileName = f'{outputDirectory}/{self.groupSuffix}_{self.startYear:04d}-{self.endYear:04d}.nc'

outputExists = os.path.exists(outFileName)
outputValid = outputExists
if outputExists:
with open_mpas_dataset(fileName=outFileName,
calendar=self.calendar,
timeVariableNames=None,
variableList=None,
startDate=startDate,
endDate=endDate) as dsOut:

for load_year in numpy.arange(self.startYear, self.endYear + 1):
for load_month in numpy.arange(1, 13):
mask = numpy.logical_and(
dsOut.year.values == load_year,
dsOut.month.values == load_month)
if numpy.count_nonzero(mask) == 0:
outputValid = False
break

if outputValid:
self.logger.info(' Time series exists -- Done.')
return

inputFiles = sorted(self.historyStreams.readpath(
'timeSeriesStatsMonthlyOutput', startDate=startDate,
endDate=endDate, calendar=self.calendar))
Expand All @@ -259,29 +282,6 @@ def run_task(self):
'Using advection velocity.')
variableList.append('timeMonthly_avg_normalVelocity')

outputExists = os.path.exists(outFileName)
outputValid = outputExists
if outputExists:
with open_mpas_dataset(fileName=outFileName,
calendar=self.calendar,
timeVariableNames=None,
variableList=None,
startDate=startDate,
endDate=endDate) as dsOut:

for inIndex in range(dsOut.sizes['Time']):

mask = numpy.logical_and(
dsOut.year[inIndex].values == years,
dsOut.month[inIndex].values == months)
if numpy.count_nonzero(mask) == 0:
outputValid = False
break

if outputValid:
self.logger.info(' Time series exists -- Done.')
return

transectMaskFileName = self.masksSubtask.maskFileName

dsTransectMask = xarray.open_dataset(transectMaskFileName)
Expand Down