Skip to content

Commit

Permalink
Merge remote-tracking branch 'xylar/MPAS-Analysis/sort_time_in_time_s…
Browse files Browse the repository at this point in the history
…eries_caches' into develop
  • Loading branch information
milenaveneziani committed Apr 13, 2017
2 parents 47f1383 + 6aa3b70 commit 686c802
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mpas_analysis/shared/time_series/time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def cache_time_series(timesInDataSet, timeSeriesCalcFunction, cacheFileName,
dsCache = xr.open_dataset(cacheFileName, decode_times=False)
cacheDataSetExists = True
except IOError:
# assuming the cache file is corrupt, so deleting it.
# assuming the cache file is corrupt, so deleting it.
message = 'Deleting cache file {}, which appears to have ' \
'been corrupted.'.format(cacheFileName)
warnings.warn(message)
Expand Down Expand Up @@ -138,12 +138,16 @@ def cache_time_series(timesInDataSet, timeSeriesCalcFunction, cacheFileName,

if cacheDataSetExists:
dsCache = xr.concat([dsCache, ds], dim='Time')
# now sort the Time dimension:
dsCache = dsCache.loc[{'Time': sorted(dsCache.Time.values)}]
else:
dsCache = ds
cacheDataSetExists = True

dsCache.to_netcdf(cacheFileName)

return dsCache.sel(Time=slice(timesInDataSet[0],timesInDataSet[-1])) # }}}
return dsCache.sel(Time=slice(timesInDataSet[0], timesInDataSet[-1]))

# }}}

# vim: foldmethod=marker ai ts=4 sts=4 et sw=4 ft=python

0 comments on commit 686c802

Please sign in to comment.