Changeset 33993 for trunk/psModules/src/objects/pmSourcePhotometry.c
- Timestamp:
- Jun 8, 2012, 6:32:36 AM (14 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/objects/pmSourcePhotometry.c (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmSourcePhotometry.c
r33963 r33993 899 899 } 900 900 901 # if (HAVE_MODEL_VAR) 901 902 double pmSourceModelWeight(const pmSource *Mi, int term, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal) 903 # else 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) 904 909 double flux = 0, wt = 1.0, factor = 0; 910 # else 911 double flux = 0, wt = 0, factor = 0; 912 # endif 905 913 906 914 const psImage *Pi = Mi->modelFlux; 907 915 assert (Pi != NULL); 908 916 917 # if (HAVE_MODEL_VAR) 909 918 const psImage *Wi = NULL; 910 919 switch (fitVarMode) { … … 922 931 psAbort("programming error"); 923 932 } 924 933 # else 934 const psImage *Wi = Mi->variance; 935 if (!unweighted_sum) { 936 assert (Wi != NULL); 937 } 938 # endif 925 939 const psImage *Ti = Mi->maskObj; 926 940 assert (Ti != NULL); … … 928 942 for (int yi = 0; yi < Pi->numRows; yi++) { 929 943 for (int xi = 0; xi < Pi->numCols; xi++) { 930 if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi] & maskVal) continue; 944 if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi] & maskVal) 945 continue; 946 # if (HAVE_MODEL_VAR) 931 947 if (fitVarMode != PM_SOURCE_PHOTFIT_CONST) { 932 948 wt = covarFactor * Wi->data.F32[yi][xi]; 933 949 if (wt == 0) continue; 934 950 } 951 # else 952 if (!unweighted_sum) { 953 wt = covarFactor * Wi->data.F32[yi][xi]; 954 if (wt == 0) 955 continue; 956 } 957 # endif 935 958 936 959 switch (term) { … … 948 971 } 949 972 973 # if (HAVE_MODEL_VAR) 950 974 // wt is 1.0 for CONST 951 975 flux += (factor * Pi->data.F32[yi][xi]) / wt; 976 # else 977 if (unweighted_sum) { 978 flux += (factor * Pi->data.F32[yi][xi]); 979 } else { 980 flux += (factor * Pi->data.F32[yi][xi]) / wt; 981 } 982 # endif 952 983 } 953 984 } … … 955 986 } 956 987 988 # if (HAVE_MODEL_VAR) 957 989 double pmSourceModelDotModel (const pmSource *Mi, const pmSource *Mj, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal) 990 # else 991 double pmSourceModelDotModel (const pmSource *Mi, const pmSource *Mj, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal) 992 # endif 958 993 { 959 994 PS_ASSERT_PTR_NON_NULL(Mi, NAN); … … 963 998 int xIs, xJs, yIs, yJs; 964 999 int xIe, yIe; 1000 # if (HAVE_MODEL_VAR) 965 1001 double flux; 966 1002 double wt = 1.0; 1003 # else 1004 double flux, wt; 1005 # endif 967 1006 968 1007 const psImage *Pi = Mi->modelFlux; … … 971 1010 assert (Pj != NULL); 972 1011 1012 # if (HAVE_MODEL_VAR) 973 1013 const psImage *Wi = NULL; 974 1014 switch (fitVarMode) { … … 986 1026 psAbort("programming error"); 987 1027 } 1028 # else 1029 const psImage *Wi = Mi->variance; 1030 if (!unweighted_sum) { 1031 assert (Wi != NULL); 1032 } 1033 # endif 988 1034 989 1035 const psImage *Ti = Mi->maskObj; … … 1015 1061 continue; 1016 1062 1063 # if (HAVE_MODEL_VAR) 1017 1064 float value = (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]); 1018 1065 switch (fitVarMode) { … … 1031 1078 1032 1079 flux += value / wt; 1080 # else 1081 // XXX skip the nonsense weight pixels? 1082 if (unweighted_sum) { 1083 flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]); 1084 } else { 1085 wt = covarFactor * Wi->data.F32[yi][xi]; 1086 if (wt > 0) { 1087 flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]) / wt; 1088 } 1089 } 1090 # endif 1033 1091 } 1034 1092 } … … 1036 1094 } 1037 1095 1096 # if (HAVE_MODEL_VAR) 1038 1097 double pmSourceDataDotModel (const pmSource *Mi, const pmSource *Mj, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal) 1098 # else 1099 double pmSourceDataDotModel (const pmSource *Mi, const pmSource *Mj, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal) 1100 # endif 1039 1101 { 1040 1102 PS_ASSERT_PTR_NON_NULL(Mi, NAN); … … 1044 1106 int xIs, xJs, yIs, yJs; 1045 1107 int xIe, yIe; 1108 # if (HAVE_MODEL_VAR) 1046 1109 double flux; 1047 1110 double wt = 1.0; 1111 # else 1112 double flux, wt; 1113 # endif 1048 1114 1049 1115 const psImage *Pi = Mi->pixels; … … 1052 1118 assert (Pj != NULL); 1053 1119 1120 # if (HAVE_MODEL_VAR) 1054 1121 const psImage *Wi = NULL; 1055 1122 switch (fitVarMode) { … … 1067 1134 psAbort("programming error"); 1068 1135 } 1136 # else 1137 const psImage *Wi = Mi->variance; 1138 if (!unweighted_sum) { 1139 assert (Wi != NULL); 1140 } 1141 # endif 1069 1142 1070 1143 const psImage *Ti = Mi->maskObj; … … 1096 1169 continue; 1097 1170 1171 # if (HAVE_MODEL_VAR) 1098 1172 float value = (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]); 1099 1173 switch (fitVarMode) { … … 1113 1187 flux += value / wt; 1114 1188 1189 # else 1190 // XXX skip the nonsense weight pixels? 1191 if (unweighted_sum) { 1192 flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]); 1193 } else { 1194 wt = covarFactor * Wi->data.F32[yi][xi]; 1195 if (wt > 0) { 1196 flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]) / wt; 1197 } 1198 } 1199 # endif 1115 1200 } 1116 1201 }
Note:
See TracChangeset
for help on using the changeset viewer.
