mesmer.stats.fit_harmonic_model#
- mesmer.stats.fit_harmonic_model(yearly_predictor, monthly_target, *, max_order=6, time_dim='time')#
fit harmonic model i.e. a Fourier Series to every gridcell using BIC score to select the order and least squares to fit the coefficients for each order.
- Parameters:
yearly_predictor (xr.DataArray) – Yearly values used as predictors, containing one value per year. Contains time_dim and possibly additional dimensions for example for gridcells or members.
monthly_target (xr.DataArray) – Monthly values to fit to, containing one value per month, for every year in yearly_predictor (starting with January). So n_months = 12 \(\cdot\) n_years. Must contain time_dim and possibly additional dimensions as yearly_predictor.
max_order (Integer, default 6) – Maximum order of Fourier Series to fit for. Default is 6 since highest meaningful maximum order is sample_frequency/2, i.e. 12/2 to fit for monthly data.
time_dim (str, default: “time”) – Name of the time dimension on yearly_predictor and monthly_target.
- Returns:
data_vars (xr.Dataset) – Dataset containing
the selected order of Fourier Series (selected_order),
the estimated coefficients of the Fourier Series (coeffs), and
the residuals of the model (residuals).