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 withinds(for example,"pr").start_year (
intorNone, optional) – First year of the analysis window, inclusive. Default isNone, in which case the year is inferred from the dataset’s first time step.end_year (
intorNone, optional) – Last year of the analysis window, inclusive. Default isNone, 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) – IfTrue, regrid to a commondeg_xxdeg_xgrid before spectral analysis. Default isFalse.deg_x (
float, optional) – Grid spacing in degrees used whencmm_gridisTrue. Default is2.5.units_adjust (
tupleorNone, optional) – Passed directly topcmdi_metrics.utils.adjust_units(). Default isNone, which skips unit conversion.segment_length (
int, optional) – Number of time steps per segment. Default is180, 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
seasonis invalid or if the dataset does not cover the requested analysis window.