From f5bd90aca9c21c5b1db89bd3440180fb5d1220ca Mon Sep 17 00:00:00 2001 From: Michael Levy Date: Mon, 6 Jan 2025 14:12:09 -0700 Subject: [PATCH] Fix some bugs in generating CUPiD config 1. adf_root should be a subdirectory of case_root 2. All components should use end_year and base_end_year for time series, not just atm 3. Look to see if specific notebooks are in template config file before changing parameters for them --- .../generate_cupid_config_for_cesm_case.py | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/helper_scripts/generate_cupid_config_for_cesm_case.py b/helper_scripts/generate_cupid_config_for_cesm_case.py index 9e5e0cb..d02f75f 100755 --- a/helper_scripts/generate_cupid_config_for_cesm_case.py +++ b/helper_scripts/generate_cupid_config_for_cesm_case.py @@ -135,13 +135,23 @@ def generate_cupid_config(case_root, cesm_root, cupid_example): my_dict["global_params"]["base_end_date"] = base_end_date my_dict["timeseries"]["case_name"] = [case, base_case] - my_dict["timeseries"]["atm"]["end_years"] = [nyears, base_nyears] - my_dict["compute_notebooks"]["glc"]["Greenland_SMB_visual_compare_obs"][ - "parameter_groups" - ]["none"]["climo_nyears"] = climo_nyears - my_dict["compute_notebooks"]["glc"]["Greenland_SMB_visual_compare_obs"][ - "parameter_groups" - ]["none"]["base_climo_nyears"] = base_climo_nyears + for component in my_dict["timeseries"]: + if ( + isinstance(my_dict["timeseries"][component], dict) + and "end_years" in my_dict["timeseries"][component] + ): + my_dict["timeseries"][component]["end_years"] = [nyears, base_nyears] + if "link_to_ADF" in my_dict["compute_notebooks"]["atm"]: + my_dict["compute_notebooks"]["atm"]["link_to_ADF"]["parameter_groups"]["none"][ + "adf_root" + ] = os.path.join(case_root, "ADF_output") + if "Greenland_SMB_visual_compare_obs" in my_dict["compute_notebooks"]["glc"]: + my_dict["compute_notebooks"]["glc"]["Greenland_SMB_visual_compare_obs"][ + "parameter_groups" + ]["none"]["climo_nyears"] = climo_nyears + my_dict["compute_notebooks"]["glc"]["Greenland_SMB_visual_compare_obs"][ + "parameter_groups" + ]["none"]["base_climo_nyears"] = base_climo_nyears # replace with environment variable my_dict["global_params"]["CESM_output_dir"] = os.path.dirname(dout_s_root)