IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 5, 2010, 1:38:43 PM (16 years ago)
Author:
eugene
Message:

updates to psphot APIs to enable stack photometry

Location:
branches/eam_branches/20091201/psphot
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091201/psphot

  • branches/eam_branches/20091201/psphot/src/psphotLoadPSF.c

    r18002 r26788  
    11# include "psphotInternal.h"
    22
     3// NOTE : pmPSF_IO.c functions must load the psf model onto the chip->analysis metadata because
     4// the I/O operation likely occurs before the readout exists.  This implementation assumes that
     5// a single psf model is valid for the entire set of readouts (not valid for a time series of readouts)
     6
     7// XXX for now (2010.01.27), the supporting programs do not define multiple PSPHOT.PSF.LOAD
     8// files to go with multiple PSPHOT.INPUT files.  as a result, the implementation below is
     9// currently going to work for the case of a single input file, but will fail if we try with a
     10// stack of images.
     11
    312// load an externally supplied psf model
    4 pmPSF *psphotLoadPSF (pmConfig *config, const pmFPAview *view, psMetadata *recipe) {
     13bool psphotLoadPSFReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index) {
     14
     15    bool status;
     16
     17    // find the currently selected readout
     18    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
     19    psAssert (file, "missing file?");
    520
    621    // find the currently selected chip
    7     pmChip *chip = pmFPAfileThisChip (config->files, view, "PSPHOT.PSF.LOAD");
    8     if (!chip) return NULL;
     22    pmChip *chip = pmFPAviewThisChip (view, file->fpa);
     23    if (!chip) return false;
    924
    1025    // find the currently selected readout
    11     pmReadout *readout = pmFPAfileThisReadout (config->files, view, "PSPHOT.PSF.LOAD");
    12     if (!readout) return NULL;
     26    pmReadout *readout = pmFPAviewThisReadout (view, file->fpa);
     27    if (!readout) return false;
    1328
    1429    // check if a PSF model is supplied by the user
    15     pmPSF *psf = psMetadataLookupPtr (NULL, chip->analysis, "PSPHOT.PSF");
     30    pmPSF *psf = psMetadataLookupPtr (&status, chip->analysis, "PSPHOT.PSF");
    1631    if (psf == NULL) {
    1732        psLogMsg ("psphot", 3, "no psf supplied for this chip");
    18         return NULL;
     33        return true;
    1934    }
    2035
    21     if (!psphotPSFstats (readout, recipe, psf)) psAbort("cannot measure PSF shape terms");
     36    if (!psphotPSFstats (readout, psf)) {
     37        psAbort("cannot measure PSF shape terms");
     38    }
    2239
    2340    psLogMsg ("psphot", 3, "using externally supplied PSF model for this readout");
    2441
    25     // we return a psf which can be free (and which may be removed from the metadata)
    26     psMemIncrRefCounter (psf);
    27     return psf;
     42    // save PSF on readout->analysis
     43    if (!psMetadataAddPtr (readout->analysis, PS_LIST_TAIL, "PSPHOT.PSF", PS_META_REPLACE | PS_DATA_UNKNOWN, "psphot psf model", psf)) {
     44        psError (PSPHOT_ERR_UNKNOWN, false, "problem saving sources on readout");
     45        return false;
     46    }
     47
     48    return true;
    2849}
     50
     51bool psphotLoadPSF (pmConfig *config, const pmFPAview *view) {
     52
     53    bool status = false;
     54
     55    // XXX PSPHOT.PSF.LOAD vs PSPHOT.INPUT -- see note at top
     56    int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
     57    psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     58
     59    // loop over the available readouts
     60    for (int i = 0; i < num; i++) {
     61
     62        // Generate the mask and weight images, including the user-defined analysis region of interest
     63        if (!psphotLoadPSFReadout (config, view, "PSPHOT.PSF.LOAD", i)) {
     64            psError (PSPHOT_ERR_CONFIG, false, "failed to load PSF model for PSPHOT.PSF.LOAD entry %d", i);
     65            return false;
     66        }
     67    }
     68    return true;
     69}
Note: See TracChangeset for help on using the changeset viewer.