Skip to content

Commit

Permalink
Clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
forsyth2 committed May 23, 2024
1 parent 0c233d7 commit 10451af
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 113 deletions.
4 changes: 2 additions & 2 deletions tests/integration/generated/test_bundles_chrysalis.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ input = "/lcrc/group/e3sm/ac.forsyth2/E3SMv2/v2.LR.historical_0201"
input_subdir = archive/atm/hist
mapping_file = "map_ne30pg2_to_cmip6_180x360_aave.20200201.nc"
# To run this test, edit `output` and `www` in this file, along with `actual_images_dir` in test_bundles.py
output = "/lcrc/group/e3sm/ac.forsyth2/zppy_test_bundles_output/test-346/v2.LR.historical_0201"
output = "/lcrc/group/e3sm/ac.forsyth2/zppy_test_bundles_output/unique_id/v2.LR.historical_0201"
partition = "compute"
qos = "regular"
walltime = "07:00:00"
www = "/lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_test_bundles_www/test-346"
www = "/lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_test_bundles_www/unique_id"

[bundle]

Expand Down
8 changes: 4 additions & 4 deletions tests/integration/generated/test_complete_run_chrysalis.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ input = "/lcrc/group/e3sm/ac.forsyth2//E3SMv2/v2.LR.historical_0201"
input_subdir = archive/atm/hist
mapping_file = "map_ne30pg2_to_cmip6_180x360_aave.20200201.nc"
# To run this test, edit `output` and `www` in this file, along with `actual_images_dir` in test_complete_run.py
output = "/lcrc/group/e3sm/ac.forsyth2/zppy_test_complete_run_output/test-346/v2.LR.historical_0201"
output = "/lcrc/group/e3sm/ac.forsyth2/zppy_test_complete_run_output/unique_id/v2.LR.historical_0201"
partition = "debug"
qos = "regular"
www = "/lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_test_complete_run_www/test-346"
www = "/lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_test_complete_run_www/unique_id"

[climo]
active = True
Expand Down Expand Up @@ -134,7 +134,7 @@ years = "1850:1854:2", "1850:1854:4",
ref_name = "v2.LR.historical_0201"
ref_start_yr = 1850
ref_years = "1850-1851",
reference_data_path = "/lcrc/group/e3sm/ac.forsyth2/zppy_test_complete_run_output/test-346/v2.LR.historical_0201/post/atm/180x360_aave/clim"
reference_data_path = "/lcrc/group/e3sm/ac.forsyth2/zppy_test_complete_run_output/unique_id/v2.LR.historical_0201/post/atm/180x360_aave/clim"
run_type = "model_vs_model"
short_ref_name = "v2.LR.historical_0201"
swap_test_ref = False
Expand All @@ -155,7 +155,7 @@ years = "1850:1854:2", "1850:1854:4",
ref_name = "v2.LR.historical_0201"
ref_start_yr = 1850
ref_years = "1850-1851",
reference_data_path = "/lcrc/group/e3sm/ac.forsyth2/zppy_test_complete_run_output/test-346/v2.LR.historical_0201/post/lnd/180x360_aave/clim"
reference_data_path = "/lcrc/group/e3sm/ac.forsyth2/zppy_test_complete_run_output/unique_id/v2.LR.historical_0201/post/lnd/180x360_aave/clim"
run_type = "model_vs_model"
sets = "lat_lon_land",
short_ref_name = "same simulation"
Expand Down
53 changes: 23 additions & 30 deletions tests/integration/generated/test_debug_chrysalis.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,46 @@ environment_commands = ""
input = "/lcrc/group/e3sm/ac.forsyth2//E3SMv2/v2.LR.historical_0201"
input_subdir = archive/atm/hist
mapping_file = "map_ne30pg2_to_cmip6_180x360_aave.20200201.nc"
output = "/lcrc/group/e3sm/ac.forsyth2/zppy_test_debug_output/test-346/v2.LR.historical_0201"
# To run this test, edit `output` and `www` in this file, along with `actual_images_dir` in test_complete_run.py
output = "/lcrc/group/e3sm/ac.forsyth2/zppy_test_debug_output/unique_id/v2.LR.historical_0201"
partition = "debug"
qos = "regular"
www = "/lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_test_debug_www/test-346"
www = "/lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_debug_www/unique_id"

[ts]
active = True
e3sm_to_cmip_environment_commands = ""
walltime = "00:30:00"
years = "1850:1854:2",

[[ atm_monthly_glb ]]
# Note global average won't work for 3D variables.
[[ atm_monthly_180x360_aave ]]
frequency = "monthly"
input_files = "eam.h0"
input_subdir = "archive/atm/hist"
mapping_file = "glb"
years = "1850:1860:5",
ts_fmt = "cmip"

[[ lnd_monthly_glb ]]
[[ atm_daily_180x360_aave ]]
frequency = "daily"
input_files = "eam.h1"
input_subdir = "archive/atm/hist"
vars = "PRECT"

[[ land_monthly ]]
e3sm_to_cmip_environment_commands = ""
extra_vars = "landfrac"
frequency = "monthly"
input_files = "elm.h0"
input_subdir = "archive/lnd/hist"
mapping_file = "glb"
vars = "LAISHA,LAISUN"
years = "1850:1860:5",
#vars = "FSH,RH2M"
ts_fmt = "cmip"

[mpas_analysis]
[ilamb]
active = True
anomalyRefYear = 1850
climo_years ="1850-1854", "1855-1860",
enso_years = "1850-1854", "1855-1860",
mesh = "EC30to60E2r2"
parallelTaskCount = 6
grid = '180x360_aave'
nodes = 8
partition = "compute"
qos = "regular"
ts_years = "1850-1854", "1850-1860",
walltime = "00:30:00"
short_name = 'v2.LR.historical_0201'
ts_num_years = 2
years = "1850:1854:2",

[global_time_series]
active = True
climo_years ="1850-1854", "1855-1860",
experiment_name = "v2.LR.historical_0201"
figstr = "v2_historical_0201"
moc_file=mocTimeSeries_1850-1860.nc
plots_lnd = "LAISHA,LAISUN"
ts_num_years = 5
ts_years = "1850-1854", "1850-1860",
walltime = "00:30:00"
years = "1850-1860",
[[ land_monthly ]]
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
rm -rf /lcrc/group/e3sm/public_html/zppy_test_resources/expected_bundles
# Your output will now become the new expectation.
# Copy output so you don't have to rerun zppy to generate the output.
cp -r /lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_test_bundles_www/test-346/v2.LR.historical_0201 /lcrc/group/e3sm/public_html/zppy_test_resources/expected_bundles
cp -r /lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_test_bundles_www/unique_id/v2.LR.historical_0201 /lcrc/group/e3sm/public_html/zppy_test_resources/expected_bundles
mkdir -p /lcrc/group/e3sm/public_html/zppy_test_resources/expected_bundles/bundle_files
cp -r /lcrc/group/e3sm/ac.forsyth2/zppy_test_bundles_output/test-346/v2.LR.historical_0201/post/scripts/bundle*.bash /lcrc/group/e3sm/public_html/zppy_test_resources/expected_bundles/bundle_files
cp -r /lcrc/group/e3sm/ac.forsyth2/zppy_test_bundles_output/unique_id/v2.LR.historical_0201/post/scripts/bundle*.bash /lcrc/group/e3sm/public_html/zppy_test_resources/expected_bundles/bundle_files
zppy_top_level=$(pwd)
cd /lcrc/group/e3sm/public_html/zppy_test_resources/expected_bundles
# Remove the image check failures, so they don't end up in the expected files.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
rm -rf /lcrc/group/e3sm/public_html/zppy_test_resources/expected_complete_run
# Your output will now become the new expectation.
# Copy output so you don't have to rerun zppy to generate the output.
cp -r /lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_test_complete_run_www/test-346/v2.LR.historical_0201 /lcrc/group/e3sm/public_html/zppy_test_resources/expected_complete_run
cp -r /lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_test_complete_run_www/unique_id/v2.LR.historical_0201 /lcrc/group/e3sm/public_html/zppy_test_resources/expected_complete_run
zppy_top_level=$(pwd)
cd /lcrc/group/e3sm/public_html/zppy_test_resources/expected_complete_run
# Remove the image check failures, so they don't end up in the expected files.
Expand Down
51 changes: 22 additions & 29 deletions tests/integration/template_debug.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,46 @@ environment_commands = "#expand environment_commands#"
input = "#expand user_input#/E3SMv2/v2.LR.historical_0201"
input_subdir = archive/atm/hist
mapping_file = "map_ne30pg2_to_cmip6_180x360_aave.20200201.nc"
# To run this test, edit `output` and `www` in this file, along with `actual_images_dir` in test_complete_run.py
output = "#expand user_output#zppy_test_debug_output/#expand unique_id#/v2.LR.historical_0201"
partition = "#expand partition_short#"
qos = "#expand qos_short#"
www = "#expand user_www#zppy_test_debug_www/#expand unique_id#"
www = "#expand user_www#zppy_debug_www/#expand unique_id#"

[ts]
active = True
e3sm_to_cmip_environment_commands = "#expand e3sm_to_cmip_environment_commands#"
walltime = "00:30:00"
years = "1850:1854:2",

[[ atm_monthly_glb ]]
# Note global average won't work for 3D variables.
[[ atm_monthly_180x360_aave ]]
frequency = "monthly"
input_files = "eam.h0"
input_subdir = "archive/atm/hist"
mapping_file = "glb"
years = "1850:1860:5",
ts_fmt = "cmip"

[[ lnd_monthly_glb ]]
[[ atm_daily_180x360_aave ]]
frequency = "daily"
input_files = "eam.h1"
input_subdir = "archive/atm/hist"
vars = "PRECT"

[[ land_monthly ]]
e3sm_to_cmip_environment_commands = "#expand e3sm_to_cmip_environment_commands#"
extra_vars = "landfrac"
frequency = "monthly"
input_files = "elm.h0"
input_subdir = "archive/lnd/hist"
mapping_file = "glb"
vars = "LAISHA,LAISUN"
years = "1850:1860:5",
#vars = "FSH,RH2M"
ts_fmt = "cmip"

[mpas_analysis]
[ilamb]
active = True
anomalyRefYear = 1850
climo_years ="1850-1854", "1855-1860",
enso_years = "1850-1854", "1855-1860",
mesh = "EC30to60E2r2"
parallelTaskCount = 6
grid = '180x360_aave'
nodes = 8
partition = "#expand partition_long#"
qos = "#expand qos_long#"
ts_years = "1850-1854", "1850-1860",
walltime = "#expand mpas_analysis_walltime#"
short_name = 'v2.LR.historical_0201'
ts_num_years = 2
years = "1850:1854:2",

[global_time_series]
active = True
climo_years ="1850-1854", "1855-1860",
experiment_name = "v2.LR.historical_0201"
figstr = "v2_historical_0201"
moc_file=mocTimeSeries_1850-1860.nc
plots_lnd = "LAISHA,LAISUN"
ts_num_years = 5
ts_years = "1850-1854", "1850-1860",
walltime = "00:30:00"
years = "1850-1860",
[[ land_monthly ]]
2 changes: 1 addition & 1 deletion tests/integration/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from mache import MachineInfo
from PIL import Image, ImageChops, ImageDraw

UNIQUE_ID = "test-346"
UNIQUE_ID = "unique_id"

# Image checking ##########################################################

Expand Down
61 changes: 19 additions & 42 deletions zppy/templates/coupled_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import matplotlib.pyplot as plt
import numpy as np
import xarray
import xcdat # noqa: F401
from netCDF4 import Dataset
from readTS import TS

Expand Down Expand Up @@ -586,7 +585,7 @@ def set_var(
n = 2
else:
raise RuntimeError(f"Invalid rgn={rgn}")
v = v.isel(rgn=n) # Just use nth column
v = v.isel(rgn=n) # Just use nth region
elif rgn != "glb":
# v only has one dimension -- glb.
# Therefore it is not possible to get n or s plots.
Expand Down Expand Up @@ -749,24 +748,24 @@ def run(parameters, rgn): # noqa: C901
use_ocn = plots_ocn or (not atmosphere_only and has_original_ocn_plots)
exps: List[Dict[str, Any]] = [
{
"atmos": None
if not use_atmos
else "{}/post/atm/glb/ts/monthly/{}yr/".format(case_dir, ts_num_years),
"ice": None
if not plots_ice
else "{}/post/ice/glb/ts/monthly/{}yr/".format(case_dir, ts_num_years),
"land": None
if not plots_lnd
else "{}/post/lnd/glb/ts/monthly/{}yr/".format(case_dir, ts_num_years),
"ocean": None
if not use_ocn
else "{}/post/ocn/glb/ts/monthly/{}yr/".format(case_dir, ts_num_years),
"moc": None
if not use_ocn
else "{}/post/ocn/glb/ts/monthly/{}yr/".format(case_dir, ts_num_years),
"vol": None
if not use_ocn
else "{}/post/ocn/glb/ts/monthly/{}yr/".format(case_dir, ts_num_years),
"atmos": f"{case_dir}/post/atm/glb/ts/monthly/{ts_num_years}yr/"
if use_atmos
else None,
"ice": f"{case_dir}/post/ice/glb/ts/monthly/{ts_num_years}yr/"
if plots_ice
else None,
"land": f"{case_dir}/post/lnd/glb/ts/monthly/{ts_num_years}yr/"
if plots_lnd
else None,
"ocean": f"{case_dir}/post/ocn/glb/ts/monthly/{ts_num_years}yr/"
if use_ocn
else None,
"moc": f"{case_dir}/post/ocn/glb/ts/monthly/{ts_num_years}yr/"
if use_ocn
else None,
"vol": f"{case_dir}/post/ocn/glb/ts/monthly/{ts_num_years}yr/"
if use_ocn
else None,
"name": experiment_name,
"yoffset": 0.0,
"yr": ([year1, year2],),
Expand Down Expand Up @@ -856,27 +855,5 @@ def run_by_region(parameters):
run(parameters, rgn)


def debug():
args = [
"coupled_global.py",
"/lcrc/group/e3sm/ac.forsyth2/zppy_test_debug_output/test-346/v2.LR.historical_0201",
"v2.LR.historical_0201",
"v2_historical_0201",
"1850",
"1860",
"Blue",
"5",
"net_toa_flux_restom,global_surface_air_temperature,toa_radiation,net_atm_energy_imbalance,change_ohc,max_moc,change_sea_level,net_atm_water_imbalance",
"False",
"None",
"None",
"LAISHA,LAISUN",
"None",
"glb,n,s",
]
run_by_region(args)


if __name__ == "__main__":
run_by_region(sys.argv)
# debug()
4 changes: 2 additions & 2 deletions zppy/templates/e3sm_diags.bash
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ create_links_ts()
# xml file will cover the whole period from year1 to year2
xml_name=${v}_${begin_year}01_${end_year}12.xml
export CDMS_NO_MPI=true
cdscan ${xml_name} ${v}_files.txt
cdscan -x ${xml_name} -f ${v}_files.txt
if [ $? != 0 ]; then
cd {{ scriptDir }}
echo "ERROR (${error_num})" > {{ prefix }}.status
Expand All @@ -129,7 +129,7 @@ create_links_ts_rof()
cd ${ts_rof_dir_destination}
v="RIVER_DISCHARGE_OVER_LAND_LIQ"
xml_name=${v}_${begin_year}01_${end_year}12.xml
cdscan ${xml_name} ${ts_rof_dir_source}/${v}_*.nc
cdscan -x ${xml_name} ${ts_rof_dir_source}/${v}_*.nc
if [ $? != 0 ]; then
cd {{ scriptDir }}
echo "ERROR (${error_num})" > {{ prefix }}.status
Expand Down

0 comments on commit 10451af

Please sign in to comment.