IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30175


Ignore:
Timestamp:
Dec 24, 2010, 3:29:07 PM (15 years ago)
Author:
eugene
Message:

candidate psf stars are now noted with tmpFlags; use the psf try sources.parent to mark the actual PSFSTARS

File:
1 edited

Legend:

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

    r30141 r30175  
    166166    for (int i = 0; i < sources->n; i++) {
    167167        pmSource *source = sources->data[i];
    168         if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
    169             // keep NSTARS PSF stars, unmark the rest
     168        if (source->tmpFlags & PM_SOURCE_TMPF_CANDIDATE_PSFSTAR) {
     169            // keep NSTARS PSF stars
    170170            if (stars->n < NSTARS) {
    171171                psArrayAdd (stars, 200, source);
    172             } else {
    173                 source->mode &= ~PM_SOURCE_MODE_PSFSTAR;
    174172            }
    175173        }
     
    214212        psFree(options);
    215213
    216         // unset the PSFSTAR flags (none are used):
    217         for (int i = 0; i < sources->n; i++) {
    218             pmSource *source = sources->data[i];
    219             source->mode &= ~PM_SOURCE_MODE_PSFSTAR;
    220         }
     214        // no sources are used as PSF stars
    221215
    222216        // XXX set sxx, etc from FWHM in recipe
     
    292286        psLogMsg ("psphot.pspsf", PS_LOG_INFO, "Using guess PSF model");
    293287
    294         // unset the PSFSTAR flags (none are used):
    295         for (int i = 0; i < sources->n; i++) {
    296             pmSource *source = sources->data[i];
    297             source->mode &= ~PM_SOURCE_MODE_PSFSTAR;
    298         }
     288        // no sources are used as PSF stars
    299289
    300290        // XXX set sxx, etc from FWHM in recipe
     
    322312    pmPSFtry *try = models->data[bestN];
    323313
    324     // unset the PSFSTAR flag for stars not used for PSF model
    325     // XXX a more efficient way of achieving this would be to record a pair of arrays
    326     // of the source index and the source id for the psf stars.  but that would require we do
    327     // not re-sort the source list in the meanwhile
    328     int nDrop = 0;
     314    // set the PSFSTAR flag for stars used for the PSF model
     315    int nKeep = 0;
    329316    for (int i = 0; i < try->sources->n; i++) {
    330317        pmSource *source = try->sources->data[i];
    331         if (try->mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    332             // need to find this source in the original list (these are copies, not pointers)
    333             for (int j = 0; j < sources->n; j++) {
    334                 pmSource *realSource = sources->data[j];
    335                 if (realSource->id != source->id) continue;
    336                 realSource->mode &= ~PM_SOURCE_MODE_PSFSTAR;
    337                 source->mode &= ~PM_SOURCE_MODE_PSFSTAR;
    338                 nDrop ++;
    339                 break;
    340             }
    341         }
    342     }
    343     // fprintf (stderr, "drop %d stars as PSF stars\n", nDrop);
    344 
    345     // XXX is this working?
    346     // int N1 = 0;
    347     // for (int i = 0; i < try->sources->n; i++) {
    348     //     pmSource *source = try->sources->data[i];
    349     //  fprintf (stderr, "%llx : %d\n", (long long int) source, (source->mode & PM_SOURCE_MODE_PSFSTAR));
    350     //  if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
    351     //      N1 ++;
    352     //     }
    353     // }
    354     // int N2 = 0;
    355     // for (int i = 0; i < sources->n; i++) {
    356     //     pmSource *source = sources->data[i];
    357     //  fprintf (stderr, "%llx : %d\n", (long long int) source, (source->mode & PM_SOURCE_MODE_PSFSTAR));
    358     //  if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
    359     //      N2 ++;
    360     //     }
    361     // }
    362     // fprintf (stderr, "N1: %d, N2: %d\n", N1, N2);
     318        if (try->mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue;
     319
     320        // this source was used: find the parent and set its PSFSTAR flag
     321        pmSource *realSource = source->parent;
     322        psAssert (realSource, "pmPSFtryAlloc should have set the parent pointers");
     323        realSource->mode |= PM_SOURCE_MODE_PSFSTAR;
     324        nKeep ++;
     325    }
     326    psLogMsg ("psphot.pspsf", PS_LOG_DETAIL, "used %d of %ld candidate PSF objects\n", nKeep, try->sources->n);
    363327
    364328    // build a PSF residual image
     
    386350    }
    387351
    388     // XXX test dump of psf star data and psf-subtracted image
     352    // test dump of psf star data and psf-subtracted image
    389353    if (psTraceGetLevel("psphot.psfstars") > 5) {
    390354        psphotDumpPSFStars (readout, try, options->fitRadius, maskVal, markVal);
     
    413377        return false;
    414378    }
    415     psFree (psf); // XXX double-check
    416 
    417     // move into psphotChoosePSF
     379    psFree (psf);
     380
    418381    psphotVisualShowPSFModel (readout, psf);
    419382
Note: See TracChangeset for help on using the changeset viewer.