Changeset 26279
- Timestamp:
- Nov 25, 2009, 11:50:11 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/addstar/src/find_matches_refstars.c
r21508 r26279 3 3 int find_matches_refstars (SkyRegion *region, Stars **stars, int Nstars, Catalog *catalog, AddstarClientOptions options) { 4 4 5 int i, j, k, n, m, N, J;5 int i, j, n, N, J; 6 6 double RADIUS, RADIUS2; 7 7 double *X1, *Y1, *X2, *Y2; 8 8 double dX, dY, dR; 9 int *N1, *N2, *next , *next_miss, last, last_miss;10 int Nave, NAVE, Nmeas, NMEAS, Nm iss, NMISS, Nmatch;9 int *N1, *N2, *next_meas; 10 int Nave, NAVE, Nmeas, NMEAS, Nmatch; 11 11 unsigned int objID, catID; 12 Measure *tmpmeasure;13 Missing *tmpmissing;14 12 Coords tcoords; 15 13 int Nsecfilt; … … 42 40 Nmeas = catalog[0].Nmeasure; 43 41 NMEAS = Nmeas + 1000; 44 ALLOCATE (next , int, NMEAS);42 ALLOCATE (next_meas, int, NMEAS); 45 43 REALLOCATE (catalog[0].measure, Measure, NMEAS); 46 47 Nmiss = catalog[0].Nmissing;48 NMISS = Nmiss + 1000;49 if ((NMISS < 1) || (NMISS > 1e10)) {50 fprintf (stderr, "weird value for NMISS: %d\n", NMISS);51 }52 ALLOCATE (next_miss, int, NMISS);53 REALLOCATE (catalog[0].missing, Missing, NMISS);54 44 55 45 // current max obj ID for this catalog … … 82 72 83 73 /* set up pointers for linked list of measurements */ 84 for (i = 0; i < Nmeas - 1; i++) { 85 next[i] = i+1; 86 } 87 next[i] = -1; 88 last = i; 89 90 for (i = 0; i < Nmiss - 1; i++) { 91 next_miss[i] = i+1; 92 } 93 next_miss[i] = -1; 94 last_miss = i; 74 if (catalog[0].sorted && (catalog[0].Nmeasure == catalog[0].Nmeas_disk)) { 75 // this version is only valid if we have done a full catalog load, and if the catalog 76 // is sorted while processed 77 next_meas = init_measure_links (catalog[0].average, Nave, catalog[0].measure, Nmeas); 78 } else { 79 next_meas = build_measure_links (catalog[0].average, Nave, catalog[0].measure, Nmeas); 80 } 95 81 96 82 /* choose a radius for matches */ … … 126 112 n = N2[J]; 127 113 N = N1[i]; 128 m = catalog[0].average[n].measureOffset;129 114 130 115 /** in replace mode, search for entry and replace values M, dM, R, D */ 131 if (options.replace && replace_match (&catalog[0].average[n], &catalog[0].measure[m], stars[N])) continue; 132 133 /** insert star in measurement list */ 134 /* find last measurement of this star */ 135 for (k = 0; k < catalog[0].average[n].Nmeasure - 1; k++) m = next[m]; 136 137 /* set up references */ 138 next[Nmeas] = next[m]; 139 next[m] = Nmeas; 140 141 /* last just was moved */ 142 if (next[Nmeas] == -1) last = Nmeas; 116 if (options.replace && replace_match (&catalog[0].average[n], catalog[0].measure, stars[N])) continue; 117 118 /* add to end of measurement list */ 119 add_meas_link (&catalog[0].average[n], next_meas, Nmeas, NMEAS); 143 120 144 121 /** add measurements for this star **/ … … 206 183 if (Nmeas == NMEAS) { 207 184 NMEAS = Nmeas + 1000; 208 REALLOCATE (next , int, NMEAS);185 REALLOCATE (next_meas, int, NMEAS); 209 186 REALLOCATE (catalog[0].measure, Measure, NMEAS); 210 187 } 211 188 212 update_coords (&catalog[0].average[n], &catalog[0].measure[0], next );189 update_coords (&catalog[0].average[n], &catalog[0].measure[0], next_meas); 213 190 } 214 191 i++; … … 295 272 296 273 stars[N][0].found = Nmeas; 297 next[last] = Nmeas;298 next[Nmeas] = -1;299 last = Nmeas;300 274 Nmeas ++; 301 275 if (Nmeas == NMEAS) { 302 276 NMEAS = Nmeas + 1000; 303 REALLOCATE (next , int, NMEAS);277 REALLOCATE (next_meas, int, NMEAS); 304 278 REALLOCATE (catalog[0].measure, Measure, NMEAS); 305 279 } … … 314 288 } 315 289 316 free (catalog[0].found);317 290 REALLOCATE (catalog[0].average, Average, Nave); 318 291 319 /* fix order of Measure (memory intensive, but fast) */ 320 N = 0; 321 ALLOCATE (tmpmeasure, Measure, Nmeas); 322 for (i = 0; i < Nave; i++) { 323 n = catalog[0].average[i].measureOffset; 324 catalog[0].average[i].measureOffset = N; 325 for (k = 0; k < catalog[0].average[i].Nmeasure; k++, N++) { 326 tmpmeasure[N] = catalog[0].measure[n]; 327 tmpmeasure[N].averef = i; 328 n = next[n]; 329 } 330 } 331 free (catalog[0].measure); 332 catalog[0].measure = tmpmeasure; 333 334 /* fix order of Missing (memory intensive, but fast) */ 335 N = 0; 336 ALLOCATE (tmpmissing, Missing, Nmiss); 337 for (i = 0; i < Nave; i++) { 338 if (catalog[0].average[i].Nmissing > 0) { 339 n = catalog[0].average[i].missingOffset; 340 catalog[0].average[i].missingOffset = N; 341 for (k = 0; k < catalog[0].average[i].Nmissing; k++, N++) { 342 tmpmissing[N] = catalog[0].missing[n]; 343 n = next_miss[n]; 344 } 345 } 346 } 347 free (catalog[0].missing); 348 catalog[0].missing = tmpmissing; 292 // XXX allow for unsorted output? 293 catalog[0].measure = sort_measure (catalog[0].average, Nave, catalog[0].measure, Nmeas, next_meas); 349 294 350 295 /* note stars which have been found in this catalog */ … … 357 302 } 358 303 304 catalog[0].objID = objID; // new max value, save on catalog close 305 catalog[0].Naverage = Nave; 306 catalog[0].Nmeasure = Nmeas; 307 catalog[0].Nsecf_mem = Nave*Nsecfilt; 308 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas: %d %d %d, (%d matches)\n", Nstars, Nave, Nmeas, Nmatch); 309 310 free (catalog[0].found); 359 311 free (X1); 360 312 free (Y1); … … 363 315 free (Y2); 364 316 free (N2); 365 free (next); 366 free (next_miss); 367 368 catalog[0].objID = objID; // new max value, save on catalog close 369 catalog[0].Naverage = Nave; 370 catalog[0].Nmeasure = Nmeas; 371 catalog[0].Nmissing = Nmiss; 372 catalog[0].Nsecf_mem = Nave*Nsecfilt; 373 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas, Nmiss: %d %d %d %d, (%d matches)\n", Nstars, Nave, Nmeas, Nmiss, Nmatch); 317 free (next_meas); 318 374 319 return (Nmatch); 375 320 }
Note:
See TracChangeset
for help on using the changeset viewer.
