fit_model

petrofit.modeling.fit_model(image, model, weights=None, fitter=<class 'astropy.modeling.fitting.TRFLSQFitter'>, maxiter=5000, calc_uncertainties=False, epsilon=1.4901161193847656e-08, acc=1e-07, estimate_jacobian=False)[source]

Wrapper function to conveniently fit an image to an input model.

Parameters:
imagearray

2D array to fit.

modelFittableModel

Astropy model to sample from. The model must be 2D and the inputs are (x, y) pixel coordinates.

weightsarray

Weights for fitting. For data with Gaussian uncertainties, the weights should be 1/sigma.

fitterAstropy Fitter Class

Astropy fitter class (TRFLSQFitter, LevMarLSQFitter, or LinearLSQFitter)

maxiterint

maximum number of iterations

calc_uncertaintiesbool

If the covarience matrix should be computed and set in the fit_info. Default: False

epsilonfloat

A suitable step length for the forward-difference approximation of the Jacobian (if model.fjac=None). If epsfcn is less than the machine precision, it is assumed that the relative errors in the functions are of the order of the machine precision.

accfloat

Relative error desired in the approximate solution

estimate_jacobianbool

If False (default) and if the model has a fit_deriv method, it will be used. Otherwise the Jacobian will be estimated. If True, the Jacobian will be estimated in any case.

Returns:
fitted_model, fitter
  • fitted_modelFittableModel

    A copy of the input model with parameters set by the fitter.

  • fitterLevMarLSQFitter

    Fitter used to estimate and set model parameters.