Skip to content

Commit

Permalink
ADF updates
Browse files Browse the repository at this point in the history
1. Bring in latest ADF commit as external
2. generate_cupid_config_for_cesm_case.py now has --adf-output-root argument
that lets users specify a place other than ${CASEROOT} for ADF_output/

Also cleaned up comments about start_years and end_years in timeseries.py
  • Loading branch information
mnlevy1981 committed Feb 26, 2025
1 parent 6e85a34 commit 8f06074
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cupid/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ def create_time_series(
check if time series files already exist
- overwrite_ts: list, boolean
check if existing time series files will bew overwritten
- start_years: list, str or int
- start_years: list of ints
first year for desired range of years
- end_years: list, str or int
- end_years: list of ints
last year for desired range of years
- height_dim: str
name of height dimension for given component, eg 'lev'
Expand Down
24 changes: 23 additions & 1 deletion helper_scripts/generate_cupid_config_for_cesm_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ def _parse_args():
help="CESM case directory",
)

# Command line argument location of CESM case directory
parser.add_argument(
"--adf-output-root",
action="store",
dest="adf_output_root",
default=None,
help="Directory where ADF will be run (None => case root)",
)

parser.add_argument(
"--cupid-baseline-case",
action="store",
Expand Down Expand Up @@ -104,6 +113,7 @@ def generate_cupid_config(
cupid_end_year,
cupid_base_start_year,
cupid_base_end_year,
adf_output_root=None,
):
"""
Generate a CUPiD `config.yml` file based on information from a CESM case and
Expand Down Expand Up @@ -165,6 +175,10 @@ def generate_cupid_config(
sys.path.append(os.path.join(cesm_root, "cime"))
from CIME.case import Case

# Is adf_output_root provided?
if adf_output_root is None:
adf_output_root = case_root

# Is cupid_example a valid value?
cupid_root = os.path.join(cesm_root, "tools", "CUPiD")
cupid_examples = os.path.join(cupid_root, "examples")
Expand Down Expand Up @@ -198,6 +212,14 @@ def generate_cupid_config(
"CUPiD",
"nblibrary",
)
if type(cupid_start_year) == str:
cupid_start_year = int(cupid_start_year)
if type(cupid_end_year) == str:
cupid_end_year = int(cupid_end_year)
if type(cupid_base_start_year) == str:
cupid_base_start_year = int(cupid_base_start_year)
if type(cupid_base_end_year) == str:
cupid_base_end_year = int(cupid_base_end_year)
my_dict["global_params"]["case_name"] = case
my_dict["global_params"]["start_date"] = cupid_start_year
my_dict["global_params"]["end_date"] = cupid_end_year
Expand All @@ -219,7 +241,7 @@ def generate_cupid_config(
if "link_to_ADF" in my_dict["compute_notebooks"].get("atm", {}):
my_dict["compute_notebooks"]["atm"]["link_to_ADF"]["parameter_groups"]["none"][
"adf_root"
] = os.path.join(case_root, "ADF_output")
] = os.path.join(adf_output_root, "ADF_output")

if "Greenland_SMB_visual_compare_obs" in my_dict["compute_notebooks"].get(
"glc",
Expand Down

0 comments on commit 8f06074

Please sign in to comment.