Skip to content

Commit

Permalink
Merge pull request NCAR#324 from bitterbark/mdtf_fix_freq
Browse files Browse the repository at this point in the history
Add capability for ADF to run MDTF with hourly data
  • Loading branch information
justin-richling authored Aug 22, 2024
2 parents ba61cd9 + 2ff7904 commit 7329c4d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
16 changes: 10 additions & 6 deletions lib/adf_diag.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ def call_ncrcat(cmd):

# End def

print("\n Generating CAM time series files...")

# Check if baseline time-series files are being created:
if baseline:
Expand Down Expand Up @@ -368,6 +367,7 @@ def call_ncrcat(cmd):
hist_str_list = self.hist_string["test_hist_str"]

# Notify user that script has started:
print(f"\n Writing time series files to {ts_dir}")

# End if

Expand Down Expand Up @@ -1329,8 +1329,11 @@ def move_tsfiles_for_mdtf(self, verbose):
# Going to need a dict to translate.
# Use cesm_freq_strings = freq_string_options.keys
# and then freq = freq_string_option(freq_string_found)
freq_string_options = ["month", "day", "6hr", "3hr", "1hr"]
freq_string_cesm = ["month", "day", "hour_6", "hour_3", "hour_1"] #keys
freq_string_options = ["month", "day", "6hr", "3hr", "1hr"] #values
freq_string_dict = dict(zip(freq_string_cesm,freq_string_options)) #make dict


hist_str_list = self.get_cam_info("hist_str")
case_names = self.get_cam_info("cam_case_name", required=True)
var_list = self.diag_var_list
Expand Down Expand Up @@ -1385,7 +1388,7 @@ def move_tsfiles_for_mdtf(self, verbose):
continue

found_strings = [
word for word in freq_string_options if word in dataset_freq
word for word in freq_string_cesm if word in dataset_freq
]
if len(found_strings) == 1:
if verbose > 2:
Expand All @@ -1400,13 +1403,14 @@ def move_tsfiles_for_mdtf(self, verbose):
else:
if verbose > 0:
print(
f"WARNING: None of the frequency options {freq_string_options} are present in the time_period_freq attribute {dataset_freq}"
f"WARNING: None of the frequency options {freq_string_cesm} are present in the time_period_freq attribute {dataset_freq}"
)
print(f"Skipping {adf_file}")
freq = "frequency_missing"
continue
freq = found_strings[0]

freq = freq_string_dict.get(found_strings[0])
print(f"Translated {found_strings[0]} to {freq}")

#
# Destination file is MDTF directory and name structure
#
Expand Down
3 changes: 2 additions & 1 deletion lib/adf_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ def __init__(self, config_file, debug=False):

#Grab case time series file location
input_ts_loc = Path(input_ts_locs[case_idx])
print(f"Checking existing time-series files in {input_ts_loc}")

#Get years from pre-made timeseries file(s)
found_syear, found_eyear = self.get_climo_yrs_from_ts(input_ts_loc, case_name)
Expand Down Expand Up @@ -831,4 +832,4 @@ def get_climo_yrs_from_ts(self, input_ts_loc, case_name):

#++++++++++++++++++++
#End Class definition
#++++++++++++++++++++
#++++++++++++++++++++

0 comments on commit 7329c4d

Please sign in to comment.