Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding mods to derive PRECT #260

Merged
merged 9 commits into from
Nov 3, 2023
10 changes: 7 additions & 3 deletions lib/adf_diag.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def call_ncrcat(cmd):
hist_str = 'cam.h0'
#End if

# get info about variables defaults
# get info about variable defaults
res = self.variable_defaults

#Loop over cases:
Expand Down Expand Up @@ -518,7 +518,7 @@ def call_ncrcat(cmd):
diag_var_list = self.diag_var_list
for var in diag_var_list:
if var not in hist_file_var_list:
vres = res[var]
vres = res.get(var, {})
if "derivable_from" in vres:
constit_list = vres['derivable_from']
for constit in constit_list:
Expand Down Expand Up @@ -946,7 +946,11 @@ def derive_variables(self,vars_to_derive=None,ts_dir=None):
if var == "PRECT":
# PRECT can be found by simply adding PRECL and PRECC
# grab file names for the PRECL and PRECC files from the case ts directory
constit_files = sorted(glob.glob(ts_dir+"/*PREC*"))
if len(glob.glob(os.path.join(ts_dir,"*PRECC*"))) and len(glob.glob(os.path.join(ts_dir,"*PRECL*"))):
constit_files=sorted(glob.glob(os.path.join(ts_dir,"*PREC*")))
else:
ermsg = "PRECC and PRECL were not both present; PRECT cannot be calculated."
raise FileNotFoundError(ermsg)
nusbaume marked this conversation as resolved.
Show resolved Hide resolved
# create new file name for PRECT
prect_file = constit_files[0].replace('PRECC','PRECT')
# append PRECC to the file containing PRECL
Expand Down
Loading