diff --git a/coordinator/ProcessorEpidemiology.py b/coordinator/ProcessorEpidemiology.py index 52b00073a37c90343512e6a5a1d8cc64544a3b3e..e823a2e986cd1655632f50cadb8372d097273275 100644 --- a/coordinator/ProcessorEpidemiology.py +++ b/coordinator/ProcessorEpidemiology.py @@ -64,7 +64,7 @@ class ProcessorEpidemiology(Processor): init_date = datetime.datetime.strptime(init_str,'%Y%m%d') # note that filename date represents preceding 3 hours, so day's data - # starts at file timestamp 0300 UTC + # starts at file timestamp 0300 UTC threehour_shift = datetime.timedelta(hours=3) # add 24hrs so that final day is fully included @@ -336,10 +336,21 @@ class ProcessorEpidemiology(Processor): diseases = config['Epidemiology']['DiseaseNames'] - def gather_dependent_models(config_epi,config,variable_name,start_date,reference_date,end_date,jobDataPath,lastjobDataPath,status,component='Deposition'): + def gather_dependent_models( + config_epi, + config, + variable_name, + start_date, + reference_date, + end_date, + jobDataPath, + lastjobDataPath, + status, + component='Deposition'): + # This function is only prepared for components in this list - assert component in ['Deposition','Environment'] + assert component in ['Deposition','Environment','Epidemiology'] # TODO: Simplify the set of required arguments. Check if config is necessary. @@ -365,9 +376,23 @@ class ProcessorEpidemiology(Processor): loader_dict = { 'Deposition' : loader.load_NAME_file, 'Environment' : loader.load_env_file, + 'Epidemiology' : loader.load_and_restructure_epi_file, } - loader_func = loader_dict[component] + # Use config-defined file loader + + if 'FileLoaderFunction' in config_epi[component]: + + loader_func_name = config_epi[component]['FileLoaderFunction'] + loader_func = getattr(loader,loader_func_name) + + else: + + # Use pre-defined file loader + + assert component in loader_dict.keys() + + loader_func = loader_dict.get(component) # Provide component-specific variables if component == 'Deposition': @@ -376,6 +401,7 @@ class ProcessorEpidemiology(Processor): loader_kwargs['VariableNameAlternative']= config_for_lister[component].get('VariableNameAlternative') try: + assert component in ['Deposition','Environment'] # Make use of data prepared yesterday updater.update_input( config_for_lister, @@ -543,6 +569,27 @@ class ProcessorEpidemiology(Processor): config_epi['Host']['HostCSV'] = dst_host_csv config_epi['Host']['FileNamePrepared'] = dst_host_csv + # Preparing any continue-run files + for ci in config['Epidemiology']['Epi']: + + if ci.get('continue',False) is True: + + model_name = ci['model'] + + # Get results of last day and prepare as input + + gather_dependent_models( + config_epi, + config, + variable_name, + start_date, + reference_date, + end_date, + jobDataPath, + lastjobDataPath, + status, + component=model_name) + # provide fundamental config elements to config_epi for k,v in config.items(): if k not in short_name.keys():