IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 10, 2010, 7:36:29 PM (16 years ago)
Author:
eugene
Message:

updates from eam_branches/20091201 (substantially changes to the psphotReadout APIs to support future stack photometry; improvements to the CR masking code)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotLoadPSF.c

    r18002 r26894  
    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 *outFilename, const char *inFilename, int index) {
     14
     15    bool status;
     16
     17    // find the currently selected readout
     18    pmFPAfile *inFile = pmFPAfileSelectSingle(config->files, inFilename, index); // File of interest
     19    if (inFile == NULL) {
     20        psLogMsg ("psphot", 3, "no psf supplied for this chip");
     21        return true;
     22    }
     23
     24    // find the currently selected readout
     25    pmFPAfile *outFile = pmFPAfileSelectSingle(config->files, outFilename, index); // File of interest
     26    if (outFile == NULL) {
     27        psLogMsg ("psphot", 3, "no psf supplied for this chip");
     28        return true;
     29    }
    530
    631    // find the currently selected chip
    7     pmChip *chip = pmFPAfileThisChip (config->files, view, "PSPHOT.PSF.LOAD");
    8     if (!chip) return NULL;
     32    pmChip *chip = pmFPAviewThisChip (view, inFile->fpa);
     33    if (!chip) return false;
    934
    1035    // find the currently selected readout
    11     pmReadout *readout = pmFPAfileThisReadout (config->files, view, "PSPHOT.PSF.LOAD");
    12     if (!readout) return NULL;
     36    pmReadout *readout = pmFPAviewThisReadout (view, outFile->fpa);
     37    if (!readout) return false;
    1338
    1439    // check if a PSF model is supplied by the user
    15     pmPSF *psf = psMetadataLookupPtr (NULL, chip->analysis, "PSPHOT.PSF");
     40    pmPSF *psf = psMetadataLookupPtr (&status, chip->analysis, "PSPHOT.PSF");
    1641    if (psf == NULL) {
    1742        psLogMsg ("psphot", 3, "no psf supplied for this chip");
    18         return NULL;
     43        return true;
    1944    }
    2045
    21     if (!psphotPSFstats (readout, recipe, psf)) psAbort("cannot measure PSF shape terms");
     46    if (!psphotPSFstats (readout, psf)) {
     47        psAbort("cannot measure PSF shape terms");
     48    }
    2249
    2350    psLogMsg ("psphot", 3, "using externally supplied PSF model for this readout");
    2451
    25     // we return a psf which can be free (and which may be removed from the metadata)
    26     psMemIncrRefCounter (psf);
    27     return psf;
     52    // save PSF on readout->analysis
     53    if (!psMetadataAddPtr (readout->analysis, PS_LIST_TAIL, "PSPHOT.PSF", PS_META_REPLACE | PS_DATA_UNKNOWN, "psphot psf model", psf)) {
     54        psError (PSPHOT_ERR_UNKNOWN, false, "problem saving sources on readout");
     55        return false;
     56    }
     57
     58    return true;
    2859}
     60
     61bool psphotLoadPSF (pmConfig *config, const pmFPAview *view) {
     62
     63    bool status = false;
     64
     65    // XXX PSPHOT.PSF.LOAD vs PSPHOT.INPUT -- see note at top
     66    int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
     67    psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     68
     69    // loop over the available readouts
     70    for (int i = 0; i < num; i++) {
     71
     72        // Generate the mask and weight images, including the user-defined analysis region of interest
     73        if (!psphotLoadPSFReadout (config, view, "PSPHOT.INPUT", "PSPHOT.PSF.LOAD", i)) {
     74            psError (PSPHOT_ERR_CONFIG, false, "failed to load PSF model for PSPHOT.PSF.LOAD entry %d", i);
     75            return false;
     76        }
     77    }
     78    return true;
     79}
Note: See TracChangeset for help on using the changeset viewer.