From dbee1fb20496bbafbb9b4d71ac5896f78035c16d Mon Sep 17 00:00:00 2001 From: ShixuanZhang Date: Fri, 20 Sep 2024 18:22:54 -0500 Subject: [PATCH 1/2] A potential bug fix in mean_climate_driver.py The driver contains the following code block: result_dict["Variable"] = dict() result_dict["Variable"]["id"] = varname if level is not None: result_dict["Variable"]["level"] = level * 100 # hPa to Pa that attempts to convert the specified pressure level from hPa to Pa. However, this code block conflicted with the following code block in the associated libarary model "load_and_regrid.py": if "plev" in list(ds.coords.keys()): if ds.plev.units == "Pa": level = level * 100 # hPa to Pa try: ds = ds.sel(plev=level) The plev in reanalysis such as ERA5 has a unit of Pa by default. The above two code blocks will lead to wrong level and failure of the data selection. --- pcmdi_metrics/mean_climate/mean_climate_driver.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pcmdi_metrics/mean_climate/mean_climate_driver.py b/pcmdi_metrics/mean_climate/mean_climate_driver.py index 4d094e5dc..a54672dc7 100755 --- a/pcmdi_metrics/mean_climate/mean_climate_driver.py +++ b/pcmdi_metrics/mean_climate/mean_climate_driver.py @@ -167,7 +167,9 @@ result_dict["Variable"] = dict() result_dict["Variable"]["id"] = varname if level is not None: - result_dict["Variable"]["level"] = level * 100 # hPa to Pa + result_dict["Variable"][ + "level" + ] = level # SZhang: should not "* 100" here # hPa to Pa result_dict["References"] = dict() From 0e697898206d385666ab8fc2c67afaccb4f539af Mon Sep 17 00:00:00 2001 From: ShixuanZhang Date: Fri, 20 Sep 2024 19:03:06 -0500 Subject: [PATCH 2/2] Bug fix that allows the varibility mode dtrive to identify non 4-digt year data --- .../variability_mode/lib/lib_variability_mode.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pcmdi_metrics/variability_mode/lib/lib_variability_mode.py b/pcmdi_metrics/variability_mode/lib/lib_variability_mode.py index e3c203414..8a8b14438 100644 --- a/pcmdi_metrics/variability_mode/lib/lib_variability_mode.py +++ b/pcmdi_metrics/variability_mode/lib/lib_variability_mode.py @@ -142,8 +142,8 @@ def subset_time( eyear = int(eyear) # First trimming - time1 = f"{syear}-01-01 00:00:00" - time2 = f"{eyear}-12-{eday} 23:59:59" + time1 = f"{syear:04d}-01-01 00:00:00" + time2 = f"{eyear:04d}-12-{eday:02d} 23:59:59" ds = select_subset(ds, time=(time1, time2)) # Check available time window and adjust again if needed @@ -170,8 +170,8 @@ def subset_time( # Second trimming if adjust_time_length: - time1 = f"{data_syear}-01-01 00:00:00" - time2 = f"{data_eyear}-12-{eday} 23:59:59" + time1 = f"{data_syear:04d}-01-01 00:00:00" + time2 = f"{data_eyear:04d}-12-{eday:02d} 23:59:59" ds = select_subset(ds, time=(time1, time2)) return ds