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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.