IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 28, 2006, 10:32:57 AM (20 years ago)
Author:
eugene
Message:

this is an important change. I have changed the way in which the psf
elliptical contour parameters are defined and fitted. SXX,SYY ->
1/SXX,1/SYY (ie, they are now ~ sigma, not ~1/sigma). SXY is now
fitted with the form SXY/(1/SXX2 + 1/SYY2)2

also added some additional tests and checks

File:
1 edited

Legend:

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

    r9270 r9771  
    66
    77// identify objects consistent with PSF shape/magnitude distribution
    8 // we expect dparams[4],dparams[5] to have a scatter of:
    9 // sigma_x / (S/N) * sqrt(2)
    10 // 1 / (params[4],params[5])*(S/N)
    11 
    12 // sigma_x : 1 / SX
    13 // dsx : 1 / (SX * SN)
    14 // dsx_o = hypot (1/(SX*SN), MIN_DSX)
     8// we expect dparams[PM_PAR_SXX],dparams[PM_PAR_SXX] to have a scatter of:
     9// sigma_x / (S/N)
    1510
    1611// any objects which is consistent with the PSF should have
    17 // abs(dparams[5]) < N * dsxLine(mag) & abs(dparams[6]) < N * dsyLine(mag)
     12// abs(dparams[PM_PAR_SXX]) < N * dsxLine(mag) & abs(dparams[PM_PAR_SYY]) < N * dsyLine(mag)
    1813// this includes a minimum buffer (DS) for the brighter objects
     14
     15// EAM : 2006.10.20 : I have re-defined params[PM_PAR_SXX] : it is now sqrt(2)*sigma_x, not 1/sigma_x
    1916
    2017// saturated stars should fall outside (larger), but have peaks above SATURATION
     
    5148    float dSX, dSY, SX, SY, SN;
    5249    float nSx, nSy, Chi;
     50
     51    // do we actually have a valid PSF model?
     52    if (model == NULL) {
     53        source->mode &= ~PM_SOURCE_MODE_FITTED;
     54        return false;
     55    }
     56
     57    // did the model fit fail for one or another reason?
     58    switch (model->status) {
     59      case PM_MODEL_SUCCESS:
     60        break;
     61      case PM_MODEL_UNTRIED:
     62        source->mode &= ~PM_SOURCE_MODE_FITTED;
     63        return false;
     64      case PM_MODEL_BADARGS:
     65      case PM_MODEL_NONCONVERGE:
     66      case PM_MODEL_OFFIMAGE:
     67      default:
     68        source->mode |= PM_SOURCE_MODE_FAIL;
     69        return false;
     70    }
     71
     72    // unless we prove otherwise, this object is a star.
     73    source->type = PM_SOURCE_TYPE_STAR;
     74
     75    // the following source->mode information pertains to modelPSF:
     76    source->mode |= PM_SOURCE_MODE_PSFMODEL;
     77
     78    // if the object has fitted peak above saturation, label as SATSTAR
     79    // this is a valid PSF object, but ignore the other quality tests
     80    // remember: fit does not use saturated pixels (masked)
     81    // XXX no extended object can saturate and stay extended...
     82    if (model->params->data.F32[PM_PAR_I0] >= SATURATION) {
     83        if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
     84            psLogMsg ("psphot", 5, "PSFSTAR marked SATSTAR\n");
     85        }
     86        source->mode |=  PM_SOURCE_MODE_SATSTAR;
     87        return true;
     88    }
     89
     90    // if the object has a fitted peak below 0, the fit did not converge cleanly
     91    if (model->params->data.F32[PM_PAR_I0] <= 0) {
     92        source->mode |= PM_SOURCE_MODE_FAIL;
     93        return false;
     94    }
     95
     96    // if the source was predicted to be a SATSTAR, but it fitted below saturation,
     97    // make a note to the user
     98    if (source->mode & PM_SOURCE_MODE_SATSTAR) {
     99        psLogMsg ("psphot", 5, "SATSTAR marked normal (fitted peak below saturation)\n");
     100        source->mode &= ~PM_SOURCE_MODE_SATSTAR;
     101    }
     102
     103    SN  = model->params->data.F32[PM_PAR_I0]/model->dparams->data.F32[1];
     104    SX  = model->params->data.F32[PM_PAR_SXX]/M_SQRT2;
     105    SY  = model->params->data.F32[PM_PAR_SYY]/M_SQRT2;
     106    dSX = model->dparams->data.F32[PM_PAR_SXX];
     107    dSY = model->dparams->data.F32[PM_PAR_SYY];
     108    Chi = model->chisqNorm / model->nDOF;
     109
     110    // swing of sigma_x,y in sigmas
     111    nSx = dSX / hypot (MIN_DS, (SX / SN));
     112    nSy = dSY / hypot (MIN_DS, (SY / SN));
     113
     114    // assign PM_SOURCE_MODE_GOODSTAR to bright objects within PSF region of dparams[]
     115    keep = TRUE;
     116    keep &= (fabs(nSx) < PSF_SHAPE_NSIGMA);
     117    keep &= (fabs(nSy) < PSF_SHAPE_NSIGMA);
     118    keep &= (SN > PSF_MIN_SN);
     119    keep &= (Chi < PSF_MAX_CHI);
     120    if (keep) return true;
     121
     122    // this source is not a star, warn if it was a PSFSTAR
     123    if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
     124        psLogMsg ("psphot", 5, "PSFSTAR demoted based on fit quality   (%f, %f  :  %f %f %f %f)\n",
     125                  model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], nSx, nSy, SN, Chi);
     126    } else {
     127        psLogMsg ("psphot", 5, "fails PSF fit (%f, %f  :  %f %f %f %f)\n",
     128                  model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], nSx, nSy, SN, Chi);
     129    }
     130
     131    // object appears to be small, suspected defect
     132    if ((nSx <= -PSF_SHAPE_NSIGMA) || (nSy <= -PSF_SHAPE_NSIGMA)) {
     133        source->type = PM_SOURCE_TYPE_DEFECT;
     134        return false;
     135    }
     136
     137    // object appears to be large, suspected extended source
     138    if ((nSx >= PSF_SHAPE_NSIGMA) || (nSy >= PSF_SHAPE_NSIGMA)) {
     139        source->type = PM_SOURCE_TYPE_EXTENDED;
     140        return false;
     141    }
     142
     143    // poor-quality fit; only keep if nothing else works...
     144    source->mode |= PM_SOURCE_MODE_POOR;
     145    return false;
     146}       
     147
     148// examine the model->status, fit parameters, etc and decide if the model succeeded
     149// set the source->type and source->mode appropriately
     150bool psphotEvalDBL (pmSource *source, pmModel *model) {
    53151
    54152    // do we actually have a valid PSF model?
     
    103201        source->mode &= ~PM_SOURCE_MODE_SATSTAR;
    104202    }
    105 
    106     SN  = model->params->data.F32[1]/model->dparams->data.F32[1];
    107     SX  = model->params->data.F32[4];
    108     SY  = model->params->data.F32[5];
    109     dSX = model->dparams->data.F32[4];
    110     dSY = model->dparams->data.F32[5];
    111     Chi = model->chisqNorm / model->nDOF;
    112 
    113     // swing of sigma_x,y in sigmas
    114     nSx = dSX / hypot (MIN_DS, 1 / (SX * SN));
    115     nSy = dSY / hypot (MIN_DS, 1 / (SY * SN));
    116 
    117     // assign PM_SOURCE_MODE_GOODSTAR to bright objects within PSF region of dparams[]
    118     keep = TRUE;
    119     keep &= (fabs(nSx) < PSF_SHAPE_NSIGMA);
    120     keep &= (fabs(nSy) < PSF_SHAPE_NSIGMA);
    121     keep &= (SN > PSF_MIN_SN);
    122     keep &= (Chi < PSF_MAX_CHI);
    123     if (keep) return true;
    124 
    125     // this source is not a star, warn if it was a PSFSTAR
    126     if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
    127         psLogMsg ("psphot", 5, "PSFSTAR demoted based on fit quality   (%f, %f  :  %f %f %f %f)\n",
    128                   model->params->data.F32[2], model->params->data.F32[3], nSx, nSy, SN, Chi);
    129     } else {
    130         psLogMsg ("psphot", 5, "fails PSF fit (%f, %f  :  %f %f %f %f)\n",
    131                   model->params->data.F32[2], model->params->data.F32[3], nSx, nSy, SN, Chi);
    132     }
    133 
    134     // object appears to be small, suspected defect
    135     if ((nSx <= -PSF_SHAPE_NSIGMA) || (nSy <= -PSF_SHAPE_NSIGMA)) {
    136         source->type = PM_SOURCE_TYPE_DEFECT;
    137         return false;
    138     }
    139 
    140     // object appears to be large, suspected extended source
    141     if ((nSx >= PSF_SHAPE_NSIGMA) || (nSy >= PSF_SHAPE_NSIGMA)) {
    142         source->type = PM_SOURCE_TYPE_EXTENDED;
    143         return false;
    144     }
    145 
    146     // poor-quality fit; only keep if nothing else works...
    147     source->mode |= PM_SOURCE_MODE_POOR;
    148     return false;
    149 }       
    150 
    151 // examine the model->status, fit parameters, etc and decide if the model succeeded
    152 // set the source->type and source->mode appropriately
    153 bool psphotEvalDBL (pmSource *source, pmModel *model) {
    154 
    155     // do we actually have a valid PSF model?
    156     if (model == NULL) {
    157         source->mode &= ~PM_SOURCE_MODE_FITTED;
    158         return false;
    159     }
    160 
    161     // did the model fit fail for one or another reason?
    162     switch (model->status) {
    163       case PM_MODEL_SUCCESS:
    164         break;
    165       case PM_MODEL_UNTRIED:
    166         source->mode &= ~PM_SOURCE_MODE_FITTED;
    167         return false;
    168       case PM_MODEL_BADARGS:
    169       case PM_MODEL_NONCONVERGE:
    170       case PM_MODEL_OFFIMAGE:
    171       default:
    172         source->mode |= PM_SOURCE_MODE_FAIL;
    173         return false;
    174     }
    175 
    176     // unless we prove otherwise, this object is a star.
    177     source->type = PM_SOURCE_TYPE_STAR;
    178 
    179     // the following source->mode information pertains to modelPSF:
    180     source->mode |= PM_SOURCE_MODE_PSFMODEL;
    181 
    182     // if the object has fitted peak above saturation, label as SATSTAR
    183     // this is a valid PSF object, but ignore the other quality tests
    184     // remember: fit does not use saturated pixels (masked)
    185     // XXX no extended object can saturate and stay extended...
    186     if (model->params->data.F32[1] >= SATURATION) {
    187         if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
    188             psLogMsg ("psphot", 5, "PSFSTAR marked SATSTAR\n");
    189         }
    190         source->mode |=  PM_SOURCE_MODE_SATSTAR;
    191         return true;
    192     }
    193 
    194     // if the object has a fitted peak below 0, the fit did not converge cleanly
    195     if (model->params->data.F32[1] <= 0) {
    196         source->mode |= PM_SOURCE_MODE_FAIL;
    197         return false;
    198     }
    199 
    200     // if the source was predicted to be a SATSTAR, but it fitted below saturation,
    201     // make a note to the user
    202     if (source->mode & PM_SOURCE_MODE_SATSTAR) {
    203         psLogMsg ("psphot", 5, "SATSTAR marked normal (fitted peak below saturation)\n");
    204         source->mode &= ~PM_SOURCE_MODE_SATSTAR;
    205     }
    206203    return true;
    207204}       
Note: See TracChangeset for help on using the changeset viewer.