コード例 #1
0
 def utcTimes(self, datetime_hour, **kwargs):
     if kwargs.get('use_latest_time', False):
         return {'utc_date':'latest', 'utc_time':'latest',
                 'utc_hour':'latest'}
     elif kwargs.get('use_previous_time', False):
         return {'utc_date':'previous', 'utc_time':'previous',
                 'utc_hour':'previous'}
     elif kwargs.get('use_time_in_path', False):
         return tzutils.utcTimeStrings(datetime_hour)
     else: 
         utc_times = tzutils.utcTimeStrings(datetime_hour)
         utc_times['utc_time'] = utc_times['utc_date']
         return utc_times
コード例 #2
0
 def _gribTemplateArgs(self, target_hour, variable, region, **kwargs):
     template_args = tzutils.utcTimeStrings(target_hour)
     template_args['analysis'] = self.analysis_type
     template_args['region'] = region
     template_args['source'] = self.grib_source.name
     template_args['variable'] = variable
     return template_args
コード例 #3
0
ファイル: factory.py プロジェクト: cueas-rickmoore/NDFDplus
 def templateArgs(self, target_hour, filetype, source, region):
     template_args = tzutils.utcTimeStrings(target_hour)
     template_args['filetype'] = filetype
     if region is not None:
         template_args['region'] = self.regionToFilepath(region)
     if source is not None:
         template_args['source'] = self.sourceToFilepath(source)
     return template_args
コード例 #4
0
    def hourlyGridFilename(self, filetype, target_hour, source, region,
                                 **kwargs):
        template = self.gridFilenameTemplate(filetype)
        if 'utc' in template:
            template_args = tzutils.utcTimeStrings(target_hour)
        else: template_args = self.timeToFilepath(target_hour)

        template_args.update(self.pathTemplateArgs(filetype, source, region))
        if kwargs: template_args.update(dict(kwargs))
        return template % template_args
コード例 #5
0
    def hourlyGridDirpath(self, filetype, target_hour, source, region,
                                **kwargs):
        root_dir = self.hourlyGridRootDir(filetype, **kwargs)
        template = self.anal_config.grid_subdir
        if isinstance(subdir, tuple): template = os.sep.join(template)

        if 'utc' in template:
            template_args = tzutils.utcTimeStrings(target_hour)
        else: template_args = self.timeToFilepath(target_hour)

        template_args.update(self.pathTemplateArgs(filetype, source, region))
        dirpath = os.path.join(root_dir, template % arg_dict) 
        if not os.path.exists(dirpath):
            if kwargs.get('dir_must_exist',kwargs.get('file_must_exist',False)):
                errmsg = 'Hourly grid directory does not exist :\n%s'
                raise IOError, errmsg % dirpath
            else: os.makedirs(dirpath)
        return dirpath