fitVelSpax(self,
i,
j,
comps=1,
fixno=False,
ignoreamp=False,
quiet=False,
params=None,
vlim=None,
wmin=10.0,
wpercent=0.1,
wperspace=0.25,
wmaxcut=50.0,
alim=None,
fixbg=False,
snthresh=5)
| source code
|
Compute a multi-component Gaussian fit to spaxel x=i, y=j in the velfits
instance. Modifies the velfits instance in place.
If params are not provided, the function uses the following algorithm
to produce initial guesses:
- Make a copy of the spaxel data
- Find the highest data value within the range defined by vlim, use to
give guess velocity shift and amplitude
- Compute estimate for line width
- Find nearest point to peak <= half the guess amplitude, compute
where the line between the that point, and the next point
towards the peak, is = half the guess amplitude
- If the next point towards the peak is masked, use the line
between the peak and the half-amplitude point instead
- Compute the maximum allowed width for this fitted line, based on the
guess velocity centroid
- If guess width is above this value, adjust guess to 5.0 km/s
below max allowed value
- If guess width is below wmin, adjust guess to 5.0 km/s above max
allowed value
- Subtract the guessed Gaussian profile from copy of spaxel data
- Repeat the procedure until there are enough guess parameters to fit
comps components
Inputs:
velfits - The velfits instance to be acted upon.
i - The x-index of the spaxel to be fitted.
j - The y-index of the spaxel to be fitted.
comps - The number of Gaussian components to fit to the spaxel
spectrum. Defaults to 1.
fixno - Boolean value denoting whether to force the spectrum to be
fit with comps components (True), or to incrementally try a
number of components from 1 to comps, stopping when the
limiting reduced chi-squared is acheived (False). Defaults
to False.
ignoreamp - Boolean value specifying whether to consider the nifscube's
stated amplitude limit when fitting. Defaults to False (any
fits not conforming to the limit will be considered bad).
quiet - Boolean value denoting whether or not the MPFIT fitting
routine should be quiet or not. Defaults to False.
params - Fitting parameters to be passed to the fitting routine.
Intended for use when the automatic paramter finder produces
unacceptable results. Requires fixno = True.
Takes the form of a list composed of
[background, amplitude, shift, width, amplitude....].
Defaults to None (at which point the
automatic first-guess finding will be used.)
vlim - A two-element list giving the minimum and maximum values
allowed for ALL component centroids in the fits, in units
of km/s. Defaults to None (where the minimum and maximum
velocities present in the fitvels instance will be used as
the limits.
wmin - The minimum allowed line sigma to be fit. Note this does NOT
represent a FWHM value. Defaults to 10.0
wpercent - The percentage of total line intensity allowed to be on the
opposite side of v=0 to the line peak. Used to calculate an
upper limit on the fitted line width. Must be a float
between 0.0 and 1.0. Defaults to 0.10.
wperspace - Expected percentage error on the initial guess for the line
centroid velocity. Used in the calculation of maximum
allowed fitted line width. Must be a float between 0.0 and
1.0. Defaults to 0.25.
wmaxcut - Lower limit on maximum allowed fitted line width. Avoids the
initial guess routine from trying to fit peaks of noise.
Defaults to 50.0 km/s.
alim - A two-element list giving the minimum and maximum values
allowed for the amplitude of ALL fit components, in units
km/s. Defaults to None (at which point, the amplitudes
will only be limited to be positive).
fixbg - Boolean value, specifying if the background height of the
fits should be forced to 0.0 (True) or not. Defaults to
False.
snthresh - Signal-to-noise threshold - if spaxel is below this
threshold, fits will still be made, but fitno[j,i] will then
be set to 0 afterwards. Masking calculated by the
maskFits function.
Returns:
Nil. The velfits instance is updated in place. The fit information for
the i-th, j-th pixel will be updated as follows:
If fixno = False, the fit information for the first multi-component
fit that satisfies the rchisqlim for this velfits instance will be
recorded. If all fits, up to and including the comps-component fit,
do not satisfy this limit, no fit info (and empty list) will be
recorded.
If fixno = True, then the fit will be made blindly and recorded,
with no regard to the reduced chi-squared limit.
|