diff --git a/examples/config_across_scen_T_cmip6ng_test.py b/examples/config_tas_cmip6ng_example.py similarity index 95% rename from examples/config_across_scen_T_cmip6ng_test.py rename to examples/config_tas_cmip6ng_example.py index e4c9be0c..f6c2eb26 100644 --- a/examples/config_across_scen_T_cmip6ng_test.py +++ b/examples/config_tas_cmip6ng_example.py @@ -1,6 +1,5 @@ """ -Configuration file for tests - +Example configuration file """ import os.path @@ -59,14 +58,14 @@ # members) wgt_scen_tr_eq = True -# number of created emulations (small number for testing purposes) +# number of created emulations (small number for example) nr_emus_v = 5 # seed offset for scenarios (0 meaning same emulations drawn for each scen, other # numbers will have different ones for each scen) scen_seed_offset_v = 0 -# max. nr of iterations in cross validation (small for testing purposes) +# max. nr of iterations in cross validation (small for example) max_iter_cv = 15 # predictors (for global module) diff --git a/examples/train_create_emus_automated.py b/examples/train_create_emus_automated.py index dc75e9a2..78821f10 100644 --- a/examples/train_create_emus_automated.py +++ b/examples/train_create_emus_automated.py @@ -15,10 +15,7 @@ from mesmer.utils import convert_dict_to_arr, extract_land, separate_hist_future -def main(): - - # load in configurations used in this script - import config_across_scen_T_cmip6ng_test as cfg +def main(cfg): # specify the target variable targ = cfg.targs[0] @@ -88,12 +85,12 @@ def main(): "- Prepare predictors for global variability, local trends and variability" ) - GSAT_s, time_s = separate_hist_future(gsat[esm], time[esm], cfg) + gsat_s, _ = separate_hist_future(gsat[esm], time[esm], cfg) gv_novolc_tas_s = {} for scen in gt_tas_s.keys(): - gv_novolc_tas_s[scen] = GSAT_s[scen] - gt_tas_s[scen] + gv_novolc_tas_s[scen] = gsat_s[scen] - gt_tas_s[scen] - tas_s, time_s = separate_hist_future(tas[esm], time[esm], cfg) + tas_s, _ = separate_hist_future(tas[esm], time[esm], cfg) print("- Start with global variability module") @@ -103,12 +100,12 @@ def main(): scen = list(gt_tas.keys())[0] time_v["all"] = time[esm][scen] preds_gv = {"time": time_v} - emus_gv_T = create_emus_gv(params_gv_tas, preds_gv, cfg, save_emus=True) + emus_gv_tas = create_emus_gv(params_gv_tas, preds_gv, cfg, save_emus=True) # create and save full global emulations print("- Merge the global trend and the global variability.") create_emus_g( - gt_tas, emus_gv_T, params_gt_tas, params_gv_tas, cfg, save_emus=True + gt_tas, emus_gv_tas, params_gt_tas, params_gv_tas, cfg, save_emus=True ) print("- Start with local trends module") @@ -154,7 +151,7 @@ def main(): ) # create full lv emulations - preds_lv = {"gvtas": emus_gv_T} # predictors_list + preds_lv = {"gvtas": emus_gv_tas} # predictors_list emus_lv = create_emus_lv(params_lv, preds_lv, cfg, save_emus=True) # create and save full emulations @@ -163,4 +160,8 @@ def main(): if __name__ == "__main__": - main() + + # load in configurations used in this script + import config_tas_cmip6ng_example as cfg + + main(cfg) diff --git a/mesmer/io/load_mesmer.py b/mesmer/io/load_mesmer.py index 03f49153..6cadc765 100644 --- a/mesmer/io/load_mesmer.py +++ b/mesmer/io/load_mesmer.py @@ -94,13 +94,9 @@ def load_mesmer_output( if esm_str != "_": esm_str = esm_str + "_" - path_list = glob.glob( - os.path.join( - dir_mesmer, - mid_path, - f"{name}*{method_str}*{preds_str}*{targs_str}*{esm_str}*{scen_str}*.pkl", - ) - ) + filename = f"{name}*{method_str}*{preds_str}*{targs_str}*{esm_str}*{scen_str}*.pkl" + fullname = os.path.join(dir_mesmer, mid_path, filename) + path_list = glob.glob(fullname) # load the requested output dictionary if len(path_list) == 1: