/** @file  pmSourcePhotometry.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_PHOTOMETRY_H
# define PM_SOURCE_PHOTOMETRY_H

/**
 *
 * The function returns both the magnitude of the fit, defined as -2.5log(flux),
 * where the flux is integrated under the model, theoretically from a radius of 0
 * to infinity. In practice, we integrate the model beyond 50sigma.  The aperture magnitude is
 * defined as -2.5log(flux) , where the flux is summed for all pixels which are
 * not excluded by the aperture mask. The model flux is calculated by calling the
 * model-specific function provided by pmModelFlux_GetFunction.
 *
 * XXX: must code this.
 *
 */

typedef enum {
    PM_SOURCE_PHOT_NONE   = 0x0000,
    PM_SOURCE_PHOT_GROWTH = 0x0001,
    PM_SOURCE_PHOT_APCORR = 0x0002,
    PM_SOURCE_PHOT_WEIGHT = 0x0004,
} pmSourcePhotometryMode;

bool pmSourcePhotometryModel(
    float *fitMag,                      ///< integrated fit magnitude
    pmModel *model                      ///< model used for photometry
);

bool pmSourcePhotometryAper(
    float   *apMag,                     ///< aperture flux magnitude
    pmModel *model,                     ///< model used for photometry
    psImage *image,                     ///< image pixels to be used
    psImage *mask                       ///< mask of pixels to ignore
);

bool pmSourceMagnitudesInit (psMetadata *config);
bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode);
float pmSourceCrossProduct (pmSource *Mi, pmSource *Mj);
float pmSourceCrossWeight (pmSource *Mi, pmSource *Mj);
bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask);

# endif /* PM_SOURCE_PHOTOMETRY_H */
