Skip to content

Commit

Permalink
deal with history files
Browse files Browse the repository at this point in the history
  • Loading branch information
mahf708 committed Feb 7, 2025
1 parent c4a090f commit 071bce7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
35 changes: 18 additions & 17 deletions components/eamxx/cime_config/SystemTests/ksxx.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def run(name, config):
table_data = pd.DataFrame(details).T
uc_rejections = (table_data["K-S test p-val"] < args.alpha).sum()
_hdrs = [
"h0",
"h",
"K-S test stat",
"K-S test p-val",
"K-S test p-val cor",
Expand All @@ -240,17 +240,17 @@ def run(name, config):
table_data[_hdr] = table_data[_hdr].apply(col_fmt)

tables = [
el.Table("Rejected", data=table_data[table_data["h0"] == "reject"]),
el.Table("Accepted", data=table_data[table_data["h0"] == "accept"]),
el.Table("Null", data=table_data[~table_data["h0"].isin(["accept", "reject"])]),
el.Table("Rejected", data=table_data[table_data["h"] == "reject"]),
el.Table("Accepted", data=table_data[table_data["h"] == "accept"]),
el.Table("Null", data=table_data[~table_data["h"].isin(["accept", "reject"])]),
]

bib_html = bib2html(os.path.join(os.path.dirname(__file__), "ksxx.bib"))

tabs = el.Tabs(
{"Figures": img_gal, "Details": tables, "References": [el.RawHTML(bib_html)]}
)
rejects = [var for var, dat in details.items() if dat["h0"] == "reject"]
rejects = [var for var, dat in details.items() if dat["h"] == "reject"]
if args.uncorrected:
critical = args.critical
else:
Expand Down Expand Up @@ -289,8 +289,9 @@ def case_files(args):
key2 += "2"

f_sets = {
key1: e3sm.component_monthly_files(args.test_dir, args.component, args.ninst),
key2: e3sm.component_monthly_files(args.ref_dir, args.component, args.ninst),
# note in eamxx, we use the 'h' history file
key1: e3sm.component_monthly_files(args.test_dir, args.component, args.ninst, hist_name="h"),
key2: e3sm.component_monthly_files(args.ref_dir, args.component, args.ninst, hist_name="h"),
}

for key in f_sets:
Expand Down Expand Up @@ -399,25 +400,25 @@ def compute_details(annual_avgs, common_vars, args):
# Convert to a Dataframe, transposed so that the index is the variable name
detail_df = pd.DataFrame(details).T
# Create a null hypothesis rejection column for un-corrected p-values
detail_df["h0_uc"] = detail_df["K-S test p-val"] < args.alpha
detail_df["h_uc"] = detail_df["K-S test p-val"] < args.alpha

(detail_df["h0_c"], detail_df["K-S test p-val cor"]) = smm.fdrcorrection(
(detail_df["h_c"], detail_df["K-S test p-val cor"]) = smm.fdrcorrection(
detail_df["K-S test p-val"], alpha=args.alpha, method="p", is_sorted=False
)
if args.uncorrected:
_testkey = "h0_uc"
_testkey = "h_uc"
else:
_testkey = "h0_c"
_testkey = "h_c"

for var in common_vars:
details[var]["K-S test p-val cor"] = detail_df.loc[var, "K-S test p-val cor"]

if details[var]["T test stat"] is None:
details[var]["h0"] = "-"
details[var]["h"] = "-"
elif detail_df.loc[var, _testkey]:
details[var]["h0"] = "reject"
details[var]["h"] = "reject"
else:
details[var]["h0"] = "accept"
details[var]["h"] = "accept"

return details

Expand Down Expand Up @@ -467,7 +468,7 @@ def main(args):
img_file,
test_name=args.test_case,
ref_name=args.ref_case,
pf=details[var]["h0"],
pf=details[var]["h"],
combine_hist=True,
)
_desc = monthly_avgs.query(
Expand All @@ -491,9 +492,9 @@ def main(args):

img_link = Path(*Path(args.img_dir).parts[-2:], Path(img_file).name)
_img = el.Image(
var, img_desc, img_link, relative_to="", group=details[var]["h0"]
var, img_desc, img_link, relative_to="", group=details[var]["h"]
)
images[details[var]["h0"]].append(_img)
images[details[var]["h"]].append(_img)

gals = []
for group in ["reject", "accept", "-"]:
Expand Down
3 changes: 1 addition & 2 deletions components/eamxx/cime_config/SystemTests/mvkxx.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import logging

import shutil
import yaml

from shutil import copytree

Expand Down Expand Up @@ -78,7 +77,7 @@ def update_yaml_perturbation_seed(yaml_file, seed, pertout):
# replace perturbation_random_seed: 0 with perturbation_random_seed: <seed>
new_lines.append(line.replace('perturbation_random_seed: 0', f'perturbation_random_seed: {seed}'))
found_seed = True
elif line.strip().contains('dailyAVG_coarse.yaml'):
elif 'dailyAVG_coarse.yaml' in line.strip():
# replace "dailyAVG_coarse.yaml" with "dailyAVG_coarse.yaml_{seed:04d}"
new_lines.append(line.replace('dailyAVG_coarse.yaml', f'dailyAVG_coarse.yaml_{seed:04d}'))
found_output = True
Expand Down

0 comments on commit 071bce7

Please sign in to comment.