Changeset 27628
- Timestamp:
- Apr 6, 2010, 6:38:47 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/stackphot.20100406/psphot/src/psphotSourceMatch.c
r27547 r27628 1 # include "psphotInternal.h" 2 3 // we need a couple of functions to distinguish coincident sources: 4 // XXX these are similar (identical?) to the goals of pmSourceMatch.c 5 6 # define NEXT1 { i++; continue; } 7 # define NEXT2 { j++; continue; } 8 9 psphotSourceMerge () { 10 11 float dx, dy; 12 13 // sort the source list by X 14 pmSourceSortByX (sources1); 15 pmSourceSortByX (sources2); 16 17 int i, j; 18 for (i = j = 0; (i < sources1->n) && (j < sources2->n); ) { 19 20 pmSource *src1 = sources1->data[i]; 21 pmSource *src2 = sources2->data[j]; 22 23 if (!src1) NEXT1; 24 if (!src1->peak) NEXT1; 25 if (!finite(src1->peak->xf)) NEXT1; 26 if (!finite(src1->peak->yf)) NEXT1; 27 28 if (!src2) NEXT2; 29 if (!src2->peak) NEXT2; 30 if (!finite(src2->peak->xf)) NEXT2; 31 if (!finite(src2->peak->yf)) NEXT2; 32 33 dx = src1->peak->xf - src2->peak->xf; 34 if (dx < -1.02*RADIUS) NEXT1; 35 if (dx > +1.02*RADIUS) NEXT2; 36 37 // we are within match range, look for matches: 38 for (int J = j; (dx > -1.02*radius) && (J < sources2->n); J++) { 39 40 dx = src1->peak->xf - src2->peak->xf; 41 dy = src1->peak->yf - src2->peak->yf; 42 43 dr = dx*dx + dy*dy; 44 if (dr > RADIUS2) continue; 45 46 // add to group? 47 } 48 i++; 49 } 50 } 1 # include "psphotInternal.h" 2 3 psArray *psphotMatchSources (pmConfig *config, const pmFPAview *view) 4 { 5 bool status = true; 6 7 psArray *objects = psArrayAllocEmpty(100); 8 9 int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM"); 10 psAssert (status, "programming error: must define PSPHOT.INPUT.NUM"); 11 12 // loop over the available readouts 13 for (int i = 0; i < num; i++) { 14 if (!psphotMatchSourcesReadout (objects, config, view, "PSPHOT.INPUT", i)) { 15 psError (PSPHOT_ERR_CONFIG, false, "failed to merge sources for PSPHOT.INPUT entry %d", i); 16 return false; 17 } 18 } 19 return true; 20 } 21 22 // we need a couple of functions to distinguish coincident sources: 23 // XXX these are similar (identical?) to the goals of pmSourceMatch.c 24 25 # define NEXT1 { i++; continue; } 26 # define NEXT2 { j++; continue; } 27 28 bool psphotSourceMerge (psArray *objects, pmConfig *config, const pmFPAview *view, char *filename, int index) { 29 30 float dx, dy; 31 32 // sort the source list by X 33 pmSourceSortByX (sources1); 34 pmSourceSortByX (sources2); 35 36 int i, j; 37 for (i = j = 0; (i < sources1->n) && (j < sources2->n); ) { 38 39 pmSource *src1 = sources1->data[i]; 40 pmSource *src2 = sources2->data[j]; 41 42 if (!src1) NEXT1; 43 if (!src1->peak) NEXT1; 44 if (!finite(src1->peak->xf)) NEXT1; 45 if (!finite(src1->peak->yf)) NEXT1; 46 47 if (!src2) NEXT2; 48 if (!src2->peak) NEXT2; 49 if (!finite(src2->peak->xf)) NEXT2; 50 if (!finite(src2->peak->yf)) NEXT2; 51 52 dx = src1->peak->xf - src2->peak->xf; 53 if (dx < -1.02*RADIUS) NEXT1; 54 if (dx > +1.02*RADIUS) NEXT2; 55 56 // we are within match range, look for matches: 57 for (int J = j; (dx > -1.02*radius) && (J < sources2->n); J++) { 58 59 dx = src1->peak->xf - src2->peak->xf; 60 dy = src1->peak->yf - src2->peak->yf; 61 62 dr = dx*dx + dy*dy; 63 if (dr > RADIUS2) continue; 64 65 // add to group? 66 } 67 i++; 68 } 69 }
Note:
See TracChangeset
for help on using the changeset viewer.
