IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 19, 2012, 5:24:19 PM (14 years ago)
Author:
mhuber
Message:

merging latest r34040 trunk changes to branch

Location:
branches/meh_branches/ppstack_test
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/meh_branches/ppstack_test

  • branches/meh_branches/ppstack_test/psModules

  • branches/meh_branches/ppstack_test/psModules/src/objects/pmSourcePhotometry.c

    r33415 r34041  
    899899}
    900900
     901# if (HAVE_MODEL_VAR)
     902double pmSourceModelWeight(const pmSource *Mi, int term, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal)
     903# else
    901904double pmSourceModelWeight(const pmSource *Mi, int term, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal)
     905# endif
    902906{
    903907    PS_ASSERT_PTR_NON_NULL(Mi, NAN);
     908# if (HAVE_MODEL_VAR)
     909    double flux = 0, wt = 1.0, factor = 0;
     910# else
    904911    double flux = 0, wt = 0, factor = 0;
     912# endif
    905913
    906914    const psImage *Pi = Mi->modelFlux;
    907915    assert (Pi != NULL);
     916
     917# if (HAVE_MODEL_VAR)
     918    const psImage *Wi = NULL;
     919    switch (fitVarMode) {
     920      case PM_SOURCE_PHOTFIT_CONST:
     921        break;
     922      case PM_SOURCE_PHOTFIT_IMAGE_VAR:
     923        Wi = Mi->variance;
     924        psAssert (Wi, "programming error");
     925        break;
     926      case PM_SOURCE_PHOTFIT_MODEL_VAR:
     927        Wi = Mi->modelVar;
     928        psAssert (Wi, "programming error");
     929        break;
     930      case PM_SOURCE_PHOTFIT_NONE:
     931        psAbort("programming error");
     932    }   
     933# else
    908934    const psImage *Wi = Mi->variance;
    909935    if (!unweighted_sum) {
    910936        assert (Wi != NULL);
    911937    }
     938# endif
    912939    const psImage *Ti = Mi->maskObj;
    913940    assert (Ti != NULL);
     
    917944            if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi] & maskVal)
    918945                continue;
     946# if (HAVE_MODEL_VAR)
     947            if (fitVarMode != PM_SOURCE_PHOTFIT_CONST) {
     948                wt = covarFactor * Wi->data.F32[yi][xi];
     949                if (wt == 0) continue;
     950            }
     951# else
    919952            if (!unweighted_sum) {
    920953                wt = covarFactor * Wi->data.F32[yi][xi];
     
    922955                    continue;
    923956            }
     957# endif
    924958
    925959            switch (term) {
     
    937971            }
    938972
     973# if (HAVE_MODEL_VAR)
     974            // wt is 1.0 for CONST
     975            flux += (factor * Pi->data.F32[yi][xi]) / wt;
     976# else
    939977            if (unweighted_sum) {
    940978                flux += (factor * Pi->data.F32[yi][xi]);
     
    942980                flux += (factor * Pi->data.F32[yi][xi]) / wt;
    943981            }
     982# endif
    944983        }
    945984    }
     
    947986}
    948987
     988# if (HAVE_MODEL_VAR)
     989double pmSourceModelDotModel (const pmSource *Mi, const pmSource *Mj, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal)
     990# else
    949991double pmSourceModelDotModel (const pmSource *Mi, const pmSource *Mj, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal)
     992# endif
    950993{
    951994    PS_ASSERT_PTR_NON_NULL(Mi, NAN);
     
    955998    int xIs, xJs, yIs, yJs;
    956999    int xIe, yIe;
     1000# if (HAVE_MODEL_VAR)
     1001    double flux;
     1002    double wt = 1.0;
     1003# else
    9571004    double flux, wt;
     1005# endif
    9581006
    9591007    const psImage *Pi = Mi->modelFlux;
     
    9621010    assert (Pj != NULL);
    9631011
     1012# if (HAVE_MODEL_VAR)
     1013    const psImage *Wi = NULL;
     1014    switch (fitVarMode) {
     1015      case PM_SOURCE_PHOTFIT_CONST:
     1016        break;
     1017      case PM_SOURCE_PHOTFIT_IMAGE_VAR:
     1018        Wi = Mi->variance;
     1019        psAssert (Wi, "programming error");
     1020        break;
     1021      case PM_SOURCE_PHOTFIT_MODEL_VAR:
     1022        Wi = Mi->modelVar;
     1023        psAssert (Wi, "programming error");
     1024        break;
     1025      case PM_SOURCE_PHOTFIT_NONE:
     1026        psAbort("programming error");
     1027    }   
     1028# else
    9641029    const psImage *Wi = Mi->variance;
    9651030    if (!unweighted_sum) {
    9661031        assert (Wi != NULL);
    9671032    }
     1033# endif
    9681034
    9691035    const psImage *Ti = Mi->maskObj;
     
    9951061                continue;
    9961062
     1063# if (HAVE_MODEL_VAR)
     1064            float value = (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
     1065            switch (fitVarMode) {
     1066              case PM_SOURCE_PHOTFIT_CONST:
     1067                wt = 1.0;
     1068                break;
     1069              case PM_SOURCE_PHOTFIT_IMAGE_VAR:
     1070              case PM_SOURCE_PHOTFIT_MODEL_VAR:
     1071                wt = covarFactor * Wi->data.F32[yi][xi];
     1072                break;
     1073              case PM_SOURCE_PHOTFIT_NONE:
     1074                psAbort("programming error");
     1075            }
     1076            // skip pixels with nonsense weight values
     1077            if (wt <= 0) continue;
     1078
     1079            flux += value / wt;
     1080# else
    9971081            // XXX skip the nonsense weight pixels?
    9981082            if (unweighted_sum) {
     
    10041088                }
    10051089            }
     1090# endif
    10061091        }
    10071092    }
     
    10091094}
    10101095
     1096# if (HAVE_MODEL_VAR)
     1097double pmSourceDataDotModel (const pmSource *Mi, const pmSource *Mj, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal)
     1098# else
    10111099double pmSourceDataDotModel (const pmSource *Mi, const pmSource *Mj, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal)
     1100# endif
    10121101{
    10131102    PS_ASSERT_PTR_NON_NULL(Mi, NAN);
     
    10171106    int xIs, xJs, yIs, yJs;
    10181107    int xIe, yIe;
     1108# if (HAVE_MODEL_VAR)
     1109    double flux;
     1110    double wt = 1.0;
     1111# else
    10191112    double flux, wt;
     1113# endif
    10201114
    10211115    const psImage *Pi = Mi->pixels;
     
    10241118    assert (Pj != NULL);
    10251119
     1120# if (HAVE_MODEL_VAR)
     1121    const psImage *Wi = NULL;
     1122    switch (fitVarMode) {
     1123      case PM_SOURCE_PHOTFIT_CONST:
     1124        break;
     1125      case PM_SOURCE_PHOTFIT_IMAGE_VAR:
     1126        Wi = Mi->variance;
     1127        psAssert (Wi, "programming error");
     1128        break;
     1129      case PM_SOURCE_PHOTFIT_MODEL_VAR:
     1130        Wi = Mi->modelVar;
     1131        psAssert (Wi, "programming error");
     1132        break;
     1133      case PM_SOURCE_PHOTFIT_NONE:
     1134        psAbort("programming error");
     1135    }   
     1136# else
    10261137    const psImage *Wi = Mi->variance;
    10271138    if (!unweighted_sum) {
    10281139        assert (Wi != NULL);
    10291140    }
     1141# endif
    10301142
    10311143    const psImage *Ti = Mi->maskObj;
     
    10571169                continue;
    10581170
     1171# if (HAVE_MODEL_VAR)
     1172            float value = (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
     1173            switch (fitVarMode) {
     1174              case PM_SOURCE_PHOTFIT_CONST:
     1175                wt = 1.0;
     1176                break;
     1177              case PM_SOURCE_PHOTFIT_IMAGE_VAR:
     1178              case PM_SOURCE_PHOTFIT_MODEL_VAR:
     1179                wt = covarFactor * Wi->data.F32[yi][xi];
     1180                break;
     1181              case PM_SOURCE_PHOTFIT_NONE:
     1182                psAbort("programming error");
     1183            }
     1184            // skip pixels with nonsense weight values
     1185            if (wt <= 0) continue;
     1186
     1187            flux += value / wt;
     1188
     1189# else
    10591190            // XXX skip the nonsense weight pixels?
    10601191            if (unweighted_sum) {
     
    10661197                }
    10671198            }
     1199# endif
    10681200        }
    10691201    }
Note: See TracChangeset for help on using the changeset viewer.