Changeset 29788
- Timestamp:
- Nov 16, 2010, 6:40:37 PM (15 years ago)
- Location:
- branches/eam_branches/ipp-20101103/Ohana/src/dvomerge
- Files:
-
- 1 added
- 6 edited
-
Makefile (modified) (1 diff)
-
include/dvomerge.h (modified) (1 diff)
-
src/args.c (modified) (1 diff)
-
src/dvo_image_merge_dbs.c (modified) (1 diff)
-
src/dvomerge.c (modified) (2 diffs)
-
src/dvomergeContinue.c (added)
-
src/help.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/Makefile
r29785 r29788 26 26 $(SRC)/dvomergeUpdate.$(ARCH).o \ 27 27 $(SRC)/dvomergeCreate.$(ARCH).o \ 28 $(SRC)/dvomergeContinue.$(ARCH).o \ 28 29 $(SRC)/dvo_image_merge_dbs.$(ARCH).o \ 29 30 $(SRC)/SetSignals.$(ARCH).o \ -
branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/include/dvomerge.h
r29779 r29788 105 105 int RepairTableCPT PROTO((char *cptFilenameSrc, char *cptFilenameTgt, char *cpsFilenameSrc, char *cpsFilenameTgt, Measure *measure, off_t Nmeasure, Image *image, off_t Nimage, char catformat)); 106 106 void dvorepair_help PROTO((int argc, char **argv)); 107 108 off_t getTgtIndex PROTO((e_time start, e_time stop, short photcode, off_t *TgtIndex, e_time *TgtTimes, short *TgtCodes, off_t NimagesTgt)); 109 void SortTgtByTimes PROTO((e_time *S, off_t *I, short *C, off_t N)); 110 int dvo_image_match_dbs PROTO((IDmapType *IDmap, FITS_DB *tgt, FITS_DB *src)); 111 int dvomergeImagesGetMap PROTO((IDmapType *IDmap, char *input, char *output)); 112 int dvomergeContinue PROTO((int argc, char **argv)); -
branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/src/args.c
r29001 r29788 36 36 } 37 37 38 if ((*argc != 6) && (*argc != 4)) dvomerge_usage();38 if ((*argc < 4) || (*argc > 6)) dvomerge_usage(); 39 39 return TRUE; 40 40 } -
branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c
r29001 r29788 2 2 3 3 void sort_IDmap (IDmapType *IDmap); 4 5 off_t getTgtIndex (e_time start, e_time stop, short photcode, off_t *TgtIndex, e_time *TgtTimes, short *TgtCodes, off_t NimagesTgt) { 6 7 // use bisection to find the starting entry by time 8 9 off_t Nlo, Nhi, N; 10 11 // find the last TGT before start 12 Nlo = 0; Nhi = NimagesTgt; 13 while (Nhi - Nlo > 10) { 14 N = 0.5*(Nlo + Nhi); 15 if (TgtTimes[N] < start) { 16 Nlo = MAX(N, 0); 17 } else { 18 Nhi = MIN(N + 1, NimagesTgt); 19 } 20 } 21 22 // check for the matched mosaic starting from Nlo 23 // we may have to go much beyond Nlo since stop is not sorted 24 // can we use a sorted version of stop to check when we are beyond the valid range?? 25 for (N = Nlo; N < NimagesTgt; N++) { 26 if (TgtTimes[N] < start) continue; 27 if (TgtTimes[N] > stop) return (-1); 28 if (TgtCodes[N] != photcode) continue; 29 return (TgtIndex[N]); 30 } 31 return (-1); 32 } 33 34 // sort two times vectors and an index by first time vector 35 void SortTgtByTimes (e_time *S, off_t *I, short *C, off_t N) { 36 37 # define SWAPFUNC(A,B){ e_time tmp_t; off_t tmp_i; short tmp_c; \ 38 tmp_t = S[A]; S[A] = S[B]; S[B] = tmp_t; \ 39 tmp_i = I[A]; I[A] = I[B]; I[B] = tmp_i; \ 40 tmp_c = C[A]; C[A] = C[B]; C[B] = tmp_c; \ 41 } 42 # define COMPARE(A,B)(S[A] < S[B]) 43 44 OHANA_SORT (N, COMPARE, SWAPFUNC); 45 46 # undef SWAPFUNC 47 # undef COMPARE 48 49 } 50 51 // we have two tables; 'tgt' contains some exposures from 'src' : find them and match a map 52 int dvo_image_match_dbs (IDmapType *IDmap, FITS_DB *tgt, FITS_DB *src) { 53 54 Image *imagesSrc, *imagesTgt; 55 off_t NimagesSrc, NimagesTgt; 56 off_t iSrc, iTgt; 57 off_t *TgtIndex; 58 e_time *TgtTimes; 59 short *TgtCodes; 60 61 imagesSrc = gfits_table_get_Image (&src[0].ftable, &NimagesSrc, &src[0].swapped); 62 if (!imagesSrc) { 63 fprintf (stderr, "ERROR: failed to read images from src\n"); 64 exit (2); 65 } 66 67 imagesTgt = gfits_table_get_Image (&tgt[0].ftable, &NimagesTgt, &tgt[0].swapped); 68 if (!imagesTgt) { 69 fprintf (stderr, "ERROR: failed to read images from tgt\n"); 70 exit (2); 71 } 72 73 ALLOCATE (IDmap->old, off_t, NimagesSrc); 74 ALLOCATE (IDmap->new, off_t, NimagesSrc); 75 IDmap->Nmap = NimagesSrc; 76 77 // match by time and photcode 78 ALLOCATE (TgtIndex, off_t, NimagesTgt); 79 ALLOCATE (TgtTimes, e_time, NimagesTgt); 80 ALLOCATE (TgtCodes, short, NimagesTgt); 81 82 // save the Index, Times, Codes for all TGT images 83 for (iTgt = 0; iTgt < NimagesTgt; iTgt++) { 84 TgtIndex[iTgt] = iTgt; 85 TgtTimes[iTgt] = imagesTgt[iTgt].tzero; 86 TgtCodes[iTgt] = imagesTgt[iTgt].photcode; 87 } 88 89 // sort the index, start, and stop by the start times: 90 SortTgtByTimes (TgtTimes, TgtIndex, TgtCodes, NimagesTgt); 91 92 for (iSrc = 0; iSrc < NimagesSrc; iSrc++) { 93 iTgt = getTgtIndex (imagesSrc[iSrc].tzero, imagesSrc[iSrc].tzero + (int) imagesSrc[iSrc].exptime, imagesSrc[iSrc].photcode, TgtIndex, TgtTimes, TgtCodes, NimagesTgt); 94 if (iTgt < 0) Shutdown ("failure to match images: %s\n", imagesSrc[iSrc].name); 95 IDmap[0].old[iSrc] = imagesSrc[iSrc].imageID; 96 IDmap[0].new[iSrc] = imagesTgt[iTgt].imageID; 97 } 98 99 FREE(TgtIndex); 100 FREE(TgtTimes); 101 FREE(TgtCodes); 102 103 // sort IDmap->old,new on the basis of IDmap->old: 104 sort_IDmap (IDmap); 105 106 return TRUE; 107 } 4 108 5 109 // merge db2 into db1 -
branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/src/dvomerge.c
r28327 r29788 12 12 if (argc == 6) dvomergeCreate (argc, argv); 13 13 if (argc == 4) dvomergeUpdate (argc, argv); 14 if (argc == 5) dvomergeContinue (argc, argv); 14 15 dvomerge_usage(); 15 16 exit (2); // cannot reach here. … … 18 19 /* we have two possible modes of operation: 19 20 20 Create : dvomerge (in1) and (in2) to (out) -- create a new db from two input dbs 21 Update : dvomerge (in) into (out) -- merge a new db into an existing db 21 Create : dvomerge (in1) and (in2) to (out) -- create a new db from two input dbs 22 Update : dvomerge (in) into (out) -- merge a new db into an existing db 23 Continue : dvomerge (in) into (out) continue -- merge a new db into an existing db 22 24 23 25 */ -
branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/src/help.c
r29787 r29788 4 4 fprintf (stderr, "USAGE: dvomerge (input1) and (input2) to (output)\n"); 5 5 fprintf (stderr, " OR: dvomerge (input) into (output)\n"); 6 fprintf (stderr, " OR: dvomerge (input) into (output) continue\n"); 6 7 fprintf (stderr, " [-region Rmin Rmax Dmin Dmax]\n"); 7 8 exit (2); … … 33 34 fprintf (stderr, "USAGE\n"); 34 35 fprintf (stderr, " dvomerge (input1) and (input2) to (output)\n"); 35 fprintf (stderr, " dvomerge (input) into (output)\n\n"); 36 fprintf (stderr, " dvomerge (input) into (output)\n"); 37 fprintf (stderr, " dvomerge (input) into (output) continue\n\n"); 36 38 fprintf (stderr, " merge DVO databases\n"); 37 39 fprintf (stderr, " optional flags:\n"); … … 39 41 fprintf (stderr, " -help : this list\n"); 40 42 fprintf (stderr, " -h : this list\n\n"); 43 fprintf (stderr, " -region Rmin Rmax Dmin Dmax : region to merge\n\n"); 41 44 exit (2); 42 45 }
Note:
See TracChangeset
for help on using the changeset viewer.
