def run_at_time(self, init_time): task_info = TaskInfo() task_info.init_time = init_time fcst_vars = util.getlist(self.p.getstr('config', 'FCST_VARS')) lead_seq = util.getlistint(self.p.getstr('config', 'LEAD_SEQ')) for lead in lead_seq: task_info.lead = lead for fcst_var in fcst_vars: task_info.fcst_var = fcst_var # loop over models to compare accums = util.getlist( self.p.getstr('config', fcst_var + "_ACCUM")) ob_types = util.getlist( self.p.getstr('config', fcst_var + "_OBTYPE")) for accum in accums: task_info.level = accum for ob_type in ob_types: task_info.ob_type = ob_type if lead < int(accum): continue # self.run_at_time_fcst(task_info) self.run_at_time_once(task_info.getValidTime(), task_info.level, task_info.ob_type, task_info.fcst_var)
def run_at_time(self, init_time, valid_time): task_info = TaskInfo() task_info.init_time = init_time task_info.valid_time = valid_time var_list = util.parse_var_list(self.p) max_forecast = self.p.getint('config', 'FCST_MAX_FORECAST') if self.p.has_option('config', 'FCST_MIN_FORECAST'): min_forecast = self.p.getint('config', 'FCST_MIN_FORECAST') else: min_forecast = 0 #lead_seq = util.getlistint(self.p.getstr('config', 'LEAD_SEQ')) if init_time == -1: #Create a list of files to loop over gen_seq = util.getlistint(self.p.getstr('config', 'GEN_SEQ')) init_interval = self.p.getint('config', 'FCST_INIT_INTERVAL') valid_hr = int(valid_time[8:10]) #Find lead times lead_seq = [] for gs in gen_seq: if valid_hr >= gs: current_lead = valid_hr - gs elif valid_hr < gs: current_lead = valid_hr + gs while current_lead <= max_forecast: lead_seq.append(current_lead) current_lead = current_lead + 24 for lead in lead_seq: if lead < min_forecast: continue task_info.lead = lead for var_info in var_list: self.run_at_time_once(task_info, var_info)
def run_at_time(self, init_time, valid_time): task_info = TaskInfo() task_info.init_time = init_time task_info.valid_time = valid_time var_list = util.parse_var_list(self.p) lead_seq = util.getlistint(self.p.getstr('config', 'LEAD_SEQ')) for lead in lead_seq: task_info.lead = lead for var_info in var_list: self.run_at_time_once(task_info, var_info)
def run_at_time(self, init_time, valid_time): task_info = TaskInfo() task_info.init_time = init_time task_info.valid_time = valid_time var_list = util.parse_var_list(self.p) lead_seq = util.getlistint(self.p.getstr('config', 'LEAD_SEQ')) for lead in lead_seq: task_info.lead = lead task_info.valid_time = -1 for var_info in var_list: level = var_info.obs_level if level[0].isalpha(): level = var_info.obs_level[1:] self.run_at_time_once(task_info.getValidTime(), level, var_info.obs_name)
def run_at_time(self, init_time, valid_time): task_info = TaskInfo() task_info.init_time = init_time task_info.valid_time = valid_time var_list = util.parse_var_list(self.p) lead_seq = util.getlistint(self.p.getstr('config', 'LEAD_SEQ')) # want to combine fcst data files to get total accum matching obs? # obs_level = self.p.getstr('config', 'OBS_LEVEL') fcst_level = self.p.getstr('config', 'FCST_LEVEL') # TODO: should use getpath or something? in_dir = self.p.getdir('FCST_PCP_COMBINE_INPUT_DIR') in_template = self.p.getraw('filename_templates', 'FCST_PCP_COMBINE_INPUT_TEMPLATE') out_dir = self.p.getdir('FCST_PCP_COMBINE_OUTPUT_DIR') out_template = self.p.getraw('filename_templates', 'FCST_PCP_COMBINE_OUTPUT_TEMPLATE') for lead in lead_seq: task_info.lead = lead for var_info in var_list: out_level = var_info.obs_level if out_level[0].isalpha(): out_level = out_level[1:] if not self.p.has_option('config', 'PCP_COMBINE_METHOD') or \ self.p.getstr('config', 'PCP_COMBINE_METHOD') == "ADD": self.run_add_method(task_info.getValidTime(), task_info.getInitTime(), out_level, var_info.obs_name, "FCST", True) elif self.p.getstr('config', 'PCP_COMBINE_METHOD') == "SUM": self.run_sum_method(task_info.getValidTime(), task_info.getInitTime(), fcst_level, out_level, in_dir, out_dir, out_template) elif self.p.getstr('config', 'PCP_COMBINE_METHOD') == "SUBTRACT": self.run_subtract_method(task_info, var_info, int(out_level), in_dir, out_dir, in_template, out_template) else: self.logger.error("Invalid PCP_COMBINE_METHOD specified") exit(1)
def run_at_time(self, init_time, valid_time): task_info = TaskInfo() task_info.init_time = init_time task_info.valid_time = valid_time var_list = util.parse_var_list(self.p) model_templates = util.getlist( self.p.getraw('filename_templates', 'FCST_GRID_STAT_INPUT_TEMPLATE')) model_types = util.getlist(self.p.getraw('config', 'MODEL_TYPE')) max_forecasts = util.getlist( self.p.getraw('config', 'FCST_MAX_FORECAST')) self.check_model(model_templates, model_types, max_forecasts) lead_seq = util.getlistint(self.p.getstr('config', 'LEAD_SEQ')) for md in range(len(model_templates)): cur_model = [ model_templates[md], model_types[md], max_forecasts[md] ] for lead in lead_seq: task_info.lead = lead for var_info in var_list: self.run_at_time_once(task_info, var_info, cur_model)
def run_at_time(self, init_time, valid_time): task_info = TaskInfo() task_info.init_time = init_time task_info.valid_time = valid_time var_list = util.parse_var_list(self.p) max_forecast = self.p.getint('config', 'FCST_MAX_FORECAST') if init_time == -1: #Create a list of files to loop over gen_seq = util.getlistint(self.p.getstr('config', 'GEN_SEQ')) init_interval = self.p.getint('config', 'FCST_INIT_INTERVAL') valid_hr = int(valid_time[8:10]) #Find lead times lead_seq = [] for gs in gen_seq: if valid_hr >= gs: current_lead = valid_hr - gs elif valid_hr < gs: current_lead = valid_hr + gs while current_lead <= max_forecast: lead_seq.append(current_lead) current_lead = current_lead + 24 lead_seq = sorted(lead_seq) if valid_time == -1: lead_seq = util.getlistint(self.p.getstr('config', 'LEAD_SEQ')) # want to combine fcst data files to get total accum matching obs? # obs_level = self.p.getstr('config', 'OBS_LEVEL') fcst_level = self.p.getstr('config', 'FCST_LEVEL') # TODO: should use getpath or something? in_dir = self.p.getstr('config', 'FCST_PCP_COMBINE_INPUT_DIR') in_template = self.p.getraw('filename_templates', 'FCST_PCP_COMBINE_INPUT_TEMPLATE') out_dir = self.p.getstr('config', 'FCST_PCP_COMBINE_OUTPUT_DIR') out_template = self.p.getraw('filename_templates', 'FCST_PCP_COMBINE_OUTPUT_TEMPLATE') for lead in lead_seq: task_info.lead = lead for var_info in var_list: out_level = var_info.obs_level if out_level[0].isalpha(): out_level = out_level[1:] if not self.p.has_option('config', 'PCP_COMBINE_METHOD') or \ self.p.getstr('config', 'PCP_COMBINE_METHOD') == "ADD": self.run_add_method(task_info.getValidTime(), task_info.getInitTime(), out_level, var_info.obs_name, "FCST", True) elif self.p.getstr('config', 'PCP_COMBINE_METHOD') == "SUM": self.run_sum_method(task_info.getValidTime(), task_info.getInitTime(), fcst_level, out_level, in_dir, out_dir, out_template) elif self.p.getstr('config', 'PCP_COMBINE_METHOD') == "SUBTRACT": self.run_subtract_method(task_info, var_info, int(out_level), in_dir, out_dir, in_template, out_template) else: self.logger.error("Invalid PCP_COMBINE_METHOD specified") exit(1)