#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

# include "psphot.h"

bool psphotMagnitudes (psArray *sources, psMetadata *recipe, pmPSF *psf) {

    bool status = false;
    int Nap = 0;

    psTimerStart ("psphot");

    pmSourceMagnitudesInit (recipe);

    for (int i = 0; i < sources->n; i++) {
	pmSource *source = (pmSource *) sources->data[i];
	status = pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_APCORR | PM_SOURCE_PHOT_WEIGHT);
	// status = pmSourceMagnitudes (source, psf, PM_SOURCE_PHOT_GROWTH | PM_SOURCE_PHOT_APCORR);
	if (status) Nap ++;
    }	

    psLogMsg ("psphot.magnitudes", 4, "measure magnitudes : %f sec for %ld objects (%d with apertures)\n", psTimerMark ("psphot"), sources->n, Nap);
    return true;
}

// XXX add in a measurement of the bright and faint completeness values
// XXX push these into the recipe
