Changeset 26609
- Timestamp:
- Jan 14, 2010, 11:15:29 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20091201/psModules/src/imcombine/pmSubtractionEquation.c
r26593 r26609 15 15 #include "pmSubtractionVisual.h" 16 16 17 // #define TESTING // TESTING output for debugging; may not work with threads!17 //#define TESTING // TESTING output for debugging; may not work with threads! 18 18 19 19 //#define USE_WEIGHT // Include weight (1/variance) in equation? … … 487 487 // Contribution to chi^2: a_i^2 P_i 488 488 psAssert(isfinite(penalties->data.F32[i]), "Invalid penalty"); 489 matrix->data.F64[index][index] -= norm * penalties->data.F32[i];489 matrix->data.F64[index][index] += norm * penalties->data.F32[i]; 490 490 } 491 491 } … … 1337 1337 float peak = 0.0; 1338 1338 for (int y = - footprint; y <= footprint; y++) { 1339 for (int x = - footprint; x <= footprint; x++) {1340 sum += 0.5*(target->kernel[y][x] + source->kernel[y][x] * norm);1341 peak = PS_MAX(peak, 0.5*(target->kernel[y][x] + source->kernel[y][x] * norm));1342 }1339 for (int x = - footprint; x <= footprint; x++) { 1340 sum += 0.5*(target->kernel[y][x] + source->kernel[y][x] * norm); 1341 peak = PS_MAX(peak, 0.5*(target->kernel[y][x] + source->kernel[y][x] * norm)); 1342 } 1343 1343 } 1344 1344 … … 1353 1353 1354 1354 for (int y = - footprint; y <= footprint; y++) { 1355 for (int x = - footprint; x <= footprint; x++) {1356 float dflux = 0.5*(target->kernel[y][x] + source->kernel[y][x] * norm);1357 if (dflux < 0.02*sum) continue;1358 dflux1 += residual->kernel[y][x];1359 dflux2 += PS_SQR(residual->kernel[y][x]);1360 dmax = PS_MAX(residual->kernel[y][x], dmax);1361 dmin = PS_MIN(residual->kernel[y][x], dmin);1362 npix ++;1363 }1355 for (int x = - footprint; x <= footprint; x++) { 1356 float dflux = 0.5*(target->kernel[y][x] + source->kernel[y][x] * norm); 1357 if (dflux < 0.02*sum) continue; 1358 dflux1 += residual->kernel[y][x]; 1359 dflux2 += PS_SQR(residual->kernel[y][x]); 1360 dmax = PS_MAX(residual->kernel[y][x], dmax); 1361 dmin = PS_MIN(residual->kernel[y][x], dmin); 1362 npix ++; 1363 } 1364 1364 } 1365 1365 float sigma = sqrt(dflux2 / npix - PS_SQR(dflux1/npix)); … … 1398 1398 psVector *keepStamps = psVectorAlloc(stamps->num, PS_TYPE_S32); 1399 1399 psVectorInit (keepStamps, 0); 1400 { 1401 psVector *flux = psVectorAlloc(stamps->num, PS_TYPE_F32);1402 psVectorInit (flux, 0.0);1403 1404 for (int i = 0; i < stamps->num; i++) {1405 pmSubtractionStamp *stamp = stamps->stamps->data[i];1406 if (!isfinite(stamp->flux)) continue;1407 flux->data.F32[i] = stamp->flux;1408 }1409 1410 psVector *index = psVectorSortIndex(NULL, flux);1411 for (int i = 0; (i < stamps->num) && (i < 9); i++) {1412 int n = stamps->num - i - 1;1413 keepStamps->data.S32[index->data.S32[n]] = 1;1414 fprintf (stderr, "keeping %d (%d of %d)\n", index->data.S32[n], n, 9);1415 }1416 psFree (flux);1417 psFree (index);1418 1419 // this function is called multiple times in the iteration, but 1420 // we only know after the interation is done if we will try again.1421 // therefore we must save the sample each time, and blow away the old one1422 // if it exists.1423 psFree (kernels->sampleStamps);1424 kernels->sampleStamps = psArrayAllocEmpty(9);1400 { 1401 psVector *flux = psVectorAlloc(stamps->num, PS_TYPE_F32); 1402 psVectorInit (flux, 0.0); 1403 1404 for (int i = 0; i < stamps->num; i++) { 1405 pmSubtractionStamp *stamp = stamps->stamps->data[i]; 1406 if (!isfinite(stamp->flux)) continue; 1407 flux->data.F32[i] = stamp->flux; 1408 } 1409 1410 psVector *index = psVectorSortIndex(NULL, flux); 1411 for (int i = 0; (i < stamps->num) && (i < 9); i++) { 1412 int n = stamps->num - i - 1; 1413 keepStamps->data.S32[index->data.S32[n]] = 1; 1414 fprintf (stderr, "keeping %d (%d of %d)\n", index->data.S32[n], n, 9); 1415 } 1416 psFree (flux); 1417 psFree (index); 1418 1419 // this function is called multiple times in the iteration, but 1420 // we only know after the interation is done if we will try again. 1421 // therefore we must save the sample each time, and blow away the old one 1422 // if it exists. 1423 psFree (kernels->sampleStamps); 1424 kernels->sampleStamps = psArrayAllocEmpty(9); 1425 1425 } 1426 1426 … … 1498 1498 } 1499 1499 1500 if (keepStamps->data.S32[i]) {1501 psImage *sample = psImageCopy(NULL, residual->image, PS_TYPE_F32);1502 psArrayAdd (kernels->sampleStamps, 9, sample);1503 psFree (sample);1504 }1505 1506 pmSubtractionResidualStats(fSigRes, fMaxRes, fMinRes, target, source, residual, norm, footprint);1500 if (keepStamps->data.S32[i]) { 1501 psImage *sample = psImageCopy(NULL, residual->image, PS_TYPE_F32); 1502 psArrayAdd (kernels->sampleStamps, 9, sample); 1503 psFree (sample); 1504 } 1505 1506 pmSubtractionResidualStats(fSigRes, fMaxRes, fMinRes, target, source, residual, norm, footprint); 1507 1507 1508 1508 } else { … … 1534 1534 } 1535 1535 } 1536 if (keepStamps->data.S32[i]) {1537 psImage *sample = psImageCopy(NULL, residual->image, PS_TYPE_F32);1538 psArrayAdd (kernels->sampleStamps, 9, sample);1539 psFree (sample);1540 }1541 1542 pmSubtractionResidualStats(fSigRes, fMaxRes, fMinRes, image1, image2, residual, norm, footprint);1536 if (keepStamps->data.S32[i]) { 1537 psImage *sample = psImageCopy(NULL, residual->image, PS_TYPE_F32); 1538 psArrayAdd (kernels->sampleStamps, 9, sample); 1539 psFree (sample); 1540 } 1541 1542 pmSubtractionResidualStats(fSigRes, fMaxRes, fMinRes, image1, image2, residual, norm, footprint); 1543 1543 } 1544 1544
Note:
See TracChangeset
for help on using the changeset viewer.
