Changeset 21183 for trunk/psModules/src/objects/pmPSFtry.c
- Timestamp:
- Jan 26, 2009, 8:40:07 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/objects/pmPSFtry.c (modified) (28 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmPSFtry.c
r21173 r21183 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1.68 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2009-01-27 00:01:33 $ 9 * 7 * @version $Revision: 1.69 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2009-01-27 06:39:38 $ 10 9 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 11 10 * … … 115 114 test->metricErr = psVectorAlloc (sources->n, PS_TYPE_F32); 116 115 test->fitMag = psVectorAlloc (sources->n, PS_TYPE_F32); 117 test->mask = psVectorAlloc (sources->n, PS_TYPE_ U8);116 test->mask = psVectorAlloc (sources->n, PS_TYPE_VECTOR_MASK); 118 117 119 118 psVectorInit (test->mask, 0); … … 148 147 149 148 // generate a pmPSFtry with a copy of the test PSF sources 150 pmPSFtry *pmPSFtryModel (const psArray *sources, const char *modelName, pmPSFOptions *options, ps MaskType maskVal, psMaskType markVal)149 pmPSFtry *pmPSFtryModel (const psArray *sources, const char *modelName, pmPSFOptions *options, psImageMaskType maskVal, psImageMaskType markVal) 151 150 { 152 151 bool status; … … 176 175 pmSource *source = psfTry->sources->data[i]; 177 176 if (!source->moments) { 178 psfTry->mask->data. U8[i] = PSFTRY_MASK_EXT_FAIL;177 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL; 179 178 continue; 180 179 } 181 180 if (!source->moments->nPixels) { 182 psfTry->mask->data. U8[i] = PSFTRY_MASK_EXT_FAIL;181 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL; 183 182 continue; 184 183 } … … 186 185 source->modelEXT = pmSourceModelGuess (source, psfTry->psf->type); 187 186 if (source->modelEXT == NULL) { 188 psfTry->mask->data. U8[i] = PSFTRY_MASK_EXT_FAIL;187 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL; 189 188 psTrace ("psModules.objects", 4, "masking %d (%d,%d) : failed to generate model guess\n", i, source->peak->x, source->peak->y); 190 189 continue; … … 198 197 199 198 // clear object mask to define valid pixels 200 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_ U8(markVal));199 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_IMAGE_MASK(markVal)); 201 200 202 201 // exclude the poor fits 203 202 if (!status) { 204 psfTry->mask->data. U8[i] = PSFTRY_MASK_EXT_FAIL;203 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL; 205 204 psTrace ("psModules.objects", 4, "masking %d (%d,%d) : status is poor\n", i, source->peak->x, source->peak->y); 206 205 continue; … … 231 230 232 231 // masked for: bad model fit, outlier in parameters 233 if (psfTry->mask->data. U8[i] & PSFTRY_MASK_ALL) {232 if (psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL) { 234 233 psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : source is masked\n", i, source->peak->x, source->peak->y); 235 234 continue; … … 239 238 source->modelPSF = pmModelFromPSF (source->modelEXT, psfTry->psf); 240 239 if (source->modelPSF == NULL) { 241 psfTry->mask->data. U8[i] = PSFTRY_MASK_BAD_MODEL;240 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_BAD_MODEL; 242 241 abort(); 243 242 continue; … … 253 252 // skip poor fits 254 253 if (!status) { 255 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_ U8(markVal));256 psfTry->mask->data. U8[i] = PSFTRY_MASK_PSF_FAIL;254 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_IMAGE_MASK(markVal)); 255 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_PSF_FAIL; 257 256 psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : failed PSF fit\n", i, source->peak->x, source->peak->y); 258 257 continue; … … 261 260 status = pmSourceMagnitudes (source, psfTry->psf, PM_SOURCE_PHOT_INTERP, maskVal); 262 261 if (!status || isnan(source->apMag)) { 263 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_ U8(markVal));264 psfTry->mask->data. U8[i] = PSFTRY_MASK_BAD_PHOT;262 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_IMAGE_MASK(markVal)); 263 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_BAD_PHOT; 265 264 psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : poor photometry\n", i, source->peak->x, source->peak->y); 266 265 continue; … … 268 267 269 268 // clear object mask to define valid pixels 270 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_ U8(markVal));269 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_IMAGE_MASK(markVal)); 271 270 272 271 psfTry->fitMag->data.F32[i] = source->psfMag; … … 292 291 psVector *flux = psVectorAlloc (psfTry->sources->n, PS_TYPE_F32); 293 292 psVector *chisq = psVectorAlloc (psfTry->sources->n, PS_TYPE_F32); 294 psVector *mask = psVectorAlloc (psfTry->sources->n, PS_TYPE_ MASK);293 psVector *mask = psVectorAlloc (psfTry->sources->n, PS_TYPE_VECTOR_MASK); 295 294 296 295 // generate the x and y vectors, and mask missing models … … 300 299 flux->data.F32[i] = 0.0; 301 300 chisq->data.F32[i] = 0.0; 302 mask->data. U8[i] = 0xff;301 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff; 303 302 } else { 304 303 flux->data.F32[i] = source->modelPSF->params->data.F32[PM_PAR_I0]; 305 304 chisq->data.F32[i] = source->modelPSF->chisq / source->modelPSF->nDOF; 306 mask->data. U8[i] = 0;305 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0; 307 306 } 308 307 } … … 312 311 313 312 // linear clipped fit of chisq trend vs flux 314 bool result = psVectorClipFitPolynomial1D(psfTry->psf->ChiTrend, options->stats, mask, 315 0xff, chisq, NULL, flux); 313 bool result = psVectorClipFitPolynomial1D(psfTry->psf->ChiTrend, options->stats, mask, 0xff, chisq, NULL, flux); 316 314 psStatsOptions meanStat = psStatsMeanOption(options->stats->options); // Statistic for mean 317 315 psStatsOptions stdevStat = psStatsStdevOption(options->stats->options); // Statistic for stdev … … 370 368 371 369 for (int i = 0; i < psfTry->sources->n; i++) { 372 if (psfTry->mask->data. U8[i] & PSFTRY_MASK_ALL)370 if (psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL) 373 371 continue; 374 372 r2rflux->data.F32[i] = PS_SQR(RADIUS) * pow(10.0, 0.4*psfTry->fitMag->data.F32[i]); … … 379 377 FILE *f = fopen ("apresid.dat", "w"); 380 378 for (int i = 0; i < psfTry->sources->n; i++) { 381 int keep = (psfTry->mask->data. U8[i] & PSFTRY_MASK_ALL);379 int keep = (psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL); 382 380 383 381 pmSource *source = psfTry->sources->data[i]; … … 427 425 psVector *apfit = psPolynomial1DEvalVector (poly, r2rflux); 428 426 for (int i = 0; i < psfTry->sources->n; i++) { 429 int keep = (psfTry->mask->data. U8[i] & PSFTRY_MASK_ALL);427 int keep = (psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL); 430 428 431 429 pmSource *source = psfTry->sources->data[i]; … … 603 601 for (int i = 0; i < sources->n; i++) { 604 602 // skip any masked sources (failed to fit one of the model steps or get a magnitude) 605 if (srcMask->data. U8[i]) continue;603 if (srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue; 606 604 607 605 pmSource *source = sources->data[i]; … … 624 622 625 623 psVector *dz = NULL; 626 psVector *mask = psVectorAlloc (sources->n, PS_TYPE_ U8);624 psVector *mask = psVectorAlloc (sources->n, PS_TYPE_VECTOR_MASK); 627 625 628 626 // check the fit residuals and increase Nx,Ny until the error is minimized … … 632 630 // copy srcMask to mask (we do not want the mask values set in pmPSFFitShapeParamsMap to be sticky) 633 631 for (int i = 0; i < mask->n; i++) { 634 mask->data. U8[i] = srcMask->data.U8[i];632 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i]; 635 633 } 636 634 if (!pmPSFFitShapeParamsMap (psf, i, &scatterTotal, mask, x, y, mag, e0, e1, e2, dz)) { … … 651 649 // copy srcMask to mask (we do not want the mask values set in pmPSFFitShapeParamsMap to be sticky) 652 650 for (int i = 0; i < mask->n; i++) { 653 mask->data. U8[i] = srcMask->data.U8[i];651 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i]; 654 652 } 655 653 if (!pmPSFFitShapeParamsMap (psf, entryMin, &scatterTotal, mask, x, y, mag, e0, e1, e2, dz)) { … … 663 661 // copy mask back to srcMask 664 662 for (int i = 0; i < mask->n; i++) { 665 srcMask->data. U8[i] = mask->data.U8[i];663 srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = mask->data.PS_TYPE_VECTOR_MASK_DATA[i]; 666 664 } 667 665 … … 736 734 pmTrend2DEval (psf->params->data[PM_PAR_E1], x->data.F32[i], y->data.F32[i]), 737 735 pmTrend2DEval (psf->params->data[PM_PAR_E2], x->data.F32[i], y->data.F32[i]), 738 srcMask->data. U8[i]);736 srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i]); 739 737 } 740 738 fclose (f); … … 851 849 852 850 // the mask marks the values not used to calculate the ApTrend 853 psVector *fitMask = psVectorAlloc (x_fit->n, PS_TYPE_ U8);851 psVector *fitMask = psVectorAlloc (x_fit->n, PS_TYPE_VECTOR_MASK); 854 852 // copy mask values to fitMask as a starting point 855 853 for (int i = 0; i < fitMask->n; i++) { 856 fitMask->data. U8[i] = mask->data.U8[i];854 fitMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = mask->data.PS_TYPE_VECTOR_MASK_DATA[i]; 857 855 } 858 856 … … 943 941 // XXX copy fitMask values back to mask 944 942 for (int i = 0; i < fitMask->n; i++) { 945 mask->data. U8[i] = fitMask->data.U8[i];943 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = fitMask->data.PS_TYPE_VECTOR_MASK_DATA[i]; 946 944 } 947 945 psFree (fitMask); … … 951 949 952 950 // calculate the scatter of the parameters 953 bool pmPSFShapeParamsScatter(float *scatterTotal, psVector *e0res, psVector *e1res, psVector *e2res, psVector *mask, ps MaskType maskValue, psStatsOptions stdevOpt)951 bool pmPSFShapeParamsScatter(float *scatterTotal, psVector *e0res, psVector *e1res, psVector *e2res, psVector *mask, psVectorMaskType maskValue, psStatsOptions stdevOpt) 954 952 { 955 953 … … 994 992 psVector *dE1subset = psVectorAllocEmpty (nGroup, PS_TYPE_F32); 995 993 psVector *dE2subset = psVectorAllocEmpty (nGroup, PS_TYPE_F32); 996 psVector *mkSubset = psVectorAllocEmpty (nGroup, PS_TYPE_ U8);994 psVector *mkSubset = psVectorAllocEmpty (nGroup, PS_TYPE_VECTOR_MASK); 997 995 998 996 int n = 0; … … 1007 1005 dE2subset->data.F32[j] = e2res->data.F32[N]; 1008 1006 1009 mkSubset->data. U8[j] = mask->data.U8[N];1010 if (!mask->data. U8[N]) nValid ++;1007 mkSubset->data.PS_TYPE_VECTOR_MASK_DATA[j] = mask->data.PS_TYPE_VECTOR_MASK_DATA[N]; 1008 if (!mask->data.PS_TYPE_VECTOR_MASK_DATA[N]) nValid ++; 1011 1009 } 1012 1010 if (nValid < 3) continue;
Note:
See TracChangeset
for help on using the changeset viewer.
