IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 26, 2013, 5:51:56 AM (13 years ago)
Author:
eugene
Message:

fixing the non-poisson chisq for pcm fits; normalize sky if we as for a normalized model

Location:
branches/eam_branches/ipp-20130904/psModules/src/objects
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130904/psModules/src/objects/pmModel.c

    r34498 r36314  
    217217    // the options allow us to modify various aspects of the model
    218218    if (mode & PM_MODEL_OP_NORM) {
     219        // if we are including the sky, renormalizing should force use to normalized down the sky flux
     220        params->data.F32[PM_PAR_SKY] /= params->data.F32[PM_PAR_I0];
    219221        params->data.F32[PM_PAR_I0] = 1.0;
    220222    }
    221223    if (!(mode & PM_MODEL_OP_SKY)) {
    222224        params->data.F32[PM_PAR_SKY] = 0.0;
    223     }
     225    } 
    224226    if (mode & PM_MODEL_OP_CENTER) {
    225227        params->data.F32[PM_PAR_XPOS] = image->col0 + 0.5*image->numCols;
  • branches/eam_branches/ipp-20130904/psModules/src/objects/pmPCM_MinimizeChisq.c

    r36311 r36314  
    135135        }
    136136
    137         if (1) {
     137        if (0) {
    138138            fprintf (stderr, "%d : ", min->iter);
    139139            for (int ti = 0; ti < params->n; ti++) {
  • branches/eam_branches/ipp-20130904/psModules/src/objects/pmPCMdata.c

    r36307 r36314  
    597597
    598598    // modelFlux always has unity normalization (I0 = 1.0)
    599     pmModelAdd (source->modelFlux, source->maskObj, model, PM_MODEL_OP_FULL | PM_MODEL_OP_NORM, maskVal);
     599    // pmModelAdd (source->modelFlux, source->maskObj, model, PM_MODEL_OP_FULL | PM_MODEL_OP_NORM, maskVal);
     600    pmModelAdd (source->modelFlux, NULL, model, PM_MODEL_OP_FULL | PM_MODEL_OP_SKY | PM_MODEL_OP_NORM, maskVal);
    600601
    601602    // convolve the model image with the PSF
  • branches/eam_branches/ipp-20130904/psModules/src/objects/pmSourceFitPCM.c

    r36085 r36314  
    5151# define TIMING 0
    5252
     53bool pmSourceChisqModelFlux (pmSource *source, pmModel *model, psImageMaskType maskVal);
     54
    5355bool pmSourceFitPCM (pmPCMdata *pcm, pmSource *source, pmSourceFitOptions *fitOptions, psImageMaskType maskVal, psImageMaskType markVal, int psfSize) {
    5456   
     
    113115    } else {
    114116        // xxx this is wrong because it does not convolve with the psf
    115         pmSourceChisqUnsubtracted (source, pcm->modelConv, maskVal);
     117        pmPCMMakeModel (source, pcm->modelConv, maskVal, psfSize);
     118        pmSourceChisqModelFlux (source, pcm->modelConv, maskVal);
    116119    }
    117120    if (TIMING) { t4 = psTimerMark ("pmSourceFitPCM"); }
  • branches/eam_branches/ipp-20130904/psModules/src/objects/pmSourcePhotometry.c

    r34498 r36314  
    902902}
    903903
     904bool pmSourceChisqModelFlux (pmSource *source, pmModel *model, psImageMaskType maskVal)
     905{
     906    PS_ASSERT_PTR_NON_NULL(source, false);
     907    PS_ASSERT_PTR_NON_NULL(model, false);
     908
     909    float dC = 0.0;
     910    int Npix = 0;
     911
     912    psVector *params = model->params;
     913    psImage  *image = source->pixels;
     914    psImage  *modelFlux = source->modelFlux;
     915    psImage  *mask = source->maskObj;
     916    psImage  *variance = source->variance;
     917
     918    float Io = params->data.F32[PM_PAR_I0];
     919
     920    for (int iy = 0; iy < image->numRows; iy++) {
     921        for (int ix = 0; ix < image->numCols; ix++) {
     922
     923            // skip pixels which are masked
     924            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskVal) continue;
     925
     926            if (variance->data.F32[iy][ix] <= 0) continue;
     927
     928            dC += PS_SQR (image->data.F32[iy][ix] - Io*modelFlux->data.F32[iy][ix]) / variance->data.F32[iy][ix];
     929            Npix ++;
     930        }
     931    }
     932    model->nPix = Npix;
     933    model->nDOF = Npix - model->nPar;
     934    model->chisq = dC;
     935    model->chisqNorm = dC / model->nDOF;
     936
     937    return (true);
     938}
     939
    904940double pmSourceModelWeight(const pmSource *Mi, int term, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal)
    905941{
Note: See TracChangeset for help on using the changeset viewer.