Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
523 changes: 523 additions & 0 deletions config_noresm_default.yaml

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions env/conda_environment_nird.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: adf_v1.0.0
channels:
- conda-forge
- defaults
dependencies:
- pyyaml=6.0.2
- scipy=1.12.0
- cartopy=0.23.0
- netcdf4=1.6.5
- xarray=2024.1.1
- uxarray=2025.03.0
- matplotlib=3.9.4
- pandas=2.2.0
- pint=0.23
- xskillscore=0.0.24
- geocat-comp=2024.04.0
- python=3.12
- xesmf>=0.8.8
prefix: /nird/datalake/NS16000B/ADF-env/adf_v1.0.0

24 changes: 20 additions & 4 deletions lib/adf_diag.py
Original file line number Diff line number Diff line change
Expand Up @@ -1159,11 +1159,25 @@ def derive_variables(self, res=None, hist_str=None, vars_to_derive=None, ts_dir=
whether to overwrite the file (true) or exit with a warning message.

"""

start_years = self.climo_yrs["syears"]
start_years = str(start_years[0]).zfill(4)
end_years = self.climo_yrs["eyears"]
end_years = str(end_years[0]).zfill(4)
date_range_string_case = f"{start_years}01-{end_years}12"
# Loop through derived variables
for var in vars_to_derive:
print(f"\t - deriving time series for {var}")

filename = f'{self.get_cam_info("cam_case_name")[0]}.{hist_str}*.{var}.{date_range_string_case}.nc'
if glob.glob(os.path.join(ts_dir, filename)):
expname = f'{self.get_baseline_info("cam_case_name")}'
start_years = self.climo_yrs["syear_baseline"]
start_years = str(start_years).zfill(4)
end_years = self.climo_yrs["eyear_baseline"]
end_years = str(end_years).zfill(4)
date_range_string = f"{start_years}01-{end_years}12"
else:
expname = f'{self.get_cam_info("cam_case_name")[0]}'
date_range_string = date_range_string_case
# Grab list of constituents for this variable
constit_list = constit_dict[var]

Expand All @@ -1172,9 +1186,9 @@ def derive_variables(self, res=None, hist_str=None, vars_to_derive=None, ts_dir=
for constit in constit_list:
# Check if the constituent file is present, if so add it to list
if hist_str:
const_glob_str = f"*{hist_str}*.{constit}.*.nc"
const_glob_str = f"{expname}.{hist_str}*.{constit}.{date_range_string}.nc"
else:
const_glob_str = f"*.{constit}.*.nc"
const_glob_str = f"{expname}.*.{constit}.{date_range_string}.nc"
# end if
if glob.glob(os.path.join(ts_dir, const_glob_str)):
constit_files.append(glob.glob(os.path.join(ts_dir, const_glob_str ))[0])
Expand Down Expand Up @@ -1275,6 +1289,8 @@ def derive_variables(self, res=None, hist_str=None, vars_to_derive=None, ts_dir=
# Drop all constituents from final saved dataset
# These are not necessary because they have their own time series files
ds_final = ds.drop_vars(constit_list)
if "time_bnds" in list(ds_final.keys()):
ds_final = ds_final.drop_vars("time_bnds")
# Copy attributes from constituent file to derived variable
ds_final[var].attrs = attrs
ds_final.to_netcdf(derived_file, unlimited_dims='time', mode='w')
Expand Down
7 changes: 4 additions & 3 deletions lib/adf_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ def __init__(self, config_file, debug=False):

#Grab first possible hist string, just looking for years of run
base_hist_str = baseline_hist_str[0]
print(f"AVAILABLE BASE_HIST_STR: {base_hist_str}")
starting_location = Path(baseline_hist_locs)
print(f"\tChecking history files in '{starting_location}'")
file_list = sorted(starting_location.glob("*" + base_hist_str + ".*.nc"))
Expand Down Expand Up @@ -294,7 +295,7 @@ def __init__(self, config_file, debug=False):
raise AdfError(msg)

base_climo_yrs = sorted(np.unique(base_climo_yrs))

print(f"AVAILABLE YEARS IN BASE RUN: {base_climo_yrs}")
base_found_syr = int(base_climo_yrs[0])
base_found_eyr = int(base_climo_yrs[-1])

Expand Down Expand Up @@ -488,7 +489,7 @@ def __init__(self, config_file, debug=False):
msg = f"\t ERROR: No climo years found in {cam_hist_locs[case_idx]}, "
raise AdfError(msg)
case_climo_yrs = sorted(np.unique(case_climo_yrs))

print(f'Case climo years: {case_climo_yrs}')
case_found_syr = int(case_climo_yrs[0])
case_found_eyr = int(case_climo_yrs[-1])

Expand Down Expand Up @@ -895,4 +896,4 @@ def get_climo_yrs_from_ts(self, input_ts_loc, case_name):

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