IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17813


Ignore:
Timestamp:
May 27, 2008, 9:32:16 AM (18 years ago)
Author:
Paul Price
Message:

Determine the PSF, rather than assuming it's the same as one of the inputs. Not yet tested, but I'm hopeful.........

Location:
trunk/ppSub/src
Files:
3 edited

Legend:

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

    r17368 r17813  
    174174    assert(config);
    175175
    176     psMetadataAddBool(config->arguments, PS_LIST_TAIL, "PHOTOMETRY", 0, "Do photometry?",
    177                       psArgumentGet(argc, argv, "-psf") ? true : false);
    178     pmConfigFileSetsMD(config->arguments, &argc, argv, "PSPHOT.PSF", "-psf", NULL);
    179176    pmConfigFileSetsMD(config->arguments, &argc, argv, "PPSUB.SOURCES", "-sources", NULL);
    180177
     
    214211    psMetadataAddBool(arguments, PS_LIST_TAIL, "-renorm", 0, "Renormalise weights?", false);
    215212    psMetadataAddS32(arguments, PS_LIST_TAIL, "-renorm-width", 0, "Renormalisation width", 0);
     213    psMetadataAddBool(arguments, PS_LIST_TAIL, "-photometry", 0, "Perform photometry?", false);
    216214
    217215    if (argc == 1 || !psArgumentParse(arguments, &argc, argv) || argc != 4) {
     
    298296    }
    299297
     298    if (psMetadataLookupBool(NULL, arguments, "-photometry") ||
     299        psMetadataLookupBool(NULL, recipe, "PHOTOMETRY")) {
     300        psMetadataAddBool(config->arguments, PS_LIST_TAIL, "PHOTOMETRY", 0, "Perform photometry?", true);
     301    }
     302
    300303    // Translate the kernel type
    301304    psString type = psMetadataLookupStr(NULL, arguments, "-type"); // Name of kernel type
  • trunk/ppSub/src/ppSubCamera.c

    r16916 r17813  
    135135
    136136    // psPhot input
    137     if (psMetadataLookup(config->arguments, "PSPHOT.PSF")) {
     137    if (psMetadataLookupBool(NULL, config->arguments, "PHOTOMETRY")) {
    138138        psphotModelClassInit ();        // load implementation-specific models
    139139        pmFPAfile *psphot = pmFPAfileDefineFromFPA(config, output->fpa, 1, 1, "PSPHOT.INPUT");
  • trunk/ppSub/src/ppSubReadout.c

    r17798 r17813  
    184184#endif
    185185
     186    // "Subtract" the mask and weight map
     187    outRO->mask = (psImage*)psBinaryOp(outRO->mask, inConv->mask, "|", refConv->mask);
     188    if (inConv->weight && refConv->weight) {
     189        outRO->weight = (psImage*)psBinaryOp(outRO->weight, inConv->weight, "+", refConv->weight);
     190    }
     191    outRO->data_exists = outCell->data_exists = outCell->parent->data_exists = true;
     192
     193    // Photometry is to be performed in two stages:
     194    // 1. Measure the PSF using the PSF-matched images
     195    // 2. Find and measure sources on the subtracted image
     196
     197    // Photometry stage 1: measure the PSF
     198    if (psMetadataLookupBool(NULL, config->arguments, "PHOTOMETRY")) {
     199        // We use a summed image as the basis for the PSF: this will have the maximum S/N.
     200        outRO->image = (psImage*)psBinaryOp(outRO->image, inConv->image, "+", refConv->image);
     201
     202        pmFPAfile *photFile = psMetadataLookupPtr(NULL, config->files, "PSPHOT.INPUT");
     203        pmFPACopy(photFile->fpa, outRO->parent->parent->parent);
     204
     205        // We have a list of sources, so we could use those to redetermine the PSF model.
     206        // Until Gene makes the necessary adaptations to psphot, we will simply redetermine the PSF model from
     207        // scratch.
     208
     209        // Need to ensure aperture residual is not calculated
     210        psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PSPHOT_RECIPE); // Recipe
     211        if (!recipe) {
     212            psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find %s recipe.", PSPHOT_RECIPE);
     213            return false;
     214        }
     215        const char *breakpoint = psMetadataLookupStr(NULL, recipe, "BREAK_POINT"); // Current break point
     216        psMetadataAddStr(recipe, PS_LIST_TAIL, "BREAK_POINT", PS_META_REPLACE,
     217                         "ALTERED break point for psphot operations", "PSFMODEL");
     218
     219        if (!psphotReadout(config, view)) {
     220            psWarning("Unable to perform photometry on subtracted image.");
     221            psErrorStackPrint(stderr, "Error stack from photometry:");
     222            psErrorClear();
     223        }
     224
     225        psMetadataAddStr(recipe, PS_LIST_TAIL, "BREAK_POINT", PS_META_REPLACE,
     226                         "RESTORED break point for psphot operations", breakpoint);
     227    }
     228
    186229    // Do the subtraction
    187230    {
     
    197240
    198241        outRO->image = (psImage*)psBinaryOp(outRO->image, minuend->image, "-", subtrahend->image);
    199         outRO->mask = (psImage*)psBinaryOp(outRO->mask, minuend->mask, "|", subtrahend->mask);
    200         if (minuend->weight && subtrahend->weight) {
    201             outRO->weight = (psImage*)psBinaryOp(outRO->weight, minuend->weight, "+", subtrahend->weight);
    202         }
    203         outRO->data_exists = outCell->data_exists = outCell->parent->data_exists = true;
    204242
    205243#ifdef TESTING
     
    249287    }
    250288
     289    // Photometry stage 2: find and measure sources on the subtracted image
    251290    if (psMetadataLookupBool(NULL, config->arguments, "PHOTOMETRY")) {
     291        // The PSF should already be stored for the readout
    252292        pmFPAfile *photFile = psMetadataLookupPtr(NULL, config->files, "PSPHOT.INPUT");
    253         pmFPACopy(photFile->fpa, outRO->parent->parent->parent);
    254293
    255294        // Need to ensure aperture residual is not calculated
Note: See TracChangeset for help on using the changeset viewer.