Changeset 28354
- Timestamp:
- Jun 16, 2010, 12:54:06 PM (16 years ago)
- Location:
- trunk/Ohana/src/dvomerge/src
- Files:
-
- 3 edited
-
dvo_image_merge_dbs.c (modified) (4 diffs)
-
dvomergeUpdate.c (modified) (2 diffs)
-
merge_catalogs_old.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c
r28241 r28354 1 1 # include "dvomerge.h" 2 3 void sort_IDmap (IDmapType *IDmap); 2 4 3 5 // merge db2 into db1 … … 29 31 } 30 32 33 // sort IDmap->old,new on the basis of IDmap->old: 34 sort_IDmap (IDmap); 35 31 36 if (!out[0].swapped) { 32 37 gfits_convert_Image ((Image *) out[0].ftable.buffer, sizeof(Image), Nout); … … 43 48 } 44 49 45 // optimize with sort and bisection50 // XXX isn't the map just ID_new = ID_old + offset ?? 46 51 off_t dvo_map_image_ID (IDmapType *IDmap, off_t oldID) { 47 52 48 off_t i; 53 // off_t i; 54 // 55 // for (i = 0; i < IDmap->Nmap; i++) { 56 // if (IDmap->old[i] != oldID) continue; 57 // return (IDmap->new[i]); 58 // } 49 59 50 for (i = 0; i < IDmap->Nmap; i++) { 51 if (IDmap->old[i] != oldID) continue; 52 return (IDmap->new[i]); 60 off_t Nlo, Nhi, N; 61 62 // find the a close entry below desired ID 63 Nlo = 0; Nhi = IDmap->Nmap; 64 while (Nhi - Nlo > 10) { 65 N = 0.5*(Nlo + Nhi); 66 if (IDmap->old[N] < oldID) { 67 Nlo = MAX(N, 0); 68 } else { 69 Nhi = MIN(N + 1, IDmap->Nmap); 70 } 71 } 72 73 // search for the desired ID starting from Nlo, give up at Nhi 74 for (N = Nlo; N < Nhi; N++) { 75 if (IDmap->old[N] < oldID) continue; 76 if (IDmap->old[N] > oldID) return 0; 77 return (IDmap->new[N]); 53 78 } 54 79 return 0; … … 72 97 return TRUE; 73 98 } 99 100 // sort two times vectors and an index by first time vector 101 void sort_IDmap (IDmapType *IDmap) { 102 103 # define SWAPFUNC(A,B){ off_t tmp_old, tmp_new; \ 104 tmp_old = IDmap->old[A]; IDmap->old[A] = IDmap->old[B]; IDmap->old[B] = tmp_old; \ 105 tmp_new = IDmap->new[A]; IDmap->new[A] = IDmap->new[B]; IDmap->new[B] = tmp_new; \ 106 } 107 # define COMPARE(A,B)(IDmap->old[A] < IDmap->old[B]) 108 109 OHANA_SORT (IDmap->Nmap, COMPARE, SWAPFUNC); 110 111 # undef SWAPFUNC 112 # undef COMPARE 113 114 } 115 -
trunk/Ohana/src/dvomerge/src/dvomergeUpdate.c
r28342 r28354 69 69 70 70 // load in all of the tables from input for this region 71 inlist = SkyListByBounds (insky, depth, outsky[0].regions[i].Rmin, outsky[0].regions[i].Rmax, outsky[0].regions[i].Dmin, outsky[0].regions[i].Dmax); 71 // SkyListByBounds will return neighbor catalogs if the boundaries exactly match (due to rounding). Since the regions are not infinitely small, 72 // compare to a slightly reduced footprint 73 float dPos = 2.0/3600.0; 74 inlist = SkyListByBounds (insky, depth, outsky[0].regions[i].Rmin + dPos, outsky[0].regions[i].Rmax - dPos, outsky[0].regions[i].Dmin + dPos, outsky[0].regions[i].Dmax - dPos); 72 75 for (j = 0; j < inlist[0].Nregions; j++) { 73 76 if (VERBOSE) fprintf (stderr, "input : %s\n", inlist[0].regions[j][0].name); … … 86 89 dvo_catalog_unlock (&incatalog); 87 90 dvo_catalog_free (&incatalog); 91 92 fprintf (stderr, "merged %s into %s\n", outsky[0].regions[i].name, inlist[0].regions[j][0].name); 88 93 } 89 94 SkyListFree (inlist); -
trunk/Ohana/src/dvomerge/src/merge_catalogs_old.c
r28328 r28354 2 2 # define PSPS_ID TRUE 3 3 4 # define IN_REGION(R,D) ( \ 5 ((D) >= region[0].Dmin) && ((D) < region[0].Dmax) && \ 6 ((R) >= region[0].Rmin) && ((R) < region[0].Rmax)) 4 # define MARKTIME(MSG,...) { \ 5 float dtime; \ 6 gettimeofday (&stop, (void *) NULL); \ 7 dtime = DTIME (stop, start); \ 8 fprintf (stderr, MSG, __VA_ARGS__); \ 9 gettimeofday (&start, (void *) NULL); \ 10 } 11 12 # define IN_REGION(R,D) ( \ 13 ((D) >= region[0].Dmin) && ((D) < region[0].Dmax) && \ 14 ((R) >= region[0].Rmin) && ((R) < region[0].Rmax)) 7 15 8 16 // merge the input data into the output catalog … … 10 18 int merge_catalogs_old (SkyRegion *region, Catalog *output, Catalog *input, double RADIUS) { 11 19 12 off_t i, j, Nin, offset, J, Jmin, status, Nstars;20 off_t i, j, k, Nin, offset, J, Jmin, status, Nstars; 13 21 double RADIUS2, Rmin, Rin, Din; 14 22 double *X1, *Y1, *X2, *Y2; … … 19 27 unsigned int objID, catID; 20 28 Coords tcoords; 29 30 // struct timeval start, stop; 31 // gettimeofday (&start, (void *) NULL); 21 32 22 33 Nsecfilt = output[0].Nsecfilt; … … 108 119 /* choose a radius for matches */ 109 120 RADIUS2 = RADIUS*RADIUS; 121 122 // MARKTIME("set up structures: %f sec\n", dtime); 110 123 111 124 /** find matched stars **/ … … 215 228 // update the average properties to reflect the incoming entries: 216 229 // if the original value is NAN but the input value is not, accept the input: 217 for (j = 0; j < Nsecfilt; j++) { 218 if ( isfinite(output[0].secfilt[n*Nsecfilt+j].M)) continue; 219 if (!isfinite( input[0].secfilt[N*Nsecfilt+j].M)) continue; 220 output[0].secfilt[n*Nsecfilt+j].M = input[0].secfilt[N*Nsecfilt+j].M; 221 output[0].secfilt[n*Nsecfilt+j].dM = input[0].secfilt[N*Nsecfilt+j].dM; 222 output[0].secfilt[n*Nsecfilt+j].Xm = input[0].secfilt[N*Nsecfilt+j].Xm; 223 output[0].secfilt[n*Nsecfilt+j].M_20 = input[0].secfilt[N*Nsecfilt+j].M_20; 224 output[0].secfilt[n*Nsecfilt+j].M_80 = input[0].secfilt[N*Nsecfilt+j].M_80; 225 output[0].secfilt[n*Nsecfilt+j].Ncode = input[0].secfilt[N*Nsecfilt+j].Ncode; 226 output[0].secfilt[n*Nsecfilt+j].Nused = input[0].secfilt[N*Nsecfilt+j].Nused; 230 for (k = 0; k < Nsecfilt; k++) { 231 if ( isfinite(output[0].secfilt[n*Nsecfilt+k].M)) continue; 232 if (!isfinite( input[0].secfilt[N*Nsecfilt+k].M)) continue; 233 output[0].secfilt[n*Nsecfilt+k] = input[0].secfilt[N*Nsecfilt+k]; 227 234 } 228 235 … … 232 239 i++; 233 240 } 234 235 # if (0) 236 fprintf (stderr, "--- 1 ---\n"); 237 for (i = 0; i < Nmeas; i++) { 238 fprintf (stderr, "Nave : %d, Nmeas : "OFF_T_FMT", dR: %f, dD: %f, catID: %d\n", output[0].measure[i].averef, i, output[0].measure[i].dR, output[0].measure[i].dD, output[0].measure[i].catID); 239 } 240 # endif 241 // MARKTIME("find matched stars: %f sec for "OFF_T_FMT","OFF_T_FMT" stars\n", dtime, Nstars, Nave); 241 242 242 243 /** incorporate unmatched image stars, if this star is in field of this catalog **/ … … 260 261 if (!IN_REGION (input[0].average[N].R, input[0].average[N].D)) continue; 261 262 262 // XXX should we accept the input measurements for the fields?263 // XXX should we accept the input measurements for these fields? 263 264 264 265 output[0].average[Nave].R = input[0].average[N].R; … … 344 345 int Ngroup = input[0].average[N].Nmeasure; 345 346 for (j = 0; j < Ngroup - 1; j++) { 346 next_meas[Nmeas - Ngroup + j] = Nmeas - Ngroup + j + 1;347 next_meas[Nmeas - Ngroup + j] = Nmeas - Ngroup + j + 1; 347 348 } 348 349 Nave ++; 349 350 } 350 351 352 // MARKTIME("save unmatched stars: %f sec\n", dtime); 353 351 354 REALLOCATE (output[0].average, Average, Nave); 352 355 REALLOCATE (output[0].measure, Measure, Nmeas); 353 356 354 # if (0)355 fprintf (stderr, "--- 2 ---\n");356 for (i = 0; i < Nmeas; i++) {357 fprintf (stderr, "Nave : %d, Nmeas : "OFF_T_FMT", dR: %f, dD: %f, catID: %d\n", output[0].measure[i].averef, i, output[0].measure[i].dR, output[0].measure[i].dD, output[0].measure[i].catID);358 }359 # endif360 361 357 # define NOSORT 0 362 358 if (NOSORT) { … … 366 362 output[0].measure = sort_measure (output[0].average, Nave, output[0].measure, Nmeas, next_meas); 367 363 } 368 369 # if (0)370 fprintf (stderr, "--- 3 ---\n");371 for (i = 0; i < Nmeas; i++) {372 fprintf (stderr, "Nave : %d, Nmeas : "OFF_T_FMT", dR: %f, dD: %f, catID: %d\n", output[0].measure[i].averef, i, output[0].measure[i].dR, output[0].measure[i].dD, output[0].measure[i].catID);373 }374 # endif375 364 376 365 /* note stars which have been found in this catalog */ … … 400 389 free (Y1); 401 390 free (N1); 391 392 // MARKTIME("cleanup: %f sec\n", dtime); 402 393 return (Nmatch); 403 394 }
Note:
See TracChangeset
for help on using the changeset viewer.
