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

mean climate bug fix for E3SMv2.1 evaluation #1068

Merged
merged 2 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
bug fix
  • Loading branch information
lee1043 committed Mar 10, 2024
commit 19ad29d6fc1e252ee526a6fa9fb3fd5d3d59e456
4 changes: 4 additions & 0 deletions pcmdi_metrics/mean_climate/lib/compute_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ def compute_metrics(Var, dm, do, debug=False, time_dim_sync=False):

metrics_dictionary = OrderedDict()

# QC for bounds
dm = dm.bounds.add_missing_bounds()
do = do.bounds.add_missing_bounds()

if var in ["hus"]:
sig_digits = ".5f"
else:
Expand Down
19 changes: 15 additions & 4 deletions pcmdi_metrics/mean_climate/lib/load_and_regrid.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import xcdat as xc

from pcmdi_metrics.io import xcdat_open
from pcmdi_metrics.io import xcdat_open, get_latitude, get_longitude


def load_and_regrid(
Expand Down Expand Up @@ -40,9 +40,12 @@ def load_and_regrid(
# SET CONDITIONAL ON INPUT VARIABLE
if varname == "pr":
print("Adjust units for pr")
if ds[varname_in_file].units == "kg m-2 s-1":
ds[varname_in_file] = ds[varname_in_file] * 86400
print("pr units adjusted to [mm d-1] from [kg m-2 s-1] by 86400 multiplied")
if "units" in ds[varname_in_file].attrs:
if ds[varname_in_file].units == "kg m-2 s-1":
ds[varname_in_file] = ds[varname_in_file] * 86400
print("pr units adjusted to [mm d-1] from [kg m-2 s-1] by 86400 multiplied")
else:
ds[varname_in_file] = ds[varname_in_file] * 86400 # Assumed as kg m-2 s-1

"""
# calendar quality check
Expand Down Expand Up @@ -118,6 +121,14 @@ def load_and_regrid(
print("ERROR: load and regrid can not complete")
return

# axis
lat = get_latitude(ds)
lon = get_longitude(ds)
if "axis" not in lat.attrs:
ds[lat.name].attrs["axis"] = "Y"
if "axis" not in lon.attrs:
ds[lon.name].attrs["axis"] = "X"

# regrid
if regrid_tool == "regrid2":
ds_regridded = ds.regridder.horizontal(
Expand Down
3 changes: 2 additions & 1 deletion pcmdi_metrics/mean_climate/mean_climate_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@
ds_test_dict[region],
ds_ref_dict[region],
debug=debug,
time_dim_sync=True,
)
except Exception:
result_dict["RESULTS"][model][ref][run][
Expand All @@ -407,7 +408,7 @@
ds_test_dict[region],
ds_ref_dict[region],
debug=debug,
time_dim_sync=True,
time_dim_sync=False,
)

# write individual JSON
Expand Down
Loading