Changeset 36310
- Timestamp:
- Nov 24, 2013, 3:28:13 PM (13 years ago)
- Location:
- branches/eam_branches/ipp-20130904/psphot
- Files:
-
- 3 edited
-
src/psphotExtendedSourceFits.c (modified) (1 diff)
-
src/psphotSourceFits.c (modified) (5 diffs)
-
test/tap_psphot_galaxygrid.pro (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130904/psphot/src/psphotExtendedSourceFits.c
r36307 r36310 315 315 316 316 // XXX TEST 317 if ( false &&!isInteractive) {317 if (!isInteractive) { 318 318 if (!psThreadJobAddPending(job)) { 319 319 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); -
branches/eam_branches/ipp-20130904/psphot/src/psphotSourceFits.c
r36198 r36310 19 19 static int NfitIterPCM = 0; 20 20 static int NfitPixPCM = 0; 21 22 bool psphotPCMfitCheckSize (pmPCMdata *pcm, pmSource *source, psImageMaskType maskVal, float psfSize); 21 23 22 24 bool psphotFitInit (int nThreads) { … … 585 587 } 586 588 587 float t1, t2, t 4, t5;588 t1 = t2 = t 4 = t5 = 0.0;589 float t1, t2, t3, t4, t5; 590 t1 = t2 = t3 = t4 = t5 = 0.0; 589 591 if (TIMING) { psTimerStart ("psphotFitPCM"); } 590 592 … … 642 644 } 643 645 644 if (TIMING) { t 4= psTimerMark ("psphotFitPCM"); }646 if (TIMING) { t3 = psTimerMark ("psphotFitPCM"); } 645 647 646 648 // psTraceSetLevel("psLib.math.psMinimizeLMChi2", 5); … … 648 650 NfitIterPCM += pcm->modelConv->nIter; 649 651 NfitPixPCM += pcm->modelConv->nDOF; 652 if (TIMING) { t4 = psTimerMark ("psphotFitPCM"); } 653 654 psphotPCMfitCheckSize (pcm, source, maskVal, psfSize); 650 655 if (TIMING) { t5 = psTimerMark ("psphotFitPCM"); } 651 656 652 657 if (TIMING) { 653 658 int nPixBig = source->pixels->numCols * source->pixels->numRows; 654 fprintf (stderr, "psphotFitPCM : nIter: %2d, radius: %6.1f, npix: %5d of %5d, t1: %6.4f, t2: %6.4f, t 4: %6.4f, t5: %6.4f\n", model->nIter, model->fitRadius, model->nPix, nPixBig, t1, t2, t4, t5);659 fprintf (stderr, "psphotFitPCM : nIter: %2d, radius: %6.1f, npix: %5d of %5d, t1: %6.4f, t2: %6.4f, t3: %6.4f, t4: %6.4f, t5: %6.4f\n", model->nIter, model->fitRadius, model->nPix, nPixBig, t1, t2, t3, t4, t5); 655 660 } 656 661 if (EXTRA_VERBOSE && !TIMING) { … … 1246 1251 } 1247 1252 1248 1253 // # define N_REFF_CHECK 11 1254 // float drefCheck[] = {-0.02, -0.04, -0.06, 0.0, 0.85, 0.90, 0.95, 1.00, 1.05, 1.10, 1.15, 1.20, 1.25}; 1255 1256 // we have an initial fit, check to see if the current size is besst 1257 bool psphotPCMfitCheckSize (pmPCMdata *pcm, pmSource *source, psImageMaskType maskVal, float psfSize) { 1258 1259 // PAR is already at my current best guess 1260 psF32 *PAR = pcm->modelConv->params->data.F32; 1261 1262 // store best guess as a shape 1263 psEllipseAxes centerAxes; 1264 pmModelParamsToAxes (¢erAxes, PAR[PM_PAR_SXX], PAR[PM_PAR_SXY], PAR[PM_PAR_SYY], true); 1265 1266 float xMin = NAN; 1267 float iMin = NAN; 1268 float rMin = NAN; 1269 1270 // loop over Reff, keeping the ARatio and Theta constant 1271 for (int j = -20; j < 21; j++) { 1272 1273 float dref = j * 0.02; 1274 1275 psEllipseAxes guessAxes; 1276 guessAxes.major = centerAxes.major + dref; 1277 guessAxes.minor = guessAxes.major * centerAxes.minor / centerAxes.major; 1278 guessAxes.theta = centerAxes.theta; 1279 1280 if (!isfinite(guessAxes.major)) return false; 1281 if (!isfinite(guessAxes.minor)) return false; 1282 if (!isfinite(guessAxes.theta)) return false; 1283 1284 // convert the major,minor,theta to shape parameters for an Reff-like model 1285 pmModelAxesToParams (&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], guessAxes, true); 1286 1287 // generated the modelFlux 1288 pmPCMMakeModel (source, pcm->modelConv, maskVal, psfSize); 1289 1290 float YY = 0.0; 1291 float YM = 0.0; 1292 float MM = 0.0; 1293 bool usePoisson = false; 1294 1295 for (int iy = 0; iy < source->pixels->numRows; iy++) { 1296 for (int ix = 0; ix < source->pixels->numCols; ix++) { 1297 // skip masked points 1298 if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix]) { 1299 continue; 1300 } 1301 // skip zero-variance points 1302 if (source->variance->data.F32[iy][ix] == 0) { 1303 continue; 1304 } 1305 // skip nan value points 1306 if (!isfinite(source->pixels->data.F32[iy][ix])) { 1307 continue; 1308 } 1309 1310 float fy = source->pixels->data.F32[iy][ix]; 1311 float fm = source->modelFlux->data.F32[iy][ix]; 1312 float wt = (usePoisson) ? 1.0 / source->variance->data.F32[iy][ix] : 1.0; 1313 1314 YY += PS_SQR(fy) * wt; 1315 YM += fm * fy * wt; 1316 MM += PS_SQR(fm) * wt; 1317 } 1318 } 1319 1320 float Io = YM / MM; 1321 float Chisq = YY - 2 * Io * YM + Io * Io * MM; 1322 if (isnan(xMin) || (Chisq < xMin)) { 1323 xMin = Chisq; 1324 iMin = Io; 1325 rMin = dref; 1326 } 1327 // fprintf (stderr, "%d | %f %f %f | %f %f %f\n", j, dref, Io, Chisq, rMin, iMin, xMin); 1328 } 1329 1330 psEllipseAxes guessAxes; 1331 guessAxes.major = centerAxes.major + rMin; 1332 guessAxes.minor = guessAxes.major * centerAxes.minor / centerAxes.major; 1333 guessAxes.theta = centerAxes.theta; 1334 1335 if (!isfinite(guessAxes.major)) return false; 1336 if (!isfinite(guessAxes.minor)) return false; 1337 if (!isfinite(guessAxes.theta)) return false; 1338 1339 // convert the major,minor,theta to shape parameters for an Reff-like model 1340 pmModelAxesToParams (&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], guessAxes, true); 1341 PAR[PM_PAR_I0] = iMin; 1342 1343 return true; 1344 } 1345 -
branches/eam_branches/ipp-20130904/psphot/test/tap_psphot_galaxygrid.pro
r36307 r36310 607 607 $psphotConfig = $psphotConfig -Db PSPHOT:POISSON.ERRORS.PHOT.LMM F 608 608 $psphotConfig = $psphotConfig -Db PSPHOT:EXTENDED_SOURCE_FITS_POISSON F 609 $psphotConfig = $psphotConfig -Di PSPHOT:EXT_FIT_ITER 40 609 610 610 611 # ppImage / psphot on the output … … 614 615 exec ppImage $ppImageConfig $psphotConfig -file $basename.fits $outname >>& $outname.log 615 616 break -auto on 617 end 618 619 macro cmf.load.reset 620 $fields = X Y M T R r MT 621 foreach field $fields 622 foreach set in ot 623 delete -q $field\$set\_s 624 end 625 end 626 627 delete -q min_S Min_S 616 628 end 617 629 … … 1262 1274 local radius Nrun 1263 1275 1276 if (1) 1277 $Nrun = 0 1278 foreach radius 1.0 1.5 2.0 2.5 3.0 4.0 6.0 8.0 1279 # mkexp.devexp.single tests.20131120/testrad.ps1v1.exp.$Nrun EXP $radius 1.0 1280 fitexp tests.20131120/testrad.ps1v1.exp.$Nrun tests.20131120/testrad.ps1v1.exp.$Nrun.t4s EXP_CONV 1281 $Nrun ++ 1282 end 1283 end 1284 1264 1285 $Nrun = 0 1265 1286 foreach radius 1.0 1.5 2.0 2.5 3.0 4.0 6.0 8.0 1266 mkexp.devexp.single tests.20131120/testrad.ps1v1.exp.$Nrun EXP $radius 1.0 1267 fitexp tests.20131120/testrad.ps1v1.exp.$Nrun tests.20131120/testrad.ps1v1.exp.$Nrun.t4 EXP_CONV 1268 $Nrun ++ 1269 end 1270 1271 $Nrun = 0 1272 foreach radius 1.0 1.5 2.0 2.5 3.0 4.0 6.0 8.0 1273 cmf.load.concat tests.20131120/testrad.ps1v1.exp.$Nrun.dat tests.20131120/testrad.ps1v1.exp.$Nrun.t4.cmf EXP 1287 cmf.load.concat tests.20131120/testrad.ps1v1.exp.$Nrun.dat tests.20131120/testrad.ps1v1.exp.$Nrun.t4s.cmf EXP 1274 1288 set dM_m = Mot_m - Min_m 1275 1289 vstat -q dM_m … … 1284 1298 grid.plots.devexp a 1285 1299 end 1300 1301 macro check.radius.loop 1302 if ($0 != 2) 1303 echo "USAGE: check.radius.loop (ext)" 1304 break 1305 end 1306 1307 # cmf.load.reset 1308 1309 local radius Nrun 1310 1311 $Nrun = 0 1312 foreach radius 1.0 1.5 2.0 2.5 3.0 4.0 6.0 8.0 1313 cmf.load.concat tests.20131120/testrad.ps1v1.exp.$Nrun.dat tests.20131120/testrad.ps1v1.exp.$Nrun.$1.cmf EXP 1314 set dM_m = Mot_m - Min_m 1315 vstat -q dM_m 1316 $mag_off = $MEDIAN 1317 set dR_m = Rot_m - Rin_m 1318 vstat -q dR_m 1319 $rad_off = $MEDIAN 1320 echo $radius $mag_off $rad_off 1321 $Nrun ++ 1322 end 1323 1324 grid.plots.devexp a 1325 end 1326 1327 macro check.fit 1328 if ($0 != 3) 1329 echo "USAGE: check.fit (dat) (cmf)" 1330 break 1331 end 1332 1333 cmf.load.concat $1 $2 EXP 1334 set dM_m = Mot_m - Min_m 1335 vstat -q dM_m 1336 $mag_off = $MEDIAN 1337 set dR_m = Rot_m - Rin_m 1338 vstat -q dR_m 1339 $rad_off = $MEDIAN 1340 echo $mag_off $rad_off 1341 end
Note:
See TracChangeset
for help on using the changeset viewer.
