IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 20, 2010, 2:30:45 PM (16 years ago)
Author:
watersc1
Message:

Attempting to bring branch in sync with trunk

Location:
branches/czw_branch/20101203
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20101203

  • branches/czw_branch/20101203/ppSub/src/ppSubLoop.c

    r29003 r30118  
    3636    psAssert(config, "Require configuration.");
    3737
     38    bool success = true;
     39
    3840    pmConfigCamerasCull(config, NULL);
    3941    pmConfigRecipesCull(config, "PPSUB,PPSTATS,PSPHOT,PSASTRO,MASKS,JPEG");
     
    5759    }
    5860
     61    if (data->forcedPhot1) {
     62        bool foundDetections = false;
     63        if (!ppSubInputDetections(&foundDetections, "PPSUB.POS1.SOURCES", "PPSUB.INPUT", data)) {
     64            psError(psErrorCodeLast(), false, "Unable to measure positive detections (1)");
     65            success = false;
     66            goto ESCAPE;
     67        }
     68        // if nothing was found, don't bother doing the forced photometry below
     69        if (!foundDetections) {
     70            psWarning ("no sources found in positive image 1, skipping forced photometry");
     71            data->forcedPhot1 = false;
     72        }
     73    }
     74    if (data->forcedPhot2) {
     75        // Change the recipe to use a higher nsigma limit and quit after pass1
     76        psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, PSPHOT_RECIPE);
     77
     78        psF32 nsigma_peak_save = psMetadataLookupF32 (NULL, recipe, "PEAKS_NSIGMA_LIMIT");
     79        char *breakPt_save =  psMetadataLookupStr (NULL, recipe, "BREAK_POINT");
     80
     81        bool mdok;
     82        psF32 pos2_nsigma_peak = psMetadataLookupF32 (&mdok, recipe, "PEAKS_POS2_NSIGMA_LIMIT");
     83        if (!mdok) {
     84            psWarning("PEAKS_POS2_NSIGMA_LIMIT not found in recipe. Will use 25.\n");
     85            pos2_nsigma_peak = 25.;
     86        }
     87        psMetadataAddF32(recipe, PS_LIST_TAIL, "PEAKS_NSIGMA_LIMIT", PS_META_REPLACE, "", pos2_nsigma_peak);
     88        psMetadataAddStr(recipe, PS_LIST_TAIL, "BREAK_POINT", PS_META_REPLACE, "", "PASS1");
     89
     90        bool foundDetections = false;
     91        if (!ppSubInputDetections(&foundDetections, "PPSUB.POS2.SOURCES", "PPSUB.REF", data)) {
     92            psError(psErrorCodeLast(), false, "Unable to measure positive detections (2)");
     93            psMetadataAddF32(recipe, PS_LIST_TAIL, "PEAKS_NSIGMA_LIMIT", PS_META_REPLACE, "", nsigma_peak_save);
     94            psMetadataAddStr(recipe, PS_LIST_TAIL, "BREAK_POINT", PS_META_REPLACE, "", breakPt_save);
     95            success = false;
     96            goto ESCAPE;
     97        }
     98        psMetadataAddF32(recipe, PS_LIST_TAIL, "PEAKS_NSIGMA_LIMIT", PS_META_REPLACE, "", nsigma_peak_save);
     99        psMetadataAddStr(recipe, PS_LIST_TAIL, "BREAK_POINT", PS_META_REPLACE, "", breakPt_save);
     100        // if nothing was found, don't bother doing the forced photometry below
     101        if (!foundDetections) {
     102            psWarning ("no sources found in positive image 2, skipping forced photometry");
     103            data->forcedPhot2 = false;
     104        }
     105    }
     106
     107    // XXX if it exists, use the POS1, POS2 successs for the FWHMs
    59108    if (!ppSubMatchPSFs(data)) {
    60109        psError(psErrorCodeLast(), false, "Unable to match PSFs.");
    61         return false;
     110        success = false;
     111        goto ESCAPE;
    62112    }
    63113    if (data->quality) {
    64114        // Can't do anything at all
    65         return true;
     115        success = false;
     116        goto ESCAPE;
    66117    }
    67118    // generate the residual stamp grid for visualization
    68119    if (!ppSubResidualSampleJpeg(config)) {
    69120        psError(psErrorCodeLast(), false, "Unable to update.");
    70         return false;
    71     }
     121        success = false;
     122        goto ESCAPE;
     123    }
     124
     125    // XXX add in a positive image detection step here (if needed)
     126   
    72127
    73128    psMetadataAddF32(data->stats, PS_LIST_TAIL, "TIME_MATCH", 0, "Time to match PSFs",
     
    77132    if (!ppSubFilesIterateUp(config, PPSUB_FILES_INPUT)) {
    78133        psError(PPSUB_ERR_IO, false, "Unable to close input files.");
    79         return false;
     134        success = false;
     135        goto ESCAPE;
    80136    }
    81137
    82138    if (!ppSubLowThreshold(data)) {
    83139        psError(psErrorCodeLast(), false, "Unable to threshold images.");
    84         return false;
     140        success = false;
     141        goto ESCAPE;
    85142    }
    86143
     
    88145    if (!ppSubFilesIterateDown(config, PPSUB_FILES_SUB)) {
    89146        psError(PPSUB_ERR_IO, false, "Unable to set up subtraction files.");
    90         return false;
     147        success = false;
     148        goto ESCAPE;
    91149    }
    92150
    93151    if (!ppSubDefineOutput("PPSUB.OUTPUT", config)) {
    94152        psError(psErrorCodeLast(), false, "Unable to define output.");
    95         return false;
     153        success = false;
     154        goto ESCAPE;
    96155    }
    97156
    98157    if (!data->quality && !ppSubMakePSF(data)) {
    99158        psError(psErrorCodeLast(), false, "Unable to generate PSF.");
    100         return false;
     159        success = false;
     160        goto ESCAPE;
    101161    }
    102162
     
    113173    if (!ppSubReadoutSubtract(config)) {
    114174        psError(psErrorCodeLast(), false, "Unable to subtract images.");
    115         return false;
     175        success = false;
     176        goto ESCAPE;
    116177    }
    117178    // dumpout(config, "diff.1.fits");
     
    120181    if (!ppSubFilesIterateUp(config, PPSUB_FILES_PSF | PPSUB_FILES_CONV)) {
    121182        psError(PPSUB_ERR_IO, false, "Unable to close input files.");
    122         return false;
     183        success = false;
     184        goto ESCAPE;
    123185    }
    124186    // dumpout(config, "diff.2a.fits");
     
    127189    if (!ppSubBackground(config)) {
    128190        psError(psErrorCodeLast(), false, "Unable to subtract background.");
    129         return false;
     191        success = false;
     192        goto ESCAPE;
    130193    }
    131194    // dumpout(config, "diff.2b.fits");
     
    134197    if (!ppSubVarianceRescale(config, data)) {
    135198        psError(psErrorCodeLast(), false, "Unable to rescale variance.");
    136         return false;
     199        success = false;
     200        goto ESCAPE;
    137201    }
    138202    // dumpout(config, "diff.2c.fits");
     
    140204    if (data->quality) {
    141205        // Done all we can do up to this point
    142         return true;
     206        success = false;
     207        goto ESCAPE;
    143208    }
    144209
    145210    if (!ppSubFilesIterateDown(config, PPSUB_FILES_PHOT_SUB)) {
    146211        psError(PPSUB_ERR_IO, false, "Unable to set up photometry files.");
    147         return false;
     212        success = false;
     213        goto ESCAPE;
    148214    }
    149215
    150216    if (!data->quality && !ppSubReadoutPhotometry("PPSUB.OUTPUT", data)) {
    151217        psError(psErrorCodeLast(), false, "Unable to perform photometry.");
    152         return false;
     218        success = false;
     219        goto ESCAPE;
    153220    }
    154221    // dumpout(config, "diff.3.fits");
     222
     223    // forced photometry for positive image 1
     224    if (data->forcedPhot1 && !data->quality) {
     225        if (!ppSubReadoutForcedPhot("PPSUB.FORCED1.SOURCES", "PPSUB.OUTPUT", "PPSUB.POS1.SOURCES", data)) {
     226            psError(psErrorCodeLast(), false, "Unable to perform photometry.");
     227            success = false;
     228            goto ESCAPE;
     229        }
     230    }
     231
     232    // forced photometry for positive image 2
     233    if (data->forcedPhot2 && !data->quality) {
     234        if (!ppSubReadoutForcedPhot("PPSUB.FORCED2.SOURCES", "PPSUB.OUTPUT", "PPSUB.POS2.SOURCES", data)) {
     235            psError(psErrorCodeLast(), false, "Unable to perform photometry.");
     236            success = false;
     237            goto ESCAPE;
     238        }
     239    }
    155240
    156241    if (!ppSubFilesIterateUp(config, PPSUB_FILES_PHOT_SUB)) {
    157242        psError(PPSUB_ERR_IO, false, "Unable to set up photometry files.");
    158         return false;
     243        success = false;
     244        goto ESCAPE;
    159245    }
    160246
     
    162248    if (!ppSubReadoutStats(data)) {
    163249        psError(psErrorCodeLast(), false, "Unable to collect statistics");
    164         return false;
     250        success = false;
     251        goto ESCAPE;
    165252    }
    166253    // Do Mask Stats
     
    169256      if (!ppSubMaskStats(config, view,data->stats)) {
    170257        psError(psErrorCodeLast(), false, "Unable to generate mask statistics");
    171         return(false);
     258        success = false;
     259        goto ESCAPE;
    172260      }
    173261    }
     
    177265    if (!ppSubReadoutJpeg(config)) {
    178266        psError(psErrorCodeLast(), false, "Unable to update.");
    179         return false;
     267        success = false;
     268        goto ESCAPE;
    180269    }
    181270
     
    184273        if (!ppSubFilesIterateDown(config, PPSUB_FILES_INV)) {
    185274            psError(PPSUB_ERR_IO, false, "Unable to set up inverse files.");
    186             return false;
     275            success = false;
     276            goto ESCAPE;
    187277        }
    188278
    189279        if (data->inverse && !ppSubDefineOutput("PPSUB.INVERSE", config)) {
    190280            psError(psErrorCodeLast(), false, "Unable to define inverse.");
    191             return false;
     281            success = false;
     282            goto ESCAPE;
    192283        }
    193284
    194285        if (!ppSubReadoutInverse(config)) {
    195286            psError(psErrorCodeLast(), false, "Unable to invert images.");
    196             return false;
     287            success = false;
     288            goto ESCAPE;
    197289        }
    198290
     
    200292        if (!ppSubFilesIterateUp(config, PPSUB_FILES_SUB)) {
    201293            psError(PPSUB_ERR_IO, false, "Unable to close subtraction files.");
    202             return false;
     294            success = false;
     295            goto ESCAPE;
    203296        }
    204297
    205298        if (!ppSubFilesIterateDown(config, PPSUB_FILES_PHOT_INV)) {
    206299            psError(PPSUB_ERR_IO, false, "Unable to set up inverse files.");
    207             return false;
     300            success = false;
     301            goto ESCAPE;
    208302        }
    209303
    210304        if (!data->quality && !ppSubReadoutPhotometry("PPSUB.INVERSE", data)) {
    211305            psError(psErrorCodeLast(), false, "Unable to perform photometry.");
    212             return false;
     306            success = false;
     307            goto ESCAPE;
    213308        }
    214309
     
    216311        if (!ppSubFilesIterateUp(config, PPSUB_FILES_INV | PPSUB_FILES_PHOT_INV)) {
    217312            psError(PPSUB_ERR_IO, false, "Unable to close subtraction files.");
    218             return false;
     313            success = false;
     314            goto ESCAPE;
    219315        }
    220316    } else {
     
    223319        if (!ppSubFilesIterateUp(config, PPSUB_FILES_SUB)) {
    224320            psError(PPSUB_ERR_IO, false, "Unable to close subtraction files.");
    225             return false;
    226         }
    227     }
    228 
    229     return true;
     321            success = false;
     322            goto ESCAPE;
     323        }
     324    }
     325
     326ESCAPE:
     327    pmFPAfileDropInternal(config->files, "PSPHOT.BACKGND");
     328    pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL");
     329    pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL.STDEV");
     330
     331    return success;
    230332}
Note: See TracChangeset for help on using the changeset viewer.