Changeset 33906
- Timestamp:
- May 23, 2012, 11:03:24 AM (14 years ago)
- Location:
- branches/eam_branches/ipp-20120405/Ohana/src/dvomerge
- Files:
-
- 1 added
- 7 edited
-
Makefile (modified) (2 diffs)
-
include/dvomerge.h (modified) (2 diffs)
-
src/IDmapIO.c (added)
-
src/dvo_image_merge_dbs.c (modified) (6 diffs)
-
src/dvomergeImageIDs.c (modified) (2 diffs)
-
src/dvomergeUpdate.c (modified) (1 diff)
-
src/dvomergeUpdate_catalogs.c (modified) (5 diffs)
-
src/dvomerge_client.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/Makefile
r33900 r33906 34 34 $(SRC)/dvomergeImageIDs.$(ARCH).o \ 35 35 $(SRC)/dvo_image_merge_dbs.$(ARCH).o \ 36 $(SRC)/IDmapIO.$(ARCH).o \ 36 37 $(SRC)/SetSignals.$(ARCH).o \ 37 38 $(SRC)/ConfigInit.$(ARCH).o \ … … 56 57 $(SRC)/dvomergeImageIDs.$(ARCH).o \ 57 58 $(SRC)/dvo_image_merge_dbs.$(ARCH).o \ 59 $(SRC)/IDmapIO.$(ARCH).o \ 58 60 $(SRC)/SetSignals.$(ARCH).o \ 59 61 $(SRC)/ConfigInit.$(ARCH).o \ -
branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/include/dvomerge.h
r33900 r33906 42 42 43 43 typedef struct { 44 off_t Nmap;45 off_t *old;46 off_t *new;44 unsigned int Nmap; 45 unsigned int *old; 46 unsigned int *new; 47 47 } IDmapType; 48 48 … … 125 125 int dvomergeFromList PROTO((int argc, char **argv)); 126 126 int dvomergeUpdate_threaded PROTO((int argc, char **argv)); 127 int dvomergeUpdate_catalogs PROTO((char *input, char *output, SkyTable *outsky, SkyList *inlist, int NsecfiltInput, int NsecfiltOutput, IDmapType IDmap, int *secfiltMap));127 int dvomergeUpdate_catalogs PROTO((char *input, char *output, SkyTable *outsky, SkyList *inlist, int NsecfiltInput, int NsecfiltOutput, IDmapType *IDmap, int *secfiltMap)); 128 128 129 129 int replace_match PROTO((Average *average_out, Measure *measure_out, Average *average_in, Measure *measure_in)); 130 131 int IDmapSave PROTO((char *filename, IDmapType *IDmap)); 132 IDmapType *IDmapLoad PROTO((char *filename)); -
branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c
r33738 r33906 1 1 # include "dvomerge.h" 2 2 3 // utility functions 3 4 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 } 5 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); 50 7 51 8 // we have two tables; 'tgt' contains some exposures from 'src' : find them and match a map … … 71 28 } 72 29 73 ALLOCATE (IDmap->old, off_t, NimagesSrc);74 ALLOCATE (IDmap->new, off_t, NimagesSrc);30 ALLOCATE (IDmap->old, unsigned int, NimagesSrc); 31 ALLOCATE (IDmap->new, unsigned int, NimagesSrc); 75 32 IDmap->Nmap = NimagesSrc; 76 33 … … 130 87 } 131 88 132 ALLOCATE (IDmap->old, off_t, Nimages);133 ALLOCATE (IDmap->new, off_t, Nimages);89 ALLOCATE (IDmap->old, unsigned int, Nimages); 90 ALLOCATE (IDmap->new, unsigned int, Nimages); 134 91 IDmap->Nmap = Nimages; 135 92 … … 165 122 } 166 123 167 // XXX isn't the map just ID_new = ID_old + offset ?? 124 // map this ID to the new table 125 // XXX isn't the map just ID_new = ID_old + offset ?? (probably not) 168 126 off_t dvo_map_image_ID (IDmapType *IDmap, off_t oldID) { 169 127 … … 199 157 } 200 158 159 // given a table of detections, update their image IDs based on the new map 201 160 int dvo_update_image_IDs (IDmapType *IDmap, Catalog *catalog) { 202 161 … … 237 196 } 238 197 198 off_t getTgtIndex (e_time start, e_time stop, short photcode, off_t *TgtIndex, e_time *TgtTimes, short *TgtCodes, off_t NimagesTgt) { 199 200 // use bisection to find the starting entry by time 201 202 off_t Nlo, Nhi, N; 203 204 // find the last TGT before start 205 Nlo = 0; Nhi = NimagesTgt; 206 while (Nhi - Nlo > 10) { 207 N = 0.5*(Nlo + Nhi); 208 if (TgtTimes[N] < start) { 209 Nlo = MAX(N, 0); 210 } else { 211 Nhi = MIN(N + 1, NimagesTgt); 212 } 213 } 214 215 // check for the matched mosaic starting from Nlo 216 // we may have to go much beyond Nlo since stop is not sorted 217 // can we use a sorted version of stop to check when we are beyond the valid range?? 218 for (N = Nlo; N < NimagesTgt; N++) { 219 if (TgtTimes[N] < start) continue; 220 if (TgtTimes[N] > stop) return (-1); 221 if (TgtCodes[N] != photcode) continue; 222 return (TgtIndex[N]); 223 } 224 return (-1); 225 } 226 227 // sort two times vectors and an index by first time vector 228 void SortTgtByTimes (e_time *S, off_t *I, short *C, off_t N) { 229 230 # define SWAPFUNC(A,B){ e_time tmp_t; off_t tmp_i; short tmp_c; \ 231 tmp_t = S[A]; S[A] = S[B]; S[B] = tmp_t; \ 232 tmp_i = I[A]; I[A] = I[B]; I[B] = tmp_i; \ 233 tmp_c = C[A]; C[A] = C[B]; C[B] = tmp_c; \ 234 } 235 # define COMPARE(A,B)(S[A] < S[B]) 236 237 OHANA_SORT (N, COMPARE, SWAPFUNC); 238 239 # undef SWAPFUNC 240 # undef COMPARE 241 242 } 243 -
branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/src/dvomergeImageIDs.c
r33905 r33906 1 1 # include "dvomerge.h" 2 2 3 /*** update theimage table ***/3 /*** generate the IDmap for the given databases, and update the output image table ***/ 4 4 int dvomergeImagesUpdate (IDmapType *IDmap, char *input, char *output) { 5 5 … … 53 53 } 54 54 55 /*** update the image table***/55 /*** generate the map for the given 2 databases ***/ 56 56 int dvomergeImagesGetMap (IDmapType *IDmap, char *input, char *output) { 57 57 -
branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/src/dvomergeUpdate.c
r33834 r33906 105 105 SetPhotcodeTable(NULL); 106 106 107 dvomergeUpdate_catalogs (input, output, outsky, inlist, NsecfiltInput, NsecfiltOutput, IDmap, secfiltMap);107 dvomergeUpdate_catalogs (input, output, outsky, inlist, NsecfiltInput, NsecfiltOutput, &IDmap, secfiltMap); 108 108 109 109 // save the output sky table copy -
branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c
r33904 r33906 8 8 // output tables 9 9 10 int dvomergeUpdate_parallel (char *input, char *output, SkyTable *outsky );11 12 int dvomergeUpdate_catalogs (char *input, char *output, SkyTable *outsky, SkyList *inlist, int NsecfiltInput, int NsecfiltOutput, IDmapType IDmap, int *secfiltMap) {10 int dvomergeUpdate_parallel (char *input, char *output, SkyTable *outsky, IDmapType *IDmap); 11 12 int dvomergeUpdate_catalogs (char *input, char *output, SkyTable *outsky, SkyList *inlist, int NsecfiltInput, int NsecfiltOutput, IDmapType *IDmap, int *secfiltMap) { 13 13 14 14 off_t i, j; … … 17 17 18 18 if (PARALLEL && !HOST_ID) { 19 int status = dvomergeUpdate_parallel (input, output, outsky );19 int status = dvomergeUpdate_parallel (input, output, outsky, IDmap); 20 20 return status; 21 21 } … … 145 145 LoadCatalog (&outcatalog, outlist[0].regions[j], outcatalog.filename, "w", NsecfiltOutput); 146 146 147 dvo_update_image_IDs ( &IDmap, &incatalog);147 dvo_update_image_IDs (IDmap, &incatalog); 148 148 merge_catalogs_old (outlist[0].regions[j], &outcatalog, &incatalog, RADIUS, secfiltMap); 149 149 … … 185 185 } 186 186 187 int dvomergeUpdate_parallel (char *input, char *output, SkyTable *outsky) { 188 189 // launch the dvomergeUpdate_client jobs to the parallel hosts 187 // launch the dvomergeUpdate_client jobs to the parallel hosts 188 int dvomergeUpdate_parallel (char *input, char *output, SkyTable *outsky, IDmapType *IDmap) { 189 190 // ensure that the paths are absolute path names 191 char *absinput = abspath (input, DVO_MAX_PATH); 192 char *absoutput = abspath (output, DVO_MAX_PATH); 193 194 // name of image subset file: 195 char IDmapFilename[DVO_MAX_PATH]; 196 snprintf (IDmapFilename, DVO_MAX_PATH, "%s/IDmap.fits", absoutput); 197 198 // save IDmap information 199 if (!IDmapSave (IDmapFilename, IDmap)) { 200 fprintf (stderr, "ERROR: failure to save the image ID map\n"); 201 exit (1); 202 } 190 203 191 204 // load the list of hosts … … 203 216 free (table->hosts[i].pathname); 204 217 table->hosts[i].pathname = tmppath; 205 206 // ensure that the paths are absolute path names207 char *absinput = abspath (input, DVO_MAX_PATH);208 char *absoutput = abspath (output, DVO_MAX_PATH);209 218 210 219 // options / arguments that can affect relastro_client -update-objects: -
branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/src/dvomerge_client.c
r33834 r33906 10 10 SkyList *inlist; 11 11 char filename[256], *input, *output; 12 IDmapType IDmap;12 IDmapType *IDmap; 13 13 PhotCodeData *inputPhotcodes; 14 14 PhotCodeData *outputPhotcodes; … … 51 51 } 52 52 53 dvomergeImagesGetMap (&IDmap, input, output); 53 char *absoutput = abspath (output, DVO_MAX_PATH); 54 char IDmapFilename[DVO_MAX_PATH]; 55 snprintf (IDmapFilename, DVO_MAX_PATH, "%s/IDmap.fits", absoutput); 56 57 // save IDmap information 58 IDmap = IDmapLoad (IDmapFilename); 59 if (!IDmap) { 60 fprintf (stderr, "ERROR: failure to save the image ID map\n"); 61 exit (1); 62 } 54 63 55 64 // load the sky table for the existing database … … 74 83 SetPhotcodeTable(NULL); 75 84 76 dvomergeUpdate_catalogs (input, output, outsky, inlist, NsecfiltInput, NsecfiltOutput, IDmap, secfiltMap);85 dvomergeUpdate_catalogs (input, output, outsky, inlist, NsecfiltInput, NsecfiltOutput, IDmap, secfiltMap); 77 86 78 87 exit (0);
Note:
See TracChangeset
for help on using the changeset viewer.
