Skip to content

Commit

Permalink
Fix cosp_bin_sum() condition for subsetting
Browse files Browse the repository at this point in the history
- Needed to sort the `prs_range` and `tau_range` in ascending order before creating `cond` to pass to `.where()`, otherwise if out of order then there is a possibility that the condition will fail entirely
  • Loading branch information
tomvothecoder committed Feb 15, 2024
1 parent ecacd2e commit 546c76e
Show file tree
Hide file tree
Showing 7 changed files with 435 additions and 672 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@
" raise IOError(\"No files found at DEV_PATH and/or MAIN_PATH.\")\n",
"\n",
"if len(DEV_GLOB) != len(MAIN_GLOB):\n",
" #raise IOError(f\"Number of files do not match at DEV_PATH ({len(DEV_GLOB)}) and MAIN_PATH {len(MAIN_GLOB)}.\")\n",
" print(f\"Number of files do not match at DEV_PATH ({len(DEV_GLOB)}) and MAIN_PATH {len(MAIN_GLOB)}.\")"
" # raise IOError(f\"Number of files do not match at DEV_PATH ({len(DEV_GLOB)}) and MAIN_PATH {len(MAIN_GLOB)}.\")\n",
" print(\n",
" f\"Number of files do not match at DEV_PATH ({len(DEV_GLOB)}) and MAIN_PATH {len(MAIN_GLOB)}.\"\n",
" )"
]
},
{
Expand Down Expand Up @@ -1378,20 +1380,20 @@
"rtol = 1e-5\n",
"\n",
"for filepath_dev in DEV_GLOB:\n",
" if ('test.nc' in filepath_dev or 'ref.nc' in filepath_dev):\n",
" if \"test.nc\" in filepath_dev or \"ref.nc\" in filepath_dev:\n",
" filepath_main = filepath_dev.replace(SET_DIR, \"main\")\n",
" print(\"Comparing:\")\n",
" print(filepath_dev, \"\\n\", filepath_main)\n",
" ds1 = xr.open_dataset(filepath_dev)\n",
" ds2 = xr.open_dataset(filepath_main)\n",
"\n",
" var_key = filepath_dev.split(\"-\")[-3] \n",
" var_key = filepath_dev.split(\"-\")[-3]\n",
" # for 3d vars such as T-200\n",
" var_key.isdigit()\n",
" if var_key.isdigit(): \n",
" var_key = filepath_dev.split(\"-\")[-4] \n",
" \n",
" print('var_key', var_key)\n",
" if var_key.isdigit():\n",
" var_key = filepath_dev.split(\"-\")[-4]\n",
"\n",
" print(\"var_key\", var_key)\n",
" try:\n",
" np.testing.assert_allclose(\n",
" ds1[var_key].values,\n",
Expand All @@ -1402,9 +1404,7 @@
" except AssertionError as e:\n",
" print(e)\n",
" else:\n",
" print(f\" * All close and within relative tolerance ({rtol})\")\n",
" \n",
" "
" print(f\" * All close and within relative tolerance ({rtol})\")"
]
},
{
Expand All @@ -1413,7 +1413,8 @@
"source": [
"### Results\n",
"\n",
"- The relative tolerance of all files are 1e-05, which means things should be good to go.\n"
"- Issues with variable outputs not being produced\n",
"- Mismatching `nan` values and large diffs\n"
]
}
],
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,5 @@
SET_DIR = "debug-654-zonal_mean_xy"
# CFG_PATH = "auxiliary_tools/cdat_regression_testing/654-zonal_mean_xy/debug_zonal_mean_xy_model_vs_obs.cfg"

# run_set(SET_NAME, SET_DIR, CFG_PATH)
run_set(SET_NAME, SET_DIR)


"""
2024-02-15 09:47:22,274 [INFO]: zonal_mean_xy_driver.py(run_diag:68) >> Variable: FLUT
2024-02-15 09:47:22,644 [ERROR]: core_parameter.py(_run_diag:341) >> Error in e3sm_diags.driver.zonal_mean_xy_driver
Traceback (most recent call last):
File "/global/u2/v/vo13/E3SM-Project/e3sm_diags/e3sm_diags/parameter/core_parameter.py", line 338, in _run_diag
single_result = module.run_diag(self)
File "/global/u2/v/vo13/E3SM-Project/e3sm_diags/e3sm_diags/driver/zonal_mean_xy_driver.py", line 72, in run_diag
parameter._set_name_yrs_attrs(test_ds, ref_ds, season)
File "/global/u2/v/vo13/E3SM-Project/e3sm_diags/e3sm_diags/parameter/core_parameter.py", line 293, in _set_name_yrs_attrs
self.ref_name_yrs = ds_ref.get_name_yrs_attr(season)
File "/global/u2/v/vo13/E3SM-Project/e3sm_diags/e3sm_diags/driver/utils/dataset_xr.py", line 166, in get_name_yrs_attr
diag_name = self._get_ref_name()
File "/global/u2/v/vo13/E3SM-Project/e3sm_diags/e3sm_diags/driver/utils/dataset_xr.py", line 228, in _get_ref_name
raise AttributeError(
AttributeError: Either `parameter.short_ref_name`, `parameter.reference_name`, or `parameter.ref_name` must be set to get the name and years attribute for reference datasets.
"""
# run_set(SET_NAME, SET_DIR, CFG_PATH, multiprocessing=False)
Loading

0 comments on commit 546c76e

Please sign in to comment.