Skip to content

Commit

Permalink
Revert "Propose a general number formula for mean climate metrics out…
Browse files Browse the repository at this point in the history
…put"

This reverts commit ae9bd8b.
  • Loading branch information
lee1043 committed Sep 24, 2024
1 parent ae9bd8b commit c2ba107
Showing 1 changed file with 38 additions and 35 deletions.
73 changes: 38 additions & 35 deletions pcmdi_metrics/mean_climate/lib/compute_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ def compute_metrics(Var, dm, do, debug=False, time_dim_sync=False):
dm = dm.bounds.add_missing_bounds()
do = do.bounds.add_missing_bounds()

float_format = "{:.5e}"
if var in ["hus"]:
sig_digits = ".5f"
else:
sig_digits = ".3f"

# CALCULATE ANNUAL CYCLE SPACE-TIME RMS, CORRELATIONS and STD
print("metrics-CALCULATE ANNUAL CYCLE SPACE-TIME RMS, CORRELATIONS and STD")
Expand Down Expand Up @@ -153,23 +156,23 @@ def compute_metrics(Var, dm, do, debug=False, time_dim_sync=False):
):
metrics_dictionary[stat] = OrderedDict()

metrics_dictionary["mean-obs_xy"]["ann"] = float_format.format(meanObs_xy)
metrics_dictionary["mean_xy"]["ann"] = float_format.format(mean_xy)
metrics_dictionary["std-obs_xy"]["ann"] = float_format.format(stdObs_xy)
metrics_dictionary["std_xy"]["ann"] = float_format.format(std_xy)
metrics_dictionary["std-obs_xyt"]["ann"] = float_format.format(stdObs_xyt)
metrics_dictionary["std_xyt"]["ann"] = float_format.format(std_xyt)
metrics_dictionary["std-obs_xy_devzm"]["ann"] = float_format.format(stdObs_xy_devzm)
metrics_dictionary["std_xy_devzm"]["ann"] = float_format.format(std_xy_devzm)
metrics_dictionary["rms_xyt"]["ann"] = float_format.format(rms_xyt)
metrics_dictionary["rms_xy"]["ann"] = float_format.format(rms_xy)
metrics_dictionary["rmsc_xy"]["ann"] = float_format.format(rmsc_xy)
metrics_dictionary["cor_xy"]["ann"] = float_format.format(cor_xy)
metrics_dictionary["bias_xy"]["ann"] = float_format.format(bias_xy)
metrics_dictionary["mae_xy"]["ann"] = float_format.format(mae_xy)
metrics_dictionary["mean-obs_xy"]["ann"] = format(meanObs_xy, sig_digits)
metrics_dictionary["mean_xy"]["ann"] = format(mean_xy, sig_digits)
metrics_dictionary["std-obs_xy"]["ann"] = format(stdObs_xy, sig_digits)
metrics_dictionary["std_xy"]["ann"] = format(std_xy, sig_digits)
metrics_dictionary["std-obs_xyt"]["ann"] = format(stdObs_xyt, sig_digits)
metrics_dictionary["std_xyt"]["ann"] = format(std_xyt, sig_digits)
metrics_dictionary["std-obs_xy_devzm"]["ann"] = format(stdObs_xy_devzm, sig_digits)
metrics_dictionary["std_xy_devzm"]["ann"] = format(std_xy_devzm, sig_digits)
metrics_dictionary["rms_xyt"]["ann"] = format(rms_xyt, sig_digits)
metrics_dictionary["rms_xy"]["ann"] = format(rms_xy, sig_digits)
metrics_dictionary["rmsc_xy"]["ann"] = format(rmsc_xy, sig_digits)
metrics_dictionary["cor_xy"]["ann"] = format(cor_xy, sig_digits)
metrics_dictionary["bias_xy"]["ann"] = format(bias_xy, sig_digits)
metrics_dictionary["mae_xy"]["ann"] = format(mae_xy, sig_digits)
# ZONAL MEAN CONTRIBUTIONS
metrics_dictionary["rms_y"]["ann"] = float_format.format(rms_y)
metrics_dictionary["rms_devzm"]["ann"] = float_format.format(rms_xy_devzm)
metrics_dictionary["rms_y"]["ann"] = format(rms_y, sig_digits)
metrics_dictionary["rms_devzm"]["ann"] = format(rms_xy_devzm, sig_digits)

# CALCULATE SEASONAL MEANS
for sea in ["djf", "mam", "jja", "son"]:
Expand All @@ -191,15 +194,15 @@ def compute_metrics(Var, dm, do, debug=False, time_dim_sync=False):
meanObs_xy_sea = stats.mean_xy(do_sea, var)
mean_xy_sea = stats.mean_xy(dm_sea, var)

metrics_dictionary["bias_xy"][sea] = float_format.format(bias_sea)
metrics_dictionary["rms_xy"][sea] = float_format.format(rms_sea)
metrics_dictionary["rmsc_xy"][sea] = float_format.format(rmsc_sea)
metrics_dictionary["cor_xy"][sea] = float_format.format(cor_sea)
metrics_dictionary["mae_xy"][sea] = float_format.format(mae_sea)
metrics_dictionary["std-obs_xy"][sea] = float_format.format(stdObs_xy_sea)
metrics_dictionary["std_xy"][sea] = float_format.format(std_xy_sea)
metrics_dictionary["mean-obs_xy"][sea] = float_format.format(meanObs_xy_sea)
metrics_dictionary["mean_xy"][sea] = float_format.format(mean_xy_sea)
metrics_dictionary["bias_xy"][sea] = format(bias_sea, sig_digits)
metrics_dictionary["rms_xy"][sea] = format(rms_sea, sig_digits)
metrics_dictionary["rmsc_xy"][sea] = format(rmsc_sea, sig_digits)
metrics_dictionary["cor_xy"][sea] = format(cor_sea, sig_digits)
metrics_dictionary["mae_xy"][sea] = format(mae_sea, sig_digits)
metrics_dictionary["std-obs_xy"][sea] = format(stdObs_xy_sea, sig_digits)
metrics_dictionary["std_xy"][sea] = format(std_xy_sea, sig_digits)
metrics_dictionary["mean-obs_xy"][sea] = format(meanObs_xy_sea, sig_digits)
metrics_dictionary["mean_xy"][sea] = format(mean_xy_sea, sig_digits)

rms_mo_l = []
rmsc_mo_l = []
Expand Down Expand Up @@ -245,15 +248,15 @@ def compute_metrics(Var, dm, do, debug=False, time_dim_sync=False):
meanObs_xy_mo = stats.mean_xy(do_mo, var)
mean_xy_mo = stats.mean_xy(dm_mo, var)

rms_mo_l.append(float_format.format(rms_mo))
rmsc_mo_l.append(float_format.format(rmsc_mo))
cor_mo_l.append(float_format.format(cor_mo))
mae_mo_l.append(float_format.format(mae_mo))
bias_mo_l.append(float_format.format(bias_mo))
stdObs_xy_mo_l.append(float_format.format(stdObs_xy_mo))
std_xy_mo_l.append(float_format.format(std_xy_mo))
meanObs_xy_mo_l.append(float_format.format(meanObs_xy_mo))
mean_xy_mo_l.append(float_format.format(mean_xy_mo))
rms_mo_l.append(format(rms_mo, sig_digits))
rmsc_mo_l.append(format(rmsc_mo, sig_digits))
cor_mo_l.append(format(cor_mo, sig_digits))
mae_mo_l.append(format(mae_mo, sig_digits))
bias_mo_l.append(format(bias_mo, sig_digits))
stdObs_xy_mo_l.append(format(stdObs_xy_mo, sig_digits))
std_xy_mo_l.append(format(std_xy_mo, sig_digits))
meanObs_xy_mo_l.append(format(meanObs_xy_mo, sig_digits))
mean_xy_mo_l.append(format(mean_xy_mo, sig_digits))

metrics_dictionary["bias_xy"]["CalendarMonths"] = bias_mo_l
metrics_dictionary["rms_xy"]["CalendarMonths"] = rms_mo_l
Expand Down

0 comments on commit c2ba107

Please sign in to comment.