IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 22, 2010, 6:28:58 AM (16 years ago)
Author:
eugene
Message:

define concept of source parent; psf-matched apertures used the source children

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101205/psphot/src/psphotMergeSources.c

    r29936 r30142  
    513513    }
    514514
    515     return true;
    516 }
    517 
     515    // loop over the sources, redefine their pixels to point at the new filerule image,
     516    // copy the source data, and add a reference back to the original source
     517   
     518
     519    return true;
     520}
     521
     522// copy the detections from one pmFPAfile to another
     523bool psphotSourceChildren (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc)
     524{
     525    bool status = true;
     526
     527    int num = psphotFileruleCount(config, ruleSrc);
     528
     529    // skip the chisq image because it is a duplicate of the detection version
     530    int chisqNum = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.CHISQ.NUM");
     531    if (!status) chisqNum = -1;
     532
     533    // loop over the available readouts
     534    for (int i = 0; i < num; i++) {
     535        if (i == chisqNum) continue; // skip chisq image
     536        if (!psphotSourceChildrenReadout (config, view, ruleOut, ruleSrc, i)) {
     537            psError (PSPHOT_ERR_CONFIG, false, "failed to copy sources from %s to %s entry %d", ruleSrc, ruleOut, i);
     538            return false;
     539        }
     540    }
     541    return true;
     542}
     543
     544// add newly selected sources to the existing list of sources
     545bool psphotSourceChildrenReadout (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc, int index) {
     546
     547    bool status;
     548
     549    // find the currently selected readout
     550    pmFPAfile *fileSrc = pmFPAfileSelectSingle(config->files, ruleSrc, index); // File of interest
     551    psAssert (fileSrc, "missing file?");
     552
     553    pmReadout *readoutSrc = pmFPAviewThisReadout(view, fileSrc->fpa);
     554    psAssert (readoutSrc, "missing readout?");
     555
     556    pmDetections *detectionsSrc = psMetadataLookupPtr (&status, readoutSrc->analysis, "PSPHOT.DETECTIONS");
     557    psAssert (detectionsSrc, "missing detections?");
     558
     559    psArray *sourcesSrc = detectionsSrc->allSources;
     560    psAssert (sourcesSrc, "missing sources?");
     561
     562    // find the currently selected readout
     563    pmFPAfile *fileOut = pmFPAfileSelectSingle(config->files, ruleOut, index); // File of interest
     564    psAssert (fileOut, "missing file?");
     565
     566    pmReadout *readoutOut = pmFPAviewThisReadout(view, fileOut->fpa);
     567    psAssert (readoutOut, "missing readout?");
     568
     569    // loop over the sources, redefine their pixels to point at the new filerule image,
     570    // copy the source data, and add a reference back to the original source
     571   
     572    // XXX currently, this is only used by psphotStackReadout (sources go on allSources so that psphotChoosePSF can be called repeatedly)
     573    pmDetections *detectionsOut = psMetadataLookupPtr (&status, readoutOut->analysis, "PSPHOT.DETECTIONS");
     574    if (!detectionsOut) {
     575        detectionsOut = pmDetectionsAlloc();
     576        detectionsOut->allSources = psArrayAllocEmpty (100);
     577        // save detections on the readout->analysis
     578        if (!psMetadataAddPtr (readoutOut->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE | PS_DATA_UNKNOWN, "psphot detections", detectionsOut)) {
     579            psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout");
     580            return false;
     581        }
     582        psFree(detectionsOut); // a copy remains on the analysis metadata
     583    }
     584
     585    // copy the sources from sourceSrcs to the new detection structure
     586    for (int i = 0; i < sourcesSrc->n; i++) {
     587      pmSource *sourceSrc = sourcesSrc->data[i];
     588
     589      pmSource *sourceOut = pmSourceCopy(sourceSrc);
     590      sourceOut->parent = sourceSrc;
     591     
     592      // does this copy all model data?
     593
     594      // drop the references to the original image pixels:
     595      // pmSourceFreePixels (sourceOut);
     596
     597      // allocate image, weight, mask for the new image for each peak (square of radius OUTER)
     598      pmSourceRedefinePixels (sourceOut, readout, sourceOut->peak->x, sourceOut->peak->y, sourceSrc->fitRadius, true);
     599
     600      // XXX source ID, imageID : how are they really used?
     601      sourceOut->imageID = sourceSrc->imageID;
     602      // P_PM_SOURCE_SET_ID(source, i);
     603
     604      psArrayAdd (detections->allSources, 100, sourceOut);
     605    }
     606    psLogMsg ("psphot", 3, "%ld known sources supplied", detections->allSources->n);
     607
     608
     609    return true;
     610}
     611
Note: See TracChangeset for help on using the changeset viewer.