IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28677


Ignore:
Timestamp:
Jul 15, 2010, 6:31:24 AM (16 years ago)
Author:
eugene
Message:

correctly unmark unused PSF candidates using source id; grid search for sersic terms

Location:
branches/eam_branches/ipp-20100621/psphot/src
Files:
3 edited

Legend:

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

    r28657 r28677  
    244244
    245245    // try each model option listed in config
     246    // pmPSFtryModel makes a local copy of the sources -- those points are not the same as those for 'sources'
    246247    for (int i = 0; i < modelNames->n; i++) {
    247248        char *modelName = modelNames->data[i];
     
    321322
    322323    // unset the PSFSTAR flag for stars not used for PSF model
     324    // XXX a more efficient way of achieving this would be to record a pair of arrays
     325    // of the source index and the source id for the psf stars.  but that would require we do
     326    // not re-sort the source list in the meanwhile
     327    int nDrop = 0;
    323328    for (int i = 0; i < try->sources->n; i++) {
    324329        pmSource *source = try->sources->data[i];
    325330        if (try->mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    326             source->mode &= ~PM_SOURCE_MODE_PSFSTAR;
    327         }
    328     }
     331            // need to find this source in the original list (these are copies, not pointers)
     332            for (int j = 0; j < sources->n; j++) {
     333                pmSource *realSource = sources->data[j];
     334                if (realSource->id != source->id) continue;
     335                realSource->mode &= ~PM_SOURCE_MODE_PSFSTAR;
     336                source->mode &= ~PM_SOURCE_MODE_PSFSTAR;
     337                nDrop ++;
     338                break;
     339            }
     340        }
     341    }
     342    // fprintf (stderr, "drop %d stars as PSF stars\n", nDrop);
     343
     344    // XXX is this working?
     345    // int N1 = 0;
     346    // for (int i = 0; i < try->sources->n; i++) {
     347    //     pmSource *source = try->sources->data[i];
     348    //  fprintf (stderr, "%llx : %d\n", (long long int) source, (source->mode & PM_SOURCE_MODE_PSFSTAR));
     349    //  if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
     350    //      N1 ++;
     351    //     }
     352    // }
     353    // int N2 = 0;
     354    // for (int i = 0; i < sources->n; i++) {
     355    //     pmSource *source = sources->data[i];
     356    //  fprintf (stderr, "%llx : %d\n", (long long int) source, (source->mode & PM_SOURCE_MODE_PSFSTAR));
     357    //  if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
     358    //      N2 ++;
     359    //     }
     360    // }
     361    // fprintf (stderr, "N1: %d, N2: %d\n", N1, N2);
    329362
    330363    // build a PSF residual image
  • branches/eam_branches/ipp-20100621/psphot/src/psphotSourceFits.c

    r28657 r28677  
    345345
    346346    // copy most data from the primary source (modelEXT, blends stay NULL)
    347     pmSource *newSrc = pmSourceCopy (source);
     347    pmSource *newSrc = pmSourceCopyData (source);
    348348    newSrc->modelPSF = psMemIncrRefCounter (DBL->data[1]);
    349349    newSrc->modelPSF->fitRadius = radius;
     
    447447    maskVal |= markVal;
    448448
    449     psTraceSetLevel("psLib.math.psMinimizeLMChi2", 5);
     449    // psTraceSetLevel("psLib.math.psMinimizeLMChi2", 5);
    450450
    451451    // use the source moments, etc to guess basic model parameters
     
    460460    }
    461461
    462     // for sersic models, get the initial guess more carefully
     462    // for sersic models, use a grid search to choose an index, then float the params there
    463463    if (modelType == pmModelClassGetType("PS_MODEL_SERSIC")) {
    464464        psphotFitSersicIndex (source, EXT, fitOptions, maskVal);
    465465    }
    466466
    467     // fit EXT (not PSF) model (set/unset the pixel mask)
    468     options.mode = PM_SOURCE_FIT_EXT;
     467    if (modelType == pmModelClassGetType("PS_MODEL_SERSIC")) {
     468        options.mode = PM_SOURCE_FIT_NO_INDEX;
     469    } else {
     470        options.mode = PM_SOURCE_FIT_EXT;
     471    }
    469472    pmSourceFitModel (source, EXT, &options, maskVal);
    470473
    471     psTraceSetLevel("psLib.math.psMinimizeLMChi2", 0);
     474    // psTraceSetLevel("psLib.math.psMinimizeLMChi2", 0);
    472475    return (EXT);
    473476}
    474477
    475 float indexGuess[] = {0.5, 0.25, 0.125};
     478// note that these should be 1/2n of the standard sersic index
     479float indexGuess[] = {0.5, 0.33, 0.25, 0.167, 0.125, 0.083};
    476480
    477481// A sersic model is very sensitive to the index.  attempt to find the index first by grid search in just the index
  • branches/eam_branches/ipp-20100621/psphot/src/psphotSourceSize.c

    r28643 r28677  
    364364        float nSigmaMYY = (Myy - psfClump->Y) / hypot(psfClump->dY, psfClump->Y*psfClump->Y*source->errMag);
    365365
    366         fprintf (stderr, "Mxx: %f, Myy: %f, dx: %f, dy: %f, psfMag: %f, apMag: %f, dMag: %f, errMag: %f, nSigmaMag: %f\n",
    367                  Mxx, Myy, source->peak->xf - source->moments->Mx, source->peak->yf - source->moments->My,
     366        fprintf (stderr, "%f %f : Mxx: %f, Myy: %f, dx: %f, dy: %f, psfMag: %f, apMag: %f, dMag: %f, errMag: %f, nSigmaMag: %f\n",
     367                 source->peak->xf, source->peak->yf, Mxx, Myy, source->peak->xf - source->moments->Mx, source->peak->yf - source->moments->My,
    368368                 source->psfMag, apMag, dMag, source->errMag, nSigmaMAG);
    369369
Note: See TracChangeset for help on using the changeset viewer.