def update_time_bounds_in_config(config): # {{{ """ Updates the start and end year (and associated full date) for climatologies, time series and climate indices based on the files that are actually available. Parameters ---------- config : ``MpasAnalysisConfigParser`` object contains config options """ # By updating the bounds for each component, we should end up with the # more constrained time bounds if any component has less output than others for componentName in ['ocean', 'seaIce']: for section in ['climatology', 'timeSeries', 'index']: update_time_bounds_from_file_names(config, section, componentName)
def test_update_climatology_bounds_and_create_symlinks(self): mpasClimatologyTask = self.setup_task() config = mpasClimatologyTask.config # first make sure the start and end years stay unchanged when we use # the start and end years already in the config file startYear = 2 endYear = 2 startDate = '{:04d}-01-01_00:00:00'.format(startYear) endDate = '{:04d}-12-31_23:59:59'.format(endYear) update_time_bounds_from_file_names(config, 'climatology', 'ocean') mpasClimatologyTask._create_symlinks() assert (mpasClimatologyTask.startYear == startYear) assert (mpasClimatologyTask.endYear == endYear) assert (mpasClimatologyTask.startDate == startDate) assert (mpasClimatologyTask.endDate == endDate) # Now, set the the start and end years out of range and make sure they # get changed back to the values that are in range startYear = 1 endYear = 5 startDate = '{:04d}-01-01_00:00:00'.format(startYear) endDate = '{:04d}-12-31_23:59:59'.format(endYear) config.set('climatology', 'startYear', str(startYear)) config.set('climatology', 'endYear', str(endYear)) config.set('climatology', 'startDate', startDate) config.set('climatology', 'endDate', endDate) update_time_bounds_from_file_names(config, 'climatology', 'ocean') mpasClimatologyTask._create_symlinks() startYear = 2 endYear = 2 startDate = '{:04d}-01-01_00:00:00'.format(startYear) endDate = '{:04d}-12-31_23:59:59'.format(endYear) assert (mpasClimatologyTask.startYear == startYear) assert (mpasClimatologyTask.endYear == endYear) assert (mpasClimatologyTask.startDate == startDate) assert (mpasClimatologyTask.endDate == endDate)