IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29937 for trunk


Ignore:
Timestamp:
Dec 5, 2010, 9:45:46 PM (15 years ago)
Author:
eugene
Message:

add forced photometry of positive sources; generate a background model for PPSUB.OUTPUT even if PSPHOT.BACKMDL exists (is certain to be for the wrong image)

Location:
trunk/ppSub
Files:
10 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/ppSub/src/Makefile.am

    r29003 r29937  
    3838        ppSubLoop.c                     \
    3939        ppSubDefineOutput.c             \
     40        ppSubInputDetections.c          \
    4041        ppSubExtras.c                   \
    4142        ppSubFlagNeighbors.c            \
     
    4647        ppSubReadoutJpeg.c              \
    4748        ppSubReadoutPhotometry.c        \
     49        ppSubReadoutForcedPhot.c        \
    4850        ppSubReadoutStats.c             \
    4951        ppSubReadoutSubtract.c          \
  • trunk/ppSub/src/ppSub.h

    r29003 r29937  
    4545    bool photometry;                    // Perform photometry?
    4646    bool inverse;                       // Output inverse subtraction as well?
     47    bool forcedPhot1;                   // perform forced photometry?
     48    bool forcedPhot2;                   // perform forced photometry?
    4749    bool saveInConv;                    // Save convolved input?
    4850    bool saveRefConv;                   // Save convolved reference?
     
    105107                            ppSubData *data ///< Processing data
    106108    );
     109
     110bool ppSubInputDetections (bool *foundDetections, const char *sourcesName, const char *imageName, ppSubData *data);
     111bool ppSubReadoutForcedPhot(const char *outputName, const char *targetName, const char *sourceName, ppSubData *data);
     112bool psphotCopyResults (bool *foundDetections, pmFPAfile *target, pmFPAfile *source, pmFPAview *view);
    107113
    108114/// Higher-order background subtraction
  • trunk/ppSub/src/ppSubArguments.c

    r27596 r29937  
    8686    psMetadataAddS32(arguments, PS_LIST_TAIL, "-convolve", 0, "Image to convolve [1 or 2]", 0);
    8787    psMetadataAddBool(arguments, PS_LIST_TAIL, "-photometry", 0, "Perform photometry?", NULL);
     88    psMetadataAddBool(arguments, PS_LIST_TAIL, "-forced-phot", 0, "Perform forced photometry?", NULL);
     89    psMetadataAddBool(arguments, PS_LIST_TAIL, "-forced-input1", 0, "Perform forced photometry?", NULL);
     90    psMetadataAddBool(arguments, PS_LIST_TAIL, "-forced-input2", 0, "Perform forced photometry?", NULL);
    8891    psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp", 0, "Zero point for photometry", NAN);
    8992    psMetadataAddBool(arguments, PS_LIST_TAIL, "-inverse", 0, "Generate inverse subtractions?", false);
  • trunk/ppSub/src/ppSubBackground.c

    r29003 r29937  
    3737    pmFPAview *view = ppSubViewReadout(); // View to readout
    3838    pmReadout *outRO = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT"); // Output image
    39     pmReadout *modelRO = pmFPAfileThisReadout(config->files, view, "PSPHOT.BACKMDL"); // Background model
    4039
    41     // Generate the background model, if required
     40    // Generate the background model
     41    if (!psphotModelBackground(config, view, "PPSUB.OUTPUT")) {
     42      psError(psErrorCodeLast(), false, "Unable to model background");
     43      psFree(view);
     44      return false;
     45    }
     46
     47    // select the model readout (should now exist)
     48    pmReadout *modelRO = pmFPAfileThisReadout(config->files, view, "PSPHOT.BACKMDL");
    4249    if (!modelRO) {
    43         // Create the background model
    44         if (!psphotModelBackgroundReadoutFileIndex(config, view, "PPSUB.OUTPUT", 0)) {
    45             psError(psErrorCodeLast(), false, "Unable to model background");
    46             psFree(view);
    47             return false;
    48         }
    49         // select the model readout (should now exist)
    50         modelRO = pmFPAfileThisReadout(config->files, view, "PSPHOT.BACKMDL");
    51         if (!modelRO) {
    52             psError(psErrorCodeLast(), false, "Unable to find background model");
    53             psFree(view);
    54             return false;
    55         }
     50      psError(psErrorCodeLast(), false, "Unable to find background model");
     51      psFree(view);
     52      return false;
    5653    }
    5754    psFree(view);
    5855
    59     psImageBinning *binning = psMetadataLookupPtr(&mdok, modelRO->analysis,
    60                                                   "PSPHOT.BACKGROUND.BINNING"); // Binning for model
     56    psImageBinning *binning = psMetadataLookupPtr(&mdok, modelRO->analysis, "PSPHOT.BACKGROUND.BINNING"); // Binning for model
    6157    psImage *modelImage = modelRO->image; // Background model
    6258    psImage *image = outRO->image; // Image of interest
     
    8379    }
    8480
    85     pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL");
    86     pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL.STDEV");
    87 
    8881    return true;
    8982}
  • trunk/ppSub/src/ppSubCamera.c

    r27661 r29937  
    221221                          "Generate inverse subtractions?", true);
    222222    }
    223 
    224     data->inverse = psMetadataLookupBool(NULL, recipe, "INVERSE");
    225     data->photometry = psMetadataLookupBool(NULL, recipe, "PHOTOMETRY");
     223    if (psMetadataLookupBool(NULL, config->arguments, "-forced-phot")) {
     224        psMetadataAddBool(recipe, PS_LIST_TAIL, "FORCED.PHOTOMETRY.BOTH", PS_META_REPLACE, "Perform forced photometry?", true);
     225    }
     226    if (psMetadataLookupBool(NULL, config->arguments, "-forced-input1")) {
     227        psMetadataAddBool(recipe, PS_LIST_TAIL, "FORCED.PHOTOMETRY.INPUT1", PS_META_REPLACE, "Perform forced photometry?", true);
     228    }
     229    if (psMetadataLookupBool(NULL, config->arguments, "-forced-input2")) {
     230        psMetadataAddBool(recipe, PS_LIST_TAIL, "FORCED.PHOTOMETRY.INPUT2", PS_META_REPLACE, "Perform forced photometry?", true);
     231    }
     232
     233    data->inverse     = psMetadataLookupBool(NULL, recipe, "INVERSE");
     234    data->photometry  = psMetadataLookupBool(NULL, recipe, "PHOTOMETRY");
     235    data->forcedPhot1 = psMetadataLookupBool(NULL, recipe, "FORCED.PHOTOMETRY.BOTH") || psMetadataLookupBool(NULL, recipe, "FORCED.PHOTOMETRY.INPUT1");
     236    data->forcedPhot2 = psMetadataLookupBool(NULL, recipe, "FORCED.PHOTOMETRY.BOTH") || psMetadataLookupBool(NULL, recipe, "FORCED.PHOTOMETRY.INPUT2");
    226237
    227238    // Convolved input image
     
    363374            return false;
    364375        }
    365         // specify the number of psphot input images
    366         psMetadataAddS32 (config->arguments, PS_LIST_TAIL, "PSPHOT.INPUT.NUM", PS_META_REPLACE, "number of inputs", 1);
    367376        pmFPAfileActivate(config->files, false, "PSPHOT.INPUT");
    368377
     
    405414            invSources->save = true;
    406415        }
     416
     417        // files need to do the forced photometry on the positions of sources in the positive images
     418        if (data->forcedPhot1) {
     419            // this pmFPAfile is used to carry sources detected in the positive image #1
     420            pmFPAfile *posSources1 = defineOutputFile(config, output, true, "PPSUB.POS1.SOURCES", PM_FPA_FILE_CMF);
     421            if (!posSources1) {
     422                psError(psErrorCodeLast(), false, "Unable to set up forced source file.");
     423                return false;
     424            }
     425            posSources1->save = true;
     426
     427            // this pmFPAfile is used to carry sources detected in the diff image @ the positions from positive image #1
     428            pmFPAfile *frcSources1 = defineOutputFile(config, output, true, "PPSUB.FORCED1.SOURCES", PM_FPA_FILE_CMF);
     429            if (!frcSources1) {
     430                psError(psErrorCodeLast(), false, "Unable to set up forced source file.");
     431                return false;
     432            }
     433            frcSources1->save = true;
     434        }
     435
     436        if (data->forcedPhot2) {
     437            // this pmFPAfile is used to carry sources detected in the positive image #2
     438            pmFPAfile *posSources2 = defineOutputFile(config, inverse, true, "PPSUB.POS2.SOURCES", PM_FPA_FILE_CMF);
     439            if (!posSources2) {
     440                psError(psErrorCodeLast(), false, "Unable to set up forced source file.");
     441                return false;
     442            }
     443            posSources2->save = true;
     444
     445            // this pmFPAfile is used to carry sources detected in the diff image @ the positions from positive image #2
     446            pmFPAfile *frcSources2 = defineOutputFile(config, inverse, true, "PPSUB.FORCED2.SOURCES", PM_FPA_FILE_CMF);
     447            if (!frcSources2) {
     448                psError(psErrorCodeLast(), false, "Unable to set up forced source file.");
     449                return false;
     450            }
     451            frcSources2->save = true;
     452        }
    407453    }
    408454
  • trunk/ppSub/src/ppSubFlagNeighbors.c

    r29003 r29937  
    235235        src = sources->data[Imin];
    236236
    237         fprintf (stderr, "j: %d, Imin: %d, obj x,y: %f, %f  src x,y: %f, %f, SN: %f, ID: %d\n", j, Imin, obj->x, obj->y, src->peak->xf, src->peak->yf, src->peak->SN, src->id);
     237        // fprintf (stderr, "j: %d, Imin: %d, obj x,y: %f, %f  src x,y: %f, %f, SN: %f, ID: %d\n", j, Imin, obj->x, obj->y, src->peak->xf, src->peak->yf, src->peak->SN, src->id);
    238238
    239239        // add source to object
  • trunk/ppSub/src/ppSubLoop.c

    r29003 r29937  
    5757    }
    5858
     59    if (data->forcedPhot1) {
     60        bool foundDetections = false;
     61        if (!ppSubInputDetections(&foundDetections, "PPSUB.POS1.SOURCES", "PPSUB.INPUT", data)) {
     62            psError(psErrorCodeLast(), false, "Unable to measure positive detections (1)");
     63            return false;
     64        }
     65        // if nothing was found, don't bother doing the forced photometry below
     66        if (!foundDetections) {
     67            psWarning ("no sources found in positive image 1, skipping forced photometry");
     68            data->forcedPhot1 = false;
     69        }
     70    }
     71    if (data->forcedPhot2) {
     72        bool foundDetections = false;
     73        if (!ppSubInputDetections(&foundDetections, "PPSUB.POS2.SOURCES", "PPSUB.REF", data)) {
     74            psError(psErrorCodeLast(), false, "Unable to measure positive detections (2)");
     75            return false;
     76        }
     77        // if nothing was found, don't bother doing the forced photometry below
     78        if (!foundDetections) {
     79            psWarning ("no sources found in positive image 1, skipping forced photometry");
     80            data->forcedPhot1 = false;
     81        }
     82    }
     83
     84    // XXX if it exists, use the POS1, POS2 results for the FWHMs
    5985    if (!ppSubMatchPSFs(data)) {
    6086        psError(psErrorCodeLast(), false, "Unable to match PSFs.");
     
    7096        return false;
    7197    }
     98
     99    // XXX add in a positive image detection step here (if needed)
     100   
    72101
    73102    psMetadataAddF32(data->stats, PS_LIST_TAIL, "TIME_MATCH", 0, "Time to match PSFs",
     
    153182    }
    154183    // dumpout(config, "diff.3.fits");
     184
     185    // forced photometry for positive image 1
     186    if (data->forcedPhot1 && !data->quality) {
     187        if (!ppSubReadoutForcedPhot("PPSUB.FORCED1.SOURCES", "PPSUB.OUTPUT", "PPSUB.POS1.SOURCES", data)) {
     188            psError(psErrorCodeLast(), false, "Unable to perform photometry.");
     189            return false;
     190        }
     191    }
     192
     193    // forced photometry for positive image 2
     194    if (data->forcedPhot2 && !data->quality) {
     195        if (!ppSubReadoutForcedPhot("PPSUB.FORCED2.SOURCES", "PPSUB.OUTPUT", "PPSUB.POS2.SOURCES", data)) {
     196            psError(psErrorCodeLast(), false, "Unable to perform photometry.");
     197            return false;
     198        }
     199    }
    155200
    156201    if (!ppSubFilesIterateUp(config, PPSUB_FILES_PHOT_SUB)) {
     
    227272    }
    228273
     274    pmFPAfileDropInternal(config->files, "PSPHOT.BACKGND");
     275    pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL");
     276    pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL.STDEV");
     277
    229278    return true;
    230279}
  • trunk/ppSub/src/ppSubMakePSF.c

    r28049 r29937  
    3535
    3636    psTimerStart("PPSUB_PHOT");
    37 
    38     psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSub
    39     psAssert(recipe, "We checked this earlier, so it should be here.");
    40 
    41     if (!psMetadataLookupBool(NULL, recipe, "PHOTOMETRY")) {
    42         return true;
    43     }
    4437
    4538    bool reverse = psMetadataLookupBool(NULL, config->arguments, "REVERSE"); // Reverse sense of subtraction?
     
    9386    // use flags to toss totally bogus entries?
    9487    psArray *goodSources = ppSubSelectPSFSources (sources);
    95     if (!psphotReadoutFindPSF(config, view, goodSources)) {
     88    if (!psphotReadoutFindPSF(config, view, "PSPHOT.INPUT", goodSources)) {
    9689        // This is likely a data quality issue
    9790        // XXX Split into multiple cases using error codes?
  • trunk/ppSub/src/ppSubMatchPSFs.c

    r29593 r29937  
    7272    // Extract the loaded sources from the associated readout, and generate PSF
    7373    // Here, we assume the image is background-subtracted
    74     if (!psphotReadoutFindPSF(config, view, sources)) {
     74    if (!psphotReadoutFindPSF(config, view, "PSPHOT.INPUT", sources)) {
    7575        psErrorStackPrint(stderr, "Unable to determine PSF");
    7676        psWarning("Unable to determine PSF.");
  • trunk/ppSub/src/ppSubReadoutPhotometry.c

    r29003 r29937  
    3131
    3232    if (!data->photometry) {
    33         return true;
    34     }
    35 
    36     // Look up recipe values
    37     psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSim
    38     psAssert(recipe, "We checked this earlier, so it should be here.");
    39 
    40     if (!psMetadataLookupBool(NULL, recipe, "PHOTOMETRY")) {
    41         pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL");
    42         pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL.STDEV");
    4333        return true;
    4434    }
     
    8171    }
    8272
    83     if (!psphotReadoutMinimal(config, view)) {
     73    if (!psphotReadoutMinimal(config, view, "PSPHOT.INPUT")) {
    8474        // This is likely a data quality issue
    8575        // XXX Split into multiple cases using error codes?
     
    9080
    9181    // If no sources were found, there's no error,  but we want to trigger 'bad quality'
     82    psWarning("no sources found: why is this being set to bad quality??");
    9283    pmDetections *detections = psMetadataLookupPtr(NULL, photRO->analysis, "PSPHOT.DETECTIONS"); // Sources
    9384    if (!detections) {
     
    136127        }
    137128    }
    138 
    139     pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL");
    140     pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL.STDEV");
    141129
    142130    return true;
Note: See TracChangeset for help on using the changeset viewer.