- Timestamp:
- Jan 9, 2012, 8:36:04 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20111122/psModules/src/objects/pmSourcePhotometry.c
r32923 r33044 900 900 } 901 901 902 double pmSourceModelWeight(const pmSource *Mi, int term, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal)902 double pmSourceModelWeight(const pmSource *Mi, int term, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal) 903 903 { 904 904 PS_ASSERT_PTR_NON_NULL(Mi, NAN); … … 907 907 const psImage *Pi = Mi->modelFlux; 908 908 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 913 924 const psImage *Ti = Mi->maskObj; 914 925 assert (Ti != NULL); … … 916 927 for (int yi = 0; yi < Pi->numRows; yi++) { 917 928 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) { 921 931 wt = covarFactor * Wi->data.F32[yi][xi]; 922 if (wt == 0) 923 continue; 932 if (wt == 0) continue; 924 933 } 925 934 … … 948 957 } 949 958 950 double pmSourceModelDotModel (const pmSource *Mi, const pmSource *Mj, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal)959 double pmSourceModelDotModel (const pmSource *Mi, const pmSource *Mj, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal) 951 960 { 952 961 PS_ASSERT_PTR_NON_NULL(Mi, NAN); … … 963 972 assert (Pj != NULL); 964 973 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 } 969 987 970 988 const psImage *Ti = Mi->maskObj; … … 996 1014 continue; 997 1015 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: 1002 1023 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; 1007 1030 } 1008 1031 } … … 1010 1033 } 1011 1034 1012 double pmSourceDataDotModel (const pmSource *Mi, const pmSource *Mj, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal)1035 double pmSourceDataDotModel (const pmSource *Mi, const pmSource *Mj, const pmSourceFitVarMode fitVarMode, const float covarFactor, psImageMaskType maskVal) 1013 1036 { 1014 1037 PS_ASSERT_PTR_NON_NULL(Mi, NAN); … … 1025 1048 assert (Pj != NULL); 1026 1049 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 } 1031 1063 1032 1064 const psImage *Ti = Mi->maskObj; … … 1058 1090 continue; 1059 1091 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: 1064 1099 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 1069 1107 } 1070 1108 }
Note:
See TracChangeset
for help on using the changeset viewer.
