IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 16, 2011, 10:48:28 AM (14 years ago)
Author:
eugene
Message:

ppSubMakePSF needs to copy the detections from the input cmf file source to the detection image (minuend) if no convolution is selected (if convolution is selected, this operation takes place in ppSubMatchPSFs before the psf match is done)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppSub/src/ppSubLoop.c

    r31435 r32676  
    2323bool dumpout(pmConfig *config, char *name)
    2424{
    25   pmFPAview *view = ppSubViewReadout(); // View to readout
    26   pmReadout *out = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT");
    27   psphotSaveImage (NULL, out->image, name);
    28   psFree(view);
    29   return true;
     25    pmFPAview *view = ppSubViewReadout(); // View to readout
     26    pmReadout *out = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT");
     27    psphotSaveImage (NULL, out->image, name);
     28    psFree(view);
     29    return true;
    3030}
    3131
     
    3333bool ppSubLoop(ppSubData *data)
    3434{
     35    bool mdok = false;
     36    bool success = true;
     37
    3538    psAssert(data, "Require processing data");
    3639    pmConfig *config = data->config;    // Configuration
    3740    psAssert(config, "Require configuration.");
    3841
    39     bool success = true;
     42    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSim
     43    psAssert(recipe, "We checked this earlier, so it should be here.");
     44    bool noConvolve = psMetadataLookupBool(&mdok, recipe, "NOCONVOLVE"); // Do not use convolved images.
    4045
    4146    pmConfigCamerasCull(config, NULL);
    4247    pmConfigRecipesCull(config, "PPSUB,PPSTATS,PSPHOT,PSASTRO,MASKS,JPEG");
    43 
    4448
    4549    pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PPSUB.INPUT");
     
    7579    if (data->forcedPhot2) {
    7680        // Change the recipe to use a higher nsigma limit and quit after pass1
    77         psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, PSPHOT_RECIPE);
    78 
    79         psF32 nsigma_peak_save = psMetadataLookupF32 (NULL, recipe, "PEAKS_NSIGMA_LIMIT");
    80         char *breakPt_save =  psMetadataLookupStr (NULL, recipe, "BREAK_POINT");
    81 
    82         bool mdok;
    83         psF32 pos2_nsigma_peak = psMetadataLookupF32 (&mdok, recipe, "PEAKS_POS2_NSIGMA_LIMIT");
     81        psMetadata *psphotRecipe = psMetadataLookupPtr (NULL, config->recipes, PSPHOT_RECIPE);
     82
     83        psF32 nsigma_peak_save = psMetadataLookupF32 (NULL, psphotRecipe, "PEAKS_NSIGMA_LIMIT");
     84        char *breakPt_save =  psMetadataLookupStr (NULL, psphotRecipe, "BREAK_POINT");
     85
     86        psF32 pos2_nsigma_peak = psMetadataLookupF32 (&mdok, psphotRecipe, "PEAKS_POS2_NSIGMA_LIMIT");
    8487        if (!mdok) {
    85             psWarning("PEAKS_POS2_NSIGMA_LIMIT not found in recipe. Will use 25.\n");
     88            psWarning("PEAKS_POS2_NSIGMA_LIMIT not found in psphotRecipe. Will use 25.\n");
    8689            pos2_nsigma_peak = 25.;
    8790        }
    88         psMetadataAddF32(recipe, PS_LIST_TAIL, "PEAKS_NSIGMA_LIMIT", PS_META_REPLACE, "", pos2_nsigma_peak);
    89         psMetadataAddStr(recipe, PS_LIST_TAIL, "BREAK_POINT", PS_META_REPLACE, "", "PASS1");
     91        psMetadataAddF32(psphotRecipe, PS_LIST_TAIL, "PEAKS_NSIGMA_LIMIT", PS_META_REPLACE, "", pos2_nsigma_peak);
     92        psMetadataAddStr(psphotRecipe, PS_LIST_TAIL, "BREAK_POINT", PS_META_REPLACE, "", "PASS1");
    9093
    9194        bool foundDetections = false;
    9295        if (!ppSubInputDetections(&foundDetections, "PPSUB.POS2.SOURCES", "PPSUB.REF", data)) {
    9396            psError(psErrorCodeLast(), false, "Unable to measure positive detections (2)");
    94             psMetadataAddF32(recipe, PS_LIST_TAIL, "PEAKS_NSIGMA_LIMIT", PS_META_REPLACE, "", nsigma_peak_save);
    95             psMetadataAddStr(recipe, PS_LIST_TAIL, "BREAK_POINT", PS_META_REPLACE, "", breakPt_save);
    96             success = false;
    97             goto ESCAPE;
    98         }
    99         psMetadataAddF32(recipe, PS_LIST_TAIL, "PEAKS_NSIGMA_LIMIT", PS_META_REPLACE, "", nsigma_peak_save);
    100         psMetadataAddStr(recipe, PS_LIST_TAIL, "BREAK_POINT", PS_META_REPLACE, "", breakPt_save);
     97            psMetadataAddF32(psphotRecipe, PS_LIST_TAIL, "PEAKS_NSIGMA_LIMIT", PS_META_REPLACE, "", nsigma_peak_save);
     98            psMetadataAddStr(psphotRecipe, PS_LIST_TAIL, "BREAK_POINT", PS_META_REPLACE, "", breakPt_save);
     99            success = false;
     100            goto ESCAPE;
     101        }
     102        psMetadataAddF32(psphotRecipe, PS_LIST_TAIL, "PEAKS_NSIGMA_LIMIT", PS_META_REPLACE, "", nsigma_peak_save);
     103        psMetadataAddStr(psphotRecipe, PS_LIST_TAIL, "BREAK_POINT", PS_META_REPLACE, "", breakPt_save);
    101104        // if nothing was found, don't bother doing the forced photometry below
    102105        if (!foundDetections) {
     
    107110
    108111    // XXX if it exists, use the POS1, POS2 successs for the FWHMs
    109     psMetadata *recipe = psMetadataLookupPtr(NULL, config->recipes, PPSUB_RECIPE);
    110     bool noConvolve = psMetadataLookupBool(NULL, recipe, "NOCONVOLVE"); // Do not use convolved images.
    111     if (noConvolve) {
    112       psWarning("not matching PSFs because NOCONVOLVE is TRUE\n");
    113     } else {
    114       if (!ppSubMatchPSFs(data)) {
    115         psError(psErrorCodeLast(), false, "Unable to match PSFs.");
    116         success = false;
    117         goto ESCAPE;
    118       }
    119     }
    120 
     112    if (!ppSubMatchPSFs(data)) {
     113        psError(psErrorCodeLast(), false, "Unable to match PSFs.");
     114        success = false;
     115        goto ESCAPE;
     116    }
    121117
    122118    if (data->quality) {
     
    138134                     psTimerClear("PPSUB_MATCH"));
    139135
    140     // Close input files
     136    // Close input files (freeing up space) : for the noConvolve case, we cannot close the
     137    // inputs since we will use them for subtraction below.  wait until later to do the work
    141138    if (!noConvolve) {
    142     if (!ppSubFilesIterateUp(config, PPSUB_FILES_INPUT)) {
    143         psError(PPSUB_ERR_IO, false, "Unable to close input files.");
    144         success = false;
    145         goto ESCAPE;
    146     }
     139        if (!ppSubFilesIterateUp(config, PPSUB_FILES_INPUT)) {
     140            psError(PPSUB_ERR_IO, false, "Unable to close input files.");
     141            success = false;
     142            goto ESCAPE;
     143        }
    147144    }
    148145    if (!ppSubLowThreshold(data)) {
     
    165162    }
    166163
    167     if (!noConvolve) {
    168164    if (!data->quality && !ppSubMakePSF(data)) {
    169165        psError(psErrorCodeLast(), false, "Unable to generate PSF.");
     
    171167        goto ESCAPE;
    172168    }
    173     }
     169
    174170    // Now we've got a PSF, blow away detections in case they're confused with real output detections
    175171    {
     
    197193    // dumpout(config, "diff.2a.fits");
    198194    if (noConvolve) {
    199       if (!ppSubFilesIterateUp(config, PPSUB_FILES_INPUT)) {
    200         psError(PPSUB_ERR_IO, false, "Unable to close input files.");
    201         success = false;
    202         goto ESCAPE;
    203       }
     195        if (!ppSubFilesIterateUp(config, PPSUB_FILES_INPUT)) {
     196            psError(PPSUB_ERR_IO, false, "Unable to close input files.");
     197            success = false;
     198            goto ESCAPE;
     199        }
    204200    }
    205201   
     
    271267    // Do Mask Stats
    272268    {
    273       pmFPAview *view = ppSubViewReadout(); // View to readout
    274       if (!ppSubMaskStats(config, view,data->stats)) {
    275         psError(psErrorCodeLast(), false, "Unable to generate mask statistics");
    276         success = false;
    277         psFree(view);
    278         goto ESCAPE;
    279       }
    280       psFree(view);
     269        pmFPAview *view = ppSubViewReadout(); // View to readout
     270        if (!ppSubMaskStats(config, view,data->stats)) {
     271            psError(psErrorCodeLast(), false, "Unable to generate mask statistics");
     272            success = false;
     273            psFree(view);
     274            goto ESCAPE;
     275        }
     276        psFree(view);
    281277    }
    282278    // dumpout(config, "diff.4.fits");
     
    344340    }
    345341
    346 ESCAPE:
     342 ESCAPE:
    347343    pmFPAfileDropInternal(config->files, "PSPHOT.BACKGND");
    348344    pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL");
Note: See TracChangeset for help on using the changeset viewer.