- Timestamp:
- Jan 1, 2016, 3:04:44 PM (11 years ago)
- Location:
- trunk/Ohana/src/dvomerge
- Files:
-
- 5 edited
-
include/dvomerge.h (modified) (2 diffs)
-
src/args.c (modified) (2 diffs)
-
src/dvo_image_merge_dbs.c (modified) (5 diffs)
-
src/dvomergeImageIDs.c (modified) (2 diffs)
-
src/dvomergeUpdate_catalogs.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/dvomerge/include/dvomerge.h
r39281 r39299 46 46 char *UPDATE_CATCOMPRESS; 47 47 48 int MATCH_BY_EXTERN_ID; 49 48 50 int MATCHED_TABLES; 49 51 int REPAIR_BY_OBJID; … … 202 204 off_t getTgtIndex PROTO((e_time start, e_time stop, short photcode, off_t *TgtIndex, e_time *TgtTimes, short *TgtCodes, off_t NimagesTgt)); 203 205 void SortTgtByTimes PROTO((e_time *S, off_t *I, short *C, off_t N)); 204 int dvo_image_match_dbs PROTO((IDmapType *IDmap, FITS_DB *tgt, FITS_DB *src));205 206 int dvomergeImagesGetMap PROTO((IDmapType *IDmap, char *input, char *output)); 206 207 int dvomergeFromList PROTO((int argc, char **argv)); 207 208 int dvomergeUpdate_threaded PROTO((int argc, char **argv)); 208 209 int dvomergeUpdate_catalogs PROTO((char *input, char *output, SkyTable *outsky, SkyList *inlist, int NsecfiltInput, int NsecfiltOutput, IDmapType *IDmap, int *secfiltMap)); 210 211 int dvo_image_match_dbs_by_time_and_photcode PROTO((IDmapType *IDmap, FITS_DB *tgt, FITS_DB *src)); 212 int dvo_image_match_dbs_by_extern_id PROTO((IDmapType *IDmap, FITS_DB *tgt, FITS_DB *src)); 209 213 210 214 int replace_match PROTO((Average *average_out, Measure *measure_out, off_t *next_meas, Average *average_in, Measure *measure_in)); -
trunk/Ohana/src/dvomerge/src/args.c
r38986 r39299 44 44 if ((N = get_argument (*argc, argv, "-matched-tables"))) { 45 45 MATCHED_TABLES = TRUE; 46 remove_argument (N, argc, argv); 47 } 48 49 /* extra error messages */ 50 MATCH_BY_EXTERN_ID = FALSE; 51 if ((N = get_argument (*argc, argv, "-match-by-extern-id"))) { 52 MATCH_BY_EXTERN_ID = TRUE; 46 53 remove_argument (N, argc, argv); 47 54 } … … 245 252 } 246 253 254 /* extra error messages */ 255 MATCH_BY_EXTERN_ID = FALSE; 256 if ((N = get_argument (*argc, argv, "-match-by-extern-id"))) { 257 MATCH_BY_EXTERN_ID = TRUE; 258 remove_argument (N, argc, argv); 259 } 260 247 261 UPDATE_CATFORMAT = NULL; 248 262 if ((N = get_argument (*argc, argv, "-update-catformat"))) { -
trunk/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c
r39142 r39299 3 3 // utility functions 4 4 void sort_IDmap (IDmapType *IDmap); 5 5 6 void SortTgtByTimes (e_time *S, off_t *I, short *C, off_t N); 6 off_t getTgtIndex (e_time start, e_time stop, short photcode, off_t *TgtIndex, e_time *TgtTimes, short *TgtCodes, off_t NimagesTgt); 7 void SortTgtByExtID (unsigned int *S, off_t *I, off_t N); 8 9 off_t getTgtIndexByExtID (unsigned int extID, off_t *TgtIndex, unsigned int *TgtExtID, off_t NimagesTgt); 10 off_t getTgtIndexByTimeAndPhotcode (e_time start, e_time stop, short photcode, off_t *TgtIndex, e_time *TgtTimes, short *TgtCodes, off_t NimagesTgt); 7 11 8 12 void dvo_image_map_init (IDmapType *IDmap) { … … 22 26 23 27 // we have two tables; 'tgt' contains some exposures from 'src' : find them and match a map 24 int dvo_image_match_dbs (IDmapType *IDmap, FITS_DB *tgt, FITS_DB *src) { 28 int dvo_image_match_dbs_by_extern_id (IDmapType *IDmap, FITS_DB *tgt, FITS_DB *src) { 29 30 Image *imagesSrc, *imagesTgt; 31 off_t NimagesSrc, NimagesTgt; 32 off_t iSrc, iTgt; 33 off_t *TgtIndex; 34 unsigned int *TgtExtID; 35 36 imagesSrc = gfits_table_get_Image (&src[0].ftable, &NimagesSrc, &src[0].scaledValue, &src[0].nativeOrder); 37 if (!imagesSrc) { 38 fprintf (stderr, "ERROR: failed to read images from src\n"); 39 exit (2); 40 } 41 42 imagesTgt = gfits_table_get_Image (&tgt[0].ftable, &NimagesTgt, &tgt[0].scaledValue, &tgt[0].nativeOrder); 43 if (!imagesTgt) { 44 fprintf (stderr, "ERROR: failed to read images from tgt\n"); 45 exit (2); 46 } 47 48 ALLOCATE (IDmap->old, unsigned int, NimagesSrc); 49 ALLOCATE (IDmap->new, unsigned int, NimagesSrc); 50 IDmap->Nmap = NimagesSrc; 51 52 // match by time and photcode 53 ALLOCATE (TgtIndex, off_t, NimagesTgt); 54 ALLOCATE (TgtExtID, unsigned int, NimagesTgt); 55 56 // save the Index, Times, Codes for all TGT images 57 for (iTgt = 0; iTgt < NimagesTgt; iTgt++) { 58 TgtIndex[iTgt] = iTgt; 59 TgtExtID[iTgt] = imagesTgt[iTgt].externID; 60 } 61 62 // sort the index, start, and stop by the start times: 63 SortTgtByExtID (TgtExtID, TgtIndex, NimagesTgt); 64 65 for (iSrc = 0; iSrc < NimagesSrc; iSrc++) { 66 iTgt = getTgtIndexByExtID (imagesSrc[iSrc].externID, TgtIndex, TgtExtID, NimagesTgt); 67 if (iTgt < 0) Shutdown ("failure to find matching image: %s\n", imagesSrc[iSrc].name); 68 IDmap[0].old[iSrc] = imagesSrc[iSrc].imageID; 69 IDmap[0].new[iSrc] = imagesTgt[iTgt].imageID; 70 } 71 72 create_IDmap_lookup (IDmap); 73 74 FREE(TgtIndex); 75 FREE(TgtExtID); 76 77 // sort IDmap->old,new on the basis of IDmap->old: 78 sort_IDmap (IDmap); 79 80 return TRUE; 81 } 82 83 // we have two tables; 'tgt' contains some exposures from 'src' : find them and match a map 84 int dvo_image_match_dbs_by_time_and_photcode (IDmapType *IDmap, FITS_DB *tgt, FITS_DB *src) { 25 85 26 86 Image *imagesSrc, *imagesTgt; … … 63 123 64 124 for (iSrc = 0; iSrc < NimagesSrc; iSrc++) { 65 iTgt = getTgtIndex (imagesSrc[iSrc].tzero, imagesSrc[iSrc].tzero + (int) imagesSrc[iSrc].exptime, imagesSrc[iSrc].photcode, TgtIndex, TgtTimes, TgtCodes, NimagesTgt);125 iTgt = getTgtIndexByTimeAndPhotcode (imagesSrc[iSrc].tzero, imagesSrc[iSrc].tzero + (int) imagesSrc[iSrc].exptime, imagesSrc[iSrc].photcode, TgtIndex, TgtTimes, TgtCodes, NimagesTgt); 66 126 if (iTgt < 0) Shutdown ("failure to match images: %s\n", imagesSrc[iSrc].name); 67 127 IDmap[0].old[iSrc] = imagesSrc[iSrc].imageID; … … 256 316 } 257 317 258 off_t getTgtIndex (e_time start, e_time stop, short photcode, off_t *TgtIndex, e_time *TgtTimes, short *TgtCodes, off_t NimagesTgt) { 318 off_t getTgtIndexByExtID (unsigned int extID, off_t *TgtIndex, unsigned int *TgtExtID, off_t NimagesTgt) { 319 320 // use bisection to find the starting entry by time 321 322 off_t Nlo, Nhi, N; 323 324 // find the last TGT before start 325 Nlo = 0; Nhi = NimagesTgt; 326 while (Nhi - Nlo > 10) { 327 N = 0.5*(Nlo + Nhi); 328 if (TgtExtID[N] < extID) { 329 Nlo = MAX(N, 0); 330 } else { 331 Nhi = MIN(N + 1, NimagesTgt); 332 } 333 } 334 335 // check for the matched mosaic starting from Nlo 336 // we may have to go much beyond Nlo since stop is not sorted 337 // can we use a sorted version of stop to check when we are beyond the valid range?? 338 for (N = Nlo; N < NimagesTgt; N++) { 339 if (TgtExtID[N] < extID) continue; 340 if (TgtExtID[N] > extID) return (-1); 341 return (TgtIndex[N]); 342 } 343 return (-1); 344 } 345 346 off_t getTgtIndexByTimeAndPhotcode (e_time start, e_time stop, short photcode, off_t *TgtIndex, e_time *TgtTimes, short *TgtCodes, off_t NimagesTgt) { 259 347 260 348 // use bisection to find the starting entry by time … … 302 390 } 303 391 392 // sort two times vectors and an index by first time vector 393 void SortTgtByExtID (unsigned int *S, off_t *I, off_t N) { 394 395 # define SWAPFUNC(A,B){ unsigned int tmp_s; off_t tmp_i; \ 396 tmp_s = S[A]; S[A] = S[B]; S[B] = tmp_s; \ 397 tmp_i = I[A]; I[A] = I[B]; I[B] = tmp_i; \ 398 } 399 # define COMPARE(A,B)(S[A] < S[B]) 400 401 OHANA_SORT (N, COMPARE, SWAPFUNC); 402 403 # undef SWAPFUNC 404 # undef COMPARE 405 } 406 304 407 // we need a lookup table of length (oldIDmax + 1) to record if a given oldIDmax has not been found in Tgt 305 408 int create_IDmap_lookup (IDmapType *IDmap) { -
trunk/Ohana/src/dvomerge/src/dvomergeImageIDs.c
r38553 r39299 62 62 // if so, then just match the image IDs 63 63 if (VERBOSE) fprintf (stderr, "already merged image table\n"); 64 dvo_image_match_dbs(IDmap, &outDB, &inDB); 64 if (MATCH_BY_EXTERN_ID) { 65 dvo_image_match_dbs_by_extern_id(IDmap, &outDB, &inDB); 66 } else { 67 dvo_image_match_dbs_by_time_and_photcode(IDmap, &outDB, &inDB); 68 } 65 69 dvo_image_unlock (&outDB); // unlock output 66 70 … … 145 149 146 150 // convert database table to internal structure & add to output image db 147 dvo_image_match_dbs(IDmap, &outDB, &inDB); 151 if (MATCH_BY_EXTERN_ID) { 152 dvo_image_match_dbs_by_extern_id(IDmap, &outDB, &inDB); 153 } else { 154 dvo_image_match_dbs_by_time_and_photcode(IDmap, &outDB, &inDB); 155 } 156 // dvo_image_match_dbs(IDmap, &outDB, &inDB); 148 157 149 158 gfits_db_free (&inDB); -
trunk/Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c
r38986 r39299 300 300 if (FORCE_MERGE) { strextend (&command, "-force-merge"); } 301 301 if (MATCHED_TABLES) { strextend (&command, "-matched-tables"); } 302 if (MATCH_BY_EXTERN_ID) { strextend (&command, "-match-by-extern-id"); } 302 303 if (UPDATE_CATFORMAT) { strextend (&command, "-update-catformat %s", UPDATE_CATFORMAT); } 303 304 if (UPDATE_CATCOMPRESS) { strextend (&command, "-update-catcompress %s", UPDATE_CATCOMPRESS); }
Note:
See TracChangeset
for help on using the changeset viewer.
