From c9c89a80b5c0706c74b4f7dafa10fe0b8e5cee1e Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Wed, 1 Nov 2023 15:27:03 -0600 Subject: [PATCH 1/4] Correct a comment. --- python/ctsm/crop_calendars/generate_gdds_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/ctsm/crop_calendars/generate_gdds_functions.py b/python/ctsm/crop_calendars/generate_gdds_functions.py index cb05f1920d..b677423173 100644 --- a/python/ctsm/crop_calendars/generate_gdds_functions.py +++ b/python/ctsm/crop_calendars/generate_gdds_functions.py @@ -217,7 +217,7 @@ def import_and_process_1yr( else: chunks = None - # Get h2 file (list) + # Get h1 file (list) h1_pattern = os.path.join(indir, "*h1.*.nc") h1_filelist = glob.glob(h1_pattern) if not h1_filelist: From d0592208e9cdd9579a0ace44b994fcf77dec1c33 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Wed, 1 Nov 2023 15:35:39 -0600 Subject: [PATCH 2/4] Print error()s to console, not just log file. --- python/ctsm/crop_calendars/generate_gdds_functions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/ctsm/crop_calendars/generate_gdds_functions.py b/python/ctsm/crop_calendars/generate_gdds_functions.py index b677423173..e741b59bb7 100644 --- a/python/ctsm/crop_calendars/generate_gdds_functions.py +++ b/python/ctsm/crop_calendars/generate_gdds_functions.py @@ -45,6 +45,7 @@ def log(logger, string): def error(logger, string): + print(string) logger.error(string) raise RuntimeError(string) From b311d1d35b34eb05ad12e9276832404ca64f8562 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Wed, 1 Nov 2023 15:27:44 -0600 Subject: [PATCH 3/4] Rearrange search for h2 files in import_and_process_1yr(). --- .../ctsm/crop_calendars/generate_gdds_functions.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/python/ctsm/crop_calendars/generate_gdds_functions.py b/python/ctsm/crop_calendars/generate_gdds_functions.py index e741b59bb7..74207c6e2c 100644 --- a/python/ctsm/crop_calendars/generate_gdds_functions.py +++ b/python/ctsm/crop_calendars/generate_gdds_functions.py @@ -478,13 +478,14 @@ def import_and_process_1yr( log(logger, f" Importing accumulated GDDs...") clm_gdd_var = "GDDACCUM" myVars = [clm_gdd_var, "GDDHARV"] - pattern = os.path.join(indir, f"*h2.{thisYear-1}-01-01*.nc") - h2_files = glob.glob(pattern) - if not h2_files: - pattern = os.path.join(indir, f"*h2.{thisYear-1}-01-01*.nc.base") + patterns = [f"*h2.{thisYear-1}-01-01*.nc", f"*h2.{thisYear-1}-01-01*.nc.base"] + for p in patterns: + pattern = os.path.join(indir, p) h2_files = glob.glob(pattern) - if not h2_files: - error(logger, f"No files found matching pattern '*h2.{thisYear-1}-01-01*.nc(.base)'") + if h2_files: + break + if not h2_files: + error(logger, f"No files found matching patterns: {patterns}") h2_ds = utils.import_ds( h2_files, myVars=myVars, From fa843e5ee095431bd5faf1930be8c764fb392f8e Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Wed, 1 Nov 2023 15:36:15 -0600 Subject: [PATCH 4/4] Fix h2 file patterns in import_and_process_1yr(). --- python/ctsm/crop_calendars/generate_gdds_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/ctsm/crop_calendars/generate_gdds_functions.py b/python/ctsm/crop_calendars/generate_gdds_functions.py index 74207c6e2c..bc197cd429 100644 --- a/python/ctsm/crop_calendars/generate_gdds_functions.py +++ b/python/ctsm/crop_calendars/generate_gdds_functions.py @@ -478,7 +478,7 @@ def import_and_process_1yr( log(logger, f" Importing accumulated GDDs...") clm_gdd_var = "GDDACCUM" myVars = [clm_gdd_var, "GDDHARV"] - patterns = [f"*h2.{thisYear-1}-01-01*.nc", f"*h2.{thisYear-1}-01-01*.nc.base"] + patterns = [f"*h2.{thisYear-1}-01*.nc", f"*h2.{thisYear-1}-01*.nc.base"] for p in patterns: pattern = os.path.join(indir, p) h2_files = glob.glob(pattern)