5. MJO

This notebook demonstrates the basic usage of the Madden-Julian Oscillation (MJO) metrics driver.

Before running this demo, please ensure that the sample data has been downloaded by running the Demo 0: Download Data notebook, if you haven’t already.

Scientific information about the MJO metrics is available through the README.

References:

  • Lee, J., P. J. Gleckler, M.-S. Ahn, A. Ordonez, P. Ullrich, K. R. Sperber, K. E. Taylor, Y. Y. Planton, E. Guilyardi, P. Durack, C. Bonfils, M. D. Zelinka, L.-W. Chao, B. Dong, C. Doutriaux, C. Zhang, T. Vo, J. Boutte, M. F. Wehner, A. G. Pendergrass, D. Kim, Z. Xue, A. T. Wittenberg, and J. Krasting, 2024: Systematic and Objective Evaluation of Earth System Models: PCMDI Metrics Package (PMP) version 3. Geoscientific Model Development, 17, 3919–3948, doi: 10.5194/gmd-17-3919-2024.

  • Ahn, M.-S., D. Kim, K. R. Sperber, I.-S. Kang, E. Maloney, D. Waliser, H. Hendon, 2017: MJO simulation in CMIP5 climate models: MJO skill metrics and process-oriented diagnosis. Clim. Dynam., 49, 4023-4045. doi: 10.1007/s00382-017-3558-4.

First we load the demo directory choices (read from user_choices.py file in the current directory, which is generated when running the Demo 0):

[1]:
from user_choices import demo_data_directory, demo_output_directory

The --help flag is available to provide more information on the mjo_metrics_driver:

[2]:
%%bash
mjo_metrics_driver.py --help
usage: mjo_metrics_driver.py [-h] [--parameters PARAMETERS]
                             [--diags OTHER_PARAMETERS [OTHER_PARAMETERS ...]]
                             [--results_dir RESULTS_DIR]
                             [--reference_data_path REFERENCE_DATA_PATH]
                             [--modpath MODPATH] [--mip MIP] [--exp EXP]
                             [--frequency FREQUENCY] [--realm REALM]
                             [--reference_data_name REFERENCE_DATA_NAME]
                             [--reference_data_lf_path REFERENCE_DATA_LF_PATH]
                             [--modpath_lf MODPATH_LF] [--varOBS VAROBS]
                             [--varModel VARMODEL]
                             [--ObsUnitsAdjust OBSUNITSADJUST]
                             [--ModUnitsAdjust MODUNITSADJUST] [--units UNITS]
                             [--osyear OSYEAR] [--msyear MSYEAR]
                             [--oeyear OEYEAR] [--meyear MEYEAR]
                             [--seasons SEASONS [SEASONS ...]]
                             [--modnames MODNAMES [MODNAMES ...]]
                             [-r REALIZATION] [--case_id CASE_ID] [-d DEBUG]
                             [--nc_out NC_OUT] [--plot PLOT]
                             [--update_json UPDATE_JSON] [--cmec] [--no_cmec]
                             [--parallel] [--includeOBS] [--no_OBS]
                             [--num_workers NUM_WORKERS]

Runs PCMDI MJO Computations

options:
  -h, --help            show this help message and exit
  --parameters PARAMETERS, -p PARAMETERS
  --diags OTHER_PARAMETERS [OTHER_PARAMETERS ...]
                        Path to other user-defined parameter file.
  --results_dir RESULTS_DIR, --rd RESULTS_DIR
                        The name of the folder where all runs will be stored.
  --reference_data_path REFERENCE_DATA_PATH, --rdp REFERENCE_DATA_PATH
                        The path/filename of reference (obs) data.
  --modpath MODPATH, --mp MODPATH
                        Explicit path to model data
  --mip MIP             A WCRP MIP project such as CMIP3 and CMIP5
  --exp EXP             An experiment such as amip, historical or piContorl
  --frequency FREQUENCY
  --realm REALM
  --reference_data_name REFERENCE_DATA_NAME
                        Name of reference data set
  --reference_data_lf_path REFERENCE_DATA_LF_PATH
                        Path of landsea mask for reference data set
  --modpath_lf MODPATH_LF
                        Path of landsea mask for model data set
  --varOBS VAROBS       Name of variable in reference data
  --varModel VARMODEL   Name of variable in model(s)
  --ObsUnitsAdjust OBSUNITSADJUST
                        For unit adjust for OBS dataset. For example:
                        - (True, 'divide', 100.0)  # Pa to hPa
                        - (True, 'subtract', 273.15)  # degK to degC
                        - (False, 0, 0) # No adjustment (default)
  --ModUnitsAdjust MODUNITSADJUST
                        For unit adjust for model dataset. For example:
                        - (True, 'divide', 100.0)  # Pa to hPa
                        - (True, 'subtract', 273.15)  # degK to degC
                        - (False, 0, 0) # No adjustment (default)
  --units UNITS         Final units for the variable
  --osyear OSYEAR       Start year for reference data set
  --msyear MSYEAR       Start year for model data set
  --oeyear OEYEAR       End year for reference data set
  --meyear MEYEAR       End year for model data set
  --seasons SEASONS [SEASONS ...]
                        List of seasons. Available: 'NDJFMA', 'MJJASO'
  --modnames MODNAMES [MODNAMES ...]
                        List of models. 'all' for every available models
  -r REALIZATION, --realization REALIZATION
                        Consider all accessible realizations as idividual
                        - r1i1p1: default, consider only 'r1i1p1' member
                                  Or, specify realization, e.g, r3i1p1'
                        - *: consider all available realizations
  --case_id CASE_ID     version as date, e.g., v20191116 (yyyy-mm-dd)
  -d DEBUG, --debug DEBUG
                        Option for debug: False (defualt) or True
  --nc_out NC_OUT       Option for generate netCDF file output: True (default) / False
  --plot PLOT           Option for generate individual plots: True (default) / False
  --update_json UPDATE_JSON
                        Option for update existing JSON file: True (i.e., update) (default) / False (i.e., overwrite)
  --cmec                Option to save metrics in CMEC format
  --no_cmec             Option to not save metrics in CMEC format
  --parallel            Turn on the parallel mode for running code using multiple CPUs
  --includeOBS          include observation
  --no_OBS              include observation
  --num_workers NUM_WORKERS
                        Start year for model data set

Basic Use

The MJO driver can read a parameter file to load user settings. A basic parameter file is shown here:

[3]:
with open("basic_mjo_param.py") as f:
    print(f.read())
import os

#
#  OPTIONS ARE SET BY USER IN THIS FILE AS INDICATED BELOW BY:
#
#

case_id = 'Ex1'
realization = 'r6i1p1'

# ROOT PATH FOR MODELS CLIMATOLOGIES
modnames = ['GISS-E2-H']
modpath = 'demo_data/CMIP5_demo_timeseries/historical/atmos/day/pr/pr_day_%(model)_historical_r6i1p1_20000101-20051231.nc'
varModel = 'pr'
ModUnitsAdjust = (True, 'multiply', 86400.0, 'mm d-1')  # kg m-2 s-1 to mm day-1
units = 'mm/d'
msyear = 2000
meyear = 2002
seasons = ['NDJFMA', 'MJJASO']

# ROOT PATH FOR OBSERVATIONS
reference_data_name = 'GPCP-IP'
reference_data_path = 'demo_data/obs4MIPs_PCMDI_daily/NASA-JPL/GPCP-1-3/day/pr/gn/latest/pr_day_GPCP-1-3_PCMDI_gn_19961002-20170101.nc'
varOBS = 'pr'
ObsUnitsAdjust = (True, 'multiply', 86400.0, 'mm d-1')  # kg m-2 s-1 to mm day-1
osyear = 1998
oeyear = 1999

# DIRECTORY WHERE TO PUT RESULTS
results_dir = 'demo_output/mjo/%(case_id)'

# MISCELLANEOUS
nc_out = False
plot = True  # Create map graphics
update_json = True

This parameter file can be passed to the mjo driver via the command line:

mjo_metrics_driver.py -p basic_mjo_param.py

This example is run as a subprocess in the next cell.

[4]:
%%bash
mjo_metrics_driver.py -p basic_mjo_param.py
includeOBS: True
models: ['GISS-E2-H']
realization:  r6i1p1
output directories:
graphics : demo_output/mjo/Ex1
diagnostic_results : demo_output/mjo/Ex1
metrics_results : demo_output/mjo/Ex1
CMEC: False
debug:  False
parallel: False
 -----  obs  ---------------------
 ---  GPCP-IP  ---
demo_data/obs4MIPs_PCMDI_daily/NASA-JPL/GPCP-1-3/day/pr/gn/latest/pr_day_GPCP-1-3_PCMDI_gn_19961002-20170101.nc
 --  NDJFMA  --
DEBUG::2026-07-09 16:11::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Opening file: demo_data/obs4MIPs_PCMDI_daily/NASA-JPL/GPCP-1-3/day/pr/gn/latest/pr_day_GPCP-1-3_PCMDI_gn_19961002-20170101.nc
2026-07-09 16:11:18,905 [DEBUG]: mjo_metric_calc.py(mjo_metric_ewr_calculation:256) >> Opening file: demo_data/obs4MIPs_PCMDI_daily/NASA-JPL/GPCP-1-3/day/pr/gn/latest/pr_day_GPCP-1-3_PCMDI_gn_19961002-20170101.nc
DEBUG::2026-07-09 16:11::pcmdi_metrics.mjo.lib.mjo_metric_calc:: start_year=1998, end_year=1999, NL=144, NT=180
2026-07-09 16:11:19,434 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:161) >> start_year=1998, end_year=1999, NL=144, NT=180
Converting units by  multiply 86400.0
DEBUG::2026-07-09 16:11::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Processed seasonal cycle for year 1998
2026-07-09 16:11:20,631 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:178) >> Processed seasonal cycle for year 1998
DEBUG::2026-07-09 16:11::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Computed spectrum for year 1998
2026-07-09 16:11:21,626 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:205) >> Computed spectrum for year 1998
INFO::2026-07-09 16:11::pcmdi_metrics.mjo.lib.mjo_metric_calc:: EWR=2.9337  east=0.0166  west=0.0056
2026-07-09 16:11:21,652 [INFO]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:212) >> EWR=2.9337  east=0.0166  west=0.0056
2026-07-09 16:11:21,652 [INFO]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:212) >> EWR=2.9337  east=0.0166  west=0.0056
 --  MJJASO  --
DEBUG::2026-07-09 16:11::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Opening file: demo_data/obs4MIPs_PCMDI_daily/NASA-JPL/GPCP-1-3/day/pr/gn/latest/pr_day_GPCP-1-3_PCMDI_gn_19961002-20170101.nc
2026-07-09 16:11:22,216 [DEBUG]: mjo_metric_calc.py(mjo_metric_ewr_calculation:256) >> Opening file: demo_data/obs4MIPs_PCMDI_daily/NASA-JPL/GPCP-1-3/day/pr/gn/latest/pr_day_GPCP-1-3_PCMDI_gn_19961002-20170101.nc
DEBUG::2026-07-09 16:11::pcmdi_metrics.mjo.lib.mjo_metric_calc:: start_year=1998, end_year=1999, NL=144, NT=180
2026-07-09 16:11:22,576 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:161) >> start_year=1998, end_year=1999, NL=144, NT=180
Converting units by  multiply 86400.0
DEBUG::2026-07-09 16:11::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Processed seasonal cycle for year 1998
2026-07-09 16:11:23,407 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:178) >> Processed seasonal cycle for year 1998
DEBUG::2026-07-09 16:11::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Computed spectrum for year 1998
2026-07-09 16:11:24,638 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:205) >> Computed spectrum for year 1998
INFO::2026-07-09 16:11::pcmdi_metrics.mjo.lib.mjo_metric_calc:: EWR=2.8125  east=0.0013  west=0.0005
2026-07-09 16:11:24,665 [INFO]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:212) >> EWR=2.8125  east=0.0013  west=0.0005
2026-07-09 16:11:24,665 [INFO]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:212) >> EWR=2.8125  east=0.0013  west=0.0005
INFO::2026-07-09 16:12::pcmdi_metrics:: Results saved to a json file: /pscratch/sd/l/lee1043/git/pcmdi_metrics/doc/jupyter/Demo/demo_output/mjo/Ex1/mjo_stat_cmip5_historical_da_atm_obs_GPCP-IP_2000-2002.json
2026-07-09 16:12:01,929 [INFO]: base.py(write:394) >> Results saved to a json file: /pscratch/sd/l/lee1043/git/pcmdi_metrics/doc/jupyter/Demo/demo_output/mjo/Ex1/mjo_stat_cmip5_historical_da_atm_obs_GPCP-IP_2000-2002.json
2026-07-09 16:12:01,929 [INFO]: base.py(write:394) >> Results saved to a json file: /pscratch/sd/l/lee1043/git/pcmdi_metrics/doc/jupyter/Demo/demo_output/mjo/Ex1/mjo_stat_cmip5_historical_da_atm_obs_GPCP-IP_2000-2002.json
INFO::2026-07-09 16:12::pcmdi_metrics:: Results saved to a json file: /pscratch/sd/l/lee1043/git/pcmdi_metrics/doc/jupyter/Demo/demo_output/mjo/Ex1/mjo_stat_cmip5_historical_da_atm_2000-2002.json
2026-07-09 16:12:37,493 [INFO]: base.py(write:394) >> Results saved to a json file: /pscratch/sd/l/lee1043/git/pcmdi_metrics/doc/jupyter/Demo/demo_output/mjo/Ex1/mjo_stat_cmip5_historical_da_atm_2000-2002.json
2026-07-09 16:12:37,493 [INFO]: base.py(write:394) >> Results saved to a json file: /pscratch/sd/l/lee1043/git/pcmdi_metrics/doc/jupyter/Demo/demo_output/mjo/Ex1/mjo_stat_cmip5_historical_da_atm_2000-2002.json
Done
 -----  GISS-E2-H  ---------------------
 ---  r6i1p1  ---
demo_data/CMIP5_demo_timeseries/historical/atmos/day/pr/pr_day_GISS-E2-H_historical_r6i1p1_20000101-20051231.nc
 --  NDJFMA  --
DEBUG::2026-07-09 16:12::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Opening file: demo_data/CMIP5_demo_timeseries/historical/atmos/day/pr/pr_day_GISS-E2-H_historical_r6i1p1_20000101-20051231.nc
2026-07-09 16:12:37,494 [DEBUG]: mjo_metric_calc.py(mjo_metric_ewr_calculation:256) >> Opening file: demo_data/CMIP5_demo_timeseries/historical/atmos/day/pr/pr_day_GISS-E2-H_historical_r6i1p1_20000101-20051231.nc
DEBUG::2026-07-09 16:12::pcmdi_metrics.mjo.lib.mjo_metric_calc:: start_year=2000, end_year=2002, NL=144, NT=180
2026-07-09 16:12:37,782 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:161) >> start_year=2000, end_year=2002, NL=144, NT=180
Converting units by  multiply 86400.0
DEBUG::2026-07-09 16:12::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Processed seasonal cycle for year 2000
2026-07-09 16:12:37,836 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:178) >> Processed seasonal cycle for year 2000
Converting units by  multiply 86400.0
DEBUG::2026-07-09 16:12::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Processed seasonal cycle for year 2001
2026-07-09 16:12:37,956 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:178) >> Processed seasonal cycle for year 2001
DEBUG::2026-07-09 16:12::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Computed spectrum for year 2000
2026-07-09 16:12:38,859 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:205) >> Computed spectrum for year 2000
DEBUG::2026-07-09 16:12::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Computed spectrum for year 2001
2026-07-09 16:12:39,618 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:205) >> Computed spectrum for year 2001
INFO::2026-07-09 16:12::pcmdi_metrics.mjo.lib.mjo_metric_calc:: EWR=4.2728  east=0.0030  west=0.0007
2026-07-09 16:12:39,644 [INFO]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:212) >> EWR=4.2728  east=0.0030  west=0.0007
2026-07-09 16:12:39,644 [INFO]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:212) >> EWR=4.2728  east=0.0030  west=0.0007
 --  MJJASO  --
DEBUG::2026-07-09 16:12::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Opening file: demo_data/CMIP5_demo_timeseries/historical/atmos/day/pr/pr_day_GISS-E2-H_historical_r6i1p1_20000101-20051231.nc
2026-07-09 16:12:39,817 [DEBUG]: mjo_metric_calc.py(mjo_metric_ewr_calculation:256) >> Opening file: demo_data/CMIP5_demo_timeseries/historical/atmos/day/pr/pr_day_GISS-E2-H_historical_r6i1p1_20000101-20051231.nc
DEBUG::2026-07-09 16:12::pcmdi_metrics.mjo.lib.mjo_metric_calc:: start_year=2000, end_year=2002, NL=144, NT=180
2026-07-09 16:12:39,961 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:161) >> start_year=2000, end_year=2002, NL=144, NT=180
Converting units by  multiply 86400.0
DEBUG::2026-07-09 16:12::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Processed seasonal cycle for year 2000
2026-07-09 16:12:40,006 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:178) >> Processed seasonal cycle for year 2000
Converting units by  multiply 86400.0
DEBUG::2026-07-09 16:12::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Processed seasonal cycle for year 2001
2026-07-09 16:12:40,065 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:178) >> Processed seasonal cycle for year 2001
DEBUG::2026-07-09 16:12::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Computed spectrum for year 2000
2026-07-09 16:12:40,882 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:205) >> Computed spectrum for year 2000
DEBUG::2026-07-09 16:12::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Computed spectrum for year 2001
2026-07-09 16:12:41,633 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:205) >> Computed spectrum for year 2001
INFO::2026-07-09 16:12::pcmdi_metrics.mjo.lib.mjo_metric_calc:: EWR=1.1739  east=0.0011  west=0.0009
2026-07-09 16:12:41,658 [INFO]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:212) >> EWR=1.1739  east=0.0011  west=0.0009
2026-07-09 16:12:41,658 [INFO]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:212) >> EWR=1.1739  east=0.0011  west=0.0009
INFO::2026-07-09 16:13::pcmdi_metrics:: Results saved to a json file: /pscratch/sd/l/lee1043/git/pcmdi_metrics/doc/jupyter/Demo/demo_output/mjo/Ex1/mjo_stat_cmip5_historical_da_atm_GISS-E2-H_r6i1p1_2000-2002.json
2026-07-09 16:13:17,633 [INFO]: base.py(write:394) >> Results saved to a json file: /pscratch/sd/l/lee1043/git/pcmdi_metrics/doc/jupyter/Demo/demo_output/mjo/Ex1/mjo_stat_cmip5_historical_da_atm_GISS-E2-H_r6i1p1_2000-2002.json
2026-07-09 16:13:17,633 [INFO]: base.py(write:394) >> Results saved to a json file: /pscratch/sd/l/lee1043/git/pcmdi_metrics/doc/jupyter/Demo/demo_output/mjo/Ex1/mjo_stat_cmip5_historical_da_atm_GISS-E2-H_r6i1p1_2000-2002.json
INFO::2026-07-09 16:13::pcmdi_metrics:: Results saved to a json file: /pscratch/sd/l/lee1043/git/pcmdi_metrics/doc/jupyter/Demo/demo_output/mjo/Ex1/mjo_stat_cmip5_historical_da_atm_2000-2002.json
2026-07-09 16:13:53,688 [INFO]: base.py(write:394) >> Results saved to a json file: /pscratch/sd/l/lee1043/git/pcmdi_metrics/doc/jupyter/Demo/demo_output/mjo/Ex1/mjo_stat_cmip5_historical_da_atm_2000-2002.json
2026-07-09 16:13:53,688 [INFO]: base.py(write:394) >> Results saved to a json file: /pscratch/sd/l/lee1043/git/pcmdi_metrics/doc/jupyter/Demo/demo_output/mjo/Ex1/mjo_stat_cmip5_historical_da_atm_2000-2002.json
Done

Command line arguments

It is also possible to use the command line to pass other arguments to the MJO driver. The command line arguments will override the settings in the parameter file.

In these example, we change a few different things. The new case_id will show up as a new folder in the result directory because of how the result_dir variable is set in the parameter file. NetCDF output and plots will be saved. The analysis start and end years for the models are changed to match the observations.

The includeOBS flag means that results will also be generated for observations, while the no_OBS flag excludes observations.

[5]:
%%bash
mjo_metrics_driver.py -p basic_mjo_param.py \
--case_id 'Ex2' \
--no_OBS \
--nc_out True \
--plot True \
--msyear 2000 \
--meyear 2005
includeOBS: False
models: ['GISS-E2-H']
realization:  r6i1p1
output directories:
graphics : demo_output/mjo/Ex2
diagnostic_results : demo_output/mjo/Ex2
metrics_results : demo_output/mjo/Ex2
CMEC: False
debug:  False
parallel: False
 -----  GISS-E2-H  ---------------------
 ---  r6i1p1  ---
demo_data/CMIP5_demo_timeseries/historical/atmos/day/pr/pr_day_GISS-E2-H_historical_r6i1p1_20000101-20051231.nc
 --  NDJFMA  --
DEBUG::2026-07-09 16:14::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Opening file: demo_data/CMIP5_demo_timeseries/historical/atmos/day/pr/pr_day_GISS-E2-H_historical_r6i1p1_20000101-20051231.nc
2026-07-09 16:14:05,510 [DEBUG]: mjo_metric_calc.py(mjo_metric_ewr_calculation:256) >> Opening file: demo_data/CMIP5_demo_timeseries/historical/atmos/day/pr/pr_day_GISS-E2-H_historical_r6i1p1_20000101-20051231.nc
DEBUG::2026-07-09 16:14::pcmdi_metrics.mjo.lib.mjo_metric_calc:: start_year=2000, end_year=2005, NL=144, NT=180
2026-07-09 16:14:05,693 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:161) >> start_year=2000, end_year=2005, NL=144, NT=180
Converting units by  multiply 86400.0
DEBUG::2026-07-09 16:14::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Processed seasonal cycle for year 2000
2026-07-09 16:14:05,767 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:178) >> Processed seasonal cycle for year 2000
Converting units by  multiply 86400.0
DEBUG::2026-07-09 16:14::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Processed seasonal cycle for year 2001
2026-07-09 16:14:05,835 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:178) >> Processed seasonal cycle for year 2001
Converting units by  multiply 86400.0
DEBUG::2026-07-09 16:14::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Processed seasonal cycle for year 2002
2026-07-09 16:14:05,933 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:178) >> Processed seasonal cycle for year 2002
Converting units by  multiply 86400.0
DEBUG::2026-07-09 16:14::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Processed seasonal cycle for year 2003
2026-07-09 16:14:06,040 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:178) >> Processed seasonal cycle for year 2003
Converting units by  multiply 86400.0
DEBUG::2026-07-09 16:14::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Processed seasonal cycle for year 2004
2026-07-09 16:14:06,167 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:178) >> Processed seasonal cycle for year 2004
DEBUG::2026-07-09 16:14::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Computed spectrum for year 2000
2026-07-09 16:14:07,221 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:205) >> Computed spectrum for year 2000
DEBUG::2026-07-09 16:14::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Computed spectrum for year 2001
2026-07-09 16:14:08,066 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:205) >> Computed spectrum for year 2001
DEBUG::2026-07-09 16:14::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Computed spectrum for year 2002
2026-07-09 16:14:08,769 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:205) >> Computed spectrum for year 2002
DEBUG::2026-07-09 16:14::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Computed spectrum for year 2003
2026-07-09 16:14:09,490 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:205) >> Computed spectrum for year 2003
DEBUG::2026-07-09 16:14::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Computed spectrum for year 2004
2026-07-09 16:14:10,216 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:205) >> Computed spectrum for year 2004
INFO::2026-07-09 16:14::pcmdi_metrics.mjo.lib.mjo_metric_calc:: EWR=1.5491  east=0.0059  west=0.0038
2026-07-09 16:14:10,241 [INFO]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:212) >> EWR=1.5491  east=0.0059  west=0.0038
2026-07-09 16:14:10,241 [INFO]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:212) >> EWR=1.5491  east=0.0059  west=0.0038
 --  MJJASO  --
DEBUG::2026-07-09 16:14::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Opening file: demo_data/CMIP5_demo_timeseries/historical/atmos/day/pr/pr_day_GISS-E2-H_historical_r6i1p1_20000101-20051231.nc
2026-07-09 16:14:11,071 [DEBUG]: mjo_metric_calc.py(mjo_metric_ewr_calculation:256) >> Opening file: demo_data/CMIP5_demo_timeseries/historical/atmos/day/pr/pr_day_GISS-E2-H_historical_r6i1p1_20000101-20051231.nc
DEBUG::2026-07-09 16:14::pcmdi_metrics.mjo.lib.mjo_metric_calc:: start_year=2000, end_year=2005, NL=144, NT=180
2026-07-09 16:14:11,222 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:161) >> start_year=2000, end_year=2005, NL=144, NT=180
Converting units by  multiply 86400.0
DEBUG::2026-07-09 16:14::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Processed seasonal cycle for year 2000
2026-07-09 16:14:11,280 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:178) >> Processed seasonal cycle for year 2000
Converting units by  multiply 86400.0
DEBUG::2026-07-09 16:14::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Processed seasonal cycle for year 2001
2026-07-09 16:14:11,334 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:178) >> Processed seasonal cycle for year 2001
Converting units by  multiply 86400.0
DEBUG::2026-07-09 16:14::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Processed seasonal cycle for year 2002
2026-07-09 16:14:11,422 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:178) >> Processed seasonal cycle for year 2002
Converting units by  multiply 86400.0
DEBUG::2026-07-09 16:14::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Processed seasonal cycle for year 2003
2026-07-09 16:14:11,523 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:178) >> Processed seasonal cycle for year 2003
Converting units by  multiply 86400.0
DEBUG::2026-07-09 16:14::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Processed seasonal cycle for year 2004
2026-07-09 16:14:11,643 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:178) >> Processed seasonal cycle for year 2004
DEBUG::2026-07-09 16:14::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Computed spectrum for year 2000
2026-07-09 16:14:12,439 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:205) >> Computed spectrum for year 2000
DEBUG::2026-07-09 16:14::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Computed spectrum for year 2001
2026-07-09 16:14:13,235 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:205) >> Computed spectrum for year 2001
DEBUG::2026-07-09 16:14::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Computed spectrum for year 2002
2026-07-09 16:14:13,975 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:205) >> Computed spectrum for year 2002
DEBUG::2026-07-09 16:14::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Computed spectrum for year 2003
2026-07-09 16:14:14,673 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:205) >> Computed spectrum for year 2003
DEBUG::2026-07-09 16:14::pcmdi_metrics.mjo.lib.mjo_metric_calc:: Computed spectrum for year 2004
2026-07-09 16:14:15,375 [DEBUG]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:205) >> Computed spectrum for year 2004
INFO::2026-07-09 16:14::pcmdi_metrics.mjo.lib.mjo_metric_calc:: EWR=0.9988  east=0.0025  west=0.0025
2026-07-09 16:14:15,400 [INFO]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:212) >> EWR=0.9988  east=0.0025  west=0.0025
2026-07-09 16:14:15,400 [INFO]: mjo_metric_calc.py(compute_mjo_ewr_from_dataset:212) >> EWR=0.9988  east=0.0025  west=0.0025
INFO::2026-07-09 16:14::pcmdi_metrics:: Results saved to a json file: /pscratch/sd/l/lee1043/git/pcmdi_metrics/doc/jupyter/Demo/demo_output/mjo/Ex2/mjo_stat_cmip5_historical_da_atm_GISS-E2-H_r6i1p1_2000-2005.json
2026-07-09 16:14:52,702 [INFO]: base.py(write:394) >> Results saved to a json file: /pscratch/sd/l/lee1043/git/pcmdi_metrics/doc/jupyter/Demo/demo_output/mjo/Ex2/mjo_stat_cmip5_historical_da_atm_GISS-E2-H_r6i1p1_2000-2005.json
2026-07-09 16:14:52,702 [INFO]: base.py(write:394) >> Results saved to a json file: /pscratch/sd/l/lee1043/git/pcmdi_metrics/doc/jupyter/Demo/demo_output/mjo/Ex2/mjo_stat_cmip5_historical_da_atm_GISS-E2-H_r6i1p1_2000-2005.json
INFO::2026-07-09 16:15::pcmdi_metrics:: Results saved to a json file: /pscratch/sd/l/lee1043/git/pcmdi_metrics/doc/jupyter/Demo/demo_output/mjo/Ex2/mjo_stat_cmip5_historical_da_atm_2000-2005.json
2026-07-09 16:15:29,546 [INFO]: base.py(write:394) >> Results saved to a json file: /pscratch/sd/l/lee1043/git/pcmdi_metrics/doc/jupyter/Demo/demo_output/mjo/Ex2/mjo_stat_cmip5_historical_da_atm_2000-2005.json
2026-07-09 16:15:29,546 [INFO]: base.py(write:394) >> Results saved to a json file: /pscratch/sd/l/lee1043/git/pcmdi_metrics/doc/jupyter/Demo/demo_output/mjo/Ex2/mjo_stat_cmip5_historical_da_atm_2000-2005.json
Done

A png image is created showing the wavenumber-frequency power spectra.

[6]:
from IPython.display import Image
Image(filename=demo_output_directory+"/mjo/Ex2/cmip5_GISS-E2-H_historical_r6i1p1_mjo_2000-2005_NDJFMA_cmmGrid.png")
[6]:
../_images/examples_Demo_5_mjo_metrics_12_0.png

You can also incorporate the public API as follows in your workflow (PMP version 4.1.1 or higher). Detailed description for the API can be found here.

[7]:
from pcmdi_metrics.mjo import compute_mjo_ewr_from_dataset