E3SM-Project/e3sm_diags

Add ability to run on subset of variables with just the Python script

Opened this issue · 1 comments

Overview

I am executing ex1.py using a Python Interactive Console. I defined a param.variables=["SST"] to debug performance with a single variable.

e3sm_diags is running the SST variable 71 times for each variable diagnostic defined in lat_lon_model_vs_model.cfg file (refer to log output at the bottom).

Proposed Solution

Since I defined param.variables = ["SST"] in a Python script, the default diags cfg file should not be used (I think?).

This means there should only be 1 CoreParameter object being created for the single "SST" variable.

Call stack

  1. Execute runner.run_diags()
  2. Call to self.get_final_parameters()
  1. Call to get_other_diags() -- should be skipped since we defined diagnostics through the Python script
  2. Inside get_other_diags() - the default diags path is used
  • # If the user has passed in args with -d.
    if args.other_parameters:
    params = self.parser.get_cfg_parameters(argparse_vals_only=False)
    else:
    default_diags_paths = [
    get_default_diags_path(set_name, run_type, False)
    for set_name in self.sets_to_run
    ]
    params = self.parser.get_cfg_parameters(
    files_to_open=default_diags_paths, argparse_vals_only=False
    )

Example:

My version of ex1.py with updated paths (change to yours) and setting param.variables=["SST"]

import os

from e3sm_diags.parameter.core_parameter import CoreParameter
from e3sm_diags.run import runner

param = CoreParameter()

# Location of the data.
param.test_data_path = "/global/cfs/cdirs/e3sm/e3sm_diags/test_model_data_for_acme_diags/time-series/E3SM_v1"
param.reference_data_path = "/global/cfs/cdirs/e3sm/e3sm_diags/test_model_data_for_acme_diags/time-series/E3SM_v1"

# Set this parameter to True.
# By default, e3sm_diags expects the test data to be climo data.
param.test_timeseries_input = True
# Years to slice the test data, base this off the years in the filenames.
param.test_start_yr = "2011"
param.test_end_yr = "2013"

# Set this parameter to True.
# By default, e3sm_diags expects the ref data to be climo data.
param.ref_timeseries_input = True
# Years to slice the ref data, base this off the years in the filenames
param.ref_start_yr = "1850"
param.ref_end_yr = "1852"

# When running with time-series data, you don't need to specify the name of the data.
# But you should, otherwise nothing is displayed when the test/ref name is needed.
param.short_test_name = "historical_H1"
param.short_ref_name = "historical_H1"

# This parameter modifies the software to accommodate model vs model runs.
# The default setting for run_type is 'model_vs_obs'.
param.run_type = "model_vs_model"
# Name of the folder where the results are stored.
# Change `prefix` to use your directory.
prefix = "/global/cfs/cdirs/e3sm/www/vo13/examples"
param.results_dir = os.path.join(prefix, "ex1_modTS_vs_modTS_3years")

# Below are more optional arguments.

# What plotsets to run the diags on.
# If not defined, then all available sets are used.
# param.sets = ["lat_lon"]
runner.sets_to_run = ["lat_lon"]
# What seasons to run the diags on.
# If not defined, diags are run on ['ANN', 'DJF', 'MAM', 'JJA', 'SON'].
param.seasons = ["ANN"]
# Title of the difference plots.
param.diff_title = "Model (2011-2013) - Model (1850-1852)"

# For running with multiprocessing.
param.multiprocessing = False
# param.num_workers = 1

param.variables = ["SST"]

runner.run_diags([param])

Output

(e3sm_diags_dev) vo13@login04:~/E3SM-Project/e3sm_diags> python examples/ex1-model_ts-vs-model_ts/ex1.py 
2023-09-05 12:54:34,052 [INFO]: e3sm_diags_driver.py(_save_env_yml:60) >> Saved environment yml file to: /global/cfs/cdirs/e3sm/www/vo13/examples/ex1_modTS_vs_modTS_3years/prov/environment.yml
2023-09-05 12:54:34,053 [INFO]: e3sm_diags_driver.py(_save_parameter_files:71) >> Saved command used to: /global/cfs/cdirs/e3sm/www/vo13/examples/ex1_modTS_vs_modTS_3years/prov/cmd_used.txt
2023-09-05 12:54:34,054 [INFO]: e3sm_diags_driver.py(_save_python_script:135) >> Saved Python script to: /global/cfs/cdirs/e3sm/www/vo13/examples/ex1_modTS_vs_modTS_3years/prov/ex1.py
2023-09-05 12:54:35,885 [INFO]: lat_lon_driver.py(run_diag:146) >> Variable: SST
2023-09-05 12:54:36,992 [INFO]: lat_lon_driver.py(run_diag:225) >> 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-09-05 12:54:38,003 [INFO]: lat_lon_driver.py(create_and_save_data_and_metrics:51) >> Metrics saved in /global/cfs/cdirs/e3sm/www/vo13/examples/ex1_modTS_vs_modTS_3years/lat_lon/model_vs_model/-SST-ANN-global.json
2023-09-05 12:54:39,494 [INFO]: lat_lon_plot.py(plot:320) >> Plot saved in: /global/cfs/cdirs/e3sm/www/vo13/examples/ex1_modTS_vs_modTS_3years/lat_lon/model_vs_model/-SST-ANN-global.png
2023-09-05 12:54:39,494 [INFO]: lat_lon_plot.py(plot:320) >> Plot saved in: /global/cfs/cdirs/e3sm/www/vo13/examples/ex1_modTS_vs_modTS_3years/lat_lon/model_vs_model/-SST-ANN-global.png
2023-09-05 12:54:39,734 [INFO]: lat_lon_driver.py(run_diag:146) >> Variable: SST
2023-09-05 12:54:39,895 [INFO]: lat_lon_driver.py(run_diag:225) >> Selected region: global
2023-09-05 12:54:40,433 [INFO]: lat_lon_driver.py(create_and_save_data_and_metrics:51) >> Metrics saved in /global/cfs/cdirs/e3sm/www/vo13/examples/ex1_modTS_vs_modTS_3years/lat_lon/model_vs_model/-SST-ANN-global.json
2023-09-05 12:54:41,625 [INFO]: lat_lon_plot.py(plot:320) >> Plot saved in: /global/cfs/cdirs/e3sm/www/vo13/examples/ex1_modTS_vs_modTS_3years/lat_lon/model_vs_model/-SST-ANN-global.png
2023-09-05 12:54:41,625 [INFO]: lat_lon_plot.py(plot:320) >> Plot saved in: /global/cfs/cdirs/e3sm/www/vo13/examples/ex1_modTS_vs_modTS_3years/lat_lon/model_vs_model/-SST-ANN-global.png
2023-09-05 12:54:41,754 [INFO]: lat_lon_driver.py(run_diag:146) >> Variable: SST
2023-09-05 12:54:41,892 [INFO]: lat_lon_driver.py(run_diag:225) >> 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-09-05 12:54:42,843 [INFO]: lat_lon_driver.py(create_and_save_data_and_metrics:51) >> Metrics saved in /global/cfs/cdirs/e3sm/www/vo13/examples/ex1_modTS_vs_modTS_3years/lat_lon/model_vs_model/-SST-ANN-global.json
2023-09-05 12:54:43,761 [INFO]: lat_lon_plot.py(plot:320) >> Plot saved in: /global/cfs/cdirs/e3sm/www/vo13/examples/ex1_modTS_vs_modTS_3years/lat_lon/model_vs_model/-SST-ANN-global.png
2023-09-05 12:54:43,761 [INFO]: lat_lon_plot.py(plot:320) >> Plot saved in: /global/cfs/cdirs/e3sm/www/vo13/examples/ex1_modTS_vs_modTS_3years/lat_lon/model_vs_model/-SST-ANN-global.png
2023-09-05 12:54:44,116 [INFO]: lat_lon_driver.py(run_diag:146) >> Variable: SST
2023-09-05 12:54:44,621 [INFO]: lat_lon_driver.py(run_diag:225) >> 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-09-05 12:54:45,556 [INFO]: lat_lon_driver.py(create_and_save_data_and_metrics:51) >> Metrics saved in /global/cfs/cdirs/e3sm/www/vo13/examples/ex1_modTS_vs_modTS_3years/lat_lon/model_vs_model/-SST-ANN-global.json
2023-09-05 12:54:47,003 [INFO]: lat_lon_plot.py(plot:320) >> Plot saved in: /global/cfs/cdirs/e3sm/www/vo13/examples/ex1_modTS_vs_modTS_3years/lat_lon/model_vs_model/-SST-ANN-global.png
2023-09-05 12:54:47,003 [INFO]: lat_lon_plot.py(plot:320) >> Plot saved in: /global/cfs/cdirs/e3sm/www/vo13/examples/ex1_modTS_vs_modTS_3years/lat_lon/model_vs_model/-SST-ANN-global.png
2023-09-05 12:54:47,152 [INFO]: lat_lon_driver.py(run_diag:146) >> Variable: SST
2023-09-05 12:54:47,461 [INFO]: lat_lon_driver.py(run_diag:225) >> 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-09-05 12:54:48,510 [INFO]: lat_lon_driver.py(create_and_save_data_and_metrics:51) >> Metrics saved in /global/cfs/cdirs/e3sm/www/vo13/examples/ex1_modTS_vs_modTS_3years/lat_lon/model_vs_model/-SST-ANN-global.json
2023-09-05 12:54:49,911 [INFO]: lat_lon_plot.py(plot:320) >> Plot saved in: /global/cfs/cdirs/e3sm/www/vo13/examples/ex1_modTS_vs_modTS_3years/lat_lon/model_vs_model/-SST-ANN-global.png
2023-09-05 12:54:49,911 [INFO]: lat_lon_plot.py(plot:320) >> Plot saved in: /global/cfs/cdirs/e3sm/www/vo13/examples/ex1_modTS_vs_modTS_3years/lat_lon/model_vs_model/-SST-ANN-global.png
2023-09-05 12:54:49,974 [INFO]: lat_lon_driver.py(run_diag:146) >> Variable: SST
2023-09-05 12:54:50,146 [INFO]: lat_lon_driver.py(run_diag:225) >> 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-09-05 12:54:51,092 [INFO]: lat_lon_driver.py(create_and_save_data_and_metrics:51) >> Metrics saved in /global/cfs/cdirs/e3sm/www/vo13/examples/ex1_modTS_vs_modTS_3years/lat_lon/model_vs_model/-SST-ANN-global.json
2023-09-05 12:54:51,862 [INFO]: lat_lon_plot.py(plot:320) >> Plot saved in: /global/cfs/cdirs/e3sm/www/vo13/examples/ex1_modTS_vs_modTS_3years/lat_lon/model_vs_model/-SST-ANN-global.png
2023-09-05 12:54:51,862 [INFO]: lat_lon_plot.py(plot:320) >> Plot saved in: /global/cfs/cdirs/e3sm/www/vo13/examples/ex1_modTS_vs_modTS_3years/lat_lon/model_vs_model/-SST-ANN-global.png
2023-09-05 12:54:51,917 [INFO]: lat_lon_driver.py(run_diag:146) >> Variable: SST
2023-09-05 12:54:52,079 [INFO]: lat_lon_driver.py(run_diag:225) >> Selected region: global

.... (continues)

By default, with e3sm_diags, a built in set of variables are defined for each diagonostics sets. To do a short run, e.g. only running through a subset of variables, a configuration file is needed to customize the run.

https://e3sm-project.github.io/e3sm_diags/_build/html/main/quickguides/quick-guide-perlmutter.html#advanced-running-custom-diagnostics

We should include Python scripts too.