Changeset 18854
- Timestamp:
- Aug 1, 2008, 10:40:59 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotMakeFluxScale.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotMakeFluxScale.c
r14963 r18854 14 14 15 15 pmTrend2D *trend = pmTrend2DAlloc (PM_TREND_MAP, image, Nx, Ny, stats); 16 16 17 17 psVector *xPts = psVectorAlloc (Nx*Ny, PS_TYPE_F32); 18 18 psVector *yPts = psVectorAlloc (Nx*Ny, PS_TYPE_F32); … … 20 20 21 21 int Npts = 0; 22 bool success = true; // Function succeeded? 22 23 23 // generate a set of test normalized PSF fluxes filling the grid 24 // generate a set of test normalized PSF fluxes filling the grid 24 25 for (int ix = 0; ix < Nx; ix++) { 25 for (int iy = 0; iy < Ny; iy++) { 26 27 float x = psImageBinningGetFineX (trend->map->binning, ix + 0.5); 28 float y = psImageBinningGetFineY (trend->map->binning, iy + 0.5); 26 for (int iy = 0; iy < Ny; iy++) { 29 27 30 // create normalized model object at xc,yc 31 pmModel *model = pmModelFromPSFforXY (psf, x, y, 1.0);28 float x = psImageBinningGetFineX (trend->map->binning, ix + 0.5); 29 float y = psImageBinningGetFineY (trend->map->binning, iy + 0.5); 32 30 33 // measure the fitMag for this model 34 float fitSum = model->modelFlux (model->params); 35 assert (fitSum > 0); 36 assert (isfinite(fitSum)); 31 // create normalized model object at xc,yc 32 pmModel *model = pmModelFromPSFforXY (psf, x, y, 1.0); 33 if (!model) { 34 psError(PS_ERR_UNKNOWN, false, "Unable to generate model for grid point %d,%d", ix, iy); 35 success = false; 36 goto DONE; 37 } 37 38 38 xPts->data.F32[Npts] = x; 39 yPts->data.F32[Npts] = y; 40 fPts->data.F32[Npts] = fitSum; 41 Npts ++; 42 assert (Npts <= xPts->nalloc); 43 psFree (model); 44 } 39 // measure the fitMag for this model 40 float fitSum = model->modelFlux (model->params); 41 assert (fitSum > 0); 42 assert (isfinite(fitSum)); 43 44 xPts->data.F32[Npts] = x; 45 yPts->data.F32[Npts] = y; 46 fPts->data.F32[Npts] = fitSum; 47 Npts ++; 48 assert (Npts <= xPts->nalloc); 49 psFree (model); 50 } 45 51 } 46 52 xPts->n = Npts; 47 53 yPts->n = Npts; 48 54 fPts->n = Npts; 49 50 // XXX test for errors here 51 pmTrend2DFit (trend, NULL, 0xff, xPts, yPts, fPts, NULL); 52 55 56 if (!pmTrend2DFit (trend, NULL, 0xff, xPts, yPts, fPts, NULL)) { 57 psError(PS_ERR_UNKNOWN, false, "Unable to fit trend"); 58 success = false; 59 goto DONE; 60 } 61 53 62 // XXX do something useful to measure residual statistics 54 63 55 psf->FluxScale = trend;64 psf->FluxScale = psMemIncrRefCounter(trend); 56 65 57 psFree (xPts); 58 psFree (yPts); 59 psFree (fPts); 60 psFree (stats); 66 DONE: 67 psFree(xPts); 68 psFree(yPts); 69 psFree(fPts); 70 psFree(stats); 71 psFree(trend); 61 72 62 return true;73 return success; 63 74 }
Note:
See TracChangeset
for help on using the changeset viewer.
