Closed forsyth2 closed 6 months ago
Using this script:
diags_set=polar
cd e3sm_diags
# https://anaconda.org/cdat/repo?sort=_name&sort_order=asc
for cdat_package in cd77 cdat cdat_compute_graph cdat_info cdat_jupyter_vcdat cdms2 cdp cdtime cdutil cibots compute_graph django-allow-cidr dv3d e3sm_nex esgf-compute-api esgf-compute-cert esgf-search ezget genutil image-compare jupyter-vcdat jupyterlab-git lats libcdms lmoments mesalib myproxyclient output_viewer selenium_testlib testsrunner thermo toolchain vcdat vcs vcs-js vcsaddons vtk vtk-cdat wk xmgrace
do
git grep -n ${cdat_package} e3sm_diags/driver/${diags_set}_driver.py > /dev/null
if [ $? == 0 ]; then
echo ""
echo "git grep -n ${cdat_package} e3sm_diags/driver/${diags_set}_driver.py"
git grep -n ${cdat_package} e3sm_diags/driver/${diags_set}_driver.py
fi
git grep -n ${cdat_package} e3sm_diags/plot/cartopy/${diags_set}_plot.py > /dev/null
if [ $? == 0 ]; then
echo ""
echo "git grep -n ${cdat_package} e3sm_diags/plot/cartopy/${diags_set}_plot.py"
git grep -n ${cdat_package} e3sm_diags/plot/cartopy/${diags_set}_plot.py
fi
done
I get:
git grep -n cdms2 e3sm_diags/driver/polar_driver.py
e3sm_diags/driver/polar_driver.py:6:import cdms2
e3sm_diags/driver/polar_driver.py:74: with cdms2.open(mask_path) as f:
e3sm_diags/driver/polar_driver.py:94: # This is cdms2 fix for bad mask, Denis' fix should fix this.
e3sm_diags/driver/polar_driver.py:98: # This is cdms2 fix for bad mask, Denis' fix should fix this.
e3sm_diags/driver/polar_driver.py:101: # This is cdms2 fix for bad mask, Denis' fix should fix this.
@chengzhuzhang @tomvothecoder Are the testing directions at https://e3sm-project.github.io/e3sm_diags/_build/html/main/dev_guide/testing.html up to date? I tried running ./tests/test.sh
on the main
branch and got:
================================================================================================== short test summary info ==================================================================================================
FAILED tests/integration/test_diags.py::TestAllSets::test_lat_lon - AssertionError: Lists differ: ['ERA-Interim-T-850-ANN-global.png'] != []
FAILED tests/integration/test_diags.py::TestAllSets::test_lat_lon_regional - AssertionError: Lists differ: ['ERA-Interim-T-850-ANN-CONUS_RRM.png'] != []
FAILED tests/integration/test_diags.py::TestAllSets::test_polar - AssertionError: Lists differ: ['ERA-Interim-T-850-ANN-polar_S.png'] != []
FAILED tests/integration/test_diags.py::TestAllSets::test_zonal_mean_2d - AssertionError: Lists differ: ['ERA-Interim-T-ANN-global.png'] != []
=================================================================================== 4 failed, 23 passed, 22 warnings in 351.33s (0:05:51) ===================================================================================
@chengzhuzhang @tomvothecoder Are the testing directions at e3sm-project.github.io/e3sm_diags/_build/html/main/dev_guide/testing.html up to date? I tried running
./tests/test.sh
on themain
branch and got:================================================================================================== short test summary info ================================================================================================== FAILED tests/integration/test_diags.py::TestAllSets::test_lat_lon - AssertionError: Lists differ: ['ERA-Interim-T-850-ANN-global.png'] != [] FAILED tests/integration/test_diags.py::TestAllSets::test_lat_lon_regional - AssertionError: Lists differ: ['ERA-Interim-T-850-ANN-CONUS_RRM.png'] != [] FAILED tests/integration/test_diags.py::TestAllSets::test_polar - AssertionError: Lists differ: ['ERA-Interim-T-850-ANN-polar_S.png'] != [] FAILED tests/integration/test_diags.py::TestAllSets::test_zonal_mean_2d - AssertionError: Lists differ: ['ERA-Interim-T-ANN-global.png'] != [] =================================================================================== 4 failed, 23 passed, 22 warnings in 351.33s (0:05:51) ===================================================================================
I don't recall any changes to how tests are run on the main
or the cdat-migration-fy24
branches. I'm not sure why these tests are failing on main
.
I recently squashed the cdat-migration-fy24
branch to a few commits and just rebased this branch on top of it.
Can you make sure to checkout the latest version of his branch? I also recommend stashing and reapplying any changes you might have.
Note to self: see https://github.com/forsyth2/e3sm_diags/pull/4 (#752) for an example.
@tomvothecoder What am I supposed to rebase to remove that initial commit for #677 (d1aec8248cfb6dab90455c0ef918bb0933fe34e2)? If I run git rebase upstream/cdat-migration-fy24
, I get merge conflicts, specifically on e3sm_diags/run.py
. But that doesn't make sense because the commit history for that branch (https://github.com/E3SM-Project/e3sm_diags/commits/cdat-migration-fy24/) does in fact include that pull request's merge, and my later commits don't touch that file.
Re: testing this branch: I basically took the tests from #752 and updated them to be more like the lat_lon
tests in https://github.com/E3SM-Project/e3sm_diags/blob/main/examples/ex5-model-vs-obs/diags.cfg, since polar
is pretty similar in purpose to lat_lon
. I then ran them using the directions at https://e3sm-project.github.io/e3sm_diags/_build/html/master/examples.html#running-the-diagnostics. However, I'm getting the following errors.
$ python run_polar.py -d diags.cfg
Traceback (most recent call last):
File "/gpfs/fs1/home/ac.forsyth2/e3sm_diags/examples/run_polar.py", line 42, in <module>
runner.run_diags([param])
File "/home/ac.forsyth2/miniconda3/envs/e3sm_diags_dev_659/lib/python3.10/site-packages/e3sm_diags/run.py", line 28, in run_diags
final_params = self.get_final_parameters(parameters)
File "/home/ac.forsyth2/miniconda3/envs/e3sm_diags_dev_659/lib/python3.10/site-packages/e3sm_diags/run.py", line 65, in get_final_parameters
other_params = self._get_other_diags(parameters[0].run_type)
File "/home/ac.forsyth2/miniconda3/envs/e3sm_diags_dev_659/lib/python3.10/site-packages/e3sm_diags/run.py", line 249, in _get_other_diags
params = self.parser.get_cfg_parameters(argparse_vals_only=False)
File "/home/ac.forsyth2/miniconda3/envs/e3sm_diags_dev_659/lib/python3.10/site-packages/e3sm_diags/parser/core_parser.py", line 798, in get_cfg_parameters
params = self._get_cfg_parameters(
File "/home/ac.forsyth2/miniconda3/envs/e3sm_diags_dev_659/lib/python3.10/site-packages/e3sm_diags/parser/core_parser.py", line 817, in _get_cfg_parameters
cfg_file_obj = self._create_cfg_hash_titles(cfg_file)
File "/home/ac.forsyth2/miniconda3/envs/e3sm_diags_dev_659/lib/python3.10/site-packages/e3sm_diags/parser/core_parser.py", line 851, in _create_cfg_hash_titles
with open(cfg_file) as f:
FileNotFoundError: [Errno 2] No such file or directory: 'examples/test_refactor/diags.cfg'
[WARNING] yaksa: 10 leaked handle pool objects
and
$ python run_polar.py -d diags.cfg --multiprocessing --num_workers=32
Traceback (most recent call last):
File "/gpfs/fs1/home/ac.forsyth2/e3sm_diags/examples/run_polar.py", line 42, in <module>
runner.run_diags([param])
File "/home/ac.forsyth2/miniconda3/envs/e3sm_diags_dev_659/lib/python3.10/site-packages/e3sm_diags/run.py", line 28, in run_diags
final_params = self.get_final_parameters(parameters)
File "/home/ac.forsyth2/miniconda3/envs/e3sm_diags_dev_659/lib/python3.10/site-packages/e3sm_diags/run.py", line 65, in get_final_parameters
other_params = self._get_other_diags(parameters[0].run_type)
File "/home/ac.forsyth2/miniconda3/envs/e3sm_diags_dev_659/lib/python3.10/site-packages/e3sm_diags/run.py", line 249, in _get_other_diags
params = self.parser.get_cfg_parameters(argparse_vals_only=False)
File "/home/ac.forsyth2/miniconda3/envs/e3sm_diags_dev_659/lib/python3.10/site-packages/e3sm_diags/parser/core_parser.py", line 798, in get_cfg_parameters
params = self._get_cfg_parameters(
File "/home/ac.forsyth2/miniconda3/envs/e3sm_diags_dev_659/lib/python3.10/site-packages/e3sm_diags/parser/core_parser.py", line 817, in _get_cfg_parameters
cfg_file_obj = self._create_cfg_hash_titles(cfg_file)
File "/home/ac.forsyth2/miniconda3/envs/e3sm_diags_dev_659/lib/python3.10/site-packages/e3sm_diags/parser/core_parser.py", line 851, in _create_cfg_hash_titles
with open(cfg_file) as f:
FileNotFoundError: [Errno 2] No such file or directory: 'examples/test_refactor/diags.cfg'
[WARNING] yaksa: 10 leaked handle pool objects
Oh I just realized the directory information is wrong. Rerunning
Using the allocation command from #767. A lot of UnboundLocalError: local variable 'proj' referenced before assignment
. The viewers is generated but none of the table entries link to plots.
$ python run_polar.py -d diags.cfg
2023-12-18 14:42:02,046 [INFO]: e3sm_diags_driver.py(_save_env_yml:57) >> Saved environment yml file to: /global/cfs/cdirs/e3sm/www/forsyth/test_e3sm_refactor/ex5_model_to_obs/prov/environment.yml
2023-12-18 14:42:02,054 [INFO]: e3sm_diags_driver.py(_save_parameter_files:68) >> Saved command used to: /global/cfs/cdirs/e3sm/www/forsyth/test_e3sm_refactor/ex5_model_to_obs/prov/cmd_used.txt
2023-12-18 14:42:02,071 [INFO]: e3sm_diags_driver.py(_save_parameter_files:98) >> Saved cfg file to: /global/cfs/cdirs/e3sm/www/forsyth/test_e3sm_refactor/ex5_model_to_obs/prov/diags.cfg
2023-12-18 14:42:02,081 [INFO]: e3sm_diags_driver.py(_save_python_script:132) >> Saved Python script to: /global/cfs/cdirs/e3sm/www/forsyth/test_e3sm_refactor/ex5_model_to_obs/prov/run_polar.py
2023-12-18 14:42:02,741 [INFO]: polar_driver.py(run_diag:79) >> Variable: TREFHT
2023-12-18 14:42:03,008 [INFO]: polar_driver.py(run_diag:205) >> Selected region: land
WARNING: Edge bounds are the same. The results of conservative regridding will not conserve.
coordMin = -90.00, boundMin = -90.00, coordMax = 90.00, boundMax = 90.00
2023-12-18 14:42:11,760 [ERROR]: __init__.py(plot:58) >> Error while plotting polar with backend cartopy
Traceback (most recent call last):
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/__init__.py", line 56, in plot
plot_fcn(ref, test, diff, metrics_dict, parameter)
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/cartopy/polar_plot.py", line 179, in plot
proj,
UnboundLocalError: local variable 'proj' referenced before assignment
Traceback (most recent call last):
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/__init__.py", line 56, in plot
plot_fcn(ref, test, diff, metrics_dict, parameter)
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/cartopy/polar_plot.py", line 179, in plot
proj,
UnboundLocalError: local variable 'proj' referenced before assignment
2023-12-18 14:42:12,214 [INFO]: polar_driver.py(run_diag:79) >> Variable: TREFHT
2023-12-18 14:42:12,312 [INFO]: polar_driver.py(run_diag:205) >> Selected region: global
WARNING: Edge bounds are the same. The results of conservative regridding will not conserve.
coordMin = -90.00, boundMin = -90.00, coordMax = 90.00, boundMax = 90.00
2023-12-18 14:42:15,538 [ERROR]: __init__.py(plot:58) >> Error while plotting polar with backend cartopy
Traceback (most recent call last):
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/__init__.py", line 56, in plot
plot_fcn(ref, test, diff, metrics_dict, parameter)
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/cartopy/polar_plot.py", line 179, in plot
proj,
UnboundLocalError: local variable 'proj' referenced before assignment
Traceback (most recent call last):
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/__init__.py", line 56, in plot
plot_fcn(ref, test, diff, metrics_dict, parameter)
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/cartopy/polar_plot.py", line 179, in plot
proj,
UnboundLocalError: local variable 'proj' referenced before assignment
2023-12-18 14:42:16,186 [INFO]: polar_driver.py(run_diag:79) >> Variable: TREFHT
2023-12-18 14:42:16,450 [INFO]: polar_driver.py(run_diag:205) >> Selected region: land
WARNING: Edge bounds are the same. The results of conservative regridding will not conserve.
coordMin = -90.00, boundMin = -90.00, coordMax = 90.00, boundMax = 90.00
2023-12-18 14:42:24,646 [ERROR]: __init__.py(plot:58) >> Error while plotting polar with backend cartopy
Traceback (most recent call last):
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/__init__.py", line 56, in plot
plot_fcn(ref, test, diff, metrics_dict, parameter)
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/cartopy/polar_plot.py", line 179, in plot
proj,
UnboundLocalError: local variable 'proj' referenced before assignment
Traceback (most recent call last):
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/__init__.py", line 56, in plot
plot_fcn(ref, test, diff, metrics_dict, parameter)
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/cartopy/polar_plot.py", line 179, in plot
proj,
UnboundLocalError: local variable 'proj' referenced before assignment
2023-12-18 14:42:24,944 [INFO]: polar_driver.py(run_diag:79) >> Variable: TREFHT
2023-12-18 14:42:25,037 [INFO]: polar_driver.py(run_diag:205) >> Selected region: global
WARNING: Edge bounds are the same. The results of conservative regridding will not conserve.
coordMin = -90.00, boundMin = -90.00, coordMax = 90.00, boundMax = 90.00
2023-12-18 14:42:28,250 [ERROR]: __init__.py(plot:58) >> Error while plotting polar with backend cartopy
Traceback (most recent call last):
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/__init__.py", line 56, in plot
plot_fcn(ref, test, diff, metrics_dict, parameter)
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/cartopy/polar_plot.py", line 179, in plot
proj,
UnboundLocalError: local variable 'proj' referenced before assignment
Traceback (most recent call last):
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/__init__.py", line 56, in plot
plot_fcn(ref, test, diff, metrics_dict, parameter)
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/cartopy/polar_plot.py", line 179, in plot
proj,
UnboundLocalError: local variable 'proj' referenced before assignment
2023-12-18 14:42:29,014 [INFO]: polar_driver.py(run_diag:79) >> Variable: TREFHT
2023-12-18 14:42:29,282 [INFO]: polar_driver.py(run_diag:205) >> Selected region: land
WARNING: Edge bounds are the same. The results of conservative regridding will not conserve.
coordMin = -90.00, boundMin = -90.00, coordMax = 90.00, boundMax = 90.00
2023-12-18 14:42:37,520 [ERROR]: __init__.py(plot:58) >> Error while plotting polar with backend cartopy
Traceback (most recent call last):
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/__init__.py", line 56, in plot
plot_fcn(ref, test, diff, metrics_dict, parameter)
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/cartopy/polar_plot.py", line 179, in plot
proj,
UnboundLocalError: local variable 'proj' referenced before assignment
Traceback (most recent call last):
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/__init__.py", line 56, in plot
plot_fcn(ref, test, diff, metrics_dict, parameter)
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/cartopy/polar_plot.py", line 179, in plot
proj,
UnboundLocalError: local variable 'proj' referenced before assignment
2023-12-18 14:42:37,869 [INFO]: polar_driver.py(run_diag:79) >> Variable: TREFHT
2023-12-18 14:42:37,987 [INFO]: polar_driver.py(run_diag:205) >> Selected region: global
WARNING: Edge bounds are the same. The results of conservative regridding will not conserve.
coordMin = -90.00, boundMin = -90.00, coordMax = 90.00, boundMax = 90.00
2023-12-18 14:42:41,183 [ERROR]: __init__.py(plot:58) >> Error while plotting polar with backend cartopy
Traceback (most recent call last):
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/__init__.py", line 56, in plot
plot_fcn(ref, test, diff, metrics_dict, parameter)
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/cartopy/polar_plot.py", line 179, in plot
proj,
UnboundLocalError: local variable 'proj' referenced before assignment
Traceback (most recent call last):
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/__init__.py", line 56, in plot
plot_fcn(ref, test, diff, metrics_dict, parameter)
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/cartopy/polar_plot.py", line 179, in plot
proj,
UnboundLocalError: local variable 'proj' referenced before assignment
2023-12-18 14:42:41,757 [INFO]: polar_driver.py(run_diag:79) >> Variable: TREFHT
2023-12-18 14:42:42,006 [INFO]: polar_driver.py(run_diag:205) >> Selected region: land
WARNING: Edge bounds are the same. The results of conservative regridding will not conserve.
coordMin = -90.00, boundMin = -90.00, coordMax = 90.00, boundMax = 90.00
2023-12-18 14:42:50,180 [ERROR]: __init__.py(plot:58) >> Error while plotting polar with backend cartopy
Traceback (most recent call last):
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/__init__.py", line 56, in plot
plot_fcn(ref, test, diff, metrics_dict, parameter)
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/cartopy/polar_plot.py", line 179, in plot
proj,
UnboundLocalError: local variable 'proj' referenced before assignment
Traceback (most recent call last):
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/__init__.py", line 56, in plot
plot_fcn(ref, test, diff, metrics_dict, parameter)
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/cartopy/polar_plot.py", line 179, in plot
proj,
UnboundLocalError: local variable 'proj' referenced before assignment
2023-12-18 14:42:50,520 [INFO]: polar_driver.py(run_diag:79) >> Variable: TREFHT
2023-12-18 14:42:50,604 [INFO]: polar_driver.py(run_diag:205) >> Selected region: global
WARNING: Edge bounds are the same. The results of conservative regridding will not conserve.
coordMin = -90.00, boundMin = -90.00, coordMax = 90.00, boundMax = 90.00
2023-12-18 14:42:53,774 [ERROR]: __init__.py(plot:58) >> Error while plotting polar with backend cartopy
Traceback (most recent call last):
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/__init__.py", line 56, in plot
plot_fcn(ref, test, diff, metrics_dict, parameter)
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/cartopy/polar_plot.py", line 179, in plot
proj,
UnboundLocalError: local variable 'proj' referenced before assignment
Traceback (most recent call last):
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/__init__.py", line 56, in plot
plot_fcn(ref, test, diff, metrics_dict, parameter)
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/cartopy/polar_plot.py", line 179, in plot
proj,
UnboundLocalError: local variable 'proj' referenced before assignment
2023-12-18 14:42:54,354 [INFO]: polar_driver.py(run_diag:79) >> Variable: TREFHT
2023-12-18 14:42:54,598 [INFO]: polar_driver.py(run_diag:205) >> Selected region: land
WARNING: Edge bounds are the same. The results of conservative regridding will not conserve.
coordMin = -90.00, boundMin = -90.00, coordMax = 90.00, boundMax = 90.00
2023-12-18 14:43:02,808 [ERROR]: __init__.py(plot:58) >> Error while plotting polar with backend cartopy
Traceback (most recent call last):
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/__init__.py", line 56, in plot
plot_fcn(ref, test, diff, metrics_dict, parameter)
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/cartopy/polar_plot.py", line 179, in plot
proj,
UnboundLocalError: local variable 'proj' referenced before assignment
Traceback (most recent call last):
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/__init__.py", line 56, in plot
plot_fcn(ref, test, diff, metrics_dict, parameter)
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/cartopy/polar_plot.py", line 179, in plot
proj,
UnboundLocalError: local variable 'proj' referenced before assignment
2023-12-18 14:43:03,146 [INFO]: polar_driver.py(run_diag:79) >> Variable: TREFHT
2023-12-18 14:43:03,262 [INFO]: polar_driver.py(run_diag:205) >> Selected region: global
WARNING: Edge bounds are the same. The results of conservative regridding will not conserve.
coordMin = -90.00, boundMin = -90.00, coordMax = 90.00, boundMax = 90.00
2023-12-18 14:43:06,475 [ERROR]: __init__.py(plot:58) >> Error while plotting polar with backend cartopy
Traceback (most recent call last):
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/__init__.py", line 56, in plot
plot_fcn(ref, test, diff, metrics_dict, parameter)
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/cartopy/polar_plot.py", line 179, in plot
proj,
UnboundLocalError: local variable 'proj' referenced before assignment
Traceback (most recent call last):
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/__init__.py", line 56, in plot
plot_fcn(ref, test, diff, metrics_dict, parameter)
File "/global/homes/f/forsyth/miniconda3/envs/e3sm_diags_659/lib/python3.10/site-packages/e3sm_diags/plot/cartopy/polar_plot.py", line 179, in plot
proj,
UnboundLocalError: local variable 'proj' referenced before assignment
2023-12-18 14:43:06,642 [INFO]: main.py(create_viewer:130) >> polar /global/cfs/cdirs/e3sm/www/forsyth/test_e3sm_refactor/ex5_model_to_obs/viewer
2023-12-18 14:43:06,989 [INFO]: main.py(create_viewer:133) >> ('Polar contour maps', 'polar/index.html')
2023-12-18 14:43:07,003 [INFO]: e3sm_diags_driver.py(main:390) >> Viewer HTML generated at /global/cfs/cdirs/e3sm/www/forsyth/test_e3sm_refactor/ex5_model_to_obs/viewer/index.html
2023-12-18 14:43:07,016 [INFO]: logger.py(move_log_to_prov_dir:106) >> Log file saved in /global/cfs/cdirs/e3sm/www/forsyth/test_e3sm_refactor/ex5_model_to_obs/prov/e3sm_diags_run.log
[WARNING] yaksa: 10 leaked handle pool objects
I tried changing regions to be regions = ["N", "S"]
but that just causes KeyError
s
Ran into this permissions issue while testing on Perlmutter: https://github.com/E3SM-Project/e3sm_diags/discussions/772
@tomvothecoder Based on https://github.com/E3SM-Project/e3sm_diags/pull/749#issuecomment-1793087795, I think I have actually removed all the CDAT dependencies from polar
. I was able to run the example/test on Perlmutter: https://portal.nersc.gov/cfs/e3sm/forsyth/test_e3sm_refactor/test_659/viewer/polar/index.html
Re: these lines:
e3sm_diags/driver/polar_driver.py:94: # This is cdms2 fix for bad mask, Denis' fix should fix this.
e3sm_diags/driver/polar_driver.py:98: # This is cdms2 fix for bad mask, Denis' fix should fix this.
e3sm_diags/driver/polar_driver.py:101: # This is cdms2 fix for bad mask, Denis' fix should fix this.
These refer to MV2
, which I seem to recall being CDAT-related, but is not listed at https://anaconda.org/cdat/repo?sort=_name&sort_order=asc.
@tomvothecoder Based on https://github.com/E3SM-Project/e3sm_diags/pull/749#issuecomment-1793087795, I think I have actually removed all the CDAT dependencies from polar. I was able to run the example/test on Perlmutter: portal.nersc.gov/cfs/e3sm/forsyth/test_e3sm_refactor/test_659/viewer/polar/index.html
Great, now you'll need to refactor the driver and plotter code to operate on Xarray objects. The current polar code uses CDAT-based modules such as the old Dataset class. You need to update the implementation logic to use the latest Xarray-based utilities and modules.
I recommend taking a look at the refactored lat_lon set or Jill's PR.
Fixing lost code from force-push:
$ git checkout refactor/659-polar-set
$ git checkout -b refactor/659-polar-set-pre-force-push
$ git push forsyth2 refactor/659-polar-set-pre-force-push
# Create https://github.com/forsyth2/e3sm_diags/pull/6 to see diff
# Looks like this PR is just missing 2 of the 4 commits on that diff.
$ git checkout refactor/659-polar-set
$ git fetch forsyth2
$ git reset --hard forsyth2 refactor/659-polar-set # To match the code as it is on GitHub
# Cherry-pick the remaining 2 commits:
$ git cherry-pick c5fc0a5042908d977fef3ae8eb7028f940182434
$ git cherry-pick 4f31cf44aa028210f2b4fb997eb8976263f2c312
$ git push forsyth2 refactor/659-polar-set
# Now this PR and https://github.com/forsyth2/e3sm_diags/pull/6 look the same.
Just an FYI that we don't need to refactor the block of code below and it can be removed entirely (related comment). It is found in several drivers, including polar_driver.py
. This makes refactoring a bit easier.
FYI the template run script and template regression testing notebooks are now available on cdat-migration-fy24
. You'll need to rebase your branch on the latest cdat-migration-fy24
to access them.
I also updated the instructions on the wiki guide for how to use them.
@tomvothecoder I finished comparing the old e3sm_diags/plot/cartopy/polar_plot.py
to the new e3sm_diags/plot/polar_plot.py
(which is more or less just a copy of e3sm_diags/plot/lat_lon_plot.py
at this point). Not surprisingly, the parts that still need a refactoring are the polar-grid specific code blocks.
Clearly _add_colormap
in e3sm_diags/plot/utils.py
needs to have some way of knowing which projections to use. Do you have a preferred method of updating it? Possible ideas:
lat_lon
, polar
) and then conditionally choose the proper projection, etc.lat_lon_plot.py
, polar_plot.py
) pass in what projection should be used.I guess my main point here is do you want perhaps many parameters added to _add_colormap
or do we want to bundle all set-specific items in a single new parameter?
It also occurs to me we might be able to extract some info from the already-present parameter: CoreParameter
input, but polar
and lat_lon
don't seem to have dedicated parameter subclasses.
Clearly
_add_colormap
ine3sm_diags/plot/utils.py
needs to have some way of knowing which projections to use. Do you have a preferred method of updating it? Possible ideas:* Pass in the name of the set (e.g., `lat_lon`, `polar`) and then conditionally choose the proper projection, etc. * Have the plotter (e.g., `lat_lon_plot.py`, `polar_plot.py`) pass in what projection should be used.
Thanks for coming up with some ideas. I prefer the second option because it seems cleaner to add a projection
arg to _add_color_map()
.
The current _add_color_map()
has some lat_lon
/aerosol_aeronet
specific code that needs to be extracted to a smaller utility function with conditionals. For example: https://github.com/E3SM-Project/e3sm_diags/blob/7bc413081def922b7b3f8fbf5f747f560f740dcb/e3sm_diags/plot/utils.py#L191-L205
@tomvothecoder In testing this, I discovered an error in the following: https://github.com/E3SM-Project/e3sm_diags/blob/6b296b1fc4f8ddaea2a5efaa6639b95a31a009a8/e3sm_diags/driver/lat_lon_driver.py#L78-L107:
The first two conditions make it so the elif is_dims_diff
block would never be called.
Should be:
is_test_3d = has_z_axis(dv_test)
is_ref_3d = has_z_axis(dv_ref)
is_dims_diff = is_test_3d != is_ref_3d
is_vars_3d = is_test_3d and is_ref_3d
if is_dims_diff:
raise RuntimeError(
"Dimensions of the two variables are different. Aborting."
)
elif is_vars_3d:
# For variables with a z-axis.
_run_diags_3d(
parameter,
ds_test,
ds_ref,
ds_land_sea_mask,
season,
regions,
var_key,
ref_name,
)
else:
# For variables without a z-axis.
_run_diags_2d(
parameter,
ds_test,
ds_ref,
ds_land_sea_mask,
season,
regions,
var_key,
ref_name,
)
@tomvothecoder @chengzhuzhang, following up on my point above: in the polar test I have:
param.reference_data_path = (
"/global/cfs/cdirs/e3sm/e3sm_diags/obs_for_e3sm_diags/climatology/"
)
param.test_data_path = (
"/global/cfs/cdirs/e3sm/e3sm_diags/postprocessed_e3sm_v2_data_for_e3sm_diags/20210528.v2rc3e.piControl.ne30pg2_EC30to60E2r2.chrysalis/climatology/rgr"
)
which matches #752 examples/test_refactor/run_zonal_mean_xy.py
.
But it looks like my test is 2D and my ref is 3D. Am I using the wrong data?
And actually, shouldn't we be able to still process 3D data with 2D data by simply dropping the 3rd dimension, rather than erroring out?
@tomvothecoder When running the polar version of https://github.com/E3SM-Project/e3sm_diags/blob/cdat-migration-fy24/auxiliary_tools/cdat_regression_testing/template_cdat_regression_test_json.ipynb, VS Code prompts "Type to choose a kernel source". What should I choose there? Do I need to set up something?
@tomvothecoder @chengzhuzhang, following up on my point above: in the polar test I have:
param.reference_data_path = ( "/global/cfs/cdirs/e3sm/e3sm_diags/obs_for_e3sm_diags/climatology/" ) param.test_data_path = ( "/global/cfs/cdirs/e3sm/e3sm_diags/postprocessed_e3sm_v2_data_for_e3sm_diags/20210528.v2rc3e.piControl.ne30pg2_EC30to60E2r2.chrysalis/climatology/rgr" )
which matches #752
examples/test_refactor/run_zonal_mean_xy.py
.But it looks like my test is 2D and my ref is 3D. Am I using the wrong data?
And actually, shouldn't we be able to still process 3D data with 2D data by simply dropping the 3rd dimension, rather than erroring out?
I think you are using the right paths for data. Are you testing for all variables or just a few. For testing I would suggest to start with a small dataset to begin. See an example: here
@tomvothecoder When running the polar version of https://github.com/E3SM-Project/e3sm_diags/blob/cdat-migration-fy24/auxiliary_tools/cdat_regression_testing/template_cdat_regression_test_json.ipynb, VS Code prompts "Type to choose a kernel source". What should I choose there? Do I need to set up something?
@forsyth2 have you had Jupyter notebook installed? Here is what I selected.
@tomvothecoder @chengzhuzhang, following up on my point above: in the polar test I have:
param.reference_data_path = ( "/global/cfs/cdirs/e3sm/e3sm_diags/obs_for_e3sm_diags/climatology/" ) param.test_data_path = ( "/global/cfs/cdirs/e3sm/e3sm_diags/postprocessed_e3sm_v2_data_for_e3sm_diags/20210528.v2rc3e.piControl.ne30pg2_EC30to60E2r2.chrysalis/climatology/rgr" )
which matches #752
examples/test_refactor/run_zonal_mean_xy.py
. But it looks like my test is 2D and my ref is 3D. Am I using the wrong data? And actually, shouldn't we be able to still process 3D data with 2D data by simply dropping the 3rd dimension, rather than erroring out?I think you are using the right paths for data. Are you testing for all variables or just a few. For testing I would suggest to start with a small dataset to begin. See an example: here
I agree with Jill, it is a good idea and more efficient to test development using small datasets/few variables in a custom run script. This allows you to go through a more immediate feedback loop.
Then once all outputs are successfully reproduced by your custom run script, you can try the template_run_script.py
which runs all variables for the set you're testing.
@tomvothecoder When running the polar version of
cdat-migration-fy24
/auxiliary_tools/cdat_regression_testing/template_cdat_regression_test_json.ipynb, VS Code prompts "Type to choose a kernel source". What should I choose there? Do I need to set up something?@tomvothecoder When running the polar version of
cdat-migration-fy24
/auxiliary_tools/cdat_regression_testing/template_cdat_regression_test_json.ipynb, VS Code prompts "Type to choose a kernel source". What should I choose there? Do I need to set up something?@forsyth2 have you had Jupyter notebook installed? Here is what I selected.
The "How to Use" section includes instructions on setting up a conda environment with the appropriate Python kernel. You can skip the third step for activating the env, and instead select the kernel in Jupyter.
The "How to Use" section includes instructions on setting up a conda environment with the appropriate Python kernel. You can skip the third step for activating the env, and instead select the kernel in Jupyter.
@tomvothecoder Yes, I followed those steps but when I clicked the "Execute Cell" play-button, it prompted "Type to choose a kernel source", with no kernels suggested.
It had a dropdown suggestion of installing a Jupyter extension. I did that and tried again, clicking on cdat_regression_test
in the dropdown, as in https://github.com/E3SM-Project/e3sm_diags/pull/749#issuecomment-1931073592. (So kernel source is the same as the conda environment then??)
However, that first cell now gives:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[4], [line 5](vscode-notebook-cell:?execution_count=4&line=5)
[2](vscode-notebook-cell:?execution_count=4&line=2) import glob
[4](vscode-notebook-cell:?execution_count=4&line=4) import numpy as np
----> [5](vscode-notebook-cell:?execution_count=4&line=5) import xarray as xr
[7](vscode-notebook-cell:?execution_count=4&line=7) SET_NAME = "polar"
[8](vscode-notebook-cell:?execution_count=4&line=8) SET_DIR = "659-polar"
ModuleNotFoundError: No module named 'xarray'
The "How to Use" section includes instructions on setting up a conda environment with the appropriate Python kernel. You can skip the third step for activating the env, and instead select the kernel in Jupyter.
@tomvothecoder Yes, I followed those steps but when I clicked the "Execute Cell" play-button, it prompted "Type to choose a kernel source", with no kernels suggested.
It had a dropdown suggestion of installing a Jupyter extension. I did that and tried again, clicking on
cdat_regression_test
in the dropdown, as in #749 (comment). (So kernel source is the same as the conda environment then??)However, that first cell now gives:
--------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) Cell In[4], [line 5](vscode-notebook-cell:?execution_count=4&line=5) [2](vscode-notebook-cell:?execution_count=4&line=2) import glob [4](vscode-notebook-cell:?execution_count=4&line=4) import numpy as np ----> [5](vscode-notebook-cell:?execution_count=4&line=5) import xarray as xr [7](vscode-notebook-cell:?execution_count=4&line=7) SET_NAME = "polar" [8](vscode-notebook-cell:?execution_count=4&line=8) SET_DIR = "659-polar" ModuleNotFoundError: No module named 'xarray'
When you see ModuleNotFoundError
in Python that means the module is not found in the current environment. If you trace back to the install command you ran, xarray
is not included. The reason being is that you're using the env created with template_cdat_regression_test_json.ipynb with template_cdat_regression_test_nc.ipynb (which requires xarray
)
Each notebook has a different environment in the instructions. It can probably be simplified to be a single environment, but I didn't write them with that in mind.
I completed refactoring with successful regression test. All variables are within the relative diff tolerance of 1e-5. I will be merging this PR once the CI/CD build passes.
Polar viewers:
Description
Refactor the polar set. Following the directions at https://github.com/E3SM-Project/e3sm_diags/wiki/CDAT-Migration-FY24-%E2%80%90-General-Guide#getting-started:
Summary of Changes:
polar_driver.py
andpolar_plot.py
driver/utils/regrid.py
subset_and_align_datasets()
to make copies of dataset objects before performing computations for cleaner code and ease of debugging_subset_on_region()
not subsetting specific regions correctly due to order of subsetting tuple. This function makes sure that the axes/axes being subsetted on is in ascending order. If it is not in ascending order, some slice specifications might have two negative values (e.g., (-90, -55) for 'polar_S') which can result in the subset incorrectly excluding of values that seem like they don't fit within the slice slice spec range when they actually are (circular coordinates).plot/utils.py
rect
arg to_add_colorbar()
for adjustment of therect
used for creating colorbar, along with_get_rect()
, which can vary based on the setleft_text_pos
andright_text_pos
args to_add_min_mean_max_test()
andadd_rmse_and_corr_text()
for adjustment of the x and y position of each respective text, which can vary based on the setcosp_histogram_py
_save_plot()
zonal_mean_2d_plot.py
auxiliary_tools/cdat_regression_testing/template_run_script.py
chown
command withchmod
.Checklist
If applicable: