Skip to content

Commit

Permalink
Merge pull request #122 from mnlevy1981/demo_key_metrics
Browse files Browse the repository at this point in the history
Some clean-up for key_metrics
  • Loading branch information
mnlevy1981 authored Sep 4, 2024
2 parents 5c2b957 + c0ab02a commit 17e745c
Show file tree
Hide file tree
Showing 6 changed files with 430 additions and 144 deletions.
61 changes: 48 additions & 13 deletions cupid/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,54 @@ def run(
for component, comp_bool in component_options.items():
if comp_bool:

# set time series output directory:
# set time series input and output directory:
# -----
if isinstance(timeseries_params["case_name"], list):
ts_input_dirs = []
for cname in timeseries_params["case_name"]:
ts_input_dirs.append(global_params["CESM_output_dir"]+"/"+cname+f"/{component}/hist/")
else:
ts_input_dirs = [
global_params["CESM_output_dir"] + "/" +
timeseries_params["case_name"] + f"/{component}/hist/",
]

if "ts_output_dir" in timeseries_params:
ts_output_dir = os.path.join(
timeseries_params["ts_output_dir"],
f"{component}", "proc", "tseries",
)
if isinstance(timeseries_params["ts_output_dir"], list):
ts_output_dirs = []
for ts_outdir in timeseries_params["ts_output_dir"]:
ts_output_dirs.append([
os.path.join(
ts_outdir,
f"{component}", "proc", "tseries",
),
])
else:
ts_output_dirs = [
os.path.join(
timeseries_params["ts_output_dir"],
f"{component}", "proc", "tseries",
),
]
else:
ts_output_dir = os.path.join(
global_params["CESM_output_dir"],
timeseries_params["case_name"],
f"{component}", "proc", "tseries",
)
if isinstance(timeseries_params["case_name"], list):
ts_output_dirs = []
for cname in timeseries_params["case_name"]:
ts_output_dirs.append(
os.path.join(
global_params["CESM_output_dir"],
cname,
f"{component}", "proc", "tseries",
),
)
else:
ts_output_dirs = [
os.path.join(
global_params["CESM_output_dir"],
timeseries_params["case_name"],
f"{component}", "proc", "tseries",
),
]
# -----

# fmt: off
Expand All @@ -132,10 +167,10 @@ def run(
component,
timeseries_params[component]["vars"],
timeseries_params[component]["derive_vars"],
[timeseries_params["case_name"]],
timeseries_params["case_name"],
timeseries_params[component]["hist_str"],
[global_params["CESM_output_dir"]+"/"+timeseries_params["case_name"]+f"/{component}/hist/"],
[ts_output_dir],
ts_input_dirs,
ts_output_dirs,
# Note that timeseries output will eventually go in
# /glade/derecho/scratch/${USER}/archive/${CASE}/${component}/proc/tseries/
timeseries_params["ts_done"],
Expand Down
5 changes: 5 additions & 0 deletions cupid/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ def create_time_series(
"""

# Don't do anything if list of requested diagnostics is empty
if not diag_var_list:
print(f"\n No time series files requested for {component}...")
return

# Notify user that script has started:
print(f"\n Generating {component} time series files...")

Expand Down
47 changes: 24 additions & 23 deletions examples/key_metrics/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,55 +42,58 @@ computation_config:
# All parameters under global_params get passed to all the notebooks

global_params:
case_name: 'b.e23_alpha17f.BLT1850.ne30_t232.092'
case_name: 'b.e30_beta02.BLT1850.ne30_t232.104'
base_case_name: 'b.e23_alpha17f.BLT1850.ne30_t232.092'
CESM_output_dir: /glade/campaign/cesm/development/cross-wg/diagnostic_framework/CESM_output_for_testing
start_date: '0001-01-01'
end_date: '0101-01-01'
lc_kwargs:
threads_per_worker: 1

timeseries:
num_procs: 8
ts_done: [False]
overwrite_ts: [False]
case_name: 'b.e23_alpha17f.BLT1850.ne30_t232.092'
ts_done: [False, False]
overwrite_ts: [False, False]
case_name: ['b.e30_beta02.BLT1850.ne30_t232.104', 'b.e23_alpha17f.BLT1850.ne30_t232.092']

atm:
vars: ['PSL']
derive_vars: []
hist_str: 'h0a'
start_years: [1]
end_years: [100]
start_years: [1,1]
end_years: [100,100]
level: 'lev'

lnd:
vars: ['ALTMAX', 'COST_NACTIVE', 'DENIT', 'EFLX_DYNBAL'] #['process_all']
vars: []
derive_vars: []
hist_str: 'h0'
start_years: [1]
end_years: [100]
start_years: [1,1]
end_years: [100,100]
level: 'lev'

ocn:
vars: ['taux', 'tauy'] # ['process_all']
vars: []
derive_vars: []
hist_str: 'h.frc'
start_years: [1]
end_years: [100]
hist_str: 'h.z'
start_years: [1,1]
end_years: [100,100]
level: 'lev'

ice:
vars: ['hi', 'hs', 'snowfrac', 'Tsfc'] #['process_all']
vars: []
derive_vars: []
hist_str: 'h'
start_years: [1]
end_years: [100]
start_years: [1,1]
end_years: [100,100]
level: 'lev'

glc:
vars: ['usurf', 'topg'] #['process_all']
vars: []
derive_vars: []
hist_str: 'initial_hist'
start_years: [1]
end_years: [100]
start_years: [1,1]
end_years: [100,100]
level: 'lev'

compute_notebooks:
Expand All @@ -111,10 +114,9 @@ compute_notebooks:
nmse_PSL:
parameter_groups:
none:
regridded_output: True
regridded_output: False # it looks like output is already on f09 grid, didn't need to regrid time-series file
base_regridded_output: True
validation_path: '/glade/campaign/cesm/development/cross-wg/diagnostic_framework/nmse_validation/fv0.9x1.25'
start_date: '0001-01-01'
end_date: '0101-01-01'

glc:
LIWG_SMB_diagnostic:
Expand All @@ -123,7 +125,6 @@ compute_notebooks:
obs_path: '/glade/u/home/gunterl/obs_diagnostic_cesm/'
obs_name: 'GrIS_MARv3.12_climo_1960_1999.nc'
climo_nyears: 40
last_year: 101

# ice:
# seaice:
Expand Down
Loading

0 comments on commit 17e745c

Please sign in to comment.