IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 9, 2012, 8:36:04 AM (15 years ago)
Author:
eugene
Message:

preparing to use model variance for fitting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20111122/psModules/src/objects/pmSourcePhotometry.c

    r32923 r33044  
    900900}
    901901
    902 double pmSourceModelWeight(const pmSource *Mi, int term, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal)
     902double pmSourceModelWeight(const pmSource *Mi, int term, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal)
    903903{
    904904    PS_ASSERT_PTR_NON_NULL(Mi, NAN);
     
    907907    const psImage *Pi = Mi->modelFlux;
    908908    assert (Pi != NULL);
    909     const psImage *Wi = Mi->variance;
    910     if (!unweighted_sum) {
    911         assert (Wi != NULL);
    912     }
     909
     910    const psImage *Wi = NULL;
     911    switch (fitVarMode) {
     912      case PM_SOURCE_PHOTFIT_CONST:
     913        break;
     914      case PM_SOURCE_PHOTFIT_IMAGE_VAR:
     915        Wi = Mi->variance;
     916        psAssert (Wi, "programming error");
     917        break;
     918      case PM_SOURCE_PHOTFIT_MODEL_VAR:
     919        Wi = Mi->modelVar;
     920        psAssert (Wi, "programming error");
     921        break;
     922    }   
     923
    913924    const psImage *Ti = Mi->maskObj;
    914925    assert (Ti != NULL);
     
    916927    for (int yi = 0; yi < Pi->numRows; yi++) {
    917928        for (int xi = 0; xi < Pi->numCols; xi++) {
    918             if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi] & maskVal)
    919                 continue;
    920             if (!unweighted_sum) {
     929            if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi] & maskVal) continue;
     930            if (fitVarMode != PM_SOURCE_PHOTFIT_CONST) {
    921931                wt = covarFactor * Wi->data.F32[yi][xi];
    922                 if (wt == 0)
    923                     continue;
     932                if (wt == 0) continue;
    924933            }
    925934
     
    948957}
    949958
    950 double pmSourceModelDotModel (const pmSource *Mi, const pmSource *Mj, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal)
     959double pmSourceModelDotModel (const pmSource *Mi, const pmSource *Mj, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal)
    951960{
    952961    PS_ASSERT_PTR_NON_NULL(Mi, NAN);
     
    963972    assert (Pj != NULL);
    964973
    965     const psImage *Wi = Mi->variance;
    966     if (!unweighted_sum) {
    967         assert (Wi != NULL);
    968     }
     974    const psImage *Wi = NULL;
     975    switch (fitVarMode) {
     976      case PM_SOURCE_PHOTFIT_CONST:
     977        break;
     978      case PM_SOURCE_PHOTFIT_IMAGE_VAR:
     979        Wi = Mi->variance;
     980        psAssert (Wi, "programming error");
     981        break;
     982      case PM_SOURCE_PHOTFIT_MODEL_VAR:
     983        Wi = Mi->modelVar;
     984        psAssert (Wi, "programming error");
     985        break;
     986    }   
    969987
    970988    const psImage *Ti = Mi->maskObj;
     
    9961014                continue;
    9971015
    998             // XXX skip the nonsense weight pixels?
    999             if (unweighted_sum) {
    1000                 flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
    1001             } else {
     1016            float value = (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
     1017            switch (fitVarMode) {
     1018              case PM_SOURCE_PHOTFIT_CONST:
     1019                wt = 1.0;
     1020                break;
     1021              case PM_SOURCE_PHOTFIT_IMAGE_VAR:
     1022              case PM_SOURCE_PHOTFIT_MODEL_VAR:
    10021023                wt = covarFactor * Wi->data.F32[yi][xi];
    1003                 if (wt > 0) {
    1004                     flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]) / wt;
    1005                 }
    1006             }
     1024                break;
     1025            }
     1026            // skip pixels with nonsense weight values
     1027            if (wt <= 0) continue;
     1028
     1029            flux += value / wt;
    10071030        }
    10081031    }
     
    10101033}
    10111034
    1012 double pmSourceDataDotModel (const pmSource *Mi, const pmSource *Mj, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal)
     1035double pmSourceDataDotModel (const pmSource *Mi, const pmSource *Mj, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal)
    10131036{
    10141037    PS_ASSERT_PTR_NON_NULL(Mi, NAN);
     
    10251048    assert (Pj != NULL);
    10261049
    1027     const psImage *Wi = Mi->variance;
    1028     if (!unweighted_sum) {
    1029         assert (Wi != NULL);
    1030     }
     1050    const psImage *Wi = NULL;
     1051    switch (fitVarMode) {
     1052      case PM_SOURCE_PHOTFIT_CONST:
     1053        break;
     1054      case PM_SOURCE_PHOTFIT_IMAGE_VAR:
     1055        Wi = Mi->variance;
     1056        psAssert (Wi, "programming error");
     1057        break;
     1058      case PM_SOURCE_PHOTFIT_MODEL_VAR:
     1059        Wi = Mi->modelVar;
     1060        psAssert (Wi, "programming error");
     1061        break;
     1062    }   
    10311063
    10321064    const psImage *Ti = Mi->maskObj;
     
    10581090                continue;
    10591091
    1060             // XXX skip the nonsense weight pixels?
    1061             if (unweighted_sum) {
    1062                 flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
    1063             } else {
     1092            float value = (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
     1093            switch (fitVarMode) {
     1094              case PM_SOURCE_PHOTFIT_CONST:
     1095                wt = 1.0;
     1096                break;
     1097              case PM_SOURCE_PHOTFIT_IMAGE_VAR:
     1098              case PM_SOURCE_PHOTFIT_MODEL_VAR:
    10641099                wt = covarFactor * Wi->data.F32[yi][xi];
    1065                 if (wt > 0) {
    1066                     flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]) / wt;
    1067                 }
    1068             }
     1100                break;
     1101            }
     1102            // skip pixels with nonsense weight values
     1103            if (wt <= 0) continue;
     1104
     1105            flux += value / wt;
     1106
    10691107        }
    10701108    }
Note: See TracChangeset for help on using the changeset viewer.