IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 26784


Ignore:
Timestamp:
Feb 5, 2010, 1:31:49 PM (16 years ago)
Author:
eugene
Message:

updates to psphot APIs to enable stack photometry

Location:
branches/eam_branches/20091201/ppSub/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091201/ppSub/src/ppSubMakePSF.c

    r26649 r26784  
    6666    pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout to photometer
    6767
    68     // we need to remove any existing PSPHOT.SOURCES (why not do this in psphot?)
    69     if (psMetadataLookup(photRO->analysis, "PSPHOT.SOURCES")) {
    70         psMetadataRemoveKey(photRO->analysis, "PSPHOT.SOURCES");
     68    // we need to remove any existing PSPHOT.DETECTIONS (why not do this in psphot?)
     69    if (psMetadataLookup(photRO->analysis, "PSPHOT.DETECTIONS")) {
     70        psMetadataRemoveKey(photRO->analysis, "PSPHOT.DETECTIONS");
    7171    }
    7272    if (psMetadataLookup(photRO->parent->parent->analysis, "PSPHOT.PSF")) {
     
    8383    // Extract the loaded sources from the associated readout, and generate PSF
    8484    // Here, we assume the image is background-subtracted
    85     psArray *sources = psMetadataLookupPtr(&mdok, minuend->analysis, "PSPHOT.SOURCES");
     85    pmDetections *detections = psMetadataLookupPtr(&mdok, minuend->analysis, "PSPHOT.DETECTIONS");
     86    psAssert(detections, "missing detections?");
     87    psArray *sources = detections->allSources;
     88    psAssert(sources, "missing sources?");
    8689   
    8790    // XXX filter sources?  limit the total number and return only brighter objects?
  • branches/eam_branches/20091201/ppSub/src/ppSubMatchPSFs.c

    r26769 r26784  
    6363    pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout to photometer
    6464
    65     if (psMetadataLookup(photRO->analysis, "PSPHOT.SOURCES")) {
    66         psMetadataRemoveKey(photRO->analysis, "PSPHOT.SOURCES");
     65    if (psMetadataLookup(photRO->analysis, "PSPHOT.DETECTIONS")) {
     66        psMetadataRemoveKey(photRO->analysis, "PSPHOT.DETECTIONS");
    6767    }
    6868    if (psMetadataLookup(photRO->parent->parent->analysis, "PSPHOT.PSF")) {
     
    123123    pmReadout *inSourceRO = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT.SOURCES");
    124124    pmReadout *refSourceRO = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.SOURCES");
    125     psArray *inSources = psMetadataLookupPtr(NULL, inSourceRO->analysis, "PSPHOT.SOURCES"); // Input sources
    126     psArray *refSources = psMetadataLookupPtr(NULL, refSourceRO->analysis, "PSPHOT.SOURCES"); // Ref sources
     125    // XXX assert on inSourcesRO and refSourcesRO?
     126
     127    pmDetections *inDetections = psMetadataLookupPtr(NULL, inSourceRO->analysis, "PSPHOT.DETECTIONS"); // Input sources
     128    pmDetections *refDetections = psMetadataLookupPtr(NULL, refSourceRO->analysis, "PSPHOT.DETECTIONS"); // Ref sources
    127129
    128130    psFree(view);
    129131
    130     if (!inSources || !refSources) {
     132    if (!inDetections || !refDetections) {
    131133        psWarning("Unable to scale kernel, since no sources were provided.");
    132134        return true;
    133135    }
     136
     137    psArray *inSources = inDetections->allSources;
     138    psAssert (inSources, "missing inSources?");
     139
     140    psArray *refSources = refDetections->allSources;
     141    psAssert (refSources, "missing refSources?");
    134142
    135143    float inFWHM = subImagePSF(data, inRO, inSources); // FWHM for input
     
    198206    pmReadout *inSourceRO = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT.SOURCES");
    199207    pmReadout *refSourceRO = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.SOURCES");
    200     psArray *inSources = inSourceRO ? psMetadataLookupPtr(&mdok, inSourceRO->analysis, "PSPHOT.SOURCES") :
    201         NULL; // Source list from input image
    202     psArray *refSources = refSourceRO ? psMetadataLookupPtr(&mdok, refSourceRO->analysis, "PSPHOT.SOURCES") :
    203         NULL ; // Source list from reference image
     208
     209    pmDetections *inDetections  = inSourceRO  ? psMetadataLookupPtr(&mdok, inSourceRO->analysis,  "PSPHOT.DETECTIONS") : NULL; // Input sources
     210    pmDetections *refDetections = refSourceRO ? psMetadataLookupPtr(&mdok, refSourceRO->analysis, "PSPHOT.DETECTIONS") : NULL; // Ref sources
    204211
    205212    psFree(view);
    206213
    207     psArray *sources = NULL;            // Merged list of sources
    208     if (inSources && refSources) {
     214    pmDetections *detections = NULL;    // Merged detection set
     215    if (inDetections && refDetections) {
     216        psArray *inSources  = inDetections->allSources;
     217        psArray *refSources = refDetections->allSources;
     218
     219        psAssert (inSources, "missing in sources?");
     220        psAssert (refSources, "missing ref sources?");
     221
     222        detections = pmDetectionsAlloc();
    209223        float radius = psMetadataLookupF32(NULL, recipe, "SOURCE.RADIUS"); // Matching radius
    210224        psArray *lists = psArrayAlloc(2); // Source lists
    211225        lists->data[0] = psMemIncrRefCounter(inSources);
    212226        lists->data[1] = psMemIncrRefCounter(refSources);
    213         sources = pmSourceMatchMerge(lists, radius);
     227        detections->allSources = pmSourceMatchMerge(lists, radius);
    214228        psFree(lists);
    215         if (!sources) {
     229        if (!detections->allSources) {
    216230            psError(PS_ERR_UNKNOWN, false, "Unable to merge source lists");
     231            psFree(detections);
    217232            return false;
    218233        }
    219     } else if (inSources) {
    220         sources = psMemIncrRefCounter(inSources);
    221     } else if (refSources) {
    222         sources = psMemIncrRefCounter(refSources);
    223     }
    224 
    225     psMetadataAddArray(inConv->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_META_REPLACE,
    226                        "Merged source list", sources);
    227     psMetadataAddArray(refConv->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_META_REPLACE,
    228                        "Merged source list", sources);
    229     psFree(sources);                    // Drop reference
     234    }
     235    if (!detections && inDetections) {
     236        detections = psMemIncrRefCounter(inDetections);
     237    }
     238    if (!detections && refDetections) {
     239        detections = psMemIncrRefCounter(refDetections);
     240    }
     241
     242    psMetadataAddPtr(inConv->analysis,  PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE | PS_DATA_UNKNOWN, "Merged source list", detections);
     243    psMetadataAddPtr(refConv->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE | PS_DATA_UNKNOWN, "Merged source list", detections);
     244    psFree(detections);                    // Drop reference
    230245
    231246    int footprint = psMetadataLookupS32(NULL, recipe, "STAMP.FOOTPRINT"); // Stamp half-size
     
    326341    } else {
    327342        success = pmSubtractionMatch(inConv, refConv, inRO, refRO, footprint, stride, regionSize,
    328                                      spacing, threshold, sources, data->stamps, type, size, order,
     343                                     spacing, threshold, detections->allSources, data->stamps, type, size, order,
    329344                                     widths, orders, inner, ringsOrder, binning, penalty, optimum,
    330345                                     optWidths, optOrder, optThresh, iter, rej, normFrac,
  • branches/eam_branches/20091201/ppSub/src/ppSubReadoutPhotometry.c

    r26649 r26784  
    5858    }
    5959
    60     // drop references to PSPHOT.SOURCES on both of these  (why is this needed for both??)
     60    // drop references to PSPHOT.DETECTIONS on both of these  (why is this needed for both??)
    6161    pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout to photometer
    62     if (psMetadataLookup(photRO->analysis, "PSPHOT.SOURCES")) {
    63         psMetadataRemoveKey(photRO->analysis, "PSPHOT.SOURCES");
     62    if (psMetadataLookup(photRO->analysis, "PSPHOT.DETECTIONS")) {
     63        psMetadataRemoveKey(photRO->analysis, "PSPHOT.DETECTIONS");
    6464    }
    6565    pmReadout *inRO = pmFPAfileThisReadout(config->files, view, name); // Readout with image and sources
    66     if (psMetadataLookup(inRO->analysis, "PSPHOT.SOURCES")) {
    67         psMetadataRemoveKey(inRO->analysis, "PSPHOT.SOURCES");
     66    if (psMetadataLookup(inRO->analysis, "PSPHOT.DETECTIONS")) {
     67        psMetadataRemoveKey(inRO->analysis, "PSPHOT.DETECTIONS");
    6868    }
    6969
     
    9090
    9191    // If no sources were found, there's no error,  but we want to trigger 'bad quality'
    92     psArray *sources = psMetadataLookupPtr(NULL, photRO->analysis, "PSPHOT.SOURCES"); // Sources
    93     if (!sources) {
     92    pmDetections *detections = psMetadataLookupPtr(NULL, photRO->analysis, "PSPHOT.DETECTIONS"); // Sources
     93    if (!detections) {
    9494        ppSubDataQuality(data, PSPHOT_ERR_DATA, PPSUB_FILES_PHOT_SUB | PPSUB_FILES_PHOT_INV);
    9595    }
     96    psArray *sources = detections->allSources;
     97    psAssert (sources, "missing sources?");
    9698
    9799    if (data->stats) {
     
    108110
    109111    if (!data->quality) {
    110         if (!psMetadataCopySingle(inRO->analysis, photRO->analysis, "PSPHOT.SOURCES")) {
    111             psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to copy PSPHOT.SOURCES");
     112        if (!psMetadataCopySingle(inRO->analysis, photRO->analysis, "PSPHOT.DETECTIONS")) {
     113            psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to copy PSPHOT.DETECTIONS");
    112114            return false;
    113115        }
     
    132134    {
    133135        pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout with the sources
    134         psArray *sources = psMetadataLookupPtr(NULL, photRO->analysis, "PSPHOT.SOURCES"); // Sources
     136        pmDetections *detections = psMetadataLookupPtr(NULL, photRO->analysis, "PSPHOT.DETECTIONS"); // Sources
     137        psArray *sources = detections->allSources;
    135138        FILE *sourceFile = fopen("sources.dat", "w"); // File for sources
    136139        fprintf(sourceFile,
Note: See TracChangeset for help on using the changeset viewer.