Skip to content

Instantly share code, notes, and snippets.

@zshaheen
Created June 13, 2019 02:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zshaheen/e7ee498c83aa1f2c2849e7e0db50969c to your computer and use it in GitHub Desktop.
Save zshaheen/e7ee498c83aa1f2c2849e7e0db50969c to your computer and use it in GitHub Desktop.
Running E3SM Diagnostics via the API

Running E3SM Diagnostics via the API

Getting the Environment Setup

We are running all of these tests on Cori. Here's how you setup the environment.

  1. wget the environment yml file from the aprime_try1 branch.
    wget https://raw.githubusercontent.com/E3SM-Project/e3sm_diags/aprime_try1/conda/e3sm_diags_env_dev.yml
    
  2. Create the environment.
    conda env create -f e3sm_diags_env_dev.yml --name e3sm_diags_env_dev_jun12
    
  3. Clone the e3sm_diags repo and go to the aprime_try1 branch like so.
    git checkout aprime_try1
    git pull origin aprime_try1
    
  4. Install the software. Note we are not using python setup.py install.
    pip install .
    

Also, feel free to play around the with settings, since your testing will help.

Running from the Cori Quick Start Guide

Below is the code to run the paramameter file linked here., call it lat_lon_demo.py

Remember to change prefix accordingly to a directory you can access. Since we're running the software via Python, we can do Pythonic things, like using os.path.join().

import os
from acme_diags.parameter.core_parameter import CoreParameter
from acme_diags.run import runner

param = CoreParameter()

param.reference_data_path = '/global/project/projectdirs/acme/acme_diags/obs_for_e3sm_diags/climatology/'
param.test_data_path = '/global/project/projectdirs/acme/acme_diags/test_model_data_for_acme_diags/climatology/'
param.test_name = '20161118.beta0.FC5COSP.ne30_ne30.edison'
param.seasons = ["ANN"]

prefix = '/global/project/projectdirs/acme/www/shaheen2/runs_with_api'
param.results_dir = os.path.join(prefix, 'lat_lon_demo')

runner.sets_to_run = ['lat_lon']
runner.run_diags([param])

Run it like so with multiprocessing:

python lat_lon_demo.py --multiprocessing --num_workers=32

We could have also set these multiprocessing parameters in the lat_lon_demo.py as well. But we're showing that you can still submit parameters via the command line.

Again, this new way of running is basically a replacement for the params.py in e3sm_diags -p params.py -d diags.cfg.

Viewing the Results

The results are here. When you click on the Provenance folder and click on lat_lon_demo.py, you can see a copy of the script used.

Again, in that folder, you can view the command used to run the software in cmd_used.txt. In this file, you can see that we ran with multiprocessing.

Also, look in the provenance under "Show Output Metadata". Try modifying these values to change things. You'll notice that to run the provenance, we have the set name (lat_lon) after the e3sm_diags argument. This is a small change that a user shouldn't notice. Ex:

e3sm_diags lat_lon --no_viewer --case_id 'CRU_IPCC' ...

Running with custom parameters for zonal_mean_2d

In the file e3sm_diags/acme_diags/parameter/zonal_mean_2d_parameter.py, you can see the default value for plevs in the zonal_mean_2d set. Say we want to change these to [10.0, 20.0, 30.0].

Call the file below zonal_mean_2d_plevs.py. Notice that we are:

  • adding 'zonal_mean_2d' to runner.sets_to_run.
  • adding the new parameter, zonal_mean_2d_param, to runner.run_diags() in addition to the original core parameter.
    • This is how the new plevs are propagated to the diags.

Also note that we can do more Pythonic things. If we want to select only T and PRECT to run the diags on, you do what's commented out. It's much easier than the other way, under "Using the selectors parameter".

import os
from acme_diags.parameter.core_parameter import CoreParameter
from acme_diags.parameter.zonal_mean_2d_parameter import ZonalMean2dParameter
from acme_diags.run import runner

param = CoreParameter()

param.reference_data_path = '/global/project/projectdirs/acme/acme_diags/obs_for_e3sm_diags/climatology/'
param.test_data_path = '/global/project/projectdirs/acme/acme_diags/test_model_data_for_acme_diags/climatology/'
param.test_name = '20161118.beta0.FC5COSP.ne30_ne30.edison'
param.seasons = ["ANN"]

prefix = '/global/project/projectdirs/acme/www/shaheen2/runs_with_api'
param.results_dir = os.path.join(prefix, 'zonal_mean_2d_and_lat_lon_demo')

# Uncomment the two lines below to just
# run the diags with T and PRECT.
# param.selectors += ['variables']
# param.variables = ['T', 'PRECT']

# The new changes are below.
zonal_mean_2d_param = ZonalMean2dParameter()
zonal_mean_2d_param.plevs = [10.0, 20.0, 30.0]

runner.sets_to_run = ['zonal_mean_2d', 'lat_lon']
runner.run_diags([param, zonal_mean_2d_param])

Run the diags:

python zonal_mean_2d_plevs.py --multiprocessing --num_workers=32

Results

The results are here.

Notice that though the plevs parameter was changed in the zonal_mean_2d plots, it's unchanged for lat_lon. For lat_lon, you can see that we still have 200 and 850 as the pressure levels.

@chengzhuzhang
Copy link

Both example runs are good from my side.
The system tests failed when i do e3sm_diags -d all_sets.cfg.

@chengzhuzhang
Copy link

I have one concern. The parameter 'regions' should be lat lon set specific. Can we move it from core parameter to lat_lon_parameters.py ? I suppose this will impact running the package in an old way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment