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

Feature request: Add benchmark results paths and other related info to the the config object #306

Open
1 task done
yantosca opened this issue Feb 22, 2024 · 0 comments
Open
1 task done
Assignees
Labels
category: Feature Request New feature or request topic: Benchmark Plots and Tables Issues pertaining to generating plots/tables from benchmark output

Comments

@yantosca
Copy link
Contributor

yantosca commented Feb 22, 2024

Name and Institution (Required)

Name: Bob Yantosca
Institution: Harvard + GCST

Confirm you have reviewed the following documentation

New GCPy feature or discussion

In each of the scripts run_benchmark.py, run_1yr_fullchem_benchmark.py, run_1yr_tt_benchmark.py, there is repeated code similar to this that defines the various data directories and other quantities:

# ======================================================================
# Data directories
# ======================================================================
# Diagnostics file directory paths
gcc_vs_gcc_refdir = os.path.join(
config["paths"]["main_dir"],
config["data"]["ref"]["gcc"]["dir"],
config["data"]["ref"]["gcc"]["outputs_subdir"],
)
gcc_vs_gcc_devdir = os.path.join(
config["paths"]["main_dir"],
config["data"]["dev"]["gcc"]["dir"],
config["data"]["dev"]["gcc"]["outputs_subdir"],
)
gchp_vs_gcc_refdir = os.path.join(
config["paths"]["main_dir"],
config["data"]["dev"]["gcc"]["dir"],
config["data"]["dev"]["gcc"]["outputs_subdir"],
)
gchp_vs_gcc_devdir = os.path.join(
config["paths"]["main_dir"],
config["data"]["dev"]["gchp"]["dir"],
config["data"]["dev"]["gchp"]["outputs_subdir"],
)
gchp_vs_gchp_refdir = os.path.join(
config["paths"]["main_dir"],
config["data"]["ref"]["gchp"]["dir"],
config["data"]["ref"]["gchp"]["outputs_subdir"],
)
gchp_vs_gchp_devdir = os.path.join(
config["paths"]["main_dir"],
config["data"]["dev"]["gchp"]["dir"],
config["data"]["dev"]["gchp"]["outputs_subdir"],
)
# Restart file directory paths
gcc_vs_gcc_refrstdir = os.path.join(
config["paths"]["main_dir"],
config["data"]["ref"]["gcc"]["dir"],
config["data"]["ref"]["gcc"]["restarts_subdir"]
)
gcc_vs_gcc_devrstdir = os.path.join(
config["paths"]["main_dir"],
config["data"]["dev"]["gcc"]["dir"],
config["data"]["dev"]["gcc"]["restarts_subdir"]
)
gchp_vs_gcc_refrstdir = os.path.join(
config["paths"]["main_dir"],
config["data"]["dev"]["gcc"]["dir"],
config["data"]["dev"]["gcc"]["restarts_subdir"]
)
gchp_vs_gcc_devrstdir = os.path.join(
config["paths"]["main_dir"],
config["data"]["dev"]["gchp"]["dir"],
config["data"]["dev"]["gchp"]["restarts_subdir"]
)
gchp_vs_gchp_refrstdir = os.path.join(
config["paths"]["main_dir"],
config["data"]["ref"]["gchp"]["dir"],
config["data"]["ref"]["gchp"]["restarts_subdir"]
)
gchp_vs_gchp_devrstdir = os.path.join(
config["paths"]["main_dir"],
config["data"]["dev"]["gchp"]["dir"],
config["data"]["dev"]["gchp"]["restarts_subdir"]
)
# Directories where plots & tables will be created
mainresultsdir = os.path.join(
config["paths"]["results_dir"]
)
gcc_vs_gcc_resultsdir = os.path.join(
mainresultsdir,
config["options"]["comparisons"]["gcc_vs_gcc"]["dir"]
)
gchp_vs_gcc_resultsdir = os.path.join(
mainresultsdir,
config["options"]["comparisons"]["gchp_vs_gcc"]["dir"]
)
gchp_vs_gchp_resultsdir = os.path.join(
mainresultsdir,
config["options"]["comparisons"]["gchp_vs_gchp"]["dir"]
)
diff_of_diffs_resultsdir = os.path.join(
mainresultsdir,
"GCHP_GCC_diff_of_diffs"
)
# Make copy of benchmark script in results directory
if not os.path.exists(mainresultsdir):
os.mkdir(mainresultsdir)
curfile = os.path.realpath(__file__)
dest = os.path.join(mainresultsdir, curfile.split("/")[-1])
if not os.path.exists(dest):
copyfile(curfile, dest)
# Create results directories that don't exist,
# and place a copy of this file in each results directory
results_list = [
gcc_vs_gcc_resultsdir,
gchp_vs_gchp_resultsdir,
gchp_vs_gcc_resultsdir,
diff_of_diffs_resultsdir
]
comparisons_list = [
config["options"]["comparisons"]["gcc_vs_gcc"]["run"],
config["options"]["comparisons"]["gchp_vs_gchp"]["run"],
config["options"]["comparisons"]["gchp_vs_gcc"]["run"],
config["options"]["comparisons"]["gchp_vs_gcc_diff_of_diffs"]["run"]
]
for resdir, plotting_type in zip(results_list, comparisons_list):
if plotting_type and not os.path.exists(resdir):
os.mkdir(resdir)
if resdir in results_list:
curfile = os.path.realpath(__file__)
dest = os.path.join(resdir, curfile.split("/")[-1])
if not os.path.exists(dest):
copyfile(curfile, dest)
# Tables directories
gcc_vs_gcc_tablesdir = os.path.join(
gcc_vs_gcc_resultsdir,
config["options"]["comparisons"]["gcc_vs_gcc"]["tables_subdir"],
)
gchp_vs_gcc_tablesdir = os.path.join(
gchp_vs_gcc_resultsdir,
config["options"]["comparisons"]["gchp_vs_gcc"]["tables_subdir"],
)
gchp_vs_gchp_tablesdir = os.path.join(
gchp_vs_gchp_resultsdir,
config["options"]["comparisons"]["gchp_vs_gchp"]["tables_subdir"],
)
## Budget directories
#gcc_vs_gcc_budgetdir = os.path.join(gcc_vs_gcc_resultsdir, "Budget")
#gchp_vs_gcc_budgetdir = os.path.join(gchp_vs_gcc_resultsdir, "Budget")
#gchp_vs_gchp_budgetdir = os.path.join(gchp_vs_gchp_resultsdir, "Budget")
# Models vs. observations directories
gcc_vs_gcc_models_vs_obs_dir = os.path.join(
gcc_vs_gcc_resultsdir, "ModelVsObs"
)
gchp_vs_gcc_models_vs_obs_dir = os.path.join(
gchp_vs_gcc_resultsdir, "ModelVsObs"
)
gchp_vs_gchp_models_vs_obs_dir = os.path.join(
gchp_vs_gchp_resultsdir, "ModelVsObs"
)
# ======================================================================
# Plot title strings
# ======================================================================
gcc_vs_gcc_refstr = config["data"]["ref"]["gcc"]["version"]
gcc_vs_gcc_devstr = config["data"]["dev"]["gcc"]["version"]
gchp_vs_gcc_refstr = config["data"]["dev"]["gcc"]["version"]
gchp_vs_gcc_devstr = config["data"]["dev"]["gchp"]["version"]
gchp_vs_gchp_refstr = config["data"]["ref"]["gchp"]["version"]
gchp_vs_gchp_devstr = config["data"]["dev"]["gchp"]["version"]
diff_of_diffs_refstr = bmk.diff_of_diffs_toprow_title(config, "gcc")
diff_of_diffs_devstr = bmk.diff_of_diffs_toprow_title(config, "gchp")
# ======================================================================
# Observational data files
# ======================================================================
sondes_data_file = os.path.join(
config["paths"]["obs_data"]["sondes"]["data_dir"],
config["paths"]["obs_data"]["sondes"]["data_file"],
)
sondes_site_file = os.path.join(
config["paths"]["obs_data"]["sondes"]["data_dir"],
config["paths"]["obs_data"]["sondes"]["site_file"],
)

These could be folded into the config object when the YAML configuration file is read. This would clean up the run*benchmark..py scripts quite a bit.

Also see this issue:

NOTE: "DRY" = "Don't repeat yourself"

Tagging @lizziel @msulprizio

@yantosca yantosca added category: Feature Request New feature or request topic: Benchmark Plots and Tables Issues pertaining to generating plots/tables from benchmark output labels Feb 22, 2024
@yantosca yantosca self-assigned this Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: Feature Request New feature or request topic: Benchmark Plots and Tables Issues pertaining to generating plots/tables from benchmark output
Projects
None yet
Development

No branches or pull requests

1 participant