IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 13, 2005, 6:43:44 AM (21 years ago)
Author:
eugene
Message:

substantial work on ensemble PSF fitting, better functions for evaluation, overall code cleanups

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotMarkPSF.c

    r5672 r5772  
    11# include "psphot.h"
     2
     3// given a pmSource which has been fitted using modelPSF, evaluate the
     4// resulting fit: did the fit succeed? is this object PSF-like? is this object
     5// extended?  return status is TRUE for a valid PSF, FALSE otherwise.
    26
    37// identify objects consistent with PSF shape/magnitude distribution
     
    1418// this includes a minimum buffer (DS) for the brighter objects
    1519
    16 // saturated stars should fall outside (but are already IDed)
    17 // galaxies should be larger, cosmic rays smaller, but need to test?
     20// saturated stars should fall outside (larger), but have peaks above SATURATE
     21// galaxies should be larger, cosmic rays smaller
    1822// we also reject objects with S/N too low or ChiSquare to high
    19 
    20 // any object which meets the criterion is marked as PM_SOURCE_BRIGHTSTAR
    2123
    2224// floor for DS value
     
    3335
    3436    // do we actually have a valid PSF model?
    35     if (model == NULL) return (false);
     37    if (model == NULL) {
     38        source->mode &= ~PM_SOURCE_FITTED;
     39        return false;
     40    }
    3641
    3742    // did the model fit fail for one or another reason?
    3843    switch (model->status) {
     44      case PM_MODEL_UNTRIED:
     45        source->mode &= ~PM_SOURCE_FITTED;
     46        return false;
    3947      case PM_MODEL_BADARGS:
    40       case PM_MODEL_UNTRIED:
    41         source->type = PM_SOURCE_FAIL_FIT_PSF;  // better choice?
     48        source->mode |= PM_SOURCE_FAIL;
    4249        return false;
    4350      case PM_MODEL_SUCCESS:
     
    4653      case PM_MODEL_OFFIMAGE:
    4754        psLogMsg ("psphot", 5, "PSF fit failed for %f, %f (%d iterations)\n", model->params->data.F32[2], model->params->data.F32[3], model->nIter);
    48         source->type = PM_SOURCE_FAIL_FIT_PSF;  // better choice?
     55        source->mode |= PM_SOURCE_FAIL;
    4956        return false;
    5057      default:
     
    5259    }
    5360
     61    // unless we prove otherwise, this object is a star.
     62    source->type = PM_SOURCE_STAR;
     63
    5464    // if the object has fitted peak above saturation, label as SATSTAR
    5565    // this is a valid PSF object, but ignore the other quality tests
    5666    // remember: fit does not use saturated pixels (masked)
     67    // XXX no extended object can saturate and stay extended...
    5768    if (model->params->data.F32[1] >= SATURATE) {
    58         if (source->type == PM_SOURCE_PSFSTAR) {
     69        if (source->mode & PM_SOURCE_PSFSTAR) {
    5970            psLogMsg ("psphot", 5, "PSFSTAR marked SATSTAR\n");
    6071        }
    61         source->type = PM_SOURCE_SATSTAR;
    62         return (true);
     72        source->mode &= ~PM_SOURCE_PSFSTAR;
     73        source->mode |=  PM_SOURCE_SATSTAR;
     74        return true;
    6375    }
    6476
    6577    // if the object has a fitted peak below 0, the fit did not converge cleanly
    6678    if (model->params->data.F32[1] < 0) {
    67         source->type = PM_SOURCE_FAIL_FIT_PSF;
    68         return (false);
     79        source->mode |= PM_SOURCE_FAIL;
     80        return false;
    6981    }
    7082
    7183    // if the source was predicted to be a SATSTAR, but it fitted below saturation,
    7284    // make a note to the user
    73     if (source->type == PM_SOURCE_SATSTAR) {
    74         psLogMsg ("psphot", 5, "SATSTAR marked GOODSTAR (fitted peak below saturation)\n");
    75         source->type = PM_SOURCE_GOODSTAR;
     85    if (source->mode & PM_SOURCE_SATSTAR) {
     86        psLogMsg ("psphot", 5, "SATSTAR marked normal (fitted peak below saturation)\n");
     87        source->mode &= ~PM_SOURCE_SATSTAR;
    7688    }
    7789
     
    93105    keep &= (SN > minSN);
    94106    keep &= (Chi < maxChi);
    95     if (keep) {
    96         if (source->type == PM_SOURCE_PSFSTAR) return (true);
    97         source->type = PM_SOURCE_GOODSTAR;
    98         return (true);
    99     }
    100    
    101     if (source->type == PM_SOURCE_PSFSTAR) {
     107    if (keep) return true;
     108
     109    // this source is not a star, unflag as PSFSTAR
     110    // XXX : if this object was used to build the PSF, this flag should
     111    //       be set even if the object is not a star...
     112    if (source->mode & PM_SOURCE_PSFSTAR) {
     113        source->mode &= ~PM_SOURCE_PSFSTAR;
    102114        psLogMsg ("psphot", 5, "PSFSTAR demoted based on fit quality\n");
    103115    }
     
    106118    if ((nSx <= -shapeNsigma) || (nSy <= -shapeNsigma)) {
    107119        source->type = PM_SOURCE_DEFECT;
    108         return (false);
     120        return false;
    109121    }
    110122
     
    112124    if ((nSx >= shapeNsigma) || (nSy >= shapeNsigma)) {
    113125        source->type = PM_SOURCE_GALAXY;
    114         return (false);
     126        return false;
    115127    }
    116128
    117     // object appears to be extremely faint: what is this?
    118     if (SN < minSN) {
    119         source->type = PM_SOURCE_FAINTSTAR;
    120         return (false);
    121     }
    122 
    123     // these are pooly fitted, probable stars near other stars?
    124     source->type = PM_SOURCE_POOR_FIT_PSF;
    125     return (false);
     129    // poor-quality fit; only keep if nothing else works...
     130    source->mode |= PM_SOURCE_POOR;
     131    return false;
    126132}       
Note: See TracChangeset for help on using the changeset viewer.