IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32628


Ignore:
Timestamp:
Nov 8, 2011, 2:41:42 PM (15 years ago)
Author:
eugene
Message:

match sources before final linear fit (to enable forced photometry of PSF mags); only a single detection per image allowed for an object; distinguish conditions for Radial Aperture analysis and Petrosian analysis; no Radial Aperture analysis for chisq image

Location:
branches/eam_branches/ipp-20110906/psphot/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110906/psphot/src/psphotExtendedSourceAnalysis.c

    r32348 r32628  
    209209        // if we have checked the source validity on the basis of the object set, then
    210210        // we either skip these tests below or we skip the source completely
    211         if (source->tmpFlags & PM_SOURCE_TMPF_STACK_SKIP) continue;
    212         if (source->tmpFlags & PM_SOURCE_TMPF_STACK_KEEP) goto keepSource;
     211        if (source->tmpFlags & PM_SOURCE_TMPF_PETRO_SKIP) continue;
     212        if (source->tmpFlags & PM_SOURCE_TMPF_PETRO_KEEP) goto keepSource;
    213213
    214214        // skip PSF-like and non-astronomical objects
  • branches/eam_branches/ipp-20110906/psphot/src/psphotRadialApertures.c

    r32616 r32628  
    2626    int num = psphotFileruleCount(config, filerule);
    2727
     28    // skip the chisq image (optionally?)
     29    int chisqNum = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.CHISQ.NUM");
     30    if (!status) chisqNum = -1;
     31
    2832    // loop over the available readouts
    2933    for (int i = 0; i < num; i++) {
     34        if (i == chisqNum) continue; // skip chisq image
     35
    3036        if (!psphotRadialAperturesReadout (config, view, filerule, i, recipe, entry)) {
    3137            psError (PSPHOT_ERR_CONFIG, false, "failed on measure extended source aperture-like parameters for %s entry %d", filerule, i);
     
    218224        pmSource *source = sources->data[i];
    219225
     226        // if we have checked the source validity on the basis of the object set, then
     227        // we either skip these tests below or we skip the source completely
     228        if (source->tmpFlags & PM_SOURCE_TMPF_RADIAL_SKIP) continue;
     229        if (source->tmpFlags & PM_SOURCE_TMPF_RADIAL_KEEP) goto keepSource;
     230
    220231        // skip PSF-like and non-astronomical objects
    221232        if (source->type == PM_SOURCE_TYPE_DEFECT) continue;
     
    235246        if (source->peak->x > region->x1) continue;
    236247        if (source->peak->y > region->y1) continue;
     248
     249    keepSource:
    237250
    238251        // allocate pmSourceExtendedParameters, if not already defined
  • branches/eam_branches/ipp-20110906/psphot/src/psphotSourceMatch.c

    r32619 r32628  
    6767    objects = psArraySort (objects, pmPhotObjSortByX);
    6868 
    69     psVector *found = psVectorAlloc(sources->n, PS_TYPE_U8);
    70     psVectorInit (found, 0);
     69    psVector *foundSrc = psVectorAlloc(sources->n, PS_TYPE_U8);
     70    psVectorInit (foundSrc, 0);
     71
     72    psVector *foundObj = psVectorAlloc(sources->n, PS_TYPE_U8);
     73    psVectorInit (foundObj, 0);
    7174
    7275    // match sources to existing objects
     
    9396        if (dx > +1.02*RADIUS) NEXT2;
    9497 
     98        /* this block will match a given detection to the closest object within range of that detection.
     99           XXX note that this matches ALL detections within range of the single object to that same object
     100           this is bad, but I cannot just go in linear order (ie, mark off each object as they are
     101           used).  I should make a list of all Nobj * Ndet pairs in range and choose the matches
     102           based on their separations.  UGH
     103        */
     104   
    95105        // we are within match range, look for matches:
    96106        int Jmin = -1;
     
    98108        for (int J = j; (dx > -1.02*RADIUS) && (J < objects->n); J++) {
    99109 
     110            // skip objects that are already assigned:
     111            if (foundObj->data.U8[J]) continue;
    100112            obj = objects->data[J];
    101113           
     
    117129        }
    118130        obj = objects->data[Jmin];
     131        foundObj->data.U8[Jmin] = 1;
    119132
    120133        // add to object
    121134        pmPhotObjAddSource (obj, src);
    122         found->data.U8[i] = 1;
     135        foundSrc->data.U8[i] = 1;
    123136        i++;
    124137    }
     
    128141    for (i = 0; i < sources->n; i++) {
    129142
    130         if (found->data.U8[i]) continue;
     143        if (foundSrc->data.U8[i]) continue;
    131144
    132145        pmSource *src = sources->data[i];
     
    139152    psLogMsg ("psphot", PS_LOG_DETAIL, "matched sources (%ld vs %ld)", sources->n, objects->n);
    140153
    141     psFree (found);
     154    psFree (foundSrc);
     155    psFree (foundObj);
    142156    return true;
    143157}
     
    270284        pmPhotObj *obj = objects->data[i];
    271285        nSources += obj->sources->n;
     286        psAssert (obj->sources->n == nImages, "failed to match sources?");
    272287    }
    273288    psLogMsg ("psphot", PS_LOG_DETAIL, "total of %d sources for %d images", nSources, nImages);
  • branches/eam_branches/ipp-20110906/psphot/src/psphotStackObjects.c

    r32348 r32628  
    7070
    7171    // S/N limit to perform full non-linear fits
    72     float SN_LIM = psMetadataLookupF32 (&status, recipe, "EXTENDED_SOURCE_SN_LIM");
     72    float SN_LIM_PETRO  = psMetadataLookupF32 (&status, recipe, "EXTENDED_SOURCE_SN_LIM");
     73    float SN_LIM_RADIAL = psMetadataLookupF32 (&status, recipe, "RADIAL_APERTURES_SN_LIM");
    7374
    7475    bool doPetroStars   = psMetadataLookupBool (&status, recipe, "PETROSIAN_FOR_STARS");
     
    8182        // we check each source for an object and keep the object if any source is valid
    8283
    83         bool keepObject = false;
     84        bool keepObjectRadial = false;
     85        bool keepObjectPetro = false;
    8486        for (int j = 0; j < object->sources->n; j++) {
    8587
     
    9496            if (source->mode & PM_SOURCE_MODE_SATSTAR) continue;
    9597           
    96         // optionally allow non-extended objects to get petrosians as well
    97         if (!doPetroStars) {
    98             if (!(source->mode & PM_SOURCE_MODE_EXT_LIMIT)) continue;
    99             if (source->type == PM_SOURCE_TYPE_STAR) continue;
    100         }
    101 
    102             // limit selection to some SN limit
    103             // assert (source->peak); // how can a source not have a peak?
    104             // limit selection to some SN limit
    105             bool skipSource = false;
    106             if (source->mode & PM_SOURCE_MODE_EXT_LIMIT) {
    107                 skipSource = (source->moments->KronFlux < SN_LIM * source->moments->KronFluxErr);
    108             } else {
    109                 skipSource = (sqrt(source->peak->detValue) < SN_LIM);
    110             }
    111             if (skipSource) continue;
    112 
    11398            // limit selection by analysis region (this automatically apply
    11499            if (source->peak->x < AnalysisRegion.x0) continue;
     
    117102            if (source->peak->y > AnalysisRegion.y1) continue;
    118103           
    119             keepObject = true;
     104            // SN limit tests for RADIAL APERTURES:
     105            bool skipSourceRadial = false;
     106            if (source->mode & PM_SOURCE_MODE_EXT_LIMIT) {
     107                skipSourceRadial = (source->moments->KronFlux < SN_LIM_RADIAL * source->moments->KronFluxErr);
     108            } else {
     109                skipSourceRadial = (sqrt(source->peak->detValue) < SN_LIM_RADIAL);
     110            }
     111            if (!skipSourceRadial) keepObjectRadial = true;
     112
     113            // SN limit tests for PETRO
     114            bool skipSourcePetro = false;
     115            if (source->mode & PM_SOURCE_MODE_EXT_LIMIT) {
     116                skipSourcePetro = (source->moments->KronFlux < SN_LIM_PETRO * source->moments->KronFluxErr);
     117            } else {
     118                skipSourcePetro = doPetroStars ? (sqrt(source->peak->detValue) < SN_LIM_PETRO) : true;
     119            }
     120            if (!skipSourcePetro) keepObjectPetro = true;
     121
     122            keepObjectPetro = true;
    120123        }
    121124
     
    128131            // avoid the single-detection tests
    129132
    130             if (keepObject) {
    131                 source->tmpFlags |=  PM_SOURCE_TMPF_STACK_KEEP;
    132                 source->tmpFlags &= ~PM_SOURCE_TMPF_STACK_SKIP;
     133            if (keepObjectPetro) {
     134                source->tmpFlags |=  PM_SOURCE_TMPF_PETRO_KEEP;
     135                source->tmpFlags &= ~PM_SOURCE_TMPF_PETRO_SKIP;
    133136            } else {
    134                 source->tmpFlags |=  PM_SOURCE_TMPF_STACK_SKIP;
    135                 source->tmpFlags &= ~PM_SOURCE_TMPF_STACK_KEEP;
     137                source->tmpFlags |=  PM_SOURCE_TMPF_PETRO_SKIP;
     138                source->tmpFlags &= ~PM_SOURCE_TMPF_PETRO_KEEP;
     139            }       
     140
     141            if (keepObjectRadial) {
     142                source->tmpFlags |=  PM_SOURCE_TMPF_RADIAL_KEEP;
     143                source->tmpFlags &= ~PM_SOURCE_TMPF_RADIAL_SKIP;
     144            } else {
     145                source->tmpFlags |=  PM_SOURCE_TMPF_RADIAL_SKIP;
     146                source->tmpFlags &= ~PM_SOURCE_TMPF_RADIAL_KEEP;
    136147            }       
    137148        }
  • branches/eam_branches/ipp-20110906/psphot/src/psphotStackReadout.c

    r32616 r32628  
    4343
    4444bool psphotStackReadout (pmConfig *config, const pmFPAview *view) {
     45
     46    psArray *objects = NULL; // used below after 'pass1finish' label
    4547
    4648    // measure the total elapsed time in psphotReadout.  dtime is the elapsed time used jointly
     
    187189    psphotReplaceAllSources (config, view, STACK_SRC); // pass 1 (detections->allSources)
    188190
     191    // if we only do one pass, skip to extended source analysis
     192    if (!strcasecmp (breakPt, "PASS1")) goto pass1finish;
     193
    189194    // linear fit to include all sources (subtract again)
    190195    // NOTE : apply to ALL sources (extended + psf)
    191196    psphotFitSourcesLinear (config, view, STACK_SRC, true); // pass 2 (detections->allSources)
    192 
    193     // if we only do one pass, skip to extended source analysis
    194     if (!strcasecmp (breakPt, "PASS1")) goto pass1finish;
    195197
    196198    // NOTE: possibly re-measure background model here with objects subtracted / or masked
     
    241243        // XXX check on free of sources...
    242244        psphotMergeSources (config, view, STACK_SRC); // (detections->newSources + detections->allSources -> detections->allSources)
    243 
    244         // NOTE: apply to ALL sources
    245         psphotFitSourcesLinear (config, view, STACK_SRC, true); // pass 3 (detections->allSources)
    246245    }
    247246
    248247pass1finish:
     248
     249    // generate the objects (objects unify the sources from the different images) NOTE: could
     250    // this just match the detections for the chisq image, and not bother measuring the source
     251    // stats in that case...?
     252    objects = psphotMatchSources (config, view, STACK_SRC);
     253    psMemDump("matchsources");
     254
     255    psphotStackObjectsUnifyPosition (objects);
     256
     257    psphotStackObjectsSelectForAnalysis (config, view, STACK_SRC, objects);
     258
     259    // NOTE: apply to ALL sources
     260    psphotFitSourcesLinear (config, view, STACK_SRC, true); // pass 3 (detections->allSources)
    249261
    250262    // measure the radial profiles to the sky (only measures new objects)
     
    260272
    261273    psMemDump("psfstats");
    262 
    263     // XXX *** NOTE : this should happen above before the last psphotFitSourcesLinear in order
    264     // to generate psf forced photometry for the undetected sources
    265 
    266     // generate the objects (objects unify the sources from the different images)
    267     // XXX this could just match the detections for the chisq image, and not bother measuring the
    268     // source stats in that case...
    269     psArray *objects = psphotMatchSources (config, view, STACK_SRC);
    270     psMemDump("matchsources");
    271 
    272     psphotStackObjectsUnifyPosition (objects);
    273 
    274     psphotStackObjectsSelectForAnalysis (config, view, STACK_SRC, objects);
    275274
    276275    // measure elliptical apertures, petrosians (objects sorted by S/N)
     
    330329    psphotMagnitudes(config, view, STACK_SRC);
    331330
    332     if (0 && !psphotEfficiency(config, view, STACK_DET)) {
     331    // XXX NOTE: this function wants to have the PSF of the image, but we (so far) only measure the
     332    // PSF of the SRC image.  can we fake it by generating the PSF for DET as well (up above)?
     333    if (false && !psphotEfficiency(config, view, STACK_DET)) {
    333334        psErrorStackPrint(stderr, "Unable to determine detection efficiencies from fake sources");
    334335        psErrorClear();
Note: See TracChangeset for help on using the changeset viewer.