Changeset 9734 for trunk/psphot/src/psphotSourceStats.c
- Timestamp:
- Oct 24, 2006, 2:07:03 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotSourceStats.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotSourceStats.c
r9520 r9734 2 2 3 3 // 2006.02.02 : no leaks 4 psArray *psphotSourceStats (pmReadout *readout, psMetadata *recipe, psArray *peaks) 4 psArray *psphotSourceStats (pmReadout *readout, psMetadata *recipe, psArray *peaks) 5 5 { 6 6 bool status = false; … … 16 16 char *breakPt = psMetadataLookupStr (&status, recipe, "BREAK_POINT"); 17 17 18 sources = psArrayAlloc (peaks->n);18 sources = psArrayAllocEmpty (peaks->n); 19 19 20 20 for (int i = 0; i < peaks->n; i++) { 21 21 22 // create a new source, add peak23 pmSource *source = pmSourceAlloc();24 source->peak = (pmPeak *)psMemIncrRefCounter(peaks->data[i]);22 // create a new source, add peak 23 pmSource *source = pmSourceAlloc(); 24 source->peak = (pmPeak *)psMemIncrRefCounter(peaks->data[i]); 25 25 26 // allocate image, weight, mask arrays for each peak (square of radius OUTER)27 pmSourceDefinePixels (source, readout, source->peak->x, source->peak->y, OUTER);28 if (!strcasecmp (breakPt, "PEAKS")) { 29 psArrayAdd (sources, 100, source);30 psFree (source);31 continue;32 }26 // allocate image, weight, mask arrays for each peak (square of radius OUTER) 27 pmSourceDefinePixels (source, readout, source->peak->x, source->peak->y, OUTER); 28 if (!strcasecmp (breakPt, "PEAKS")) { 29 psArrayAdd (sources, 100, source); 30 psFree (source); 31 continue; 32 } 33 33 34 // XXX skip faint sources?34 // XXX skip faint sources? 35 35 36 // measure a local sky value37 // XXX EAM : this should use ROBUST not SAMPLE median, but it is broken38 status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER);39 if (!status) {40 psFree (source);41 continue;42 }36 // measure a local sky value 37 // XXX EAM : this should use ROBUST not SAMPLE median, but it is broken 38 status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER); 39 if (!status) { 40 psFree (source); 41 continue; 42 } 43 43 44 // measure the local sky variance (needed if noise is not sqrt(signal))45 // XXX EAM : this should use ROBUST not SAMPLE median, but it is broken46 status = pmSourceLocalSkyVariance (source, PS_STAT_SAMPLE_MEDIAN, INNER);47 if (!status) {48 psFree (source);49 continue;50 }44 // measure the local sky variance (needed if noise is not sqrt(signal)) 45 // XXX EAM : this should use ROBUST not SAMPLE median, but it is broken 46 status = pmSourceLocalSkyVariance (source, PS_STAT_SAMPLE_MEDIAN, INNER); 47 if (!status) { 48 psFree (source); 49 continue; 50 } 51 51 52 // measure basic source moments53 status = pmSourceMoments (source, RADIUS);54 if (status) {55 // add to the source array56 psArrayAdd (sources, 100, source);57 psFree (source);58 continue;59 }52 // measure basic source moments 53 status = pmSourceMoments (source, RADIUS); 54 if (status) { 55 // add to the source array 56 psArrayAdd (sources, 100, source); 57 psFree (source); 58 continue; 59 } 60 60 61 // if no valid pixels, or massive swing, likely saturated source,62 // try a much larger box63 BIG_RADIUS = PS_MIN (INNER, 3*RADIUS);64 psTrace ("psphot", 4, "retrying moments for %d, %d\n", source->peak->x, source->peak->y);65 status = pmSourceMoments (source, BIG_RADIUS);66 if (status) {67 // add to the source array68 psArrayAdd (sources, 100, source);69 psFree (source);70 continue;71 }61 // if no valid pixels, or massive swing, likely saturated source, 62 // try a much larger box 63 BIG_RADIUS = PS_MIN (INNER, 3*RADIUS); 64 psTrace ("psphot", 4, "retrying moments for %d, %d\n", source->peak->x, source->peak->y); 65 status = pmSourceMoments (source, BIG_RADIUS); 66 if (status) { 67 // add to the source array 68 psArrayAdd (sources, 100, source); 69 psFree (source); 70 continue; 71 } 72 72 73 psFree (source);74 continue;73 psFree (source); 74 continue; 75 75 } 76 76 77 77 psLogMsg ("psphot", 3, "%ld moments: %f sec\n", sources->n, psTimerMark ("psphot")); 78 78
Note:
See TracChangeset
for help on using the changeset viewer.
