Changeset 21173 for trunk/psModules/src/objects/pmPSFtry.c
- Timestamp:
- Jan 26, 2009, 2:01:33 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/objects/pmPSFtry.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmPSFtry.c
r20937 r21173 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1.6 7$ $Name: not supported by cvs2svn $8 * @date $Date: 200 8-12-08 02:51:14$7 * @version $Revision: 1.68 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2009-01-27 00:01:33 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 175 175 176 176 pmSource *source = psfTry->sources->data[i]; 177 if (!source->moments) { 178 psfTry->mask->data.U8[i] = PSFTRY_MASK_EXT_FAIL; 179 continue; 180 } 181 if (!source->moments->nPixels) { 182 psfTry->mask->data.U8[i] = PSFTRY_MASK_EXT_FAIL; 183 continue; 184 } 185 177 186 source->modelEXT = pmSourceModelGuess (source, psfTry->psf->type); 178 187 if (source->modelEXT == NULL) { 179 ps Error(PS_ERR_UNKNOWN, false, "failed to build model");180 ps Free(psfTry);181 return NULL;188 psfTry->mask->data.U8[i] = PSFTRY_MASK_EXT_FAIL; 189 psTrace ("psModules.objects", 4, "masking %d (%d,%d) : failed to generate model guess\n", i, source->peak->x, source->peak->y); 190 continue; 182 191 } 183 192 … … 591 600 psVector *e2 = psVectorAlloc (sources->n, PS_TYPE_F32); 592 601 psVector *mag = psVectorAlloc (sources->n, PS_TYPE_F32); 602 593 603 for (int i = 0; i < sources->n; i++) { 604 // skip any masked sources (failed to fit one of the model steps or get a magnitude) 605 if (srcMask->data.U8[i]) continue; 606 594 607 pmSource *source = sources->data[i]; 595 if (source->modelEXT == NULL) continue; 596 // XXX I am relying on the fact that none of the masked sources 597 // have modelEXT set here. perhaps use the value of psfTry->mask instead? 608 assert (source->modelEXT); // all unmasked sources should have modelEXT 598 609 599 610 psEllipsePol pol = pmPSF_ModelToFit (source->modelEXT->params->data.F32); … … 619 630 for (int i = 1; i <= PS_MAX (psf->trendNx, psf->trendNy); i++) { 620 631 621 psVectorInit (mask, 0); 632 // copy srcMask to mask (we do not want the mask values set in pmPSFFitShapeParamsMap to be sticky) 633 for (int i = 0; i < mask->n; i++) { 634 mask->data.U8[i] = srcMask->data.U8[i]; 635 } 622 636 if (!pmPSFFitShapeParamsMap (psf, i, &scatterTotal, mask, x, y, mag, e0, e1, e2, dz)) { 623 637 break; … … 635 649 } 636 650 637 // XXX supply the resulting mask values back to srcMask 638 psVectorInit (mask, 0); 651 // copy srcMask to mask (we do not want the mask values set in pmPSFFitShapeParamsMap to be sticky) 652 for (int i = 0; i < mask->n; i++) { 653 mask->data.U8[i] = srcMask->data.U8[i]; 654 } 639 655 if (!pmPSFFitShapeParamsMap (psf, entryMin, &scatterTotal, mask, x, y, mag, e0, e1, e2, dz)) { 640 656 psAbort ("failed pmPSFFitShapeParamsMap on second pass?"); … … 836 852 // the mask marks the values not used to calculate the ApTrend 837 853 psVector *fitMask = psVectorAlloc (x_fit->n, PS_TYPE_U8); 838 psVectorInit (fitMask, 0); 854 // copy mask values to fitMask as a starting point 855 for (int i = 0; i < fitMask->n; i++) { 856 fitMask->data.U8[i] = mask->data.U8[i]; 857 } 839 858 840 859 // we run 'clipIter' cycles clipping in each of x and y, with only one iteration each. … … 884 903 885 904 // construct the fitted values and the residuals 886 psVector *e0fit = pmTrend2DEvalVector (psf->params->data[PM_PAR_E0], x_tst, y_tst);887 psVector *e1fit = pmTrend2DEvalVector (psf->params->data[PM_PAR_E1], x_tst, y_tst);888 psVector *e2fit = pmTrend2DEvalVector (psf->params->data[PM_PAR_E2], x_tst, y_tst);905 psVector *e0fit = pmTrend2DEvalVector (psf->params->data[PM_PAR_E0], fitMask, 0xff, x_tst, y_tst); 906 psVector *e1fit = pmTrend2DEvalVector (psf->params->data[PM_PAR_E1], fitMask, 0xff, x_tst, y_tst); 907 psVector *e2fit = pmTrend2DEvalVector (psf->params->data[PM_PAR_E2], fitMask, 0xff, x_tst, y_tst); 889 908 890 909 psVector *e0res = (psVector *) psBinaryOp (NULL, (void *) e0obs_tst, "-", (void *) e0fit); … … 895 914 // psTraceSetLevel ("psLib.math.vectorSampleStdev", 10); 896 915 // psTraceSetLevel ("psLib.math.vectorClippedStats", 10); 897 pmPSFShapeParamsScatter (scatterTotal, e0res, e1res, e2res, psStatsStdevOption(psf->psfTrendStats->options));916 pmPSFShapeParamsScatter (scatterTotal, e0res, e1res, e2res, fitMask, 0xff, psStatsStdevOption(psf->psfTrendStats->options)); 898 917 // psTraceSetLevel ("psLib.math.vectorSampleStdev", 0); 899 918 // psTraceSetLevel ("psLib.math.vectorClippedStats", 0); … … 932 951 933 952 // calculate the scatter of the parameters 934 bool pmPSFShapeParamsScatter(float *scatterTotal, psVector *e0res, psVector *e1res, psVector *e2res, ps StatsOptions stdevOpt)953 bool pmPSFShapeParamsScatter(float *scatterTotal, psVector *e0res, psVector *e1res, psVector *e2res, psVector *mask, psMaskType maskValue, psStatsOptions stdevOpt) 935 954 { 936 955 … … 941 960 float dEsquare = 0.0; 942 961 psStatsInit (stats); 943 psVectorStats (stats, e0res, NULL, NULL, 0xff);962 psVectorStats (stats, e0res, NULL, mask, maskValue); 944 963 dEsquare += PS_SQR(psStatsGetValue(stats, stdevOpt)); 945 964 946 965 psStatsInit (stats); 947 psVectorStats (stats, e1res, NULL, NULL, 0xff);966 psVectorStats (stats, e1res, NULL, mask, maskValue); 948 967 dEsquare += PS_SQR(psStatsGetValue(stats, stdevOpt)); 949 968 950 969 psStatsInit (stats); 951 psVectorStats (stats, e2res, NULL, NULL, 0xff);970 psVectorStats (stats, e2res, NULL, mask, maskValue); 952 971 dEsquare += PS_SQR(psStatsGetValue(stats, stdevOpt)); 953 972
Note:
See TracChangeset
for help on using the changeset viewer.
