Changeset 15023 for trunk/psphot/src/psphotCheckStarDistribution.c
- Timestamp:
- Sep 25, 2007, 1:53:33 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotCheckStarDistribution.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotCheckStarDistribution.c
r15017 r15023 3 3 // examine the x,y distribution of the psfstars and extend the selection if needed 4 4 // desired region and coverage are specified by pmPSFOptions 5 bool psphotCheckStarDistribution (psArray *sources, pmPSFOptions *options) { 5 // even if stars->n is at the limit, we will add more sources to fill out the area 6 7 bool psphotCheckStarDistribution (psArray *stars, psArray *sources, pmPSFOptions *options) { 6 8 7 9 // count the number of PSFSTAR sources in each cell. for polynomial representations, we … … 16 18 // set up and image and an image binning structure to cover the field 17 19 psImage *nCell = psImageAlloc (Nx, Ny, PS_TYPE_S32); 18 psImageInit (nCell );20 psImageInit (nCell, 0); 19 21 20 22 psImageBinning *binning = psImageBinningAlloc(); … … 27 29 psImageBinningSetSkipByOffset (binning, options->psfFieldXo, options->psfFieldYo); 28 30 29 for (int i = 0; i < sources->n; i++) { 31 // where are the PSF stars located? 32 for (int i = 0; i < stars->n; i++) { 30 33 31 pmSource *source = s ources->data[i];32 if (source-> modelEXT== NULL) continue;34 pmSource *source = stars->data[i]; 35 if (source->peak == NULL) continue; 33 36 if (!(source->mode & PM_SOURCE_MODE_PSFSTAR)) continue; 34 37 35 int binX = psImageBinningGetRuffX (binning, source-> modelEXT->params->data.F32[PM_PAR_XPOS]);36 int binY = psImageBinningGetRuffX (binning, source-> modelEXT->params->data.F32[PM_PAR_YPOS]);38 int binX = psImageBinningGetRuffX (binning, source->peak->xf); 39 int binY = psImageBinningGetRuffX (binning, source->peak->yf); 37 40 38 41 assert (binX >= 0); … … 45 48 46 49 // do any cells have too few PSFSTAR sources? 50 // we use 3 as a minimum (slightly arbitrary...) 47 51 for (int iy = 0; iy < nCell->numRows; iy++) { 48 52 for (int ix = 0; ix < nCell->numCols; ix++) { 49 if (nCell->data.S32[binY][binX] < NNN) { 53 if (nCell->data.S32[iy][ix] < 3) { 54 int nNew = psphotSupplementStars (stars, sources, binning, ix, iy); 55 if (nNew) { 56 psLogMsg ("pmObjects", 3, "added %d fainter PSF candidates to %d,%d\n", nNew, ix, iy); 57 } else { 58 psLogMsg ("pmObjects", 3, "tried to add to %d,%d, but no more sources are available\n", ix, iy); 59 } 50 60 } 51 61 } 52 62 } 53 63 64 psFree (nCell); 65 psFree (binning); 66 return true; 54 67 } 55 68 56 69 // select more possible PSF stars in the specified cell 57 70 // sources should be sorted by SN before calling this function 58 bool psphotSupplementStars (psArray *sources, psImageBinning *binning, int ix, int iy) {71 int psphotSupplementStars (psArray *stars, psArray *sources, psImageBinning *binning, int ix, int iy) { 59 72 60 73 int nNew = 0; … … 66 79 float Ye = psImageBinningGetFineY (binning, iy + 1); 67 80 68 //69 81 for (int i = 0; i < sources->n; i++) { 70 82 83 // add sources which are marked as stars, in S/N order until... 71 84 pmSource *source = sources->data[i]; 72 if (source->modelEXT == NULL) continue; 73 if (!(source->mode & PM_SOURCE_MODE_PSFSTAR)) continue; 85 if (source->peak == NULL) continue; 86 if (source->moments == NULL) continue; 87 if (source->mode & PM_SOURCE_MODE_PSFSTAR) continue; 88 if (source->type != PM_SOURCE_TYPE_STAR) continue; 74 89 75 float x = source-> modelEXT->params->data.F32[PM_PAR_XPOS];76 float y = source-> modelEXT->params->data.F32[PM_PAR_YPOS];90 float x = source->peak->xf; 91 float y = source->peak->yf; 77 92 93 if (x < Xs) continue; 94 if (y < Ys) continue; 95 if (x > Xe) continue; 96 if (y > Ye) continue; 97 98 source->mode |= PM_SOURCE_MODE_PSFSTAR; 99 psArrayAdd (stars, 200, source); 100 101 nNew ++; 102 } 103 return nNew; 78 104 }
Note:
See TracChangeset
for help on using the changeset viewer.
