/* @file  pmSourceFitSet.h
 *
 * @author EAM, IfA; GLG, MHPCC
 *
 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
 * @date $Date: 2007-11-10 01:09:20 $
 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
 */

# ifndef PM_SOURCE_FIT_SET_H
# define PM_SOURCE_FIT_SET_H

/// @addtogroup Objects Object Detection / Analysis Functions
/// @{

typedef struct {
    psArray *modelSet;
    psArray *paramSet;
    psArray *derivSet;
    int nParamSet;
} pmSourceFitSetData;

// initialize data for a group of object models
pmSourceFitSetData *pmSourceFitSetDataAlloc (psArray *modelSet);
bool psMemCheckSourceFitSetData(psPtr ptr);

// function used to set limits for a group of models
bool pmSourceFitSetCheckLimits (psMinConstraintMode mode, int nParam, float *params, float *betas);

bool pmSourceFitSetJoin (psVector *deriv, psVector *param, pmSourceFitSetData *set);
bool pmSourceFitSetSplit (pmSourceFitSetData *set, const psVector *deriv, const psVector *param);
bool pmSourceFitSetValues (pmSourceFitSetData *set, const psVector *dparam, const psVector *param, pmSource *source, psMinimization *myMin, int nPix, bool fitStatus);

psF32 pmSourceFitSetFunction(psVector *deriv, const psVector *param, const psVector *x);
bool pmSourceFitSetMasks (psMinConstraint *constraint, pmSourceFitSetData *set, pmSourceFitMode mode);

/** 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
    psMaskType maskVal                  ///< Vale to mask

);

bool pmSourcePrintModelSet (FILE *file, psArray *modelSet);
bool pmSourceFitSetPrint (FILE *file, pmSourceFitSetData *set);

/// @}
# endif /* PM_SOURCE_FIT_MODEL_H */
