Changeset 33963 for trunk/Ohana/src/dvomerge
- Timestamp:
- May 30, 2012, 1:46:12 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
- 9 copied
-
. (modified) (1 prop)
-
Ohana/src/dvomerge/Makefile (modified) (6 diffs)
-
Ohana/src/dvomerge/doc/failsafe.txt (copied) (copied from branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/doc/failsafe.txt )
-
Ohana/src/dvomerge/doc/parallel.txt (copied) (copied from branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/doc/parallel.txt )
-
Ohana/src/dvomerge/include/dvomerge.h (modified) (4 diffs)
-
Ohana/src/dvomerge/src/IDmapIO.c (copied) (copied from branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/src/IDmapIO.c )
-
Ohana/src/dvomerge/src/args.c (modified) (2 diffs)
-
Ohana/src/dvomerge/src/dvo_image_merge_dbs.c (modified) (8 diffs)
-
Ohana/src/dvomerge/src/dvomergeCreate.c (modified) (6 diffs)
-
Ohana/src/dvomerge/src/dvomergeImageIDs.c (modified) (6 diffs)
-
Ohana/src/dvomerge/src/dvomergeUpdate.c (modified) (2 diffs)
-
Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c (copied) (copied from branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c )
-
Ohana/src/dvomerge/src/dvomerge_client.c (copied) (copied from branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/src/dvomerge_client.c )
-
Ohana/src/dvomerge/src/dvoverify.c (modified) (1 diff)
-
Ohana/src/dvomerge/src/help.c (modified) (2 diffs)
-
Ohana/src/dvomerge/src/merge_catalogs_old.c (modified) (2 diffs)
-
Ohana/src/dvomerge/src/replace_match.c (copied) (copied from branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/src/replace_match.c )
-
Ohana/src/dvomerge/test (modified) (1 prop)
-
Ohana/src/dvomerge/test/HostTable.dat (copied) (copied from branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/test/HostTable.dat )
-
Ohana/src/dvomerge/test/catdir.2mass (modified) (1 prop)
-
Ohana/src/dvomerge/test/dvomerge.parallel.sh (copied) (copied from branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/test/dvomerge.parallel.sh )
-
Ohana/src/dvomerge/test/dvomerge.replace.sh (copied) (copied from branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/test/dvomerge.replace.sh )
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
trunk/Ohana/src/dvomerge/Makefile
r31496 r33963 1 1 default: all 2 2 help: 3 @echo "make options: dvomerge (default)"3 @echo "make options: dvomerge dvomerge_client dvoconvert (default)" 4 4 5 5 include ../../Makefile.System … … 17 17 FULL_LDFLAGS = -lkapa -ldvo -lFITS -lohana $(BASE_LDFLAGS) 18 18 19 dvomerge : $(BIN)/dvomerge.$(ARCH) 20 dvomerge : $(BIN)/dvoconvert.$(ARCH) 19 dvomerge : $(BIN)/dvomerge.$(ARCH) 20 dvomerge_client : $(BIN)/dvomerge_client.$(ARCH) 21 dvoconvert : $(BIN)/dvoconvert.$(ARCH) 21 22 22 all: dvomerge dvo convert dvosecfilt23 all: dvomerge dvomerge_client dvoconvert dvosecfilt 23 24 24 25 # $(SRC)/dvomergeContinue.$(ARCH).o … … 28 29 $(SRC)/dvomergeUpdate.$(ARCH).o \ 29 30 $(SRC)/dvomergeCreate.$(ARCH).o \ 31 $(SRC)/dvomergeUpdate_catalogs.$(ARCH).o \ 30 32 $(SRC)/dvomergeUpdate_threaded.$(ARCH).o \ 31 33 $(SRC)/dvomergeFromList.$(ARCH).o \ 32 34 $(SRC)/dvomergeImageIDs.$(ARCH).o \ 33 35 $(SRC)/dvo_image_merge_dbs.$(ARCH).o \ 36 $(SRC)/IDmapIO.$(ARCH).o \ 34 37 $(SRC)/SetSignals.$(ARCH).o \ 35 38 $(SRC)/ConfigInit.$(ARCH).o \ … … 41 44 $(SRC)/LoadCatalog.$(ARCH).o \ 42 45 $(SRC)/build_links.$(ARCH).o \ 46 $(SRC)/replace_match.$(ARCH).o \ 43 47 $(SRC)/merge_catalogs_new.$(ARCH).o \ 44 48 $(SRC)/merge_catalogs_old.$(ARCH).o … … 47 51 48 52 $(BIN)/dvomerge.$(ARCH) : $(DVOMERGE) 53 54 DVOMERGE_CLIENT = \ 55 $(SRC)/dvomerge_client.$(ARCH).o \ 56 $(SRC)/dvomergeUpdate_catalogs.$(ARCH).o \ 57 $(SRC)/dvomergeImageIDs.$(ARCH).o \ 58 $(SRC)/dvo_image_merge_dbs.$(ARCH).o \ 59 $(SRC)/IDmapIO.$(ARCH).o \ 60 $(SRC)/SetSignals.$(ARCH).o \ 61 $(SRC)/ConfigInit.$(ARCH).o \ 62 $(SRC)/Shutdown.$(ARCH).o \ 63 $(SRC)/help.$(ARCH).o \ 64 $(SRC)/args.$(ARCH).o \ 65 $(SRC)/psps_ids.$(ARCH).o \ 66 $(SRC)/SkyTablePopulatedRange.$(ARCH).o \ 67 $(SRC)/LoadCatalog.$(ARCH).o \ 68 $(SRC)/build_links.$(ARCH).o \ 69 $(SRC)/replace_match.$(ARCH).o \ 70 $(SRC)/merge_catalogs_new.$(ARCH).o \ 71 $(SRC)/merge_catalogs_old.$(ARCH).o 72 73 $(DVOMERGE_CLIENT) : $(INC)/dvomerge.h 74 75 $(BIN)/dvomerge_client.$(ARCH) : $(DVOMERGE_CLIENT) 49 76 50 77 DVOCONVERT = \ … … 99 126 $(BIN)/dvoverify.$(ARCH) : $(DVOVERIFY) 100 127 101 INSTALL = dvomerge dvo convert dvosecfilt dvorepair dvoverify128 INSTALL = dvomerge dvomerge_client dvoconvert dvosecfilt dvorepair dvoverify 102 129 103 130 # dependancy rules for binary code ######################### -
trunk/Ohana/src/dvomerge/include/dvomerge.h
r33657 r33963 17 17 # include <glob.h> 18 18 19 # define DVO_MAX_PATH 1024 20 21 int PARALLEL; 22 int PARALLEL_MANUAL; 23 int PARALLEL_SERIAL; 24 25 int HOST_ID; 26 char *HOSTDIR; 27 28 19 29 int VERBOSE; 20 30 char CATDIR[256]; … … 26 36 int SKY_DEPTH; 27 37 int NTHREADS; 28 char *ALTERNATE_PHOTCODE_FILE; 38 char *ALTERNATE_PHOTCODE_FILE; 39 int REPLACE_BY_PHOTCODE; 29 40 30 41 SkyRegion UserPatch; // used by MODE CAT 31 42 32 43 typedef struct { 33 off_t Nmap;34 off_t *old;35 off_t *new;44 unsigned int Nmap; 45 unsigned int *old; 46 unsigned int *new; 36 47 } IDmapType; 37 48 … … 51 62 void dvomerge_help PROTO((int argc, char **argv)); 52 63 int dvomerge_args PROTO((int *argc, char **argv)); 64 65 void dvomerge_client_usage PROTO((void)); 66 void dvomerge_client_help PROTO((int argc, char **argv)); 67 int dvomerge_client_args PROTO((int *argc, char **argv)); 53 68 54 69 void dvoconvert_usage PROTO((void)); … … 110 125 int dvomergeFromList PROTO((int argc, char **argv)); 111 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)); 128 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)); -
trunk/Ohana/src/dvomerge/src/args.c
r33657 r33963 15 15 remove_argument (N, argc, argv); 16 16 ALTERNATE_PHOTCODE_FILE = strcreate(argv[N]); 17 remove_argument (N, argc, argv); 18 } 19 20 /* replace measurement, don't duplicate */ 21 REPLACE_BY_PHOTCODE = FALSE; 22 if ((N = get_argument (*argc, argv, "-replace"))) { 23 REPLACE_BY_PHOTCODE = TRUE; 17 24 remove_argument (N, argc, argv); 18 25 } … … 43 50 } 44 51 52 // XXX for the moment, make this selection manual. it needs to be automatic 53 // based on the state of the SkyTable 54 PARALLEL = FALSE; 55 if ((N = get_argument (*argc, argv, "-parallel"))) { 56 PARALLEL = TRUE; 57 remove_argument (N, argc, argv); 58 } 59 // this is a test mode : rather than launching the remote jobs and waiting for completion, 60 // relphot will simply list the remote command and wait for the user to signal completion 61 PARALLEL_MANUAL = FALSE; 62 if ((N = get_argument (*argc, argv, "-parallel-manual"))) { 63 PARALLEL = TRUE; // -parallel-manual implies -parallel 64 PARALLEL_MANUAL = TRUE; 65 remove_argument (N, argc, argv); 66 } 67 // this is a test mode : rather than launching the relphot_client jobs remotely, they are 68 // run in serial via 'system' 69 PARALLEL_SERIAL = FALSE; 70 if ((N = get_argument (*argc, argv, "-parallel-serial"))) { 71 if (PARALLEL_MANUAL) { 72 fprintf (stderr, "ERROR: cannot mix -parallel-manual and -parallel-serial\n"); 73 exit (1); 74 } 75 PARALLEL = TRUE; // -parallel-serial implies -parallel 76 PARALLEL_SERIAL = TRUE; 77 remove_argument (N, argc, argv); 78 } 79 45 80 if ((*argc < 4) || (*argc > 6)) dvomerge_usage(); 81 return TRUE; 82 } 83 84 /*** check for command line options ***/ 85 int dvomerge_client_args (int *argc, char **argv) { 86 87 int N; 88 89 // by definition, the client is not parallel 90 PARALLEL = FALSE; 91 PARALLEL_MANUAL = FALSE; 92 PARALLEL_SERIAL = FALSE; 93 94 HOST_ID = 0; 95 if ((N = get_argument (*argc, argv, "-hostID"))) { 96 remove_argument (N, argc, argv); 97 HOST_ID = atoi (argv[N]); 98 remove_argument (N, argc, argv); 99 } 100 if (!HOST_ID) dvomerge_client_usage(); 101 102 HOSTDIR = NULL; 103 if ((N = get_argument (*argc, argv, "-hostdir"))) { 104 remove_argument (N, argc, argv); 105 HOSTDIR = strcreate (argv[N]); 106 remove_argument (N, argc, argv); 107 } 108 if (!HOSTDIR) dvomerge_client_usage(); 109 110 /* extra error messages */ 111 VERBOSE = FALSE; 112 if ((N = get_argument (*argc, argv, "-v"))) { 113 VERBOSE = TRUE; 114 remove_argument (N, argc, argv); 115 } 116 117 /* replace measurement, don't duplicate */ 118 REPLACE_BY_PHOTCODE = FALSE; 119 if ((N = get_argument (*argc, argv, "-replace"))) { 120 REPLACE_BY_PHOTCODE = TRUE; 121 remove_argument (N, argc, argv); 122 } 123 124 NTHREADS = 0; 125 if ((N = get_argument (*argc, argv, "-threads"))) { 126 remove_argument (N, argc, argv); 127 NTHREADS = MAX(0, atoi(argv[N])); 128 remove_argument (N, argc, argv); 129 } 130 131 /*** provide additional data ***/ 132 /* restrict to a portion of the sky? */ 133 UserPatch.Rmin = 0; 134 UserPatch.Rmax= 360; 135 UserPatch.Dmin = -90; 136 UserPatch.Dmax = +90; 137 if ((N = get_argument (*argc, argv, "-region"))) { 138 remove_argument (N, argc, argv); 139 UserPatch.Rmin = atof (argv[N]); 140 remove_argument (N, argc, argv); 141 UserPatch.Rmax = atof (argv[N]); 142 remove_argument (N, argc, argv); 143 UserPatch.Dmin = atof (argv[N]); 144 remove_argument (N, argc, argv); 145 UserPatch.Dmax = atof (argv[N]); 146 remove_argument (N, argc, argv); 147 } 148 149 if ((*argc < 4) || (*argc > 6)) dvomerge_client_usage(); 46 150 return TRUE; 47 151 } -
trunk/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c
r31450 r33963 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 … … 116 73 int status; 117 74 75 IDmap->old = NULL; 76 IDmap->new = NULL; 77 78 // it is OK if there are no images in the database, but there should be no imageIDs to map... 79 if (in->dbstate == LCK_EMPTY) { 80 return TRUE; 81 } 82 118 83 images = gfits_table_get_Image (&in[0].ftable, &Nimages, &in[0].swapped); 119 84 if (!images) { … … 122 87 } 123 88 124 ALLOCATE (IDmap->old, off_t, Nimages);125 ALLOCATE (IDmap->new, off_t, Nimages);89 ALLOCATE (IDmap->old, unsigned int, Nimages); 90 ALLOCATE (IDmap->new, unsigned int, Nimages); 126 91 IDmap->Nmap = Nimages; 127 92 … … 157 122 } 158 123 159 // 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) 160 126 off_t dvo_map_image_ID (IDmapType *IDmap, off_t oldID) { 161 127 … … 191 157 } 192 158 159 // given a table of detections, update their image IDs based on the new map 193 160 int dvo_update_image_IDs (IDmapType *IDmap, Catalog *catalog) { 194 161 … … 198 165 oldID = catalog[0].measure[i].imageID; 199 166 if (oldID == 0) continue; 167 168 if (!IDmap->old) { 169 fprintf (stderr, "input database has image IDs, but no Image table\n"); 170 } 200 171 201 172 newID = dvo_map_image_ID (IDmap, oldID); … … 225 196 } 226 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 -
trunk/Ohana/src/dvomerge/src/dvomergeCreate.c
r33657 r33963 124 124 depth2 = insky2[0].regions[Ns].depth; 125 125 126 SkyList *outlist = SkyListByPatch (outsky, -1, &UserPatch); 127 126 128 // loop over the populatable output regions 127 for (i = 0; i < out sky[0].Nregions; i++) {128 if (!out sky[0].regions[i].table) continue;129 if (VERBOSE) fprintf (stderr, "output: %s\n", out sky[0].regions[i].name);129 for (i = 0; i < outlist[0].Nregions; i++) { 130 if (!outlist[0].regions[i][0].table) continue; 131 if (VERBOSE) fprintf (stderr, "output: %s\n", outlist[0].regions[i][0].name); 130 132 131 133 // load / create output catalog 132 LoadCatalog (&outcatalog, &outsky[0].regions[i], outsky[0].filename[i], "w", NsecfiltOutput);134 LoadCatalog (&outcatalog, outlist[0].regions[i], outlist[0].filename[i], "w", NsecfiltOutput); 133 135 134 136 // combine only tables at equal or larger depth 135 137 136 138 // load in all of the tables from input1 for this region 137 inlist = SkyListByBounds (insky1, depth1, out sky[0].regions[i].Rmin, outsky[0].regions[i].Rmax, outsky[0].regions[i].Dmin, outsky[0].regions[i].Dmax);139 inlist = SkyListByBounds (insky1, depth1, outlist[0].regions[i][0].Rmin + 0.01, outlist[0].regions[i][0].Rmax - 0.01, outlist[0].regions[i][0].Dmin + 0.01, outlist[0].regions[i][0].Dmax - 0.01); 138 140 for (j = 0; j < inlist[0].Nregions; j++) { 139 141 if (VERBOSE) fprintf (stderr, "input 1: %s\n", inlist[0].regions[j][0].name); … … 149 151 } 150 152 dvo_update_image_IDs (&IDmap1, &incatalog); 151 merge_catalogs_new ( &outsky[0].regions[i], &outcatalog, &incatalog, secfiltMap1);153 merge_catalogs_new (outlist[0].regions[i], &outcatalog, &incatalog, secfiltMap1); 152 154 dvo_catalog_unlock (&incatalog); 153 155 dvo_catalog_free (&incatalog); … … 156 158 157 159 // load in all of the tables from input2 for this region 158 inlist = SkyListByBounds (insky2, depth2, out sky[0].regions[i].Rmin, outsky[0].regions[i].Rmax, outsky[0].regions[i].Dmin, outsky[0].regions[i].Dmax);160 inlist = SkyListByBounds (insky2, depth2, outlist[0].regions[i][0].Rmin + 0.01, outlist[0].regions[i][0].Rmax - 0.01, outlist[0].regions[i][0].Dmin + 0.01, outlist[0].regions[i][0].Dmax - 0.01); 159 161 for (j = 0; j < inlist[0].Nregions; j++) { 160 162 if (VERBOSE) fprintf (stderr, "input 2: %s\n", inlist[0].regions[j][0].name); … … 170 172 } 171 173 dvo_update_image_IDs (&IDmap2, &incatalog); 172 merge_catalogs_old ( &outsky[0].regions[i], &outcatalog, &incatalog, RADIUS, secfiltMap2);174 merge_catalogs_old (outlist[0].regions[i], &outcatalog, &incatalog, RADIUS, secfiltMap2); 173 175 dvo_catalog_unlock (&incatalog); 174 176 dvo_catalog_free (&incatalog); … … 219 221 in1DB.mode = dvo_catalog_catmode (CATMODE); 220 222 in1DB.format = dvo_catalog_catformat (CATFORMAT); 221 status = dvo_image_lock (&in1DB, ImageCat, 3600.0, LCK_ XCLD); // shorter timeout?223 status = dvo_image_lock (&in1DB, ImageCat, 3600.0, LCK_SOFT); // shorter timeout? 222 224 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", in1DB.filename); 223 225 224 226 // load the image table 225 if (in1DB.dbstate == LCK_EMPTY) { 226 Shutdown ("can't find input (1) image catalog %s", in1DB.filename); 227 } 228 if (!dvo_image_load (&in1DB, VERBOSE, TRUE)) { 229 Shutdown ("can't read input (1) image catalog %s", in1DB.filename); 230 } 231 227 if (in1DB.dbstate != LCK_EMPTY) { 228 if (!dvo_image_load (&in1DB, VERBOSE, TRUE)) { 229 Shutdown ("can't read input (1) image catalog %s", in1DB.filename); 230 } 231 } 232 232 233 // convert database table to internal structure & add to output image db 234 // if in1DB has no images, we will (later) insist that there are no image IDs to map 233 235 dvo_image_merge_dbs(IDmap1, &outDB, &in1DB); 234 236 dvo_image_unlock (&in1DB); // unlock input1 235 236 237 237 238 /*** load input2/Images.dat ***/ … … 239 240 in2DB.mode = dvo_catalog_catmode (CATMODE); 240 241 in2DB.format = dvo_catalog_catformat (CATFORMAT); 241 status = dvo_image_lock (&in2DB, ImageCat, 3600.0, LCK_ XCLD); // shorter timeout?242 status = dvo_image_lock (&in2DB, ImageCat, 3600.0, LCK_SOFT); // shorter timeout? 242 243 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", in2DB.filename); 243 244 244 245 /* load the image table */ 245 if (in2DB.dbstate == LCK_EMPTY) { 246 Shutdown ("can't find input (2) image catalog %s", in2DB.filename); 247 } 248 if (!dvo_image_load (&in2DB, VERBOSE, TRUE)) { 249 Shutdown ("can't read input (2) image catalog %s", in2DB.filename); 246 if (in2DB.dbstate != LCK_EMPTY) { 247 if (!dvo_image_load (&in2DB, VERBOSE, TRUE)) { 248 Shutdown ("can't read input (2) image catalog %s", in2DB.filename); 249 } 250 250 } 251 251 252 252 // convert database table to internal structure & add to output image db 253 // if in1DB has no images, we will (later) insist that there are no image IDs to map 253 254 dvo_image_merge_dbs(IDmap2, &outDB, &in2DB); 254 255 dvo_image_unlock (&in2DB); // unlock input2 -
trunk/Ohana/src/dvomerge/src/dvomergeImageIDs.c
r29938 r33963 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 … … 12 12 inDB.mode = dvo_catalog_catmode (CATMODE); 13 13 inDB.format = dvo_catalog_catformat (CATFORMAT); 14 status = dvo_image_lock (&inDB, ImageCat, 3600.0, LCK_ XCLD); // shorter timeout?14 status = dvo_image_lock (&inDB, ImageCat, 3600.0, LCK_SOFT); // shorter timeout? 15 15 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", inDB.filename); 16 16 17 17 // load the image table 18 18 if (inDB.dbstate == LCK_EMPTY) { 19 dvo_image_unlock (&inDB); // unlock input 19 20 IDmap->Nmap = 0; 20 21 return TRUE; … … 52 53 } 53 54 54 /*** update the image table***/55 /*** generate the map for the given 2 databases ***/ 55 56 int dvomergeImagesGetMap (IDmapType *IDmap, char *input, char *output) { 56 57 … … 63 64 inDB.mode = dvo_catalog_catmode (CATMODE); 64 65 inDB.format = dvo_catalog_catformat (CATFORMAT); 65 status = dvo_image_lock (&inDB, ImageCat, 3600.0, LCK_XCLD); // shorter timeout?66 status = dvo_image_lock (&inDB, ImageCat, 5400.0, LCK_XCLD); // shorter timeout? 66 67 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", inDB.filename); 67 68 68 69 // load the image table 69 70 if (inDB.dbstate == LCK_EMPTY) { 71 dvo_image_unlock (&inDB); // unlock input 70 72 IDmap->Nmap = 0; 71 73 return TRUE; … … 76 78 Shutdown ("can't read input image catalog %s", inDB.filename); 77 79 } 80 dvo_image_unlock (&inDB); // unlock input 78 81 79 82 /*** load output/Images.dat ***/ … … 81 84 outDB.mode = dvo_catalog_catmode (CATMODE); 82 85 outDB.format = dvo_catalog_catformat (CATFORMAT); 83 status = dvo_image_lock (&outDB, ImageCat, 3600.0, LCK_XCLD); // shorter timeout?86 status = dvo_image_lock (&outDB, ImageCat, 5400.0, LCK_XCLD); // shorter timeout? 84 87 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", outDB.filename); 85 88 86 89 /* load the image table */ 87 90 if (outDB.dbstate == LCK_EMPTY) { 88 Shutdown (" only use -continue for an existing, partially merged database");91 Shutdown ("for dvomerge -continue or dvomerge_client, the output database must exist"); 89 92 } 90 93 if (!dvo_image_load (&outDB, VERBOSE, TRUE)) { 91 94 Shutdown ("can't read output image catalog %s", outDB.filename); 92 95 } 96 dvo_image_unlock (&outDB); // unlock output 93 97 94 98 // convert database table to internal structure & add to output image db 95 99 dvo_image_match_dbs(IDmap, &outDB, &inDB); 96 dvo_image_unlock (&inDB); // unlock input97 dvo_image_unlock (&outDB); // unlock output98 100 99 101 return TRUE; -
trunk/Ohana/src/dvomerge/src/dvomergeUpdate.c
r33657 r33963 4 4 5 5 int CONTINUE; 6 off_t i, j;7 6 SkyTable *outsky, *insky; 8 SkyList *outlist, *inlist; 9 Catalog incatalog, outcatalog; 7 SkyList *inlist; 10 8 char filename[256], *input, *output; 11 9 IDmapType IDmap; … … 107 105 SetPhotcodeTable(NULL); 108 106 109 // loop over the populated input regions 110 for (i = 0; i < inlist[0].Nregions; i++) { 111 if (!inlist[0].regions[i][0].table) continue; 112 if (VERBOSE) fprintf (stderr, "input: %s\n", inlist[0].regions[i][0].name); 113 114 // load / create output catalog (if catalog does not exist, it will be created) 115 LoadCatalog (&incatalog, &inlist[0].regions[i][0], inlist[0].filename[i], "r", NsecfiltInput); 116 // skip empty input catalogs 117 if (!incatalog.Naves_disk) { 118 dvo_catalog_unlock (&incatalog); 119 dvo_catalog_free (&incatalog); 120 continue; 121 } 122 123 // combine only tables at equal or larger depth 124 125 // load in all of the tables from input for this region 126 // SkyListByBounds will return neighbor catalogs if the boundaries exactly match (due to rounding). Since the regions are not infinitely small, 127 // compare to a slightly reduced footprint 128 float dPos = 2.0/3600.0; 129 outlist = SkyListByBounds (outsky, inlist[0].regions[i][0].depth, inlist[0].regions[i][0].Rmin + dPos, inlist[0].regions[i][0].Rmax - dPos, inlist[0].regions[i][0].Dmin + dPos, inlist[0].regions[i][0].Dmax - dPos); 130 for (j = 0; j < outlist[0].Nregions; j++) { 131 if (VERBOSE) fprintf (stderr, "output : %s\n", outlist[0].regions[j][0].name); 132 133 // load input catalog 134 LoadCatalog (&outcatalog, outlist[0].regions[j], outlist[0].filename[j], "w", NsecfiltOutput); 135 136 dvo_update_image_IDs (&IDmap, &incatalog); 137 merge_catalogs_old (&outsky[0].regions[j], &outcatalog, &incatalog, RADIUS, secfiltMap); 138 139 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF; 140 141 // if we receive a signal which would cause us to exit, wait until the full catalog is written 142 SetProtect (TRUE); 143 if (!dvo_catalog_save (&outcatalog, VERBOSE)) { 144 fprintf (stderr, "ERROR: failed to save catalog %s\n", outlist[0].filename[j]); 145 exit (1); 146 } 147 SetProtect (FALSE); 148 149 dvo_catalog_unlock (&outcatalog); 150 dvo_catalog_free (&outcatalog); 151 152 fprintf (stderr, "merged %s into %s\n", inlist[0].regions[i][0].name, outlist[0].regions[j][0].name); 153 } 154 SkyListFree (outlist); 155 156 dvo_catalog_unlock (&incatalog); 157 dvo_catalog_free (&incatalog); 158 } 107 dvomergeUpdate_catalogs (input, output, outsky, inlist, NsecfiltInput, NsecfiltOutput, &IDmap, secfiltMap); 159 108 160 109 // save the output sky table copy -
trunk/Ohana/src/dvomerge/src/dvoverify.c
r33657 r33963 44 44 CHECKSORTED = TRUE; 45 45 remove_argument (N, &argc, argv); 46 } 47 48 if ((N = get_argument (argc, argv, "-cpt"))) { 49 remove_argument (N, &argc, argv); 50 char *filename = strcreate (argv[N]); 51 remove_argument (N, &argc, argv); 52 53 int isBad = FALSE; 54 55 if (!VerifyTableFile (filename)) { 56 fprintf (stderr, "bad average table %s\n", filename); 57 isBad = TRUE; 58 } 59 60 // change last 't' to 's': 61 int Nlast; 62 Nlast = strlen(filename) - 1; 63 filename[Nlast] = 's'; 64 if (!VerifyTableFile (filename)) { 65 fprintf (stderr, "bad secfilt table %s\n", filename); 66 isBad = TRUE; 67 } 68 69 // change last 't' to 's': 70 Nlast = strlen(filename) - 1; 71 filename[Nlast] = 'm'; 72 if (!VerifyTableFile (filename)) { 73 fprintf (stderr, "bad measure table %s\n", filename); 74 isBad = TRUE; 75 } 76 77 if (isBad) exit (1); 78 exit (0); 46 79 } 47 80 -
trunk/Ohana/src/dvomerge/src/help.c
r30615 r33963 6 6 fprintf (stderr, " OR: dvomerge (input) into (output) continue\n"); 7 7 fprintf (stderr, " OR: dvomerge (input) into (output) from (list)\n"); 8 fprintf (stderr, " [-region Rmin Rmax Dmin Dmax]\n"); 9 exit (2); 10 } 11 12 void dvomerge_client_usage (void) { 13 fprintf (stderr, "USAGE: dvomerge_client (input) into (output)\n"); 8 14 fprintf (stderr, " [-region Rmin Rmax Dmin Dmax]\n"); 9 15 exit (2); … … 45 51 fprintf (stderr, " -h : this list\n\n"); 46 52 fprintf (stderr, " -region Rmin Rmax Dmin Dmax : region to merge\n\n"); 53 fprintf (stderr, " -replace : replace existing detections of the same photcode\n"); 54 fprintf (stderr, " (this should only be used to merge reference dbs)\n\n"); 55 exit (2); 56 } 57 58 void dvomerge_client_help (int argc, char **argv) { 59 60 /* check for help request */ 61 if (get_argument (argc, argv, "-help")) goto show_help; 62 if (get_argument (argc, argv, "-h")) goto show_help; 63 return; 64 65 show_help: 66 67 fprintf (stderr, "USAGE\n"); 68 fprintf (stderr, " dvomerge_client (input) into (output)\n"); 69 fprintf (stderr, " merge DVO databases\n"); 70 fprintf (stderr, " optional flags:\n"); 71 fprintf (stderr, " -v : verbose mode\n"); 72 fprintf (stderr, " -help : this list\n"); 73 fprintf (stderr, " -h : this list\n\n"); 74 fprintf (stderr, " -region Rmin Rmax Dmin Dmax : region to merge\n\n"); 75 fprintf (stderr, " -replace : replace existing detections of the same photcode\n"); 76 fprintf (stderr, " (this should only be used to merge reference dbs)\n\n"); 47 77 exit (2); 48 78 } -
trunk/Ohana/src/dvomerge/src/merge_catalogs_old.c
r30761 r33963 111 111 if (Nave > 1) sort_coords_index (X2, Y2, N2, Nave); 112 112 113 if (REPLACE_BY_PHOTCODE && output[0].Nmeasure && !output[0].sorted) { 114 fprintf (stderr, "ERROR: attempt to merge with replace into an unsorted database\n"); 115 exit (3); 116 } 117 118 113 119 /* set up pointers for linked list of measure */ 114 120 if (output[0].sorted && (output[0].Nmeasure >= output[0].Nmeas_disk)) { … … 186 192 offset = input[0].average[N].measureOffset + Nin; 187 193 194 if (REPLACE_BY_PHOTCODE) { 195 // index to first measure for this object 196 int Mout = output[0].average[n].measureOffset; 197 if (replace_match(&output[0].average[n], &output[0].measure[Mout], &input[0].average[N], &input[0].measure[offset])) { 198 input[0].found[N] = Mout; 199 continue; 200 } 201 } 188 202 /* add to end of measurement list */ 189 203 add_meas_link (&output[0].average[n], next_meas, Nmeas, NMEAS); -
trunk/Ohana/src/dvomerge/test
-
Property svn:ignore
set to
catdir.test
-
Property svn:ignore
set to
-
trunk/Ohana/src/dvomerge/test/catdir.2mass
-
Property svn:ignore
set to
s8230
s3730
s6730
n3000
s0000
n1500
n6000
n2230
s3000
n4500
n5230
s6000
s1500
n7500
s2230
n8230
n3730
s4500
s0730
Images.dat
s5230
n6730
s7500
-
Property svn:ignore
set to
Note:
See TracChangeset
for help on using the changeset viewer.
