IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32676


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)

Location:
trunk/ppSub/src
Files:
3 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");
  • trunk/ppSub/src/ppSubMakePSF.c

    r31435 r32676  
    4646    bool noConvolve = psMetadataLookupBool(&mdok, recipe, "NOCONVOLVE"); // Do not use convolved images.
    4747
    48     if (!noConvolve) {
    49       printf("Using Convolved images because NOCONVOLVE is FALSE\n");
    50       if (reverse) {
    51         minuend = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV");
    52         minuendFile = psMetadataLookupPtr(&mdok, config->files, "PPSUB.REF.CONV");
    53       } else {
    54         minuend = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT.CONV");
    55         minuendFile = psMetadataLookupPtr(&mdok, config->files, "PPSUB.INPUT.CONV");
    56       }
    57     }
    58     else {
    59       psWarning("Not using Convolved images because NOCONVOLVE  is TRUE\n");
    60       if (reverse) {
    61         minuend = pmFPAfileThisReadout(config->files, view, "PPSUB.REF");
    62         minuendFile = psMetadataLookupPtr(&mdok, config->files, "PPSUB.REF");
    63       } else {
    64         minuend = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT");
    65         minuendFile = psMetadataLookupPtr(&mdok, config->files, "PPSUB.INPUT");
    66       }
     48    if (noConvolve) {
     49        // if we do not convolve, we need to copy the detections to the image for analysis
     50        pmReadout *psfSourcesRO = NULL; // readout containing loaded sources for psf model
     51        psWarning("Not using Convolved images because NOCONVOLVE  is TRUE\n");
     52        if (reverse) {
     53            minuend = pmFPAfileThisReadout(config->files, view, "PPSUB.REF");
     54            minuendFile = psMetadataLookupPtr(&mdok, config->files, "PPSUB.REF");
     55            psfSourcesRO = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.SOURCES");
     56        } else {
     57            minuend = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT");
     58            minuendFile = psMetadataLookupPtr(&mdok, config->files, "PPSUB.INPUT");
     59            psfSourcesRO = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT.SOURCES");
     60        }
     61        psAssert (psfSourcesRO, "missing readout with sources");
     62        pmDetections *psfDetections = psMetadataLookupPtr(&mdok, psfSourcesRO->analysis,  "PSPHOT.DETECTIONS");
     63        psMetadataAddPtr(minuend->analysis,  PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE | PS_DATA_UNKNOWN, "Merged source list", psfDetections);
     64    } else {
     65        printf("Using Convolved images because NOCONVOLVE is FALSE\n");
     66        if (reverse) {
     67            minuend = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV");
     68            minuendFile = psMetadataLookupPtr(&mdok, config->files, "PPSUB.REF.CONV");
     69        } else {
     70            minuend = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT.CONV");
     71            minuendFile = psMetadataLookupPtr(&mdok, config->files, "PPSUB.INPUT.CONV");
     72        }
    6773    }
    6874
  • trunk/ppSub/src/ppSubMatchPSFs.c

    r31672 r32676  
    201201bool ppSubMatchPSFs(ppSubData *data)
    202202{
     203    bool mdok = false;
     204
    203205    psAssert(data, "Require processing data");
    204206    pmConfig *config = data->config;    // Configuration
     
    208210    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSim
    209211    psAssert(recipe, "We checked this earlier, so it should be here.");
     212
     213    bool noConvolve = psMetadataLookupBool(&mdok, recipe, "NOCONVOLVE"); // Do not use convolved images.
     214    if (noConvolve) {
     215        psWarning("not matching PSFs because NOCONVOLVE is TRUE\n");
     216        return true;
     217    }
    210218
    211219    pmFPAview *view = ppSubViewReadout(); // View to readout
     
    228236        psFree(refConv);
    229237    }
    230 
    231     bool mdok;                          // Status of MD lookup
    232238
    233239    // Load pre-calculated kernel, if available
Note: See TracChangeset for help on using the changeset viewer.