- Timestamp:
- May 3, 2010, 8:41:49 AM (16 years ago)
- Location:
- branches/tap_branches
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/tap_branches
- Property svn:mergeinfo changed
-
branches/tap_branches/Ohana
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/Ohana merged eligible /branches/eam_branches/Ohana.20100407 27635-27772 /branches/pap_delete/Ohana 27530-27595
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/tap_branches/Ohana/src/addstar/src/find_matches.c
r21508 r27838 1 1 # include "addstar.h" 2 2 3 int find_matches (SkyRegion *region, Stars *stars, int NstarsIn, Catalog *catalog, AddstarClientOptions options) {4 5 int i, j, n, N, J, status, Nstars;3 int find_matches (SkyRegion *region, Stars *stars, unsigned int NstarsIn, Catalog *catalog, AddstarClientOptions options) { 4 5 off_t i, j, n, N, J, status, Nstars; 6 6 double RADIUS, RADIUS2; 7 7 double *X1, *Y1, *X2, *Y2; 8 8 double dX, dY, dR; 9 int *N1, *N2,*next_meas;10 int Nave, NAVE, Nmeas, NMEAS, Nmatch;9 off_t *N1, *N2, *next_meas; 10 off_t Nave, NAVE, Nmeas, NMEAS, Nmatch; 11 11 int Nsecfilt, Nsec; 12 12 unsigned int objID, catID; 13 13 Coords tcoords; 14 15 if (NSTAR_GROUP <= 0) { 16 fprintf (stderr, "ERROR: NSTAR_GROUP NOT SET!\n"); 17 exit (1); 18 } 14 19 15 20 /* photcode data - must by of type DEP; options.photcode is equiv photcode for all input … … 24 29 ALLOCATE (X1, double, NstarsIn); 25 30 ALLOCATE (Y1, double, NstarsIn); 26 ALLOCATE (N1, int,NstarsIn);31 ALLOCATE (N1, off_t, NstarsIn); 27 32 28 33 /** allocate local arrays (catalog) **/ … … 30 35 ALLOCATE (X2, double, NAVE); 31 36 ALLOCATE (Y2, double, NAVE); 32 ALLOCATE (N2, int,NAVE);33 ALLOCATE (catalog[0].found, int, NAVE);37 ALLOCATE (N2, off_t, NAVE); 38 ALLOCATE (catalog[0].found, off_t, NAVE); 34 39 /* for secfilt j and star i, secfilt[i*Nsecfilt+j] */ 35 40 … … 103 108 104 109 /** find matched stars **/ 110 // XXX could use NSTAR_GROUP to do this match more quicky if NSTAR_GROUP > 1 105 111 for (i = j = 0; (i < Nstars) && (j < Nave); ) { 106 112 if (!finite(X1[i]) || !finite(Y1[i])) { … … 115 121 /* negative dX: j is too large */ 116 122 dX = X1[i] - X2[j]; 117 if (dX <= - 2*RADIUS) {123 if (dX <= -1.02*RADIUS) { 118 124 i++; 119 125 continue; 120 126 } 121 127 /* positive dX, i is too large */ 122 if (dX >= 2*RADIUS) {128 if (dX >= 1.02*RADIUS) { 123 129 j++; 124 130 continue; … … 126 132 127 133 /* within match range; look for matches */ 128 for (J = j; (dX > - 2*RADIUS) && (J < Nave); J++) {134 for (J = j; (dX > -1.02*RADIUS) && (J < Nave); J++) { 129 135 dX = X1[i] - X2[J]; 130 136 dY = Y1[i] - Y2[J]; … … 132 138 if (dR > RADIUS2) continue; 133 139 140 /*** a match is found, add to average, measure ***/ 141 Nmatch ++; 142 n = N2[J]; 143 N = N1[i]; 144 134 145 /* make sure there is space for next entry */ 135 146 if (Nmeas >= NMEAS) { 136 147 NMEAS = Nmeas + 1000; 137 REALLOCATE (next_meas, int, NMEAS); 148 REALLOCATE (next_meas, off_t, NMEAS); 149 138 150 REALLOCATE (catalog[0].measure, Measure, NMEAS); 139 151 } 140 141 Nmatch ++;142 n = N2[J];143 N = N1[i];144 152 145 153 /* add to end of measurement list */ … … 226 234 /* incorporate unmatched image stars, if this star is in field of this catalog */ 227 235 /* these new entries are all written out in UPDATE mode */ 228 for (i = 0; (i < Nstars) && !options.only_match; i ++) {236 for (i = 0; (i < Nstars) && !options.only_match; i += NSTAR_GROUP) { 229 237 /* make sure there is space for next entry */ 230 if (Nmeas >= NMEAS ) {238 if (Nmeas >= NMEAS - NSTAR_GROUP) { 231 239 NMEAS = Nmeas + 1000; 232 REALLOCATE (next_meas, int, NMEAS);240 REALLOCATE (next_meas, off_t, NMEAS); 233 241 REALLOCATE (catalog[0].measure, Measure, NMEAS); 234 242 } … … 248 256 catalog[0].average[Nave].dD = 0; 249 257 250 catalog[0].average[Nave].Nmeasure = 1;258 catalog[0].average[Nave].Nmeasure = NSTAR_GROUP; 251 259 catalog[0].average[Nave].Nmissing = 0; 252 260 catalog[0].average[Nave].Nextend = 0; … … 264 272 265 273 catalog[0].average[Nave].Xp = 0; 266 catalog[0].average[Nave].ChiSq = 0.0; 274 catalog[0].average[Nave].ChiSqAve = 0.0; 275 catalog[0].average[Nave].ChiSqPM = 0.0; 276 catalog[0].average[Nave].ChiSqPar = 0.0; 277 catalog[0].average[Nave].Tmean = 0; 278 catalog[0].average[Nave].Trange = 0; 267 279 catalog[0].average[Nave].Npos = 0; 268 280 … … 270 282 catalog[0].average[Nave].catID = catID; 271 283 catalog[0].average[Nave].flags = 0; 284 if (PSPS_ID) { 285 catalog[0].average[Nave].extID = CreatePSPSObjectID(catalog[0].average[Nave].R, 286 catalog[0].average[Nave].D); 287 } else { 288 catalog[0].average[Nave].extID = 0; 289 } 272 290 273 291 objID ++; … … 283 301 } 284 302 285 // supply the measurments from this detection 286 catalog[0].measure[Nmeas] = stars[N].measure; 287 288 // the following measure elements cannot be set until here: 289 catalog[0].measure[Nmeas].dR = 0.0; 290 catalog[0].measure[Nmeas].dD = 0.0; 291 catalog[0].measure[Nmeas].dbFlags = 0; 292 catalog[0].measure[Nmeas].averef = Nave; // XXX EAM : must be absolute Nave if partial read 293 catalog[0].measure[Nmeas].objID = catalog[0].average[Nave].objID; 294 catalog[0].measure[Nmeas].catID = catalog[0].catID; 295 296 /* set the average magnitude if not already set and the photcode.equiv is not 0 */ 297 /* in UPDATE mode, this value is not saved; use relphot to recalculate */ 298 if (Nsec > -1) { 299 catalog[0].secfilt[Nave*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas]); 300 } 301 302 /* next[Nmeas] should always be -1 in this context (it is always the only 303 measurement for the star) */ 304 stars[N].found = Nmeas; 305 next_meas[Nmeas] = -1; 306 Nmeas ++; 303 for (j = 0; j < NSTAR_GROUP; j++) { 304 // supply the measurments from this detection 305 catalog[0].measure[Nmeas] = stars[N].measure; 306 N = N1[i + j]; 307 308 // the following measure elements cannot be set until here: 309 catalog[0].measure[Nmeas].dR = 0.0; 310 catalog[0].measure[Nmeas].dD = 0.0; 311 catalog[0].measure[Nmeas].dbFlags = 0; 312 catalog[0].measure[Nmeas].averef = Nave; // XXX EAM : must be absolute Nave if partial read 313 catalog[0].measure[Nmeas].objID = catalog[0].average[Nave].objID; 314 catalog[0].measure[Nmeas].catID = catalog[0].catID; 315 316 /* set the average magnitude if not already set and the photcode.equiv is not 0 */ 317 /* in UPDATE mode, this value is not saved; use relphot to recalculate */ 318 if (Nsec > -1) { 319 catalog[0].secfilt[Nave*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas]); 320 } 321 322 /* next[Nmeas] should always be -1 in this context (it is always the only 323 measurement for the star) */ 324 stars[N].found = Nmeas; 325 next_meas[Nmeas] = -1; // initial value here update below 326 Nmeas ++; 327 } 328 for (j = 0; j < NSTAR_GROUP - 1; j++) { 329 next_meas[Nmeas - NSTAR_GROUP + j] = Nmeas - NSTAR_GROUP + j + 1; 330 } 307 331 Nave ++; 308 332 } … … 332 356 catalog[0].Nmeasure = Nmeas; 333 357 catalog[0].Nsecf_mem = Nave*Nsecfilt; 334 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas: % d %d %d, (%d matches)\n", Nstars, Nave, Nmeas,Nmatch);358 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas: %lld %lld %lld, (%lld matches)\n", (long long) Nstars, (long long) Nave, (long long) Nmeas, (long long) Nmatch); 335 359 336 360 free (catalog[0].found); … … 338 362 free (Y1); 339 363 free (N1); 364 free (N2); 340 365 free (X2); 341 366 free (Y2); 342 free (N2); 367 free (next_meas); 368 343 369 return (Nmatch); 344 370 }
Note:
See TracChangeset
for help on using the changeset viewer.
