# include "psphotInternal.h"

// load an externally supplied psf model
pmPSF *psphotLoadPSF (pmConfig *config, pmFPAview *view, psMetadata *recipe) {

    // find the currently selected readout
    pmReadout  *readout = pmFPAfileThisReadout (config->files, view, "PSPHOT.LOAD.PSF");
    if (!readout) return NULL;

    // check if a PSF model is supplied by the user
    pmPSF *psf = psMetadataLookupPtr (NULL, readout->analysis, "PSPHOT.PSF");
    if (psf == NULL) {
	psLogMsg ("psphot", 3, "no psf supplied for this readout");
	return NULL;
    }

    if (!psphotPSFstats (readout, recipe, psf)) psAbort("cannot measure PSF shape terms");
    return psf;
}
