Changeset 29148 for branches/eam_branches/ipp-20100823/psModules/src/imcombine/pmSubtractionEquation.c
- Timestamp:
- Sep 12, 2010, 12:38:23 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20100823/psModules/src/imcombine/pmSubtractionEquation.c
r29126 r29148 972 972 pmSubtractionStamp *stamp = stamps->stamps->data[i]; // Stamp of interest 973 973 if (stamp->status == PM_SUBTRACTION_STAMP_USED) { 974 974 975 (void)psBinaryOp(sumMatrix, sumMatrix, "+", stamp->matrix); 975 976 (void)psBinaryOp(sumVector, sumVector, "+", stamp->vector); 977 976 978 psVectorAppend(norms, stamp->norm); 979 977 980 pmSubtractionStampPrint(ds9, stamp->x, stamp->y, stamps->footprint, "green"); 978 981 numStamps++; … … 1107 1110 } 1108 1111 1109 #ifdef TESTING 1110 psFitsWriteImageSimple ("sumMatrix.fits", sumMatrix, NULL); 1112 #if 0 1113 psImage *save = psImageCopy(NULL, sumMatrix, PS_TYPE_F32); 1114 psFitsWriteImageSimple ("sumMatrix.fits", save, NULL); 1111 1115 psVectorWriteFile("sumVector.dat", sumVector); 1116 psFree (save); 1112 1117 #endif 1113 1118 … … 1191 1196 sumVector->data.F64[normIndex] = 0.0; 1192 1197 1193 solution = psMatrixSolveSVD(solution, sumMatrix, sumVector, NAN); 1194 1198 // save the matrix and vector after the NULLs have been set 1199 #if 0 1200 psImage *save = psImageCopy(NULL, sumMatrix, PS_TYPE_F32); 1201 psFitsWriteImageSimple ("sumMatrix.fits", save, NULL); 1202 psVectorWriteFile("sumVector.dat", sumVector); 1203 psFree (save); 1204 #endif 1205 1206 solution = psMatrixSolveSVD(solution, sumMatrix, sumVector, 1e-6); 1207 // solution = psMatrixSolveSVD(solution, sumMatrix, sumVector, 3e-4); 1208 // psVectorCopy (solution, sumVector, PS_TYPE_F64); 1209 // psMatrixGJSolve(sumMatrix, solution); 1195 1210 solution->data.F64[normIndex] = normValue; 1196 1211 } … … 1265 1280 } 1266 1281 1267 bool pmSubtractionResidualStats(psVector *fSigRes, psVector *fMaxRes, psVector *fMinRes, psKernel *target, psKernel *source, psKernel *residual, double norm, int footprint) { 1268 1269 // XXX measure some useful stats on the residuals 1282 // measure some useful stats on the stamp residuals: 1283 // fResSigma : the residual stdev / total flux 1284 // fResOuter : the residual fabs / total flux for R > 2 pix 1285 // fResTotal : the residual fabs / total flux for R > 0 pix 1286 bool pmSubtractionResidualStats(psVector *fResSigma, psVector *fResOuter, psVector *fResTotal, psKernel *target, psKernel *source, psKernel *residual, double norm, int footprint) { 1287 1270 1288 float sum = 0.0; 1271 1289 float peak = 0.0; … … 1277 1295 } 1278 1296 1279 // only count pixels with more than X% of the source flux1280 // calculate stdev(dflux)1297 // init counters 1298 int npix = 0; 1281 1299 float dflux1 = 0.0; 1282 1300 float dflux2 = 0.0; 1283 int npix = 0; 1284 1285 float dmax = 0.0; 1286 float dmin = 0.0; 1287 1288 // XXX update these with a bit more rigour 1301 float dOuter = 0.0; 1302 float dTotal = 0.0; 1303 1289 1304 for (int y = - footprint; y <= footprint; y++) { 1290 1305 for (int x = - footprint; x <= footprint; x++) { 1291 // float dflux = 0.5*(target->kernel[y][x] + source->kernel[y][x] * norm);1292 // if (dflux < 0.02*sum) continue;1293 1306 dflux1 += residual->kernel[y][x]; 1294 1307 dflux2 += PS_SQR(residual->kernel[y][x]); 1295 // dmax = PS_MAX(residual->kernel[y][x], dmax); 1296 // dmin = PS_MIN(residual->kernel[y][x], dmin); 1297 dmax += fabs(residual->kernel[y][x]); 1298 1308 dTotal += fabs(residual->kernel[y][x]); 1299 1309 if (hypot(x,y) > 2.0) { 1300 d min+= fabs(residual->kernel[y][x]);1310 dOuter += fabs(residual->kernel[y][x]); 1301 1311 } 1302 1312 npix ++; … … 1305 1315 float sigma = sqrt(dflux2 / npix - PS_SQR(dflux1/npix)); 1306 1316 if (!isfinite(sum)) return false; 1307 if (!isfinite(dmax)) return false;1308 if (!isfinite(dmin)) return false;1309 1317 if (!isfinite(peak)) return false; 1310 1311 fprintf (stderr, "sum: %f, peak: %f, sigma: %f, fsigma: %f, fmax: %f, fmin: %f\n", sum, peak, sigma, sigma/sum, dmax/sum, dmin/sum); 1312 psVectorAppend(fSigRes, sigma/sum); 1313 psVectorAppend(fMaxRes, dmax/sum); 1314 psVectorAppend(fMinRes, dmin/sum); 1318 if (!isfinite(dOuter)) return false; 1319 if (!isfinite(dTotal)) return false; 1320 1321 fprintf (stderr, "sum: %f, peak: %f, sigma: %f, fsigma: %f, fmax: %f, fmin: %f\n", sum, peak, sigma, sigma/sum, dOuter/sum, dTotal/sum); 1322 psVectorAppend(fResSigma, sigma/sum); 1323 psVectorAppend(fResOuter, dOuter/sum); 1324 psVectorAppend(fResTotal, dTotal/sum); 1315 1325 return true; 1316 1326 } … … 1335 1345 pmSubtractionVisualShowFitInit (stamps); 1336 1346 1337 psVector *f SigRes= psVectorAllocEmpty(stamps->num, PS_TYPE_F32);1338 psVector *f MinRes= psVectorAllocEmpty(stamps->num, PS_TYPE_F32);1339 psVector *f MaxRes= psVectorAllocEmpty(stamps->num, PS_TYPE_F32);1347 psVector *fResSigma = psVectorAllocEmpty(stamps->num, PS_TYPE_F32); 1348 psVector *fResOuter = psVectorAllocEmpty(stamps->num, PS_TYPE_F32); 1349 psVector *fResTotal = psVectorAllocEmpty(stamps->num, PS_TYPE_F32); 1340 1350 1341 1351 // we want to save the residual images for the 9 brightest stamps. … … 1449 1459 } 1450 1460 1451 pmSubtractionResidualStats(f SigRes, fMaxRes, fMinRes, target, source, residual, norm, footprint);1461 pmSubtractionResidualStats(fResSigma, fResOuter, fResTotal, target, source, residual, norm, footprint); 1452 1462 1453 1463 } else { … … 1485 1495 } 1486 1496 1487 pmSubtractionResidualStats(f SigRes, fMaxRes, fMinRes, image1, image2, residual, norm, footprint);1497 pmSubtractionResidualStats(fResSigma, fResOuter, fResTotal, image1, image2, residual, norm, footprint); 1488 1498 } 1489 1499 … … 1564 1574 1565 1575 psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); 1566 psVectorStats (stats, f SigRes, NULL, NULL, 0);1567 kernels->f SigResMean= stats->robustMedian;1568 kernels->f SigResStdev = stats->robustStdev;1576 psVectorStats (stats, fResSigma, NULL, NULL, 0); 1577 kernels->fResSigmaMean = stats->robustMedian; 1578 kernels->fResSigmaStdev = stats->robustStdev; 1569 1579 1570 1580 psStatsInit (stats); 1571 psVectorStats (stats, f MaxRes, NULL, NULL, 0);1572 kernels->f MaxResMean= stats->robustMedian;1573 kernels->f MaxResStdev = stats->robustStdev;1581 psVectorStats (stats, fResOuter, NULL, NULL, 0); 1582 kernels->fResOuterMean = stats->robustMedian; 1583 kernels->fResOuterStdev = stats->robustStdev; 1574 1584 1575 1585 psStatsInit (stats); 1576 psVectorStats (stats, f MinRes, NULL, NULL, 0);1577 kernels->f MinResMean= stats->robustMedian;1578 kernels->f MinResStdev = stats->robustStdev;1586 psVectorStats (stats, fResTotal, NULL, NULL, 0); 1587 kernels->fResTotalMean = stats->robustMedian; 1588 kernels->fResTotalStdev = stats->robustStdev; 1579 1589 1580 1590 // XXX save these values somewhere 1581 psLogMsg("psModules.imcombine", PS_LOG_INFO, "f Sigma: %f +/- %f, fMaxRes: %f +/- %f, fMinRes: %f +/- %f",1582 kernels->f SigResMean, kernels->fSigResStdev,1583 kernels->f MaxResMean, kernels->fMaxResStdev,1584 kernels->f MinResMean, kernels->fMinResStdev);1585 1586 psFree (f SigRes);1587 psFree (f MaxRes);1588 psFree (f MinRes);1591 psLogMsg("psModules.imcombine", PS_LOG_INFO, "fResSigma: %f +/- %f, fResOuter: %f +/- %f, fResTotal: %f +/- %f", 1592 kernels->fResSigmaMean, kernels->fResSigmaStdev, 1593 kernels->fResOuterMean, kernels->fResOuterStdev, 1594 kernels->fResTotalMean, kernels->fResTotalStdev); 1595 1596 psFree (fResSigma); 1597 psFree (fResOuter); 1598 psFree (fResTotal); 1589 1599 psFree (stats); 1590 1600 } … … 1592 1602 psFree(residual); 1593 1603 psFree(polyValues); 1594 1595 1604 1596 1605 return deviations;
Note:
See TracChangeset
for help on using the changeset viewer.
