marginal_fits

threadcount.fit.marginal_fits(fit_list, choices, flux=0.25, dmu=0.5)[source]

Determine which fits should be inspected by hand.

We noticed at times that when fitting multiple gaussians, there was often a case of an “embedded” gaussian. This is when a small flux narrow gaussian was fit at the same center wavelength as the highest flux gaussian. This function is intended to identify those cases and ask the user to verify that this is actually the desired fit.

This function analyzes the selected model (provided by the combination of fit_list and choices), and determines if user inspection is needed based on the relative characteristics of the gaussians. This procedure depends on the analyzed components having parameter names ending in “flux” and “center”, and was originally programmed to analyze a multi-gaussian model. Note that (“amplitude” is used as a fallback for “flux”, because lmfit’s gaussian use this name to denote integrated flux).

The “main” gaussian is selected as the model component with highest flux, lets call this main gaussian g0. For the other components g#, we compute g#_flux/g0_flux and g#_center - g0_center. If any component has both the following:

  • g#_flux/g0_flux < flux

  • g#_center - g0_center < dmu

then that fit will be flagged for examination.

Parameters:
  • fit_list (array-like of lmfit.model.ModelResult) – This assumes a spatial array (n,m) of ModelResults, with an outer dimension varying in the model used for that spaxel. e.g. shape = (3,n,m) for 3 different models.

  • choices (array-like of shape fit_list[0] containing int) – This will be used to select which model for a given spaxel will be analyzed in this function. For example, if there are 3 models, the value for choices must be 1,2,or 3 (or negative to indicate invalid).

  • flux (float, optional) – The gaussian flux ratio to main gaussian component indicating that this should be inspected by hand, by default 0.25

  • dmu (float, optional) – dmu in my head meant delta mu, the change in the x center between a gaussian component and the main gaussian, by default 0.5.

Returns:

Array of same shape as choices, where True means the user should inspect this spaxel’s fit, and False means this spaxel should be okay with the automatic guessing.

Return type:

numpy array of boolean