Skip to content

Commit

Permalink
Create manual test cases (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
forsyth2 authored Nov 26, 2024
1 parent 7d35b56 commit 87c9e54
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 66 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ __pycache__/

# Sphinx documentation
docs/_build/

# Testing
tests/integration/global_time_series/global_time_series_1985-1995_results*
97 changes: 31 additions & 66 deletions tests/integration/global_time_series/cases_global_time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,14 @@

CASE_DIR = "/lcrc/group/e3sm/ac.forsyth2/zi-test-input-data" # This is 44G.
WEB_DIR = "/lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zi-test-webdir/"
RESULTS_DIR_PREFIX = "global_time_series_1985-1995_results"

"""
[global_time_series]
active = True
environment_commands = "source /gpfs/fs1/home/ac.forsyth2/miniforge3/etc/profile.d/conda.sh; conda activate zi_dev_weekly_20241122"
experiment_name = "v3.LR.historical_0051"
figstr = "v3.LR.historical_0051"
plots_original=""
plots_atm = "TREFHT,AODDUST"
plots_lnd = "FSH,RH2M,LAISHA,LAISUN,QINTR,QOVER,QRUNOFF,QSOIL,QVEGE,QVEGT,SOILWATER_10CM,TSA,H2OSNO,TOTLITC,CWDC,SOIL1C,SOIL2C,SOIL3C,SOIL4C,WOOD_HARVESTC,TOTVEGC,NBP,GPP,AR,HR"
ts_num_years = 5
walltime = "00:30:00"
years = "1985-1995",
"""
parameters_custom: Parameters = Parameters(
{
"use_ocn": "False",
"input": "/lcrc/group/e3sm2/ac.wlin/E3SMv3/v3.LR.historical_0051",
"input_subdir": "archive/ocn/hist",
"moc_file": "mocTimeSeries_1985-1995.nc",
"moc_file": "None",
"case_dir": CASE_DIR,
"experiment_name": "v3.LR.historical_0051",
"figstr": "v3.LR.historical_0051",
Expand All @@ -39,30 +27,20 @@
"plots_ocn": "None",
"nrows": "4",
"ncols": "2",
"results_dir": "global_time_series_1985-1995_results",
"results_dir": f"{RESULTS_DIR_PREFIX}_custom",
"regions": "glb,n,s",
"start_yr": "1985",
"end_yr": "1995",
}
)

"""
[global_time_series]
active = True
environment_commands = "#expand global_time_series_environment_commands#"
experiment_name = "#expand case_name#"
figstr = "#expand case_name#"
plots_original="net_toa_flux_restom,global_surface_air_temperature,toa_radiation,net_atm_energy_imbalance,net_atm_water_imbalance"
ts_num_years = 5
walltime = "00:30:00"
years = "1985-1995",
"""

parameters_original_8_no_ocn: Parameters = Parameters(
{
"use_ocn": "False",
"input": "/lcrc/group/e3sm2/ac.wlin/E3SMv3/v3.LR.historical_0051",
"input_subdir": "archive/ocn/hist",
"moc_file": "mocTimeSeries_1985-1995.nc",
"moc_file": "None",
"case_dir": CASE_DIR,
"experiment_name": "v3.LR.historical_0051",
"figstr": "v3.LR.historical_0051",
Expand All @@ -76,26 +54,13 @@
"plots_ocn": "None",
"nrows": "4",
"ncols": "2",
"results_dir": "global_time_series_1985-1995_results",
"results_dir": f"{RESULTS_DIR_PREFIX}_original_8_no_ocn",
"regions": "glb,n,s",
"start_yr": "1985",
"end_yr": "1995",
}
)

"""
[global_time_series]
active = True
climo_years = "1985-1989", "1990-1995",
environment_commands = "#expand global_time_series_environment_commands#"
experiment_name = "#expand case_name#"
figstr = "#expand case_name#"
moc_file=mocTimeSeries_1985-1995.nc
ts_num_years = 5
ts_years = "1985-1989", "1985-1995",
walltime = "00:30:00"
years = "1985-1995",
"""
parameters_original_8: Parameters = Parameters(
{
"use_ocn": "True",
Expand All @@ -115,27 +80,13 @@
"plots_ocn": "None",
"nrows": "4",
"ncols": "2",
"results_dir": "global_time_series_1985-1995_results",
"results_dir": f"{RESULTS_DIR_PREFIX}_original_8",
"regions": "glb,n,s",
"start_yr": "1985",
"end_yr": "1995",
}
)

"""
[global_time_series]
active = True
climo_years = "1985-1989", "1990-1995",
environment_commands = "source /gpfs/fs1/home/ac.forsyth2/miniforge3/etc/profile.d/conda.sh; conda activate zi_dev_weekly_20241122"
experiment_name = "v3.LR.historical_0051"
figstr = "v3.LR.historical_0051"
moc_file=mocTimeSeries_1985-1995.nc
plots_lnd = "FSH,RH2M,LAISHA,LAISUN,QINTR,QOVER,QRUNOFF,QSOIL,QVEGE,QVEGT,SOILWATER_10CM,TSA,H2OSNO,TOTLITC,CWDC,SOIL1C,SOIL2C,SOIL3C,SOIL4C,WOOD_HARVESTC,TOTVEGC,NBP,GPP,AR,HR"
ts_num_years = 5
ts_years = "1985-1989", "1985-1995",
walltime = "00:30:00"
years = "1985-1995",
"""
parameters_comprehensive_v3: Parameters = Parameters(
{
"use_ocn": "True",
Expand All @@ -155,32 +106,46 @@
"plots_ocn": "None",
"nrows": "4",
"ncols": "2",
"results_dir": "global_time_series_1985-1995_results",
"results_dir": f"{RESULTS_DIR_PREFIX}_comprehensive_v3",
"regions": "glb,n,s",
"start_yr": "1985",
"end_yr": "1995",
}
)

if __name__ == "__main__":
print("Generating parameters")
parameters: Parameters = parameters_comprehensive_v3

# TODO: Create actual pytest cases, including image comparison checks
# (See https://github.com/E3SM-Project/zppy-interfaces/issues/5)
def generate_results(parameters: Parameters):
print(f"Generating results for {parameters.results_dir}")

# CASE_DIR is large, so we don't want to copy it every time.
# We also want to be able to reset it to the original state after running the test.
# The only modification `global_time_series` makes to CASE_DIR is add an `ocn` subdirectory.
# (It also adds a parameters.results_dir subdirectory to the current directory).
# (It also adds a parameters.results_dir subdirectory to the current directory, which we then copy to WEB_DIR).
# So, we just have to remove those
for subdir in [f"{CASE_DIR}/ocn", parameters.results_dir]:
for subdir in [
f"{CASE_DIR}/ocn",
parameters.results_dir,
f"{WEB_DIR}/{parameters.results_dir}",
]:
if os.path.exists(subdir):
print(f"Removing {subdir}")
shutil.rmtree(subdir)

print("Running main")
main(parameters)

print(f"Copying {parameters.results_dir} to {WEB_DIR}")
shutil.copytree(f"{parameters.results_dir}", WEB_DIR)
print(f"Copying {parameters.results_dir} to {WEB_DIR}/{parameters.results_dir}")
shutil.copytree(parameters.results_dir, f"{WEB_DIR}/{parameters.results_dir}")


def run_all_cases():
generate_results(parameters_custom)
generate_results(parameters_original_8_no_ocn)
generate_results(parameters_original_8)
generate_results(parameters_comprehensive_v3)


if __name__ == "__main__":
# TODO: Create actual pytest cases, including image comparison checks
# (See https://github.com/E3SM-Project/zppy-interfaces/issues/5)
run_all_cases()

0 comments on commit 87c9e54

Please sign in to comment.