/** @file  pmSourceFitModel.h
 *
 *  @author EAM, IfA; GLG, MHPCC
 *
 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
 *  @date $Date: 2006-04-17 18:01:05 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
 *
 */

# ifndef PM_SOURCE_FIT_MODEL_H
# define PM_SOURCE_FIT_MODEL_H

typedef enum {
    PM_SOURCE_FIT_NORM,
    PM_SOURCE_FIT_PSF,
    PM_SOURCE_FIT_EXT,
    PM_SOURCE_FIT_PSF_AND_SKY,
    PM_SOURCE_FIT_EXT_AND_SKY
} pmSourceFitMode;

bool pmSourceFitModelInit(
    float nIter,   ///< max number of allowed iterations
    float tol,      ///< convergence criterion
    bool poissonErrors   // use poisson errors for fits?
);

/** pmSourceFitModel()
 *
 * Fit the requested model to the specified source. The starting guess for the model is given
 * by the input source.model parameter values. The pixels of interest are specified by the
 * source.pixels and source.mask entries. This function calls psMinimizeLMChi2() on the image
 * data. The function returns TRUE on success or FALSE on failure.
 *
 */
bool pmSourceFitModel(
    pmSource *source,   ///< The input pmSource
    pmModel *model,   ///< model to be fitted
    pmSourceFitMode mode  ///< define parameters to be fitted
);


// initialize data for a group of object models
bool pmModelFitSetInit (pmModelType type);

// clear data for a group of object models
void pmModelFitSetClear (void);

// function used to fit a group of object models
psF32 pmModelFitSet(psVector *deriv,
                    const psVector *params,
                    const psVector *x);

/** pmSourceFitSet()
 *
 * Fit the requested model to the specified source. The starting guess for the model is given
 * by the input source.model parameter values. The pixels of interest are specified by the
 * source.pixels and source.mask entries. This function calls psMinimizeLMChi2() on the image
 * data. The function returns TRUE on success or FALSE on failure.
 *
 */
bool pmSourceFitSet(
    pmSource *source,   ///< The input pmSource
    psArray *modelSet,   ///< model to be fitted
    pmSourceFitMode mode  ///< define parameters to be fitted
);

# endif /* PM_SOURCE_FIT_MODEL_H */
