- Timestamp:
- Jun 19, 2012, 5:24:19 PM (14 years ago)
- Location:
- branches/meh_branches/ppstack_test
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/meh_branches/ppstack_test
- Property svn:mergeinfo changed
-
branches/meh_branches/ppstack_test/psModules
- Property svn:mergeinfo changed
-
branches/meh_branches/ppstack_test/psModules/src/objects/pmSourcePhotometry.c
r33415 r34041 899 899 } 900 900 901 # if (HAVE_MODEL_VAR) 902 double pmSourceModelWeight(const pmSource *Mi, int term, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal) 903 # else 901 904 double pmSourceModelWeight(const pmSource *Mi, int term, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal) 905 # endif 902 906 { 903 907 PS_ASSERT_PTR_NON_NULL(Mi, NAN); 908 # if (HAVE_MODEL_VAR) 909 double flux = 0, wt = 1.0, factor = 0; 910 # else 904 911 double flux = 0, wt = 0, factor = 0; 912 # endif 905 913 906 914 const psImage *Pi = Mi->modelFlux; 907 915 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 908 934 const psImage *Wi = Mi->variance; 909 935 if (!unweighted_sum) { 910 936 assert (Wi != NULL); 911 937 } 938 # endif 912 939 const psImage *Ti = Mi->maskObj; 913 940 assert (Ti != NULL); … … 917 944 if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi] & maskVal) 918 945 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 919 952 if (!unweighted_sum) { 920 953 wt = covarFactor * Wi->data.F32[yi][xi]; … … 922 955 continue; 923 956 } 957 # endif 924 958 925 959 switch (term) { … … 937 971 } 938 972 973 # if (HAVE_MODEL_VAR) 974 // wt is 1.0 for CONST 975 flux += (factor * Pi->data.F32[yi][xi]) / wt; 976 # else 939 977 if (unweighted_sum) { 940 978 flux += (factor * Pi->data.F32[yi][xi]); … … 942 980 flux += (factor * Pi->data.F32[yi][xi]) / wt; 943 981 } 982 # endif 944 983 } 945 984 } … … 947 986 } 948 987 988 # if (HAVE_MODEL_VAR) 989 double pmSourceModelDotModel (const pmSource *Mi, const pmSource *Mj, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal) 990 # else 949 991 double pmSourceModelDotModel (const pmSource *Mi, const pmSource *Mj, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal) 992 # endif 950 993 { 951 994 PS_ASSERT_PTR_NON_NULL(Mi, NAN); … … 955 998 int xIs, xJs, yIs, yJs; 956 999 int xIe, yIe; 1000 # if (HAVE_MODEL_VAR) 1001 double flux; 1002 double wt = 1.0; 1003 # else 957 1004 double flux, wt; 1005 # endif 958 1006 959 1007 const psImage *Pi = Mi->modelFlux; … … 962 1010 assert (Pj != NULL); 963 1011 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 964 1029 const psImage *Wi = Mi->variance; 965 1030 if (!unweighted_sum) { 966 1031 assert (Wi != NULL); 967 1032 } 1033 # endif 968 1034 969 1035 const psImage *Ti = Mi->maskObj; … … 995 1061 continue; 996 1062 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 997 1081 // XXX skip the nonsense weight pixels? 998 1082 if (unweighted_sum) { … … 1004 1088 } 1005 1089 } 1090 # endif 1006 1091 } 1007 1092 } … … 1009 1094 } 1010 1095 1096 # if (HAVE_MODEL_VAR) 1097 double pmSourceDataDotModel (const pmSource *Mi, const pmSource *Mj, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal) 1098 # else 1011 1099 double pmSourceDataDotModel (const pmSource *Mi, const pmSource *Mj, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal) 1100 # endif 1012 1101 { 1013 1102 PS_ASSERT_PTR_NON_NULL(Mi, NAN); … … 1017 1106 int xIs, xJs, yIs, yJs; 1018 1107 int xIe, yIe; 1108 # if (HAVE_MODEL_VAR) 1109 double flux; 1110 double wt = 1.0; 1111 # else 1019 1112 double flux, wt; 1113 # endif 1020 1114 1021 1115 const psImage *Pi = Mi->pixels; … … 1024 1118 assert (Pj != NULL); 1025 1119 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 1026 1137 const psImage *Wi = Mi->variance; 1027 1138 if (!unweighted_sum) { 1028 1139 assert (Wi != NULL); 1029 1140 } 1141 # endif 1030 1142 1031 1143 const psImage *Ti = Mi->maskObj; … … 1057 1169 continue; 1058 1170 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 1059 1190 // XXX skip the nonsense weight pixels? 1060 1191 if (unweighted_sum) { … … 1066 1197 } 1067 1198 } 1199 # endif 1068 1200 } 1069 1201 }
Note:
See TracChangeset
for help on using the changeset viewer.
