Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.mso.anu.edu.au/~mwhite/pynifs-doc/pynifs.velfit-class.html
Дата изменения: Unknown
Дата индексирования: Fri Feb 28 01:50:38 2014
Кодировка:

Поисковые слова: annular solar eclipse
pynifs.velfit
Module pynifs :: Class velfit
[hide private]
[frames] | no frames]

Class velfit

source code


A class to hold information by fitting multi-component Gaussians to a
NIFS data cube.

Attributes:
restwavl -  The rest wavelength used to determine line velocities.
vmin -      The minimum velocity value used for generating the spectrum to
            fit to.
vmax -      The maximum velocity value used for generating the spectrum to
            fit to.
scidata -   The scidata from the fitscube, trimmed down so that it only
            includes the data between vmin and vmax
vars -      The variance array from the fitscube, trimmed down to the
            velocity range of interest
dq -        The DQ pixel quality array from the fitscube, trimmed down to
            the velocity range of interest
uncertest - A 2D masked array, of the same shape as the last two axes of
            scidata, which contains the uncertainty estimate for each
            spaxel. This uncertainty estimate is derived by determining the
            1-sigma standard deviation of the science data in the original
            data cube, just outside the region of interest.
xpts -      The x-coordinates from the nifscube
ypts -      The y-coordinates from the nifscube
vpts -      The z-coordinates from the nifscube, re-expressed as km/s
            velocities.
fitno -     A 2D masked array, of the same shape as the last two axes of
            scidata, which holds the optimal number of components fit to
            each spaxel. This has been determined by a statistical F-test.
fitorig -   A 2D masked array, of the same shape as fitno. This is a copy
            of fitno, recorded BEFORE any masking if performed (i.e. by
            maskFits.)
dof -       A 2D masked array, of the same shape as the spatial axes of
            scidata, holding lists of length fitmax. Holds the degrees of
            freedom (dof) for each spaxel when fit with a number of
            Gaussian components, up to (and including) fitmax components.
            For example, the dof for a one-Gaussian fit to a given spaxel
            will be given by dof[j,i][0].
chisq -     As for dof, however, it holds the chi-squared value (NOT
            REDUCED) for each fit to the spaxel.
fits -      A 2D masked array, of the same shape as scidata, holding the
            fit information for each spaxel. The elements of fits take the
            form of a list. The first element will be the fit parameters
            corresponding to a one-Gaussian fit, the next the parameters
            for a two-Gaussian fit, and so on.
perror -    As for fits, but holding the formal perror covariance matrix
            values for each fit.
ftestlim -  The maximum value allowed for an F-test ratio to be before the
            P-value is taken. Defaults to 1.4.
ftestp -    The maximum P-value permitted for two fits to be considered
            statistically different under the F-test. Defaults to 0.05 (5%).
            
Methods:
fitVelSpax -    Computes a multi-dimensional Gaussian fit to one particular
                spaxel.
plotSpaxSpec -  Display the data, and fit components, for a particular
                spaxel.

Instance Methods [hide private]
 
__init__(self) source code
 
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)
Compute a multi-component Gaussian fit to spaxel x=i, y=j in the velfits instance.
source code
 
maskFits(self, i, j, snthresh=5)
'Mask' spaxel if signal-to-noise is under the specified value.
source code
 
maskPix(self, i, j, k)
Mask a particular pixel in the velfit instance.
source code
 
remask(self, snthresh=5)
Apply maskFits to every spaxel in the velfit instances.
source code
 
plotSpaxSpec(self, i, j, linewidth=2, plotpeak=True, highres=False, plotresid=True, rsf=0.2, ms=5, arcsecs=False)
Plot the spectrum of a given spaxel, along with any fits made.
source code
 
plotImg(self, z=100, colorbar=True, colormap=matplotlib.cm.jet, log=False, edged=False)
Plots a pseudocolor image of the specified parameter in the velfit instance.
source code
 
sumCube(self)
Sums over the velocity range of the cube, and save the result to the summed array.
source code
 
sumFitFlux(self)
Collapse the fluxes and fluxerr arrays to represent total flux, summed over all components that have been fit.
source code
 
returnFTestInfo(self, i, j)
Returns the F-test information for all fits made to spaxel (i,j).
source code
 
returnInfo(self, i, j, comps, info)
Returns fit information (e.g.
source code
 
returnFitInfo(self, i, j, comps, info)
Returns a particular fit parameter for a given spaxel.
source code
 
genInfoArray(self, info)
Generates a masked array of fit information, as returned by returnInfo.
source code
 
genFitInfoArray(self, info)
Generates a masked array of fit parameters, as returned by returnFitInfo.
source code
 
save(self, filename=None)
Save the current velfit to file.
source code
 
findVIndex(self, v)
Find the spaxel index corresponding to the given velocity value.
source code
Method Details [hide private]

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.

maskFits(self, i, j, snthresh=5)

source code 

'Mask' spaxel if signal-to-noise is under the specified value. By
'mask', the no. of fits recorded for that spaxel will be set to 0.
Signal-to-noise is determined as the ratio of the peak flux value
recorded in the spaxel to the corresponding error of that data point.

Inputs:
i, j     -  Spaxel x- and y- indices, respectively.
snthresh -  The S/N threshold value. Any spaxels with an S/N less than this
            value will be 'masked'. Defaults to 7.5.
            
Returns:
Nil. fitvels instance is updated in-situ.

maskPix(self, i, j, k)

source code 

Mask a particular pixel in the velfit instance.

Inputs: i, j, k - The pixel's x-, y- and spectral indices respectively.

Returns: Nil. The velfit instance is updated in-situ.

remask(self, snthresh=5)

source code 

Apply maskFits to every spaxel in the velfit instances.

Inputs: snthresh - The S/N threshold for masking. Defaults to 5.

Returns: Nil. fitvels instance updated in-situ.