IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 34266


Ignore:
Timestamp:
Jul 31, 2012, 6:17:31 PM (14 years ago)
Author:
bills
Message:

Add function to copy detection efficiency data from one readout
to another. To be used in psphotStack

Location:
trunk/psphot/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphot.h

    r34258 r34266  
    436436bool psphotCopySources (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc);
    437437bool psphotCopySourcesReadout (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc, int index);
     438bool psphotCopyEfficiency (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc);
     439bool psphotCopyEfficiencyReadout (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc, int index);
    438440
    439441bool psphotRadialApertures (pmConfig *config, const pmFPAview *view, const char *filerule, int entry);
  • trunk/psphot/src/psphotMergeSources.c

    r33910 r34266  
    939939}
    940940
     941bool psphotCopyEfficiency (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc)
     942{
     943    bool status = true;
     944
     945    int num = psphotFileruleCount(config, ruleSrc);
     946
     947    // skip the chisq image because it is a duplicate of the detection version
     948    int chisqNum = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.CHISQ.NUM");
     949    if (!status) chisqNum = -1;
     950
     951    // loop over the available readouts
     952    for (int i = 0; i < num; i++) {
     953        if (i == chisqNum) continue; // skip chisq image
     954        if (!psphotCopyEfficiencyReadout (config, view, ruleOut, ruleSrc, i)) {
     955            psError (PSPHOT_ERR_CONFIG, false, "failed to copy detection efficiency from %s to %s entry %d", ruleSrc, ruleOut, i);
     956            return false;
     957        }
     958    }
     959    return true;
     960}
     961
     962// add newly selected sources to the existing list of sources
     963bool psphotCopyEfficiencyReadout (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc, int index) {
     964
     965    bool status;
     966
     967    // find the currently selected readout
     968    pmFPAfile *fileSrc = pmFPAfileSelectSingle(config->files, ruleSrc, index); // File of interest
     969    psAssert (fileSrc, "missing file?");
     970
     971    pmReadout *readoutSrc = pmFPAviewThisReadout(view, fileSrc->fpa);
     972    psAssert (readoutSrc, "missing readout?");
     973
     974    // find the currently selected readout
     975    pmFPAfile *fileOut = pmFPAfileSelectSingle(config->files, ruleOut, index); // File of interest
     976    psAssert (fileOut, "missing file?");
     977
     978    pmReadout *readoutOut = pmFPAviewThisReadout(view, fileOut->fpa);
     979    psAssert (readoutOut, "missing readout?");
     980
     981    pmDetEff *de = psMetadataLookupPtr(&status, readoutSrc->analysis, PM_DETEFF_ANALYSIS); // Detection efficiency
     982    if (!status || !de) {
     983        // nothing there
     984        return true;
     985    }
     986
     987    // save DetEff on the readoutOut->analysis
     988    if (!psMetadataAddPtr (readoutOut->analysis, PS_LIST_TAIL, PM_DETEFF_ANALYSIS, PS_META_REPLACE | PS_DATA_UNKNOWN, "Detection efficiency", de)) {
     989        psError (PSPHOT_ERR_CONFIG, false, "problem saving Detection efficiency on readout");
     990        return false;
     991    }
     992
     993    return true;
     994}
  • trunk/psphot/src/psphotStackReadout.c

    r34226 r34266  
    416416    psphotMagnitudes(config, view, STACK_SRC);
    417417
    418     // XXX NOTE: this function wants to have the PSF of the image, but we (so far) only measure the
    419     // PSF of the SRC image.  can we fake it by generating the PSF for DET as well (up above)?
    420     if (false && !psphotEfficiency(config, view, STACK_DET)) {
     418    if (!useRaw) {
     419        // psphotEfficiency wants to have the PSF of the image, but since we are measuring on
     420        // the convolved images we need to generate PSFs for the DET images
     421        if (!psphotChoosePSF (config, view, STACK_DET, false)) { // pass 1
     422            psLogMsg ("psphot", 3, "failure to construct a psf model for raw input");
     423            return psphotReadoutCleanup (config, view, STACK_DET);
     424        }
     425    }
     426    if (!psphotEfficiency(config, view, STACK_DET)) {
    421427        psErrorStackPrint(stderr, "Unable to determine detection efficiencies from fake sources");
    422428        psErrorClear();
    423429    }
     430    psphotCopyEfficiency (config, view, STACK_OUT, STACK_DET);
    424431
    425432    // replace failed sources?
Note: See TracChangeset for help on using the changeset viewer.