Changeset 17384
- Timestamp:
- Apr 7, 2008, 5:03:42 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20080324/psphot/src/psphotKernelFromPSF.c
r17351 r17384 3 3 psKernel *psphotKernelFromPSF (pmSource *source, int nPix) { 4 4 5 assert (source);6 assert (source->psfFlux); // XXX build if needed?5 assert (source); 6 assert (source->psfFlux); // XXX build if needed? 7 7 8 int x0 = source->peak->xf - source->psfFlux->col0;9 int y0 = source->peak->yf - source->psfFlux->row0;8 int x0 = source->peak->xf - source->psfFlux->col0; 9 int y0 = source->peak->yf - source->psfFlux->row0; 10 10 11 // need to decide on the size: dynamically? statically?12 psKernel *psf = psKernelAlloc (-nPix, +nPix, -nPix, +nPix);11 // need to decide on the size: dynamically? statically? 12 psKernel *psf = psKernelAlloc (-nPix, +nPix, -nPix, +nPix); 13 13 14 double sum = 0.0; 14 // XXX we should just re-construct a PSF at this location 15 // psModelAdd (psf->image, NULL, source->modelPSF, PM_MODEL_OP_FULL | PM_MODEL_OP_NORM | PM_MODEL_OP_CENTER); 16 17 // if the realized PSF for this object does not cover the full kernel, give up for now 18 if (x0 + psf->xMin < 0) goto escape; 19 if (x0 + psf->xMax >= source->psfFlux->numCols) goto escape; 20 if (y0 + psf->yMin < 0) goto escape; 21 if (y0 + psf->yMax >= source->psfFlux->numRows) goto escape; 15 22 16 for (int j = psf->yMin; j <= psf->yMax; j++) { 17 for (int i = psf->xMin; i <= psf->xMax; i++) { 18 double value = source->psfFlux->data.F32[y0 + j][x0 + i]; 19 psf->kernel[j][i] = value; 20 sum += value; 23 double sum = 0.0; 24 for (int j = psf->yMin; j <= psf->yMax; j++) { 25 for (int i = psf->xMin; i <= psf->xMax; i++) { 26 double value = source->psfFlux->data.F32[y0 + j][x0 + i]; 27 psf->kernel[j][i] = value; 28 sum += value; 29 } 21 30 } 22 } 23 assert (sum > 0.0); 31 assert (sum > 0.0); 24 32 25 // psf must be normalized (integral = 1.0)26 for (int i = 0; i < psf->image->numRows; i++) {27 for (int j = 0; j < psf->image->numCols; j++) {28 psf->image->data.F32[i][j] /= sum;29 }30 }33 // psf must be normalized (integral = 1.0) 34 for (int i = 0; i < psf->image->numRows; i++) { 35 for (int j = 0; j < psf->image->numCols; j++) { 36 psf->image->data.F32[i][j] /= sum; 37 } 38 } 31 39 32 return psf; 40 return psf; 41 42 escape: 43 psFree (psf); 44 return NULL; 33 45 }
Note:
See TracChangeset
for help on using the changeset viewer.
