- 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/pmSource.c
r33415 r34041 39 39 #include "pmSourceExtendedPars.h" 40 40 #include "pmSourceDiffStats.h" 41 #include "pmSourcePhotometry.h" 41 42 #include "pmSource.h" 42 43 … … 50 51 psFree(tmp->pixels); 51 52 psFree(tmp->variance); 53 # if (HAVE_MODEL_VAR) 54 psFree(tmp->modelVar); 55 # endif 52 56 psFree(tmp->maskObj); 53 57 psFree(tmp->maskView); … … 76 80 psFree (source->pixels); 77 81 psFree (source->variance); 82 # if (HAVE_MODEL_VAR) 83 psFree (source->modelVar); 84 # endif 78 85 psFree (source->maskObj); 79 86 psFree (source->maskView); … … 83 90 source->pixels = NULL; 84 91 source->variance = NULL; 92 # if (HAVE_MODEL_VAR) 93 source->modelVar = NULL; 94 # endif 85 95 source->maskObj = NULL; 86 96 source->maskView = NULL; … … 112 122 source->pixels = NULL; 113 123 source->variance = NULL; 124 # if (HAVE_MODEL_VAR) 125 source->modelVar = NULL; 126 # endif 114 127 source->maskObj = NULL; 115 128 source->maskView = NULL; … … 159 172 source->radialAper = NULL; 160 173 source->parent = NULL; 174 source->tmpPtr = NULL; 161 175 source->imageID = -1; 176 source->nFrames = 0; 162 177 163 178 psMemSetDeallocator(source, (psFreeFunc) sourceFree); … … 197 212 source->pixels = in->pixels ? psImageCopyView(NULL, in->pixels) : NULL; 198 213 source->variance = in->variance ? psImageCopyView(NULL, in->variance) : NULL; 214 # if (HAVE_MODEL_VAR) 215 source->modelVar = NULL; 216 # endif 199 217 source->maskView = in->maskView ? psImageCopyView(NULL, in->maskView) : NULL; 200 218 … … 1026 1044 bool addNoise = mode & PM_MODEL_OP_NOISE; 1027 1045 1046 # if (HAVE_MODEL_VAR) 1047 bool addModelVar = mode & PM_MODEL_OP_MODELVAR; 1048 if (addModelVar) psAssert (source->modelVar, "programming error"); 1049 # endif 1050 1028 1051 // require the use of pmModelAddWithOffset if we are adding noise (because the model size and norm are rescaled) 1029 1052 if (!addNoise && source->modelFlux) { … … 1047 1070 } 1048 1071 1072 # if (HAVE_MODEL_VAR) 1073 psF32 **target = addModelVar ? source->modelVar->data.F32 : source->pixels->data.F32; 1074 # else 1049 1075 psF32 **target = source->pixels->data.F32; 1076 # endif 1050 1077 1051 1078 for (int iy = 0; iy < source->modelFlux->numRows; iy++) { … … 1062 1089 } 1063 1090 } 1091 # if (HAVE_MODEL_VAR) 1092 if (!addModelVar) { 1093 if (add) { 1094 source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED; 1095 } else { 1096 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED; 1097 } 1098 } 1099 # else 1064 1100 if (add) { 1065 1101 source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED; … … 1067 1103 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED; 1068 1104 } 1105 # endif 1069 1106 return true; 1070 1107 } … … 1074 1111 target = source->variance; 1075 1112 } 1113 # if (HAVE_MODEL_VAR) 1114 if (addModelVar) { 1115 target = source->modelVar; 1116 } 1117 # endif 1076 1118 1077 1119 if (add) { 1078 1120 status = pmModelAddWithOffset (target, source->maskObj, model, PM_MODEL_OP_FULL, maskVal, dx, dy); 1121 # if (HAVE_MODEL_VAR) 1122 if (!addNoise && !addModelVar) source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED; 1123 # else 1079 1124 source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED; 1125 # endif 1080 1126 } else { 1081 1127 status = pmModelSubWithOffset (target, source->maskObj, model, PM_MODEL_OP_FULL, maskVal, dx, dy); 1128 # if (HAVE_MODEL_VAR) 1129 if (!addNoise && !addModelVar) source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED; 1130 # else 1082 1131 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED; 1132 # endif 1083 1133 } 1084 1134 … … 1156 1206 PAR[PM_PAR_SYY] = oldshape.sy; 1157 1207 PAR[PM_PAR_SXY] = oldshape.sxy; 1208 1209 return true; 1210 } 1211 1212 bool pmSourceSmoothOp (pmSource *source, pmModelOpMode mode, psImage *target, float sigma, bool add, psImageMaskType maskVal, int dx, int dy) 1213 { 1214 // assert (mode & PM_MODEL_OP_NOISE); 1215 PS_ASSERT_PTR_NON_NULL(source, false); 1216 PS_ASSERT_PTR_NON_NULL(source->peak, false); 1217 PS_ASSERT_PTR_NON_NULL(target, false); 1218 1219 if (add) { 1220 psTrace ("psphot", 3, "adding smoothed object at %f,%f\n", source->peak->xf, source->peak->yf); 1221 } else { 1222 psTrace ("psphot", 3, "removing smooted object at %f,%f\n", source->peak->xf, source->peak->yf); 1223 } 1224 1225 pmModel *model = pmSourceGetModel(NULL, source); 1226 if (!model) { 1227 return false; 1228 } 1229 pmSourceSmoothOpModel (model, source, mode, target, sigma, add, maskVal, dx, dy); 1230 1231 return true; 1232 } 1233 1234 bool pmSourceSmoothOpModel (pmModel *model, pmSource *source, pmModelOpMode mode, psImage *target, float sigma, bool add, psImageMaskType maskVal, int dx, int dy) 1235 { 1236 bool status; 1237 psEllipseShape oldshape; 1238 psEllipseShape newshape; 1239 psEllipseAxes axes; 1240 1241 if (add) { 1242 psTrace ("psphot", 4, "adding smoothed object at %f,%f\n", model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS]); 1243 } else { 1244 psTrace ("psphot", 4, "removing smoothed object at %f,%f\n", model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS]); 1245 } 1246 1247 psF32 *PAR = model->params->data.F32; 1248 1249 // Isn't this hanging around somewhere? 1250 float oldFlux = NAN; 1251 if (!pmSourcePhotometryModel (NULL, &oldFlux, model)) return false; 1252 1253 // save original values 1254 float oldI0 = PAR[PM_PAR_I0]; 1255 float oldsxx = PAR[PM_PAR_SXX]; 1256 float oldsyy = PAR[PM_PAR_SYY]; 1257 float oldsxy = PAR[PM_PAR_SXY]; 1258 1259 // Since we are going to scale the flux correctly we need to get our 1260 // factors of sqrt(2) right 1261 oldshape.sx = oldsxx / M_SQRT2; 1262 oldshape.sy = oldsyy / M_SQRT2; 1263 oldshape.sxy = oldsxy; 1264 1265 // XXX can this be done more intelligently? 1266 if (oldI0 == 0.0) return false; 1267 if (!isfinite(oldI0)) return false; 1268 1269 // increase size and height of source 1270 axes = psEllipseShapeToAxes (oldshape, 20.0); 1271 axes.major = sqrt(PS_SQR(axes.major) + PS_SQR(sigma)); 1272 axes.minor = sqrt(PS_SQR(axes.minor) + PS_SQR(sigma)); 1273 newshape = psEllipseAxesToShape (axes); 1274 PAR[PM_PAR_SXX] = newshape.sx * M_SQRT2; 1275 PAR[PM_PAR_SYY] = newshape.sy * M_SQRT2; 1276 PAR[PM_PAR_SXY] = newshape.sxy; 1277 1278 PAR[PM_PAR_I0] = 1.0; 1279 1280 float newFlux; 1281 if (!pmSourcePhotometryModel (NULL, &newFlux, model)) return false; 1282 1283 PAR[PM_PAR_I0] = oldFlux / newFlux; 1284 1285 if (add) { 1286 status = pmModelAddWithOffset (target, source->maskObj, model, mode, maskVal, dx, dy); 1287 } else { 1288 status = pmModelSubWithOffset (target, source->maskObj, model, mode, maskVal, dx, dy); 1289 } 1290 1291 // restore original values 1292 PAR[PM_PAR_I0] = oldI0; 1293 PAR[PM_PAR_SXX] = oldsxx; 1294 PAR[PM_PAR_SYY] = oldsyy; 1295 PAR[PM_PAR_SXY] = oldsxy; 1158 1296 1159 1297 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
