pcmdi_metrics.mjo.compute_mjo_ewr_from_dataset

pcmdi_metrics.mjo.compute_mjo_ewr_from_dataset(ds, data_var, start_year=None, end_year=None, season='NDJFMA', cmm_grid=False, deg_x=2.5, units_adjust=None, segment_length=180)[source]

Compute the MJO east-west power ratio from an open xarray Dataset.

This is the pure-computation entry point. It performs no file I/O, writes no output files, and produces no plots. Suitable for use in Jupyter notebooks, pipelines, and unit tests.

Parameters:
  • ds (xr.Dataset) – Daily precipitation or OLR dataset. Must be CF-compliant with latitude, longitude, and a recognized time coordinate.

  • data_var (str) – Name of the variable to analyze within ds (for example, "pr").

  • start_year (int or None, optional) – First year of the analysis window, inclusive. Default is None, in which case the year is inferred from the dataset’s first time step.

  • end_year (int or None, optional) – Last year of the analysis window, inclusive. Default is None, in which case the year is inferred from the dataset’s last time step.

  • season ({"NDJFMA", "MJJASO"}, optional) – Season used to extract yearly segments. Default is "NDJFMA".

  • cmm_grid (bool, optional) – If True, regrid to a common deg_x x deg_x grid before spectral analysis. Default is False.

  • deg_x (float, optional) – Grid spacing in degrees used when cmm_grid is True. Default is 2.5.

  • units_adjust (tuple or None, optional) – Passed directly to pcmdi_metrics.utils.adjust_units(). Default is None, which skips unit conversion.

  • segment_length (int, optional) – Number of time steps per segment. Default is 180, which is 180 days for daily input data. Must be even.

Returns:

dict – Dictionary containing: - east_power: eastward power - west_power: westward power - east_west_power_ratio: east/west power ratio - analysis_time_window_start_year: resolved start year - analysis_time_window_end_year: resolved end year - _oee: intermediate output power spectrum object for downstream plotting or diagnostics

Raises:

ValueError – If season is invalid or if the dataset does not cover the requested analysis window.