mpas_analysis.shared.time_series.cache_time_series¶
- mpas_analysis.shared.time_series.cache_time_series(timesInDataSet, timeSeriesCalcFunction, cacheFileName, calendar, yearsPerCacheUpdate=1, logger=None)[source]¶
Create or update a NetCDF file
cacheFileName
containing the given time series, calculated withtimeSeriesCalcFunction
over the given times, start and end year, and time frequency with which results are cached.Note: only works with climatologies where the mask (locations of
NaN
values) doesn’t vary with time.- Parameters
timesInDataSet (array-like) – Times at which the time series is to be calculated, typically taken from
ds.Times.values
for a data set from which the time series will be extracted or computed.timeSeriesCalcFunction (function) – A function with arguments
timeIndices
, indicating the entries intimesInDataSet
to be computed, andfirstCall
, indicating whether this is the first call to the funciton (useful for printing progress information).cacheFileName (str) – The absolute path to the cache file where the times series will be stored
calendar ({'gregorian', 'noleap'}) – The name of one of the calendars supported by MPAS cores, used to determine
year
andmonth
fromTime
coordinateyearsPerCacheUpdate (int, optional) – The frequency with which the cache file is updated as the computation progresses. If the computation is expensive, it may be useful to output the file frequently. If not, there will be needless overhead in caching the file too frequently.
logger (
logging.Logger
, optional) – A logger to which to write output as the time series is computed
- Returns
climatology (object of same type as
ds
) – A data set without the'Time'
coordinate containing the mean of ds over all months in monthValues, weighted by the number of days in each month.