def gen_task_ctrl(): tc = TaskControl(__file__) year = 2006 model = 'al508' dist_thresh = 100 dotprod_thresh = 0.05 inputs = { f'al508_diag_{month:02}': fmtp(diag_orog_precip_path_tpl, model=model, year=year, month=month) for month in [6, 7, 8] } inputs['al508_direct'] = fmtp(orog_precip_mean_fields_tpl, model='al508', year=year, season='jja', dotprod_thresh=dotprod_thresh, dist_thresh=dist_thresh) inputs['ak543_direct'] = fmtp(orog_precip_mean_fields_tpl, model='ak543', year=year, season='jja', dotprod_thresh=dotprod_thresh, dist_thresh=dist_thresh) tc.add(Task(plot_fig2, inputs, [D23_fig2])) tc.add(Task(plot_fig3, inputs, [D23_fig3])) tc.add(Task(plot_fig4, inputs, [D23_fig4, D23_fig5])) return tc
def gen_task_ctrl(): tc = TaskControl(__file__) # /gws/nopw/j04/cosmic/mmuetz/data/era_interim_orog_precip years = [2006] # years = [2005, 2006, 2007, 2008] models = ['al508', 'ak543'] months = [6, 7, 8] for model, year, month in product(models, years, months): # al508a.p9200606.asia_precip.nc precip_path = fmtp(precip_path_tpl, model=model, year=year, month=month) orog_precip_inputs = { 'extended_rclim_mask': extended_rclim_mask, 'land_sea_mask': land_sea_mask, 'precip': precip_path } diag_orog_precip_path = fmtp(diag_orog_precip_path_tpl, model=model, year=year, month=month) tc.add(Task(calc_orog_precip, orog_precip_inputs, [diag_orog_precip_path], func_args=(month - 1, ))) orog_precip_fracs_inputs = { 'extended_rclim_mask': extended_rclim_mask, 'land_sea_mask': land_sea_mask, 'orog_precip': diag_orog_precip_path } diag_orog_precip_frac_path = fmtp(diag_orog_precip_frac_path_tpl, model=model, year=year, month=month) tc.add(Task(calc_orog_precip_fracs, orog_precip_fracs_inputs, [diag_orog_precip_frac_path], func_args=(month - 1, ))) variables = list(product(models, months)) columns = ['model', 'month'] combine_inputs = [fmtp(diag_orog_precip_frac_path_tpl, model=model, year=year, month=month) for model, month in variables] combine_fracs_output = [diag_combine_frac_path] tc.add(Task(combine_orog_precip_fracs, combine_inputs, combine_fracs_output, func_args=(variables, columns) )) return tc
def gen_task_ctrl(): tc = TaskControl(__file__) models = ['al508', 'ak543'] # models = ['ak543'] dist_threshs = [100] dotprod_threshs = [0.05] months = [6, 7, 8] # dist_threshs = [20, 100] # dotprod_threshs = [0.05, 0.1] year = 2006 for model, dotprod_thresh, dist_thresh in product(models, dotprod_threshs, dist_threshs): # 1 model at a time. orog_precip_paths = [fmtp(orog_precip_path_tpl, model=model, year=year, month=month, dotprod_thresh=dotprod_thresh, dist_thresh=dist_thresh) for month in months] orog_precip_mean_fields = [fmtp(orog_precip_mean_fields_tpl, model=model, year=year, season='jja', dotprod_thresh=dotprod_thresh, dist_thresh=dist_thresh)] tc.add(Task(extract_precip_mean_fields, orog_precip_paths, orog_precip_mean_fields)) for model, dotprod_thresh, dist_thresh in product(models, dotprod_threshs, dist_threshs): orog_precip_mean_fields = [fmtp(orog_precip_mean_fields_tpl, model=model, year=year, season='jja', dotprod_thresh=dotprod_thresh, dist_thresh=dist_thresh)] orog_precip_figs = [fmtp(orog_precip_fig_tpl, model=model, year=year, season='jja', dotprod_thresh=dotprod_thresh, dist_thresh=dist_thresh, precip_type=precip_type) for precip_type in ['orog', 'non_orog', 'ocean', 'orog_frac']] tc.add(Task(plot_mean_orog_precip, orog_precip_mean_fields, orog_precip_figs)) return tc for dotprod_thresh, dist_thresh in product(dotprod_threshs, dist_threshs): # Compare 2 models. orog_precip_paths = {(model, month): fmtp(orog_precip_path_tpl, model=model, year=year, month=month, dotprod_thresh=dotprod_thresh, dist_thresh=dist_thresh) for model in models for month in months} orog_precip_figs = [fmtp(orog_precip_fig_tpl, model='-'.join(models), year=year, season='jja', dotprod_thresh=dotprod_thresh, dist_thresh=dist_thresh, precip_type=precip_type) for precip_type in ['orog', 'non_orog', 'ocean']] tc.add(Task(plot_compare_mean_orog_precip, orog_precip_paths, orog_precip_figs, func_args=(models, months))) return tc
def gen_task_ctrl(test=False): tc = TaskControl(__file__) models = ['al508', 'ak543'] months = [6, 7, 8] year = 2006 regions = ['TP_southern_flank', 'sichuan_basin'] days_in_month = 30 if test: models = models[:1] months = months[:1] days_in_month = 2 # regions = regions[:1] for model, month, region in product(models, months, regions): surf_wind_path = fmtp(surf_wind_path_tpl, model=model, year=year, month=month) precip_path = fmtp(precip_path_tpl, model=model, year=year, month=month) orog_mask_path = fmtp(orog_mask_path_tpl, model=model, year=year, month=month, dotprod_thresh=0.05, dist_thresh=100) raw_data_fig_paths = [ fmtp(raw_data_fig_tpl, model=model, year=year, month=month, day=day, hour=h, region=region) for day in range(1, days_in_month + 1) for h in range(0, 24) ] tc.add( Task(plot_precip_wind_region, { 'orog': orog_path, 'surf_wind': surf_wind_path, 'precip': precip_path, 'orog_mask': orog_mask_path, }, raw_data_fig_paths, func_args=(region, month))) raw_data_dc_fig_paths = [ fmtp(raw_data_dc_fig_tpl, model=model, year=year, month=month, hour=h, region=region) for h in range(24) ] tc.add( Task(plot_dc_region, { 'orog': orog_path, 'surf_wind': surf_wind_path, 'precip': precip_path, 'orog_mask': orog_mask_path, }, raw_data_dc_fig_paths, func_args=(region, 24))) raw_data_dc_anom_wind_fig_paths = [ fmtp(raw_data_dc_anom_wind_fig_tpl, model=model, year=year, month=month, hour=h, region=region) for h in range(24) ] tc.add( Task(plot_dc_anom_wind_region, { 'orog': orog_path, 'surf_wind': surf_wind_path, 'precip': precip_path, 'orog_mask': orog_mask_path, }, raw_data_dc_anom_wind_fig_paths, func_args=(region, 24))) tc.add( Task(create_animation, raw_data_dc_anom_wind_fig_paths, [ fmtp(anim_raw_data_dc_anom_wind_fig_tpl, model=model, year=year, month=month, region=region) ], (120, ))) return tc
def gen_task_ctrl(): tc = TaskControl(__file__) years = [2006] # years = [2005, 2006, 2007, 2008] models = ['al508', 'ak543'] dist_threshs = [50, 100] dotprod_threshs = [0.05] months = [6, 7, 8] # dist_threshs = [20, 100] # dotprod_threshs = [0.05, 0.1] for dist_thresh in dist_threshs: cache_key = fmtp(cache_key_tpl, dist_thresh=dist_thresh) tc.add( Task(gen_dist_cache, {'orog': orog_path}, [cache_key], func_args=(dist_thresh, ))) for year, model, dotprod_thresh, dist_thresh in product( years, models, dotprod_threshs, dist_threshs): cache_key = fmtp(cache_key_tpl, dist_thresh=dist_thresh) for month in months: surf_wind_path = fmtp(surf_wind_path_tpl, model=model, year=year, month=month) orog_mask_path = fmtp(orog_mask_path_tpl, model=model, year=year, month=month, dotprod_thresh=dotprod_thresh, dist_thresh=dist_thresh) inputs = { 'orog': orog_path, 'cache_key': cache_key, 'surf_wind': surf_wind_path } tc.add( Task(gen_orog_mask, inputs, [orog_mask_path], func_args=(dotprod_thresh, dist_thresh))) precip_path = fmtp(precip_path_tpl, model=model, year=year, month=month) orog_precip_path = fmtp(orog_precip_path_tpl, model=model, year=year, month=month, dotprod_thresh=dotprod_thresh, dist_thresh=dist_thresh) orog_precip_inputs = { 'orog_mask': orog_mask_path, 'land_sea_mask': land_sea_mask, 'precip': precip_path } tc.add( Task(calc_orog_precip, orog_precip_inputs, [orog_precip_path])) orog_precip_frac_inputs = { 'orog_mask': orog_mask_path, 'land_sea_mask': land_sea_mask, 'orog_precip': orog_precip_path } orog_precip_frac_path = fmtp(orog_precip_frac_path_tpl, model=model, year=year, month=month, dotprod_thresh=dotprod_thresh, dist_thresh=dist_thresh) tc.add( Task(calc_orog_precip_fracs, orog_precip_frac_inputs, [orog_precip_frac_path])) variables = list(product(models, dotprod_threshs, dist_threshs, months)) columns = ['model', 'dotprod_thresh', 'dist_thresh', 'month'] combine_inputs = [ fmtp(orog_precip_frac_path_tpl, model=model, year=year, month=month, dotprod_thresh=dotprod_thresh, dist_thresh=dist_thresh) for model, dotprod_thresh, dist_thresh, month in variables ] combine_fracs_output = [combine_frac_path] tc.add( Task(combine_orog_precip_fracs, combine_inputs, combine_fracs_output, func_args=(variables, columns))) return tc