Modeling Module (cwitools.modeling)

The modeling module contains wrappers for common models (e.g. Gaussian, Moffat and Voigt profiles) which facilitate model fitting using SciPy’s differential_evolution (scipy.optimize.differential_evolution), a stochastic optimizer which is useful for well-bounded fitting scenarios. It also contains wrappers to fit these models to data, and wrappers for the Akaike and Bayesian information criteria (AIC and BIC) to facilitate model comparison.

Tools for model fitting, evaluation and comparison

Functions

aic(model, data, k) Calculate the Akaike Information Criterion for a model.
bic(model, data, k) Calculate the Bayesian Information Criterion for a model.
bic_weights(bic_list) Get weights representing relative likelihood of models based on BICs.
covar_curve(params, ksizes) Two-component model to describe increase in noise due to covariance
doublet(params, x, peaks) Fittable doublet (Gaussian) emission line profile.
exp1d(params, r) 1D Exponential profile in the form f(parameters, r)
fit_model1d(model_func, model_bounds, x, y, …) Wrapper for fitting a 1D model using SciPy’s differential evolution.
fit_model2d(model_func, model_bounds, xx, yy, zz) Fit a Gaussian or Moffat PSF
fwhm2sigma(fwhm) Convert Gaussian FWHM (Full-Width at Half Maximum) to standard deviation.
gauss1d(params, x) 1D Gaussian profile in the form f(parameters, x)
gauss2d(params, xx, yy) General 2D Gaussian profile in the form f(parameters, x)
gauss2d_sym(params, xx, yy) Symmetric 2D Gaussian profile in the form f(parameters, x)
moffat1d(params, x) 1D Moffat profile in the form f(parameters, x)
moffat2d(params, xx, yy) 2D Moffat profile in the form f(parameters, x)
powlaw1d(params, r) 1D Power-law profile in the form f(parameters, r)
rss(data, model) Get the residual sum of squares for a model and data.
rss_func1d(model_params, model_func, x, y, …) Calculate the residual sum of squares for a 1D model + 1D data.
rss_func2d(model_params, model_func, xx, yy, zz) Calculate the residual sum of squares for a 2D model + 2D data.
sersic1d(params, r) 1D Sersic profile in the form f(parameters, r)
sigma2fwhm(sigma) Convert standard deviation to FWHM (Full-Width at Half Maximum).
voigt1d