IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 27919


Ignore:
Timestamp:
May 11, 2010, 3:27:39 PM (16 years ago)
Author:
eugene
Message:

psphotStack now runs with convolved images and stack photometry

Location:
branches/eam_branches/psphot.20100506/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/psphot.20100506/src/psphot.h

    r27909 r27919  
    349349bool psphotStackImageLoop (pmConfig *config);
    350350bool psphotStackReadout (pmConfig *config, const pmFPAview *view);
    351 bool psphotStackChisqImage (pmConfig *config, const pmFPAview *view, const char *filerule);
     351bool psphotStackChisqImage (pmConfig *config, const pmFPAview *view, const char *ruleDet, const char *ruleCnv);
    352352bool psphotStackChisqImageAddReadout(const pmConfig *config, // Configuration
    353353                                     const pmFPAview *view,
     
    455455pmFPAfile *psphotStackGetConvolveSource (pmConfig *config, psphotStackOptions *options, int index);
    456456
     457bool psphotCopySources (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc);
     458bool psphotCopySourcesReadout (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc, int index);
     459
    457460#endif
  • branches/eam_branches/psphot.20100506/src/psphotMergeSources.c

    r27909 r27919  
    399399    return true;
    400400}
     401
     402// copy the detections from one pmFPAfile to another
     403bool psphotCopySources (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc)
     404{
     405    bool status = true;
     406
     407    int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
     408    psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
     409
     410    // skip the chisq image because it is a duplicate of the detection version
     411    int chisqNum = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.CHISQ.NUM");
     412    if (!status) chisqNum = -1;
     413
     414    // loop over the available readouts
     415    for (int i = 0; i < num; i++) {
     416        if (i == chisqNum) continue; // skip chisq image
     417        if (!psphotCopySourcesReadout (config, view, ruleOut, ruleSrc, i)) {
     418            psError (PSPHOT_ERR_CONFIG, false, "failed to copy sources from %s to %s entry %d", ruleSrc, ruleOut, i);
     419            return false;
     420        }
     421    }
     422    return true;
     423}
     424
     425// add newly selected sources to the existing list of sources
     426bool psphotCopySourcesReadout (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc, int index) {
     427
     428    bool status;
     429
     430    // find the currently selected readout
     431    pmFPAfile *fileSrc = pmFPAfileSelectSingle(config->files, ruleSrc, index); // File of interest
     432    psAssert (fileSrc, "missing file?");
     433
     434    pmReadout *readoutSrc = pmFPAviewThisReadout(view, fileSrc->fpa);
     435    psAssert (readoutSrc, "missing readout?");
     436
     437    pmDetections *detections = psMetadataLookupPtr (&status, readoutSrc->analysis, "PSPHOT.DETECTIONS");
     438    psAssert (detections, "missing detections?");
     439
     440    // find the currently selected readout
     441    pmFPAfile *fileOut = pmFPAfileSelectSingle(config->files, ruleOut, index); // File of interest
     442    psAssert (fileOut, "missing file?");
     443
     444    pmReadout *readoutOut = pmFPAviewThisReadout(view, fileOut->fpa);
     445    psAssert (readoutOut, "missing readout?");
     446
     447    // save detections on the readout->analysis
     448    // XXX this replaced any existing entry; allow this operation to merge?
     449    if (!psMetadataAddPtr (readoutOut->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE | PS_DATA_UNKNOWN, "psphot detections", detections)) {
     450        psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout");
     451        return false;
     452    }
     453
     454    return true;
     455}
     456
  • branches/eam_branches/psphot.20100506/src/psphotPetrosianRadialBins.c

    r27819 r27919  
    182182        psFree(values);
    183183        psFree(stats);
    184         return false;
     184        return true;
    185185    }
    186186
  • branches/eam_branches/psphot.20100506/src/psphotPetrosianStats.c

    r27819 r27919  
    1515
    1616    pmSourceRadialProfile *profile = source->extpars->petProfile;
     17
     18    if (!profile->binSB) {
     19        psLogMsg ("psphot", PS_LOG_DETAIL, "no petrosian profile, skipping source %f, %f", source->peak->xf, source->peak->yf);
     20        return true;
     21    }
    1722
    1823    psVector *binSB      = profile->binSB;
  • branches/eam_branches/psphot.20100506/src/psphotRadialBins.c

    r27819 r27919  
    4444    psVector *radMin = psMetadataLookupPtr (&status, recipe, "RADIAL.ANNULAR.BINS.LOWER");
    4545    psVector *radMax = psMetadataLookupPtr (&status, recipe, "RADIAL.ANNULAR.BINS.UPPER");
    46     if (!radMin || !radMin->n) return false;
    47     if (!radMax || !radMax->n) return false;
     46    if (!radMin || !radMin->n) {
     47        psError (PSPHOT_ERR_CONFIG, true, "error in definition of annular bins (radMin missing or empty)");
     48        return false;
     49    }
     50    if (!radMax || !radMax->n) {
     51        psError (PSPHOT_ERR_CONFIG, true, "error in definition of annular bins (radMax missing or empty)");
     52        return false;
     53    }
    4854
    4955    psVector *binSB      = psVectorAllocEmpty(radMin->n, PS_TYPE_F32); // surface brightness of radial bin
     
    155161        psFree(values);
    156162        psFree(stats);
    157         return false;
     163        return true;
    158164    }
    159165
  • branches/eam_branches/psphot.20100506/src/psphotSourceStats.c

    r27909 r27919  
    1616    psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
    1717
     18    // skip the chisq image (optionally?)
     19    // int chisqNum = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.CHISQ.NUM");
     20    // if (!status) chisqNum = -1;
     21
    1822    // loop over the available readouts
    1923    for (int i = 0; i < num; i++) {
     24        // if (i == chisqNum) continue; // skip chisq image
    2025        if (!psphotSourceStatsReadout (config, view, filerule, i, recipe, setWindow)) {
    2126            psError (PSPHOT_ERR_CONFIG, false, "failed to find initial detections for %s entry %d", filerule, i);
  • branches/eam_branches/psphot.20100506/src/psphotStackChisqImage.c

    r27909 r27919  
    66
    77// XXX supply filename or keep PSPHOT.INPUT fixed?
    8 bool psphotStackChisqImage (pmConfig *config, const pmFPAview *view, const char *filerule)
     8bool psphotStackChisqImage (pmConfig *config, const pmFPAview *view, const char *ruleDet, const char *ruleCnv)
    99{
    1010    bool status = false;
     
    2121
    2222    // loop over the available readouts
     23    // generate the chisq image from the 'detection' images
    2324    for (int i = 0; i < num; i++) {
    24         if (!psphotStackChisqImageAddReadout(config, view, filerule, &chiReadout, i)) {
    25             psError (PSPHOT_ERR_CONFIG, false, "failed to model background for %s entry %d", filerule, i);
     25        if (!psphotStackChisqImageAddReadout(config, view, ruleDet, &chiReadout, i)) {
     26            psError (PSPHOT_ERR_CONFIG, false, "failed to model background for %s entry %d", ruleDet, i);
    2627            return false;
    2728        }
     
    3536    psMetadataAddS32(config->arguments, PS_LIST_TAIL, "PSPHOT.INPUT.NUM", PS_META_REPLACE, "", num);
    3637
    37     // save the resulting image
    38     if (!psMetadataAddPtr(config->files, PS_LIST_TAIL, filerule, PS_DATA_UNKNOWN | PS_META_DUPLICATE_OK, "", chisqFile)) {
     38    // save the resulting image in the 'detection' set
     39    if (!psMetadataAddPtr(config->files, PS_LIST_TAIL, ruleDet, PS_DATA_UNKNOWN | PS_META_DUPLICATE_OK, "", chisqFile)) {
     40        psError(PM_ERR_CONFIG, false, "could not add chisqFPA to config files");
     41        return false;
     42    }
     43
     44    // save the resulting image in the 'convolved' set
     45    if (!psMetadataAddPtr(config->files, PS_LIST_TAIL, ruleCnv, PS_DATA_UNKNOWN | PS_META_DUPLICATE_OK, "", chisqFile)) {
    3946        psError(PM_ERR_CONFIG, false, "could not add chisqFPA to config files");
    4047        return false;
  • branches/eam_branches/psphot.20100506/src/psphotStackReadout.c

    r27909 r27919  
    3939    // generate a background model (median, smoothed image)
    4040    // XXX I think this is not defined correctly for an array of images.
     41    // XXX probably need to subtract the model (same model?) for both RAW and OUT
    4142    if (!psphotModelBackground (config, view, STACK_RAW)) {
    4243        return psphotReadoutCleanup (config, view, STACK_OUT);
     
    5657    }
    5758
    58     if (!psphotStackChisqImage(config, view, STACK_RAW)) {
     59    if (!psphotStackChisqImage(config, view, STACK_RAW, STACK_OUT)) {
    5960        psError (PSPHOT_ERR_UNKNOWN, false, "failure to generate chisq image");
    6061        return psphotReadoutCleanup (config, view, STACK_OUT);
     
    6869    if (!psphotFindDetections (config, view, STACK_RAW, true)) { // pass 1
    6970        // this only happens if we had an error in psphotFindDetections
     71        psError (PSPHOT_ERR_UNKNOWN, false, "failure in peak analysis");
     72        return psphotReadoutCleanup (config, view, STACK_OUT);
     73    }
     74
     75    // XXX do this now or below?
     76    // remove chisq image from config->file:PSPHOT.INPUT (why?)
     77    // psphotStackRemoveChisqFromInputs(config, STACK_RAW);
     78
     79    // copy the detections from RAW to OUT
     80    if (!psphotCopySources (config, view, STACK_OUT, STACK_RAW)) {
    7081        psError (PSPHOT_ERR_UNKNOWN, false, "failure in peak analysis");
    7182        return psphotReadoutCleanup (config, view, STACK_OUT);
     
    170181    psphotSourceFreePixels (config, view, STACK_OUT);
    171182
     183    // XXX do this now or above?
    172184    // remove chisq image from config->file:PSPHOT.INPUT (why?)
    173185    psphotStackRemoveChisqFromInputs(config, STACK_RAW);
Note: See TracChangeset for help on using the changeset viewer.