Changeset 9841
- Timestamp:
- Nov 3, 2006, 5:12:24 AM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/objects/pmPSFtry.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmPSFtry.c
r9777 r9841 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1.2 3$ $Name: not supported by cvs2svn $8 * @date $Date: 2006-1 0-30 03:03:38$7 * @version $Revision: 1.24 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2006-11-03 15:12:24 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 49 49 psFree (test->modelPSF); 50 50 psFree (test->metric); 51 psFree (test->metricErr); 51 52 psFree (test->fitMag); 52 53 psFree (test->mask); … … 67 68 pmPSFtry *test = (pmPSFtry *) psAlloc(sizeof(pmPSFtry)); 68 69 69 test->psf = pmPSFAlloc (type, poissonErrors, psfTrendMask); 70 test->sources = psMemIncrRefCounter(sources); 71 test->modelEXT = psArrayAlloc (sources->n); 72 test->modelPSF = psArrayAlloc (sources->n); 73 test->metric = psVectorAlloc (sources->n, PS_TYPE_F64); 74 test->fitMag = psVectorAlloc (sources->n, PS_TYPE_F64); 75 test->mask = psVectorAlloc (sources->n, PS_TYPE_U8); 70 test->psf = pmPSFAlloc (type, poissonErrors, psfTrendMask); 71 test->sources = psMemIncrRefCounter(sources); 72 test->modelEXT = psArrayAlloc (sources->n); 73 test->modelPSF = psArrayAlloc (sources->n); 74 test->metric = psVectorAlloc (sources->n, PS_TYPE_F64); 75 test->metricErr = psVectorAlloc (sources->n, PS_TYPE_F64); 76 test->fitMag = psVectorAlloc (sources->n, PS_TYPE_F64); 77 test->mask = psVectorAlloc (sources->n, PS_TYPE_U8); 76 78 77 79 for (int i = 0; i < test->modelEXT->n; i++) { … … 80 82 test->modelPSF->data[i] = NULL; 81 83 test->metric->data.F64[i] = 0; 84 test->metricErr->data.F64[i] = 0; 82 85 test->fitMag->data.F64[i] = 0; 83 86 } … … 175 178 psfTry->modelPSF->data[i] = modelPSF; 176 179 180 // I'm not using the pmSourceMagnitudes API, why? 177 181 // XXX : use a different aperture radius from the fit radius? 178 182 // XXX : use a different estimator for the local sky? … … 188 192 189 193 psfTry->metric->data.F64[i] = obsMag - fitMag; 194 psfTry->metricErr->data.F64[i] = modelPSF->dparams->data.F32[PM_PAR_I0] / modelPSF->params->data.F32[PM_PAR_I0]; 195 190 196 psfTry->fitMag->data.F64[i] = fitMag; 191 197 Npsf ++; … … 280 286 // linear clipped fit of ApResid to r2rflux 281 287 psPolynomial1D *poly = psPolynomial1DAlloc (PS_POLYNOMIAL_ORD, 1); 282 poly = psVectorClipFitPolynomial1D (poly, stats, psfTry->mask, PSFTRY_MASK_ALL, psfTry->metric, NULL, r2rflux); 288 289 // XXX test to only fit a constant offset (no SKYBIAS) 290 poly->mask[1] = 1; 291 292 poly = psVectorClipFitPolynomial1D (poly, stats, psfTry->mask, PSFTRY_MASK_ALL, psfTry->metric, psfTry->metricErr, r2rflux); 283 293 if (poly == NULL) { 284 294 psError(PS_ERR_UNKNOWN, false, "Failed to fit clipped poly"); … … 286 296 } 287 297 psLogMsg ("pmPSFtryMetric", 4, "fit stats: %f +/- %f\n", stats->sampleMedian, stats->sampleStdev); 298 psLogMsg ("pmPSFtryMetric", 4, "apresid: %f +/- %f\n", poly->coeff[0], poly->coeffErr[0]); 299 300 // XXX test dump of fitted model (dump when tracing?) 301 if (0) { 302 FILE *f = fopen ("resid.dat", "w"); 303 psVector *apfit = psPolynomial1DEvalVector (poly, r2rflux); 304 for (int i = 0; i < psfTry->sources->n; i++) { 305 int keep = (psfTry->mask->data.U8[i] & PSFTRY_MASK_ALL); 306 307 pmSource *source = psfTry->sources->data[i]; 308 float x = source->peak->x; 309 float y = source->peak->y; 310 311 fprintf (f, "%d %d, %f %f %f %f %f %f %f\n", 312 i, keep, x, y, 313 psfTry->fitMag->data.F64[i], 314 r2rflux->data.F64[i], 315 psfTry->metric->data.F64[i], 316 psfTry->metricErr->data.F64[i], 317 apfit->data.F64[i]); 318 } 319 fclose (f); 320 psFree (apfit); 321 } 288 322 289 323 pmPSFMaskApTrend (psfTry->psf->ApTrend, PM_PSF_APTREND_SKYBIAS);
Note:
See TracChangeset
for help on using the changeset viewer.
