Skip to content

Commit

Permalink
Fix check for preprocessed run out of range
Browse files Browse the repository at this point in the history
  • Loading branch information
xylar committed May 30, 2018
1 parent 2e35bed commit 34e574a
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions mpas_analysis/sea_ice/time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,32 @@ def run_task(self): # {{{
timeEnd = date_to_days(year=yearEnd, month=12, day=31,
calendar=calendar)

if preprocessedReferenceRunName != 'None':
# determine if we're beyond the end of the preprocessed data
# (and go ahead and cache the data set while we're checking)
outFolder = '{}/preprocessed'.format(outputDirectory)
make_directories(outFolder)
inFilesPreprocessed = '{}/icevol.{}.year*.nc'.format(
preprocessedReferenceDirectory, preprocessedReferenceRunName)
outFileName = '{}/iceVolume.nc'.format(outFolder)

combine_time_series_with_ncrcat(inFilesPreprocessed,
outFileName,
logger=self.logger)
dsPreprocessed = open_mpas_dataset(fileName=outFileName,
calendar=calendar,
timeVariableNames='xtime')
preprocessedYearEnd = days_to_datetime(dsPreprocessed.Time.max(),
calendar=calendar).year
if yearStart <= preprocessedYearEnd:
dsPreprocessedTimeSlice = \
dsPreprocessed.sel(Time=slice(timeStart, timeEnd))
else:
self.logger.warning('Preprocessed time series ends before the '
'timeSeries startYear and will not be '
'plotted.')
preprocessedReferenceRunName = 'None'

if self.refConfig is not None:

dsTimeSeriesRef = {}
Expand Down Expand Up @@ -363,12 +389,11 @@ def run_task(self): # {{{

if preprocessedReferenceRunName != 'None':
outFolder = '{}/preprocessed'.format(outputDirectory)
make_directories(outFolder)
inFilesPreprocessed = '{}/icearea.{}.year*.nc'.format(
preprocessedReferenceDirectory,
preprocessedReferenceRunName)

outFileName = '{}/iceArea{}.nc'.format(outFolder, hemisphere)
outFileName = '{}/iceArea.nc'.format(outFolder)

combine_time_series_with_ncrcat(inFilesPreprocessed,
outFileName,
Expand All @@ -385,7 +410,7 @@ def run_task(self): # {{{
inFilesPreprocessed = '{}/icevol.{}.year*.nc'.format(
preprocessedReferenceDirectory,
preprocessedReferenceRunName)
outFileName = '{}/iceVolume{}.nc'.format(outFolder, hemisphere)
outFileName = '{}/iceVolume.nc'.format(outFolder)

combine_time_series_with_ncrcat(inFilesPreprocessed,
outFileName,
Expand Down

0 comments on commit 34e574a

Please sign in to comment.