IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36325


Ignore:
Timestamp:
Nov 28, 2013, 1:25:15 PM (13 years ago)
Author:
eugene
Message:

fix up grid search for sersic index

Location:
branches/eam_branches/ipp-20130904/psphot
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130904/psphot/src/psphotSourceFits.c

    r36318 r36325  
    653653    if (TIMING) { t4 = psTimerMark ("psphotFitPCM"); }
    654654
    655     // psphotPCMfitCheckSize (pcm, source, maskVal, psfSize);
     655    if (options.isInteractive) psphotPCMfitCheckSize (pcm, source, maskVal, psfSize);
    656656    // if (pcm->modelConv->nIter == fitOptions->nIter) {
    657657    //  psphotPCMfitRetry (pcm, source, &options, maskVal, markVal, psfSize);
     
    791791
    792792// 0.5 / n for (0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 6.0)
    793 float indexGuessInv[] = {1.00, 0.50, 0.333, 0.25, 1.666, 0.125, 0.10, 0.0833};
     793float indexGuessInv[] = {1.00, 0.50, 0.333, 0.25, 0.166, 0.125, 0.10, 0.0833};
    794794float indexGuessR1q[] = {1.06, 1.19, 1.335, 1.48, 1.840, 2.290, 2.84, 3.5300};
    795795# define N_INDEX_GUESS_INV 8
     
    902902                rMin = reffGuess[j] / indexGuessR1q[i];
    903903            }
    904             // fprintf (stderr, "%d | %f %f %f %f | %f %f %f %f", i, indexGuessInv[i], reffGuess[j], Io, Chisq, sMin, rMin, iMin, xMin);
    905             // fprintf (stderr, "\n");
     904            fprintf (stderr, "%d | %f %f %f %f | %f %f %f %f", i, indexGuessInv[i], reffGuess[j], Io, Chisq, sMin, rMin, iMin, xMin);
     905            fprintf (stderr, "\n");
    906906        }
    907907    }
     
    10061006    psVector *Sidx = psVectorAllocEmpty (16, PS_TYPE_F32);
    10071007
    1008     PAR[PM_PAR_7] = indexGuessInv[nStart];
     1008    float Sm = NAN, Sp = NAN, So = NAN;
     1009    if (nStart == 0) {
     1010        Sm = indexGuessInv[nStart];
     1011        So = 0.5*(indexGuessInv[nStart + 1] + indexGuessInv[nStart]);
     1012        Sp = indexGuessInv[nStart + 1];
     1013    } else if (nStart == N_INDEX_GUESS_INV - 1) {
     1014        Sp = indexGuessInv[nStart];
     1015        So = 0.5*(indexGuessInv[nStart - 1] + indexGuessInv[nStart]);
     1016        Sm = indexGuessInv[nStart - 1];
     1017    } else {
     1018        Sm = 0.5*(indexGuessInv[nStart - 1] + indexGuessInv[nStart]);
     1019        So = indexGuessInv[nStart];
     1020        Sp = 0.5*(indexGuessInv[nStart + 1] + indexGuessInv[nStart]);
     1021    }
     1022   
     1023    PAR[PM_PAR_7] = Sm;
    10091024    pmSourceFitPCM (pcm, source, &options, maskVal, markVal, psfSize);
    10101025    if (EXTRA_VERBOSE) fprintf (stderr, "%d >>> %d %f : %f - %f %f - %f %f %f - %f\n", source->id, model->nIter, model->chisqNorm, PAR[7], PAR[2], PAR[3], PAR[4], PAR[5], PAR[6], PAR[1]);
     
    10121027    psVectorAppend (chi2, model->chisqNorm);
    10131028
    1014     PAR[PM_PAR_7] = (nStart < N_INDEX_GUESS_INV - 1) ? 0.5*(indexGuessInv[nStart + 1] + indexGuessInv[nStart]) : indexGuessInv[nStart - 1];
     1029    PAR[PM_PAR_7] = So;
    10151030    pmSourceFitPCM (pcm, source, &options, maskVal, markVal, psfSize);
    10161031    if (EXTRA_VERBOSE) fprintf (stderr, "%d >>> %d %f : %f - %f %f - %f %f %f - %f\n", source->id, model->nIter, model->chisqNorm, PAR[7], PAR[2], PAR[3], PAR[4], PAR[5], PAR[6], PAR[1]);
     
    10181033    psVectorAppend (chi2, model->chisqNorm);
    10191034
    1020     PAR[PM_PAR_7] = (nStart > 0) ? 0.5*(indexGuessInv[nStart - 1] + indexGuessInv[nStart]) : indexGuessInv[nStart + 1];
     1035    PAR[PM_PAR_7] = Sp;
    10211036    pmSourceFitPCM (pcm, source, &options, maskVal, markVal, psfSize);
    10221037    if (EXTRA_VERBOSE) fprintf (stderr, "%d >>> %d %f : %f - %f %f - %f %f %f - %f\n", source->id, model->nIter, model->chisqNorm, PAR[7], PAR[2], PAR[3], PAR[4], PAR[5], PAR[6], PAR[1]);
     
    10361051    float Smin = -0.5 * poly->coeff[1] / poly->coeff[2] / 100.0;
    10371052
    1038     // constrain Smin to be in a valid range (1.0 - 0.1, corresponding to 0.5 (Gauss) to 5.0 (slightly peakier than Dev)
    1039     Smin = PS_MAX(PS_MIN(Smin, 1.0), 0.1);
     1053    // constrain Smin to be in a valid range: allow the fitted range to go a bit beyond the 3 trial points, but no further
     1054    float Smx = Sm - 0.25*(So - Sm);
     1055    float Spx = Sp + 0.25*(Sp - So);
     1056    Smin = PS_MAX(PS_MIN(Smin, Smx), Spx);
    10401057    PAR[PM_PAR_7] = Smin;
    10411058
     
    12491266
    12501267    // loop over Reff, keeping the ARatio and Theta constant
    1251     for (int j = -20; j < 21; j++) {
    1252 
    1253         float dref = j * 0.02;
     1268    for (int j = -4; j <= 4; j++) {
     1269
     1270        float dref = j * 0.01;
    12541271
    12551272        psEllipseAxes guessAxes;
     
    13061323            rMin = dref;
    13071324        }
    1308         fprintf (stderr, "%d | %f %f %f | %f %f %f\n", j, dref, Io, Chisq, rMin, iMin, xMin);
     1325        // fprintf (stderr, "%d | %f %f %f | %f %f %f\n", j, dref, Io, Chisq, rMin, iMin, xMin);
    13091326    }
    13101327
  • branches/eam_branches/ipp-20130904/psphot/test/tap_psphot_galaxygrid.pro

    r36317 r36325  
    325325  label -x sequence -y "M_out| - M_in|"
    326326  resize 700 320
     327
     328  # check on magnitude
     329  set dI = Iot_s - Iin_s
     330  lim -n 4$1 n -1.0 1.0; clear; box; plot n dI
     331  label -x sequence -y "I_out| - I_in|"
     332  resize 700 320
    327333end
    328334
     
    624630
    625631macro cmf.load.reset
    626   $fields = X Y M T R r MT
     632  $fields = X Y M T R r MT I
    627633  foreach field $fields
    628634    foreach set in ot
     
    636642macro cmf.load.concat
    637643  if ($0 != 4)
    638     echo "USAGE: cmf.load.concat (dat) (cmf) (type)"
     644    echo "USAGE: cmf.load.concat (dat) (cmf) (inType)"
    639645    break
    640646  end
     
    643649  read Xin_all 1 Yin_all 2 Fin_all 3 Type 4 Min_all 5 RmajIn_all 7 RminIn_all 8 ThetaIn_all 9 IndexIn_all 10
    644650
     651  $TYPE_S = 83
     652  $TYPE_D = 68
     653  $TYPE_E = 69
     654  if ("$3" == "SERSIC")
     655    $InType = $TYPE_S
     656  end
     657  if ("$3" == "DEV")
     658    $InType = $TYPE_D
     659    set IndexIn_all = 0.125 + zero(Xin_all)
     660  end
     661  if ("$3" == "EXP")
     662    $InType = $TYPE_E
     663    set IndexIn_all = 0.5 + zero(Xin_all)
     664  end
     665
     666  # select only the galaxies
    645667  subset Xin = Xin_all if (Type == 1)
    646668  subset Yin = Yin_all if (Type == 1)
     
    657679  subset IndexIn = IndexIn_all if (Type == 1)
    658680
    659   $TYPE_S = 83
    660   $TYPE_D = 68
    661   $TYPE_E = 69
    662   if ("$3" == "SERSIC")
    663     $InType = $TYPE_S
    664   end
    665   if ("$3" == "DEV")
    666     $InType = $TYPE_D
    667   end
    668   if ("$3" == "EXP")
    669     $InType = $TYPE_E
    670   end
    671 
    672681  data $2
    673682
     
    675684  output -err /dev/null
    676685  read -fits Chip.xfit X_EXT Y_EXT EXT_INST_MAG EXT_WIDTH_MAJ EXT_WIDTH_MIN EXT_THETA MODEL_TYPE EXT_PAR_07
     686  $reread = not($STATUS)
    677687  output -err stderr
    678   $reread = not($STATUS)
    679688  break -auto on
    680689  if ($reread)
    681690    read -fits Chip.xfit X_EXT Y_EXT EXT_INST_MAG EXT_WIDTH_MAJ EXT_WIDTH_MIN EXT_THETA MODEL_TYPE
    682     set EXT_PAR_07 = (MODEL_TYPE:9 == 68)*4 + (MODEL_TYPE:9 == 69)
     691    set EXT_PAR_07 = (MODEL_TYPE:9 == 68)*0.125 + (MODEL_TYPE:9 == 69)*0.5
    683692  end
    684693
     
    709718  reindex rin_m = RminIn using index2
    710719 
    711   # if ("$3" == "SERSIC")
    712     reindex Iot_m = EXT_PAR_07 using index1
    713     reindex Iin_m = IndexIn using index2
    714    $fields = X Y M T R r MT I
    715   # else
    716   # $fields = X Y M T R r MT
    717   # end
     720  reindex Iot_m = EXT_PAR_07 using index1
     721  reindex Iin_m = IndexIn using index2
     722  $fields = X Y M T R r MT I
    718723 
    719724  foreach field $fields
     
    12861291    foreach radius 1.0 1.5 2.0 2.5 3.0 4.0 6.0 8.0
    12871292      mkexp.devexp.single tests.20131120/testrad.ps1v1.exp.$Nrun EXP $radius 1.0
    1288       fitexp tests.20131120/testrad.ps1v1.exp.$Nrun tests.20131120/testrad.ps1v1.exp.$Nrun.t4p EXP_CONV
     1293      fitexp tests.20131120/testrad.ps1v1.exp.$Nrun tests.20131120/testrad.ps1v1.exp.$Nrun.t4b EXP_CONV
    12891294      $Nrun ++
    12901295    end
     
    12931298  $Nrun = 0
    12941299  foreach radius 1.0 1.5 2.0 2.5 3.0 4.0 6.0 8.0
    1295     cmf.load.concat tests.20131120/testrad.ps1v1.exp.$Nrun.dat tests.20131120/testrad.ps1v1.exp.$Nrun.t4p.cmf EXP
    1296     set dM_m = Mot_m - Min_m
    1297     vstat -q dM_m
    1298     $mag_off = $MEDIAN
    1299     set dR_m = Rot_m - Rin_m
    1300     vstat -q dR_m
    1301     $rad_off = $MEDIAN
    1302     echo $radius $mag_off $rad_off
     1300    cmf.load.concat tests.20131120/testrad.ps1v1.exp.$Nrun.dat tests.20131120/testrad.ps1v1.exp.$Nrun.t4b.cmf EXP
     1301    echo -no-return $radius ""
     1302    check.fit tests.20131120/testrad.ps1v1.exp.$Nrun.dat tests.20131120/testrad.ps1v1.exp.$Nrun.t4b.cmf EXP
    13031303    $Nrun ++
    13041304  end
     
    13191319  $Nrun = 0
    13201320  foreach radius 1.0 1.5 2.0 2.5 3.0 4.0 6.0 8.0
    1321     cmf.load.concat tests.20131120/testrad.ps1v1.exp.$Nrun.dat tests.20131120/testrad.ps1v1.exp.$Nrun.$1.cmf EXP
    1322     set dM_m = Mot_m - Min_m
    1323     vstat -q dM_m
    1324     $mag_off = $MEDIAN
    1325     set dR_m = Rot_m - Rin_m
    1326     vstat -q dR_m
    1327     $rad_off = $MEDIAN
    1328     echo $radius $mag_off $rad_off
     1321    echo -no-return $radius ""
     1322    check.fit tests.20131120/testrad.ps1v1.exp.$Nrun.dat tests.20131120/testrad.ps1v1.exp.$Nrun.$1.cmf EXP
    13291323    $Nrun ++
    13301324  end
     
    13881382end
    13891383
    1390 macro check.convolve.loop
    1391   if ($0 != 2)
    1392     echo "check.convolve.loop (intype)"
     1384# EXP : tests.20131120/test.nsig
     1385# DEV : tests.20131120/test.dev
     1386
     1387# run.convolve.loop tests.20131120/test.nsig tests.20131120/test.nsig   EXP EXP_CONV
     1388# run.convolve.loop tests.20131120/test.dev  tests.20131120/test.dev    DEV DEV_CONV
     1389# run.convolve.loop tests.20131120/test.nsig tests.20131120/test.serexp EXP SER_CONV
     1390# run.convolve.loop tests.20131120/test.dev  tests.20131120/test.serdev DEV SER_CONV
     1391
     1392macro run.convolve.loop
     1393  if ($0 != 5)
     1394    echo "run.convolve.loop (inName) (fitName) (inType) (fitType)"
    13931395    break
    13941396  end
    13951397
    13961398  local radius
    1397 
    13981399  $radius = 3.0
    1399 
    14001400  cmf.load.reset
    1401 
    1402   # foreach Cin 3 5 7 9 11
    1403   foreach Cin 11
    1404     sprintf nameIn tests.20131120/test.nsig.%02d $Cin
    1405     foreach Cot 3 5 7 9 11
    1406       sprintf nameOt tests.20131120/test.serdev.%02d.%02d $Cin $Cot
    1407       echo -no-return $Cin $Cot " "
    1408       check.fit $nameIn.dat $nameOt.cmf $1
    1409     end
    1410   end
    1411   grid.plots.devexp a
    1412 end
    1413 
    1414 macro run.convolve.loop
    1415   local radius
    1416 
    1417   $radius = 3.0
    14181401
    14191402  # foreach Cin 3 5 7 9 11
    14201403  foreach Cin 11
    14211404    $CONVOLVE_NSIGMA = $Cin
    1422     sprintf nameIn tests.20131120/test.nsig.%02d $Cin
    1423     # mkexp.devexp.single $nameIn EXP $radius 1.0
     1405    sprintf nameIn %s.%02d $1 $Cin
     1406    mkexp.devexp.single $nameIn $3 $radius 1.0
    14241407    foreach Cot 3 5 7 9 11
    14251408      $NSIGMA_CONV = $Cot
    1426       sprintf nameOt tests.20131120/test.nsig.x.%02d.%02d $Cin $Cot
    1427       fitexp $nameIn $nameOt EXP_CONV
     1409      sprintf nameOt %s.%02d.%02d $2 $Cin $Cot
     1410      fitexp $nameIn $nameOt $4
    14281411    end
    14291412  end
     
    14311414  # foreach Cin 3 5 7 9 11
    14321415  foreach Cin 11
    1433     sprintf nameIn tests.20131120/test.nsig.%02d $Cin
     1416    sprintf nameIn %s.%02d $1 $Cin
    14341417    foreach Cot 3 5 7 9 11
    1435       sprintf nameOt tests.20131120/test.nsig.x.%02d.%02d $Cin $Cot
     1418      sprintf nameOt %s.%02d.%02d $2 $Cin $Cot
    14361419      check.fit $nameIn.dat $nameOt.cmf
    14371420    end
     
    14401423end
    14411424
    1442 macro run.convolve.loop.dev
     1425macro check.convolve.loop
     1426  if ($0 != 4)
     1427    echo "run.convolve.loop (inName) (fitName) (inType)"
     1428    break
     1429  end
     1430
    14431431  local radius
    1444 
    14451432  $radius = 3.0
    1446 
    1447   foreach Cin 11
    1448     $CONVOLVE_NSIGMA = $Cin
    1449     sprintf nameIn tests.20131120/test.dev.%02d $Cin
    1450     mkexp.devexp.single $nameIn DEV $radius 1.0
    1451     foreach Cot 3 5 7 9 11
    1452       $NSIGMA_CONV = $Cot
    1453       sprintf nameOt tests.20131120/test.dev.%02d.%02d $Cin $Cot
    1454       fitexp $nameIn $nameOt DEV_CONV
    1455     end
    1456   end
     1433  cmf.load.reset
    14571434
    14581435  # foreach Cin 3 5 7 9 11
    14591436  foreach Cin 11
    1460     sprintf nameIn tests.20131120/test.dev.%02d $Cin
     1437    sprintf nameIn %s.%02d $1 $Cin
    14611438    foreach Cot 3 5 7 9 11
    1462       sprintf nameOt tests.20131120/test.dev.%02d.%02d $Cin $Cot
    1463       check.fit $nameIn.dat $nameOt.cmf DEV
     1439      sprintf nameOt %s.%02d.%02d $2 $Cin $Cot
     1440      echo -no-return $Cin $Cot " "
     1441      check.fit $nameIn.dat $nameOt.cmf $3
    14641442    end
    14651443  end
    14661444  grid.plots.devexp a
    14671445end
    1468 
    1469 macro run.convolve.loop.serexp
    1470   local radius
    1471 
    1472   $radius = 3.0
    1473 
    1474   foreach Cin 11
    1475     $CONVOLVE_NSIGMA = $Cin
    1476     sprintf nameIn tests.20131120/test.nsig.%02d $Cin
    1477     foreach Cot 3 5 7 9 11
    1478       $NSIGMA_CONV = $Cot
    1479       sprintf nameOt tests.20131120/test.serexp.%02d.%02d $Cin $Cot
    1480       fitexp $nameIn $nameOt SER_CONV
    1481     end
    1482   end
    1483 
    1484   # foreach Cin 3 5 7 9 11
    1485   foreach Cin 11
    1486     sprintf nameIn tests.20131120/test.nsig.%02d $Cin
    1487     foreach Cot 3 5 7 9 11
    1488       sprintf nameOt tests.20131120/test.serexp.%02d.%02d $Cin $Cot
    1489       check.fit $nameIn.dat $nameOt.cmf EXP
    1490     end
    1491   end
    1492   grid.plots.devexp a
    1493 end
    1494 
    1495 
    1496 macro run.convolve.loop.serdev
    1497   local radius
    1498 
    1499   $radius = 3.0
    1500 
    1501   cmf.load.reset
    1502 
    1503   foreach Cin 11
    1504     $CONVOLVE_NSIGMA = $Cin
    1505     sprintf nameIn tests.20131120/test.dev.%02d $Cin
    1506     foreach Cot 3 5 7 9 11
    1507       $NSIGMA_CONV = $Cot
    1508       sprintf nameOt tests.20131120/test.serdev.%02d.%02d $Cin $Cot
    1509       fitexp $nameIn $nameOt SER_CONV
    1510     end
    1511   end
    1512 
    1513   # foreach Cin 3 5 7 9 11
    1514   foreach Cin 11
    1515     sprintf nameIn tests.20131120/test.dev.%02d $Cin
    1516     foreach Cot 3 5 7 9 11
    1517       sprintf nameOt tests.20131120/test.serdev.%02d.%02d $Cin $Cot
    1518       check.fit $nameIn.dat $nameOt.cmf DEV
    1519     end
    1520   end
    1521   grid.plots.devexp a
    1522 end
    1523 
Note: See TracChangeset for help on using the changeset viewer.