API reference

This page provides an auto-generated summary of mesmers’ API.

Top-level functions

Train mesmer

train_gt(var, targ, esm, time, cfg[, ...])

Derive global trend (emissions + volcanoes) parameters from specified ensemble type with specified method.

train_gv(gv, targ, esm, cfg[, save_params])

Derive global variability parameters for a specified method.

train_lt(preds, targs, esm, cfg[, save_params])

Derive local trends (i.e., forced response) parameters for given ESM for given set of targets and predictors.

train_lv(preds, targs, esm, cfg[, ...])

Derive local variability (i.e., natural variabiliy) parameters.

Create emulations

create_emus_gt(params_gt, preds_gt, cfg[, ...])

Create global trend (emissions + volcanoes) emulations for specified ensemble type and method.

create_emus_gv(params_gv, preds_gv, cfg[, ...])

Create global variablity emulations for specified method.

create_emus_lt(params_lt, preds_lt, cfg[, ...])

Create local trends (i.e., forced response) emulations for given parameter set and predictors.

create_emus_lv(params_lv, preds_lv, cfg[, ...])

Create local variablity emulations.

create_emus_g(emus_gt, emus_gv, params_gt, ...)

Merge global trend and global variability emulations of the same scenarios.

create_emus_l(emus_lt, emus_lv, params_lt, ...)

Merge local trends and local variability temperature emulations of the same scenarios and targets.

make_realisations(preds_lt, params_lt, ...)

Make climate realisations based on pre-calculated MESMER parameters

Individual methods and utils

Train mesmer

train_gv_AR(params_gv, gv, max_lag, sel_crit)

Derive AR parameters of global variability under the assumption that gv does not depend on the scenario.


Derive smooth global trend of variable from single ESM ic ensemble with LOWESS smoother.

train_gt_ic_OLSVOLC(var, gt_lowess, time, cfg)

Derive global trend (emissions + volcanoes) parameters from single ESM ic ensemble by adding volcanic spikes to LOWESS trend.

train_lv_AR1_sci(params_lv, targs, y, ...)

Derive parameters for AR(1) process with spatially-correlated innovations.

train_lv_find_localized_ecov(y, wgt_scen_eq, ...)

Find suitable localization radius for empirical covariance matrix and derive localized empirical cov matrix.

train_l_prepare_X_y_wgteq(preds, targs)

Create single array of predictors, single array of targets, and single array of weights.

Create emulations

create_emus_gv_AR(params_gv, nr_emus_v, ...)

Draw global variablity emulations from an AR process.

create_emus_OLS_each_gp_sep(params_lt, ...)

Create local trends with OLS with grid-point-specific predictors

create_emus_lv_AR1_sci(emus_lv, params_lv, ...)

Create local variablity emulations with AR(1) process with spatially-correlated innovations.

create_emus_lv_OLS(params_lv, preds_lv)

Create local variablity emulations with OLS.


Load CMIP-ng data


Extract time, longitude, latitude, and 3d weights from file from ETHZ cmip-ng archive.

find_files_cmipng(gen, esm, var, scenario, ...)

Find filname in ETHZ cmip-ng archive.

load_cmipng(targ, esm, scen, cfg)

Load ESM runs from cmip-ng archive at ETHZ.

load_cmipng_file(run_path, gen, scen)

Load file in ETHZ cmip-ng archive.

load_cmipng_hfds(esm, scen, cfg)

Load ESM hfds runs from cmip-ng archive at ETHZ.

load_cmipng_tas(esm, scen, cfg)

Load ESM tas runs from cmip-ng archive at ETHZ.


Preprocess datasets to manage to combine historical, ssp585, and ssp534-over into single time series.

Load constant files


smooth, exponentially decaying Gaspari-Cohn correlation function

infer_interval_breaks(x, y[, clip])

Find edges of gridcells, given their centers.

load_phi_gc(lon, lat, ls, cfg[, L_start, ...])

Loads or creates (if not available yet) distance matrix and Gaspari-Cohn correlation matrix.

load_regs_ls_wgt_lon_lat(reg_type, lon, lat)

Load constant files.

mask_percentage(regions, lon, lat)

Sample with 10 times higher resolution.

Load constant files

load_mesmer_output(name, cfg[, method_str, ...])

Load saved MESMER output (parameters or emulations).

Load observations

load_obs(targ, prod, lon, lat, cfg[, ...])

Load observations which you previously downloaded.

load_obs_tblend(prod, lon, lat, cfg, sel_ref)

Load spatially infilled tblend observations.

load_strat_aod(time, dir_obs)

Load observed global stratospheric aerosol optical depth time series.

Save mesmer bundle

save_mesmer_bundle(bundle_file, params_lt, ...)

Save all the information required to draw MESMER emulations to disk



Convert dictionary to array.

separate_hist_future(var_c, time_c, cfg)

Separate historical and future time periods into separate keys in dictionary.

extract_land(var, reg_dict, wgt, ls[, ...])

Extract all land grid points and area weights in regions and in land-sea mask for given threshold.

extract_time_period(var, time, start, end)

Extract selected time period.