Changeset 32236
- Timestamp:
- Aug 31, 2011, 3:23:36 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20110710/psphot/src/psphotKronIterate.c
r32216 r32236 37 37 psAssert (detections, "missing detections?"); 38 38 39 psArray *sources = detections-> allSources;39 psArray *sources = detections->newSources ? detections->newSources : detections->allSources; 40 40 psAssert (sources, "missing sources?"); 41 41 … … 127 127 // psphotVisualRangeImage (kapa, kronWindow, "kronwin", 0, 0.0, 1.0); 128 128 129 psphotSaveImage (NULL, kronWindow, "kron.window.v0.fits");129 // psphotSaveImage (NULL, kronWindow, "kron.window.v0.fits"); 130 130 131 131 for (int j = 0; j < 5; j++) { … … 139 139 140 140 // replace object in image 141 bool reSubtract = false; 141 142 if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) { 142 143 pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 144 reSubtract = true; 143 145 } 144 146 … … 151 153 // clear the window function for this source based on the moments 152 154 psphotKronWindowSetSource (source, kronWindow, (j > 0), false); 153 // psphotKronWindowSetSource (source, kronWindow, false, false);154 155 // psphotVisualRangeImage (kapa, kronWindow, "kronwin", 1, 0.0, 1.0); 155 156 // 165, 539;157 if ((fabs(source->peak->xf - 165) < 3) && (fabs(source->peak->yf - 539) < 3)) {158 fprintf (stderr, "test obj\n");159 }160 156 161 157 // this function populates moments->Mrf,KronFlux,KronFluxErr … … 165 161 // set a window function for each source based on the moments 166 162 psphotKronWindowSetSource (source, kronWindow, true, true); 167 // psphotKronWindowSetSource (source, kronWindow, false, true); 168 169 // test source fluxes 170 pmSourceMagnitudes (source, psf, photMode, maskVal, markVal, source->apRadius); 171 float kmag = -2.5*log10(source->moments->KronFlux); 172 # define TEST_X1 167 173 # define TEST_Y1 299 174 # define TEST_X2 180 175 # define TEST_Y2 300 176 if ((fabs(source->peak->xf - TEST_X1) < 3) && (fabs(source->peak->yf - TEST_Y1) < 3)) { 177 fprintf (stderr, "R1: %f vs %f (%f) (%f)\n", source->moments->KronRadiusPSF, source->moments->Mrf, kmag, windowRadius); 163 164 // if we subtracted it above, re-subtract the object, leave local sky 165 if (reSubtract) { 166 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 178 167 } 179 if ((fabs(source->peak->xf - TEST_X2) < 3) && (fabs(source->peak->yf - TEST_Y2) < 3)) {180 fprintf (stderr, "R2: %f vs %f (%f) (%f)\n", source->moments->KronRadiusPSF, source->moments->Mrf, kmag, windowRadius);181 }182 183 // re-subtract the object, leave local sky184 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);185 168 } 186 char name[64];187 sprintf (name, "kron.window.v%d.fits", j+1);188 psphotSaveImage (NULL, kronWindow, name);169 // char name[64]; 170 // sprintf (name, "kron.window.v%d.fits", j+1); 171 // psphotSaveImage (NULL, kronWindow, name); 189 172 } 190 173 psFree (kronWindow); … … 275 258 assert (z >= 0.0); 276 259 277 // float weight = 1.0;260 // weight by window image and wide Gaussian 278 261 float weight1 = vWin[row+Ywo][col+Xwo]*exp(-z); 279 262 float weight2 = vWin[yFlip+Ywo][xFlip+Xwo]*exp(-z); 280 // float weight1 = vWin[row+Ywo][col+Xwo];281 // float weight2 = vWin[yFlip+Ywo][xFlip+Xwo];282 263 283 264 float fDiff1 = vPix[row][col]*weight1; … … 315 296 if (fabs(yDiff) > radKron) continue; 316 297 317 // coordinate of mirror pixel318 int yFlip = yCM - yDiff;319 if (yFlip < 0) continue;320 if (yFlip >= source->pixels->numRows) continue;321 322 298 for (psS32 col = 0; col < source->pixels->numCols ; col++) { 323 299 // check mask and value for this pixel … … 328 304 if (fabs(xDiff) > radKron) continue; 329 305 330 // coordinate of mirror pixel331 int xFlip = xCM - xDiff;332 if (xFlip < 0) continue;333 if (xFlip >= source->pixels->numCols) continue;334 335 // check mask and value for mirror pixel336 if (vMsk && (vMsk[yFlip][xFlip] & maskVal)) continue;337 if (isnan(vPix[yFlip][xFlip])) continue;338 339 306 // radKron is just a function of (xDiff, yDiff) 340 307 psF32 r2 = PS_SQR(xDiff) + PS_SQR(yDiff); 341 308 if (r2 > radKron2) continue; 342 309 343 // float z = r2 * rsigma2;344 // assert (z >= 0.0);345 346 // float weight = 1.0;347 // float weight1 = vWin[row+Ywo][col+Xwo]*exp(-z);348 // float weight2 = vWin[yFlip+Ywo][xFlip+Xwo]*exp(-z);349 310 float weight1 = vWin[row+Ywo][col+Xwo]; 350 float weight2 = vWin[yFlip+Ywo][xFlip+Xwo];351 352 311 float fDiff1 = vPix[row][col]*weight1; 353 float fDiff2 = vPix[yFlip][xFlip]*weight2; 354 355 float pDiff = (fDiff1 > 0.0) ? sqrt(fabs(fDiff1*fDiff2)) : -sqrt(fabs(fDiff1*fDiff2)); 312 313 float pDiff = fDiff1; 356 314 psF32 wDiff = vWgt[row][col] * weight1; 357 315 … … 365 323 source->moments->Mrf = Mrf; 366 324 source->moments->KronFlux = Sum; 367 source->moments->KronFluxErr = Sum * (nKronPix / Win); 368 // source->moments->KronFluxErr = sqrt(Var / Win); 325 source->moments->KronFluxErr = sqrt(Var); 369 326 370 327 return true; … … 393 350 float Mminor = 0.5*(Mxx + Myy) - 0.5*sqrt(PS_SQR(Mxx - Myy) + 4.0*PS_SQR(Mxy)); 394 351 395 // float kratio = source->moments->KronFinner / source->moments->KronFlux; 396 352 // Mxx, Mxy, Myy define the elliptical shape, but Mrf defines the width 397 353 float scale = PS_SQR(0.5 * source->moments->Mrf) / Mmajor; 398 // float scale = useKronRadius ? 2.0 * source->moments->Mrf / Mmajor : 2.0;399 // float scale = (kratio > 0.4) ? 9.0 * source->moments->Mrf / Mmajor : 3.0 * source->moments->Mrf / Mmajor;400 354 401 355 float Sxx = scale * Mmajor * Mminor / Myy; // sigma_x^2
Note:
See TracChangeset
for help on using the changeset viewer.
