IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23235


Ignore:
Timestamp:
Mar 9, 2009, 3:16:06 PM (17 years ago)
Author:
Paul Price
Message:

Get input and reference source lists, and merge them to provide a source list for stamps and PSF.

Location:
trunk/ppSub/src
Files:
4 edited

Legend:

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

    r22735 r23235  
    3030    fprintf(stderr, "\nPan-STARRS PSF-matched image subtraction\n\n");
    3131    fprintf(stderr, "Usage: %s INPUT.fits REFERENCE.fits OUTPUT_ROOT \n"
    32             "\t[-psf REFERENCE.psf.fits] [-sources REFERENCE.cmf]\n\n"
     32            "\t[-psf REFERENCE.psf.fits]\n\n"
    3333            "This subtracts the convolved REFERENCE from the INPUT, by default.\n",
    3434            program);
     
    205205    }
    206206
    207     pmConfigFileSetsMD(config->arguments, &argc, argv, "PPSUB.SOURCES", "-sources", NULL);
    208 
    209207    psMetadata *arguments = config->arguments; // Command-line arguments
    210208    psMetadataAddStr(arguments, PS_LIST_TAIL, "-inmask", 0, "Input mask image", NULL);
    211209    psMetadataAddStr(arguments, PS_LIST_TAIL, "-invariance", 0, "Input variance image", NULL);
     210    psMetadataAddStr(arguments, PS_LIST_TAIL, "-insources", 0, "Input source list", NULL);
    212211    psMetadataAddStr(arguments, PS_LIST_TAIL, "-refmask", 0, "Reference mask image", NULL);
    213212    psMetadataAddStr(arguments, PS_LIST_TAIL, "-refvariance", 0, "Reference variance image", NULL);
     213    psMetadataAddStr(arguments, PS_LIST_TAIL, "-refsources", 0, "Reference source list", NULL);
    214214    psMetadataAddStr(arguments, PS_LIST_TAIL, "-stats", 0, "Statistics file", NULL);
    215215    psMetadataAddF32(arguments, PS_LIST_TAIL, "-region", 0, "Size of iso-kernel region", NAN);
     
    272272        fileList("INPUT.VARIANCE", inVariance, "Name of the input variance image", config);
    273273    }
     274    const char *inSources = psMetadataLookupStr(NULL, arguments, "-insources"); // Name of input source list
     275    if (inSources && strlen(inSources) > 0) {
     276        fileList("INPUT.SOURCES", inSources, "Name of the input source list", config);
     277    }
    274278
    275279    const char *refMask = psMetadataLookupStr(NULL, arguments, "-refmask"); // Name of reference mask
     
    280284    if (refVariance && strlen(refVariance) > 0) {
    281285        fileList("REF.VARIANCE", refVariance, "Name of the reference variance image", config);
     286    }
     287    const char *refSources = psMetadataLookupStr(NULL, arguments, "-refsources"); // Name of ref source list
     288    if (refSources && strlen(refSources) > 0) {
     289        fileList("REF.SOURCES", refSources, "Name of the reference source list", config);
    282290    }
    283291
  • trunk/ppSub/src/ppSubCamera.c

    r21524 r23235  
    4040    pmFPAfile *inputMask = pmFPAfileBindFromArgs(&status, input, config, "PPSUB.INPUT.MASK", "INPUT.MASK");
    4141    if (!status) {
    42         psError (PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.INPUT.MASK");
     42        psError(PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.INPUT.MASK");
    4343        return NULL;
    4444    }
     
    5151    pmFPAfile *inputVariance = pmFPAfileBindFromArgs(&status, input, config, "PPSUB.INPUT.VARIANCE", "INPUT.VARIANCE");
    5252    if (!status) {
    53         psError (PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.INPUT.VARIANCE");
     53        psError(PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.INPUT.VARIANCE");
    5454        return NULL;
    5555    }
    5656    if (inputVariance && inputVariance->type != PM_FPA_FILE_VARIANCE) {
    5757        psError(PS_ERR_IO, true, "PPSUB.INPUT.VARIANCE is not of type VARIANCE");
     58        return false;
     59    }
     60
     61    // Input source list
     62    pmFPAfile *inputSources = pmFPAfileBindFromArgs(&status, input, config, "PPSUB.INPUT.SOURCES", "INPUT.SOURCES");
     63    if (!status) {
     64        psError(PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.INPUT.SOURCES");
     65        return NULL;
     66    }
     67    if (inputSources && inputSources->type != PM_FPA_FILE_CMF) {
     68        psError(PS_ERR_IO, true, "PPSUB.INPUT.SOURCES is not of type CMF");
    5869        return false;
    5970    }
     
    7485    pmFPAfile *refMask = pmFPAfileBindFromArgs(&status, ref, config, "PPSUB.REF.MASK", "REF.MASK");
    7586    if (!status) {
    76         psError (PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.REF.MASK");
     87        psError(PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.REF.MASK");
    7788        return NULL;
    7889    }
     
    8596    pmFPAfile *refVariance = pmFPAfileBindFromArgs(&status, ref, config, "PPSUB.REF.VARIANCE", "REF.VARIANCE");
    8697    if (!status) {
    87         psError (PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.REF.VARIANCE");
     98        psError(PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.REF.VARIANCE");
    8899        return NULL;
    89100    }
    90101    if (refVariance && refVariance->type != PM_FPA_FILE_VARIANCE) {
    91102        psError(PS_ERR_IO, true, "PPSUB.REF.VARIANCE is not of type VARIANCE");
     103        return false;
     104    }
     105
     106    // Reference source list
     107    pmFPAfile *refSources = pmFPAfileBindFromArgs(&status, ref, config, "PPSUB.REF.SOURCES", "REF.SOURCES");
     108    if (!status) {
     109        psError(PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.REF.SOURCES");
     110        return NULL;
     111    }
     112    if (refSources && refSources->type != PM_FPA_FILE_CMF) {
     113        psError(PS_ERR_IO, true, "PPSUB.REF.SOURCES is not of type CMF");
    92114        return false;
    93115    }
     
    241263    outKernels->save = true;
    242264
    243 #if 0
    244     if (!pmFPAAddSourceFromFormat(output->fpa, "Subtraction", output->format)) {
    245         psError(PS_ERR_UNKNOWN, false, "Unable to generate output FPA.");
    246         return false;
    247     }
    248 #endif
    249 
    250     pmFPAfile *sources = pmFPAfileDefineFromArgs(&status, config, "PPSUB.SOURCES", "PPSUB.SOURCES");
    251     if (!status) {
    252         psError(PS_ERR_IO, false, "Failed to load file definition PPSUB.SOURCES");
    253         return false;
    254     }
    255     if (sources && sources->type != PM_FPA_FILE_CMF) {
    256         psError(PS_ERR_IO, true, "PPSUB.SOURCES is not of type CMF");
    257         return false;
    258     }
    259265
    260266    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSim
  • trunk/ppSub/src/ppSubMakePSF.c

    r21524 r23235  
    8181    // Extract the loaded sources from the associated readout, and generate PSF
    8282    // Here, we assume the image is background-subtracted
    83     pmReadout *sourcesRO = pmFPAfileThisReadout(config->files, view, "PPSUB.SOURCES");
    84     psArray *sources = psMetadataLookupPtr(&mdok, sourcesRO->analysis, "PSPHOT.SOURCES");
     83    psArray *sources = psMetadataLookupPtr(&mdok, minuend->analysis, "PSPHOT.SOURCES");
    8584    if (!psphotReadoutFindPSF(config, view, sources)) {
    8685        psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry on subtracted image.");
  • trunk/ppSub/src/ppSubMatchPSFs.c

    r23217 r23235  
    5050
    5151    // Sources in image, used for stamps: these must be loaded from previous analysis stages
    52     pmReadout *sourcesRO = pmFPAfileThisReadout(config->files, view, "PPSUB.SOURCES"); // Readout with sources
    53     psArray *sources = NULL;            // Sources in image; used for stamps
    54     if (sourcesRO) {
    55         sources = psMetadataLookupPtr(&mdok, sourcesRO->analysis, "PSPHOT.SOURCES");
     52    psArray *inSources = psMetadataLookupPtr(&mdok, inRO->analysis, "PSPHOT.SOURCES"); // Input source list
     53    psArray *refSources = psMetadataLookupPtr(&mdok, refRO->analysis, "PSPHOT.SOURCES"); // Ref source list
     54
     55    psArray *sources = NULL;            // Merged list of sources
     56    if (inSources && refSources) {
     57        float radius = psMetadataLookupF32(NULL, recipe, "SOURCE.RADIUS"); // Matching radius
     58        psArray *lists = psArrayAlloc(2); // Source lists
     59        lists->data[0] = psMemIncrRefCounter(inSources);
     60        lists->data[1] = psMemIncrRefCounter(refSources);
     61        sources = pmSourceMatchMerge(lists, radius);
     62        psFree(lists);
     63        if (!sources) {
     64            psError(PS_ERR_UNKNOWN, false, "Unable to merge source lists");
     65            return false;
     66        }
     67    } else if (inSources) {
     68        sources = psMemIncrRefCounter(inSources);
     69    } else if (refSources) {
     70        sources = psMemIncrRefCounter(refSources);
    5671    }
     72
     73    psMetadataAddArray(inConv->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_META_REPLACE,
     74                       "Merged source list", sources);
     75    psMetadataAddArray(refConv->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_META_REPLACE,
     76                       "Merged source list", sources);
     77    psFree(sources);                    // Drop reference
    5778
    5879    int footprint = psMetadataLookupS32(NULL, recipe, "STAMP.FOOTPRINT"); // Stamp half-size
Note: See TracChangeset for help on using the changeset viewer.