pipecal_fitpeak

sofia_redux.calibration.pipecal_fitpeak.pipecal_fitpeak(image, profile='moffat', estimates=None, bounds=None, error=None, bestnorm=True)[source]

Fit a peak profile to a 2D image.

Using scipy’s curve_fit, fit either a 2D elliptical Gaussian, Lorentzian, or Moffat function to the image.

Parameters:
image2D numpy array

The image to fit a profile to.

profile{‘gaussian’, ‘lorentzian’, ‘moffat’}, optional

Name of function to fit.

estimatesdictionary, optional

Initial estimates of fitting parameters. Keys should include:

  • baseline : background flux level

  • dpeak : peak value of the image

  • col_mean : col coordinate location of peak

  • row_mean : row coordinate location of peak

  • col_sigma : width of function in col direction

  • row_sigma : width of function in row direction

  • theta : angle function is rotated from column axis

  • beta : power law index of Moffat function. Ignored for Gaussian and Lorentzian fits.

If not provided, generic estimates are generated based on image.

boundsdictionary, optional

The limits of parameters for the fits. Must have the same keys as estimates. Each value should be a two element array-like containing the lower and upper limits of the parameter. To not impose a limit, set it to +/- inf. If not provided, reasonable default bounds are used.

error2D numpy array, optional

Array with the 1-sigma uncertainties of each pixel in image. Must be the same shape as image.

bestnormboolean, optional

Set to return the summed square weighted residuals for the best-fit parameters. Defaults to True.

Returns:
fit_paramdictionary

A dictionary containing the best fit paramters. Has the same keys as estimates.

fit_errsdictionary

A dictionary containing the 1-sigma uncertainities on the best fit parameters. Has the same keys as estimates.

bestnormfloat

The summed squared weighted residuals for the best-fit parameters. Set to None if bestnorm is False.

Raises:
PipeCalError

If a provided input is not valid.