IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 15, 2009, 6:41:32 PM (16 years ago)
Author:
eugene
Message:

rework how the psf is passed around so that we are sure we get it from the right psphot run

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091201/ppSub/src/ppSubReadoutPhotometry.c

    r26264 r26432  
    2424bool ppSubReadoutPhotometry(const char *name, ppSubData *data)
    2525{
     26    bool mdok = false;
     27
    2628    psAssert(data, "Require processing data");
    2729    pmConfig *config = data->config;    // Configuration
     
    4244    }
    4345
    44     // The PSF (measured in ppSubMakePSF) is stored on the chip->analysis of PSPHOT.INPUT
    45     // In order to use an incoming PSF, it must be stored on the chip->analysis of PSPHOT.PSF.LOAD
     46    // select the view of interest
    4647    pmFPAview *view = ppSubViewReadout(); // View to readout
    47     pmChip *psfInputChip = pmFPAfileThisChip(config->files, view, "PSPHOT.INPUT"); // Chip with PSF
    48     psAssert (psfInputChip, "should have been generated for ppSubMakePSF");
    49     pmChip *psfLoadChip = pmFPAfileThisChip(config->files, view, "PSPHOT.PSF.LOAD"); // Chip to have PSF
    50     psAssert (psfLoadChip, "PSPHOT.PSF.LOAD should have been defined in ppSubCamera");
    51     pmPSF *psf = psMetadataLookupPtr(NULL, psfInputChip->analysis, "PSPHOT.PSF"); // PSF for photometry
    52     if (!psf) {
    53         psErrorStackPrint(stderr, "No PSF available");
    54         psWarning("No PSF available --- suspect bad data quality.");
    55         ppSubDataQuality(data, psErrorCodeLast(), PPSUB_FILES_PHOT_SUB | PPSUB_FILES_PHOT_INV);
    56         return true;
    57     }
    58     psMetadataAddPtr(psfLoadChip->analysis, PS_LIST_TAIL, "PSPHOT.PSF", PS_DATA_UNKNOWN | PS_META_REPLACE,
    59                      "PSF from ppSubMakePSF", psf);
    60 
    61     bool mdok = false;
    6248
    6349    // psphotReadoutMinimal performs the photometry analysis on PSPHOT.INPUT; we need to move
    64     // around the pointers so PSPHOT.INPUT corresponds to the output image; previously, it was
    65     // equivalent to the minuend image.
    66     pmReadout *inRO = pmFPAfileThisReadout(config->files, view, name); // Readout with image and sources
    67     if (psMetadataLookup(inRO->analysis, "PSPHOT.SOURCES")) {
    68         psMetadataRemoveKey(inRO->analysis, "PSPHOT.SOURCES");
    69     }
    70 
     50    // around the pointers so PSPHOT.INPUT corresponds to the output image of interest (on one
     51    // pass this is the subtraction image, in another it is negative of the subtraction
    7152    pmFPAfile *photFile = psMetadataLookupPtr(&mdok, config->files, "PSPHOT.INPUT"); // Photometry file
    7253    pmFPAfile *inFile = psMetadataLookupPtr(&mdok, config->files, name); // Input file
     
    7657        return false;
    7758    }
     59
     60    // drop references to PSPHOT.SOURCES on both of these  (why is this needed for both??)
    7861    pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout to photometer
    7962    if (psMetadataLookup(photRO->analysis, "PSPHOT.SOURCES")) {
    8063        psMetadataRemoveKey(photRO->analysis, "PSPHOT.SOURCES");
    8164    }
     65    pmReadout *inRO = pmFPAfileThisReadout(config->files, view, name); // Readout with image and sources
     66    if (psMetadataLookup(inRO->analysis, "PSPHOT.SOURCES")) {
     67        psMetadataRemoveKey(inRO->analysis, "PSPHOT.SOURCES");
     68    }
    8269
    83     psMetadataAddPtr(photRO->parent->parent->analysis, PS_LIST_TAIL, "PSPHOT.PSF",
    84                      PS_META_REPLACE | PS_DATA_UNKNOWN, "Point-spread function", data->psf);
    85 
    86     psFree(photRO->analysis);
    87     photRO->analysis = psMetadataAlloc();
     70    // grab the PSF information from the pmFPAfile PSPHOT.PSF.LOAD
     71    pmFPAfile *psfFile = psMetadataLookupPtr(&mdok, config->files, "PSPHOT.PSF.LOAD"); // PSF file
     72    ppSubCopyPSF (photFile, psfFile, view);
    8873
    8974    // psphotSaveImage (photFile->fpa->hdu->header, photRO->image, "findsrc.im.fits");
    9075    // psphotSaveImage (photFile->fpa->hdu->header, photRO->variance, "findsrc.wt.fits");
    9176    // psphotSaveImage (photFile->fpa->hdu->header, photRO->mask, "findsrc.mk.fits");
     77
     78    // erase the overlays from a previous psphot-related step
     79    if (pmVisualIsVisual()) {
     80        psphotVisualEraseOverlays (1, "all");
     81    }
    9282
    9383    if (!psphotReadoutMinimal(config, view)) {
     
    126116            return false;
    127117        }
     118        if (!psMetadataCopySingle(inRO->analysis, photRO->analysis, PM_DETEFF_ANALYSIS)) {
     119            psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to copy Detection Efficiency");
     120            return false;
     121        }
    128122    }
    129123
     
    133127    return true;
    134128}
    135 
    136 
    137 
    138 
    139129
    140130#ifdef TESTING
Note: See TracChangeset for help on using the changeset viewer.