Changeset 36318
- Timestamp:
- Nov 28, 2013, 4:09:45 AM (13 years ago)
- Location:
- branches/eam_branches/ipp-20130904/psphot/src
- Files:
-
- 3 edited
-
psphotExtendedSourceFits.c (modified) (3 diffs)
-
psphotGalaxyShape.c (modified) (4 diffs)
-
psphotSourceFits.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130904/psphot/src/psphotExtendedSourceFits.c
r36315 r36318 120 120 } 121 121 122 float fitNsigmaConv = psMetadataLookupF32 (&status, recipe, "EXT_FIT_NSIGMA_CONV"); // number of sigma for the convolutio 123 if (!status || !isfinite(fitNsigmaConv) || fitNsigmaConv <= 0) { 124 fitNsigmaConv = 5.0; 125 } 126 122 127 bool chisqConvergence = psMetadataLookupBool (&status, recipe, "LMM_FIT_CHISQ_CONVERGENCE"); // Fit tolerance 123 128 if (!status) { … … 144 149 fitOptions->minTol = fitMinTol; 145 150 fitOptions->maxTol = fitMaxTol; 151 fitOptions->nsigma = fitNsigmaConv; 146 152 147 153 fitOptions->gainFactorMode = gainFactorMode; … … 656 662 if (source->modelEXT->isPCM) { 657 663 // fprintf (stderr, "subtract PCM extended source model for object %d @ %f, %f\n", source->id, source->moments->Mx, source->moments->My); 658 pmPCMCacheModel (source, maskVal, psfSize );664 pmPCMCacheModel (source, maskVal, psfSize, fitOptions->nsigma); 659 665 } else { 660 666 // fprintf (stderr, "subtract non-PCM extended source model for object %d @ %f, %f\n", source->id, source->moments->Mx, source->moments->My); -
branches/eam_branches/ipp-20130904/psphot/src/psphotGalaxyShape.c
r36315 r36318 97 97 assert (status); 98 98 99 float fitNsigmaConv = psMetadataLookupF32 (&status, recipe, "EXT_FIT_NSIGMA_CONV"); // number of sigma for the convolutio 100 if (!status || !isfinite(fitNsigmaConv) || fitNsigmaConv <= 0) { 101 fitNsigmaConv = 5.0; 102 } 103 99 104 // Define source fitting parameters for extended source fits 100 105 // we are not doing LMM fitting, so most options are irrelevant … … 102 107 fitOptions->mode = PM_SOURCE_FIT_EXT_AND_SKY; 103 108 fitOptions->covarFactor = psImageCovarianceFactorForAperture(readout->covariance, 10.0); // Covariance matrix 109 fitOptions->nsigma = fitNsigmaConv; 104 110 105 111 // Poisson or Constant weight for chisq tests? … … 298 304 299 305 // cache the model flux 300 pmPCMCacheModel (source, maskVal, psfSize );306 pmPCMCacheModel (source, maskVal, psfSize, fitOptions->nsigma); 301 307 } 302 308 … … 316 322 // need to reset here each time since we assign below to calculate the flux 317 323 // XXX note that this does not add sky to model 318 pmPCMMakeModel (source, pcm->modelConv, maskVal, psfSize);324 pmPCMMakeModel (source, pcm->modelConv, pcm->nsigma, maskVal, psfSize); 319 325 pcm->modelConv->params->data.F32[PM_PAR_I0] = 1.0; 320 326 -
branches/eam_branches/ipp-20130904/psphot/src/psphotSourceFits.c
r36315 r36318 653 653 if (TIMING) { t4 = psTimerMark ("psphotFitPCM"); } 654 654 655 psphotPCMfitCheckSize (pcm, source, maskVal, psfSize);656 if (pcm->modelConv->nIter == fitOptions->nIter) {657 psphotPCMfitRetry (pcm, source, &options, maskVal, markVal, psfSize);658 }655 // psphotPCMfitCheckSize (pcm, source, maskVal, psfSize); 656 // if (pcm->modelConv->nIter == fitOptions->nIter) { 657 // psphotPCMfitRetry (pcm, source, &options, maskVal, markVal, psfSize); 658 // } 659 659 if (TIMING) { t5 = psTimerMark ("psphotFitPCM"); } 660 660 … … 787 787 } 788 788 789 // float indexGuessInv[] = {0.5, 0.33, 0.25, 0.167, 0.125, 0.083}; 790 float indexGuessInv[] = {0.5, 0.4, 0.3, 0.25, 0.20, 0.15, 0.125}; 791 # define N_INDEX_GUESS_INV 7 792 793 // float reffGuess[] = {3.0, 10.0, 20.0, 30.0, 40.0}; 794 float reffGuess[] = {0.5, 0.75, 1.0, 1.4, 2.0}; 789 // 0.5 / n for (1.0, 1.25, 1.66, 2.0, 3.33, 4.0) 790 // float indexGuessInv[] = {0.5, 0.4, 0.3, 0.25, 0.20, 0.15, 0.125}; 791 792 // 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}; 794 float indexGuessR1q[] = {1.06, 1.19, 1.335, 1.48, 1.840, 2.290, 2.84, 3.5300}; 795 # define N_INDEX_GUESS_INV 8 796 797 // we are going to guess in fractions about the R1-based guess 798 float reffGuess[] = {0.8, 0.9, 1.0, 1.12, 1.25}; 795 799 # define N_REFF_GUESS 5 796 800 … … 800 804 801 805 // we get a reasonable guess from: 802 // * Reff = Kron R1 806 // * Reff = Kron R1 / Q(index) -- Q comes from Graham & Driver 803 807 // * Rmajor / Rminor & Theta from moments 804 808 // * Io from total Kron flux … … 822 826 psEllipseAxes momentAxes = psEllipseMomentsToAxes (moments, 20.0); 823 827 824 if (0) {825 psEllipseAxes guessAxes;826 guessAxes.major = source->moments->Mrf;827 guessAxes.minor = (momentAxes.minor / momentAxes.minor) * guessAxes.major;828 guessAxes.theta = momentAxes.theta;829 830 if (!isfinite(guessAxes.major)) return false;831 if (!isfinite(guessAxes.minor)) return false;832 if (!isfinite(guessAxes.theta)) return false;833 834 // convert the major,minor,theta to shape parameters for an Reff-like model835 pmModelAxesToParams (&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], guessAxes, true);836 }837 838 828 // set the model position 839 829 if (!pmModelSetPosition(&PAR[PM_PAR_XPOS], &PAR[PM_PAR_YPOS], source)) { … … 855 845 // loop over index guesses and find the best fit 856 846 for (int j = 0; j < N_REFF_GUESS; j++) { 857 858 psEllipseAxes guessAxes;859 guessAxes.major = reffGuess[j] * source->moments->Mrf;860 guessAxes.minor = guessAxes.major * (momentAxes.minor / momentAxes.major);861 guessAxes.theta = momentAxes.theta;862 863 if (!isfinite(guessAxes.major)) return false;864 if (!isfinite(guessAxes.minor)) return false;865 if (!isfinite(guessAxes.theta)) return false;866 867 // convert the major,minor,theta to shape parameters for an Reff-like model868 pmModelAxesToParams (&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], guessAxes, true);869 870 847 for (int i = 0; i < N_INDEX_GUESS_INV; i++) { 871 848 PAR[PM_PAR_7] = indexGuessInv[i]; 872 849 850 psEllipseAxes guessAxes; 851 guessAxes.major = reffGuess[j] * source->moments->Mrf / indexGuessR1q[i]; 852 guessAxes.minor = guessAxes.major * (momentAxes.minor / momentAxes.major); 853 guessAxes.theta = momentAxes.theta; 854 855 if (!isfinite(guessAxes.major)) return false; 856 if (!isfinite(guessAxes.minor)) return false; 857 if (!isfinite(guessAxes.theta)) return false; 858 859 // convert the major,minor,theta to shape parameters for an Reff-like model 860 pmModelAxesToParams (&PAR[PM_PAR_SXX], &PAR[PM_PAR_SXY], &PAR[PM_PAR_SYY], guessAxes, true); 861 873 862 // generated the modelFlux 874 863 // XXX note that this does not add sky to model 875 pmPCMMakeModel (source, pcm->modelConv, maskVal, psfSize);864 pmPCMMakeModel (source, pcm->modelConv, pcm->nsigma, maskVal, psfSize); 876 865 877 866 float YY = 0.0; … … 911 900 iMin = Io; 912 901 sMin = indexGuessInv[i]; 913 rMin = reffGuess[j] ;902 rMin = reffGuess[j] / indexGuessR1q[i]; 914 903 } 915 904 // fprintf (stderr, "%d | %f %f %f %f | %f %f %f %f", i, indexGuessInv[i], reffGuess[j], Io, Chisq, sMin, rMin, iMin, xMin); … … 1023 1012 psVectorAppend (chi2, model->chisqNorm); 1024 1013 1025 PAR[PM_PAR_7] = (nStart < N_INDEX_GUESS_INV - 1) ? 0.5*(indexGuessInv[nStart + 1] + indexGuessInv[nStart]) : 0.1;1014 PAR[PM_PAR_7] = (nStart < N_INDEX_GUESS_INV - 1) ? 0.5*(indexGuessInv[nStart + 1] + indexGuessInv[nStart]) : indexGuessInv[nStart - 1]; 1026 1015 pmSourceFitPCM (pcm, source, &options, maskVal, markVal, psfSize); 1027 1016 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]); … … 1029 1018 psVectorAppend (chi2, model->chisqNorm); 1030 1019 1031 PAR[PM_PAR_7] = (nStart > 0) ? 0.5*(indexGuessInv[nStart - 1] + indexGuessInv[nStart]) : 0.55;1020 PAR[PM_PAR_7] = (nStart > 0) ? 0.5*(indexGuessInv[nStart - 1] + indexGuessInv[nStart]) : indexGuessInv[nStart + 1]; 1032 1021 pmSourceFitPCM (pcm, source, &options, maskVal, markVal, psfSize); 1033 1022 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]); 1034 1023 psVectorAppend (Sidx, 100*PAR[PM_PAR_7]); 1035 1024 psVectorAppend (chi2, model->chisqNorm); 1036 1037 if (chi2->data.F32[1] < chi2->data.F32[2]) {1038 if (nStart == N_INDEX_GUESS_INV - 1) {1039 PAR[PM_PAR_7] = 0.11;1040 } else {1041 PAR[PM_PAR_7] = indexGuessInv[nStart + 1];1042 }1043 } else {1044 if (nStart == 0) {1045 PAR[PM_PAR_7] = 0.52;1046 } else {1047 PAR[PM_PAR_7] = indexGuessInv[nStart - 1];1048 }1049 }1050 1025 1051 1026 psPolynomial1D *poly = psPolynomial1DAlloc (PS_POLYNOMIAL_ORD, 2); … … 1292 1267 // generated the modelFlux 1293 1268 // XXX note that this does not add sky to model 1294 pmPCMMakeModel (source, pcm->modelConv, maskVal, psfSize);1269 pmPCMMakeModel (source, pcm->modelConv, pcm->nsigma, maskVal, psfSize); 1295 1270 1296 1271 float YY = 0.0; … … 1331 1306 rMin = dref; 1332 1307 } 1333 //fprintf (stderr, "%d | %f %f %f | %f %f %f\n", j, dref, Io, Chisq, rMin, iMin, xMin);1308 fprintf (stderr, "%d | %f %f %f | %f %f %f\n", j, dref, Io, Chisq, rMin, iMin, xMin); 1334 1309 } 1335 1310 … … 1375 1350 // generated the modelFlux 1376 1351 // XXX note that this does not add sky to model 1377 pmPCMMakeModel (source, pcm->modelConv, maskVal, psfSize);1352 pmPCMMakeModel (source, pcm->modelConv, pcm->nsigma, maskVal, psfSize); 1378 1353 1379 1354 float YY = 0.0;
Note:
See TracChangeset
for help on using the changeset viewer.
