Changeset 38986 for trunk/Ohana/src/dvomerge
- Timestamp:
- Oct 27, 2015, 4:49:06 PM (11 years ago)
- Location:
- trunk/Ohana
- Files:
-
- 35 edited
- 3 copied
-
. (modified) (1 prop)
-
src/dvomerge/Makefile (modified) (8 diffs)
-
src/dvomerge/include/dvomerge.h (modified) (3 diffs)
-
src/dvomerge/include/dvoutils.h (modified) (2 diffs)
-
src/dvomerge/include/dvoverify.h (modified) (2 diffs)
-
src/dvomerge/src/LoadCatalog.c (modified) (1 diff)
-
src/dvomerge/src/ReadDeleteListExternID.c (modified) (2 diffs)
-
src/dvomerge/src/args.c (modified) (2 diffs)
-
src/dvomerge/src/build_links.c (modified) (1 diff)
-
src/dvomerge/src/dvoconvert.c (modified) (1 diff)
-
src/dvomerge/src/dvomergeContinue.c (modified) (1 diff)
-
src/dvomerge/src/dvomergeContinue_threaded.c (modified) (2 diffs)
-
src/dvomerge/src/dvomergeCreate.c (modified) (1 diff)
-
src/dvomerge/src/dvomergeFromList.c (modified) (2 diffs)
-
src/dvomerge/src/dvomergeUpdate_catalogs.c (modified) (4 diffs)
-
src/dvomerge/src/dvomergeUpdate_threaded.c (modified) (2 diffs)
-
src/dvomerge/src/dvomerge_client.c (modified) (2 diffs)
-
src/dvomerge/src/dvorepair.c (modified) (1 diff)
-
src/dvomerge/src/dvorepairCPT.c (modified) (1 diff)
-
src/dvomerge/src/dvorepairDeleteImagesByExternID.c (modified) (9 diffs)
-
src/dvomerge/src/dvorepairFixImages.c (modified) (4 diffs)
-
src/dvomerge/src/dvorepairFixWarpIDs.c (copied) (copied from branches/eam_branches/ipp-20150625/Ohana/src/dvomerge/src/dvorepairFixWarpIDs.c )
-
src/dvomerge/src/dvorepairImageVsMeasure.c (modified) (1 diff)
-
src/dvomerge/src/dvorepair_by_objID.c (copied) (copied from branches/eam_branches/ipp-20150625/Ohana/src/dvomerge/src/dvorepair_by_objID.c )
-
src/dvomerge/src/dvosecfilt_catalogs.c (modified) (1 diff)
-
src/dvomerge/src/dvoutils.c (modified) (1 diff)
-
src/dvomerge/src/dvoutils_load_image_index.c (modified) (3 diffs)
-
src/dvomerge/src/dvoutils_uniq_images.c (modified) (6 diffs)
-
src/dvomerge/src/dvoverify.c (modified) (2 diffs)
-
src/dvomerge/src/dvoverify_args.c (modified) (3 diffs)
-
src/dvomerge/src/dvoverify_catalogs.c (modified) (2 diffs)
-
src/dvomerge/src/dvoverify_client.c (modified) (1 diff)
-
src/dvomerge/src/dvoverify_utils.c (modified) (5 diffs)
-
src/dvomerge/src/help.c (modified) (1 diff)
-
src/dvomerge/src/merge_catalogs_old.c (modified) (2 diffs)
-
src/dvomerge/src/repair_catalog_by_objID.c (copied) (copied from branches/eam_branches/ipp-20150625/Ohana/src/dvomerge/src/repair_catalog_by_objID.c )
-
src/dvomerge/src/replace_match.c (modified) (4 diffs)
-
src/dvomerge/src/replace_tycho.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana
-
Property svn:mergeinfo
set to
/branches/eam_branches/ipp-20150625/Ohana merged eligible
-
Property svn:mergeinfo
set to
-
trunk/Ohana/src/dvomerge/Makefile
r38468 r38986 40 40 $(SRC)/dvo_image_merge_dbs.$(ARCH).o \ 41 41 $(SRC)/IDmapIO.$(ARCH).o \ 42 $(SRC)/ConfigInit.$(ARCH).o \ 42 43 $(SRC)/SetSignals.$(ARCH).o \ 43 $(SRC)/ConfigInit.$(ARCH).o \44 44 $(SRC)/Shutdown.$(ARCH).o \ 45 45 $(SRC)/help.$(ARCH).o \ … … 51 51 $(SRC)/replace_match.$(ARCH).o \ 52 52 $(SRC)/replace_tycho.$(ARCH).o \ 53 $(SRC)/repair_catalog_by_objID.$(ARCH).o \ 53 54 $(SRC)/merge_catalogs_new.$(ARCH).o \ 54 55 $(SRC)/merge_catalogs_old.$(ARCH).o … … 75 76 $(SRC)/replace_match.$(ARCH).o \ 76 77 $(SRC)/replace_tycho.$(ARCH).o \ 78 $(SRC)/repair_catalog_by_objID.$(ARCH).o \ 77 79 $(SRC)/merge_catalogs_new.$(ARCH).o \ 78 80 $(SRC)/merge_catalogs_old.$(ARCH).o … … 122 124 $(SRC)/dvorepair.$(ARCH).o \ 123 125 $(SRC)/dvorepairFixCPT.$(ARCH).o \ 126 $(SRC)/dvorepairFixWarpIDs.$(ARCH).o \ 124 127 $(SRC)/dvorepairImagesVsMeasures.$(ARCH).o \ 125 128 $(SRC)/dvorepairDeleteImageList.$(ARCH).o \ … … 127 130 $(SRC)/dvorepairDeleteImagesByExternID.$(ARCH).o \ 128 131 $(SRC)/dvorepairFixImages.$(ARCH).o \ 132 $(SRC)/dvorepair_by_objID.$(ARCH).o \ 133 $(SRC)/repair_catalog_by_objID.$(ARCH).o \ 129 134 $(SRC)/psps_ids.$(ARCH).o \ 130 135 $(SRC)/LoadImages.$(ARCH).o \ 131 136 $(SRC)/ReadDeleteList.$(ARCH).o \ 132 137 $(SRC)/ReadDeleteListExternID.$(ARCH).o \ 138 $(SRC)/SetSignals.$(ARCH).o \ 139 $(SRC)/Shutdown.$(ARCH).o \ 133 140 $(SRC)/myIndex.$(ARCH).o \ 134 141 $(SRC)/match_image.$(ARCH).o \ … … 140 147 141 148 DVOVERIFY = \ 149 $(SRC)/SetSignals.$(ARCH).o \ 150 $(SRC)/Shutdown.$(ARCH).o \ 142 151 $(SRC)/dvoverify.$(ARCH).o \ 143 152 $(SRC)/dvoverify_args.$(ARCH).o \ … … 149 158 150 159 DVOVERIFY_CLIENT = \ 160 $(SRC)/SetSignals.$(ARCH).o \ 161 $(SRC)/Shutdown.$(ARCH).o \ 151 162 $(SRC)/dvoverify_client.$(ARCH).o \ 152 163 $(SRC)/dvoverify_args.$(ARCH).o \ … … 158 169 159 170 DVOUTILS = \ 171 $(SRC)/SetSignals.$(ARCH).o \ 172 $(SRC)/Shutdown.$(ARCH).o \ 160 173 $(SRC)/dvoutils.$(ARCH).o \ 161 174 $(SRC)/dvoutils_args.$(ARCH).o \ -
trunk/Ohana/src/dvomerge/include/dvomerge.h
r38553 r38986 47 47 48 48 int MATCHED_TABLES; 49 int REPAIR_BY_OBJID; 49 50 50 51 char *SINGLE_CPT; … … 202 203 int dvomergeUpdate_catalogs PROTO((char *input, char *output, SkyTable *outsky, SkyList *inlist, int NsecfiltInput, int NsecfiltOutput, IDmapType *IDmap, int *secfiltMap)); 203 204 204 int replace_match PROTO((Average *average_out, Measure *measure_out, Average *average_in, Measure *measure_in));205 int replace_match PROTO((Average *average_out, Measure *measure_out, off_t *next_meas, Average *average_in, Measure *measure_in)); 205 206 206 207 int IDmapSave PROTO((char *filename, IDmapType *IDmap)); … … 241 242 242 243 void replace_tycho_init (); 243 int replace_tycho (Average *averageInp, Measure *measureInp, Average *averageOut, Measure *measureOut); 244 int replace_tycho (Average *averageInp, Measure *measureInp, off_t *next_meas, Average *averageOut, Measure *measureOut); 245 int repair_catalog_by_objID (Catalog *catalog); 246 247 int dvorepair_by_objID (int argc, char **argv); 248 int dvorepairFixWarpIDs (int argc, char **argv); 249 -
trunk/Ohana/src/dvomerge/include/dvoutils.h
r37807 r38986 22 22 } DVOUTILS_OP_TYPE; 23 23 24 typedef struct { 25 int *externID; 26 short *photcode; 27 int Nimages; 28 } ImageData; 29 24 30 int VERBOSE; 25 31 int DVOUTILS_OP; … … 30 36 int dvoutils_args (int *argc, char **argv); 31 37 int dvoutils_uniq_images (char *filename); 32 int *dvoutils_load_image_index (char *filename, int *nindex); 38 39 ImageData *dvoutils_load_image_index (char *filename); 33 40 34 41 Image *dvoutils_load_image_table (char *filename, int *nimage); 42 43 int SetSignals PROTO((void)); 44 void SetProtect PROTO((int mode)); 45 void TrapSignal PROTO((int sig)); 46 int Shutdown PROTO((char *format, ...)) OHANA_FORMAT(printf, 1, 2); 47 -
trunk/Ohana/src/dvomerge/include/dvoverify.h
r38553 r38986 37 37 int LIST_MISSING; 38 38 39 int IGNORE_SORTED_STATE; 40 39 41 SkyRegion UserPatch; 40 42 … … 62 64 63 65 void FreeImageIDs (void); 66 67 int SetSignals PROTO((void)); 68 void SetProtect PROTO((int mode)); 69 void TrapSignal PROTO((int sig)); 70 int Shutdown PROTO((char *format, ...)) OHANA_FORMAT(printf, 1, 2); 71 -
trunk/Ohana/src/dvomerge/src/LoadCatalog.c
r38471 r38986 9 9 10 10 // always load all of the data (if any exists) 11 catalog[0].catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT | DVO_LOAD_LENSING | DVO_LOAD_LENSOBJ | DVO_LOAD_STARPAR | DVO_LOAD_GALPHOT; 11 // XXXX TEMP HACK : skip GALPHOT 12 // XXXX catalog[0].catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT | DVO_LOAD_LENSING | DVO_LOAD_LENSOBJ | DVO_LOAD_STARPAR | DVO_LOAD_GALPHOT; 13 catalog[0].catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT | DVO_LOAD_LENSING | DVO_LOAD_LENSOBJ | DVO_LOAD_STARPAR; 12 14 13 15 catalog[0].catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data -
trunk/Ohana/src/dvomerge/src/ReadDeleteListExternID.c
r37807 r38986 47 47 // confirm we have 9 fields broken by 8 spaces: 48 48 space = c0; // pointer to track the space-separated words 49 indexPoint = c0; // pointer to the ID on this line49 indexPoint = strchr(c0, ' '); // pointer to the ID on this line 50 50 51 for (j = 0; j < 8; j++) {51 for (j = 0; j < 9; j++) { 52 52 space = strchr(space, ' '); 53 53 if (!space) { … … 62 62 indexList[Nindex] = index; 63 63 64 //fprintf (stderr, "index: %d, line: %s\n", index, c0);64 fprintf (stderr, "index: %d, line: %s\n", index, c0); 65 65 66 66 Nindex ++; -
trunk/Ohana/src/dvomerge/src/args.c
r38553 r38986 94 94 if ((N = get_argument (*argc, argv, "-replace-tycho"))) { 95 95 REPLACE_TYCHO = TRUE; 96 remove_argument (N, argc, argv); 97 } 98 99 REPAIR_BY_OBJID = FALSE; 100 if ((N = get_argument (*argc, argv, "-repair-by-objid"))) { 101 REPAIR_BY_OBJID = TRUE; 96 102 remove_argument (N, argc, argv); 97 103 } … … 266 272 } 267 273 274 REPAIR_BY_OBJID = FALSE; 275 if ((N = get_argument (*argc, argv, "-repair-by-objid"))) { 276 REPAIR_BY_OBJID = TRUE; 277 remove_argument (N, argc, argv); 278 } 279 268 280 NTHREADS = 0; 269 281 if ((N = get_argument (*argc, argv, "-threads"))) { -
trunk/Ohana/src/dvomerge/src/build_links.c
r37814 r38986 145 145 n = average[i].measureOffset; 146 146 average[i].measureOffset = N; 147 int myObjID = average[i].objID; 147 148 for (k = 0; k < average[i].Nmeasure; k++, N++) { 148 149 if (n == -1) abort(); 149 150 tmpmeasure[N] = measure[n]; 150 if (measure[n].averef != i) abort(); 151 myAssert (measure[n].averef == i, "error in averef?"); 152 myAssert (measure[n].objID == myObjID, "error in objID?"); 151 153 tmpmeasure[N].averef = i; 152 154 n = next_meas[n]; -
trunk/Ohana/src/dvomerge/src/dvoconvert.c
r38441 r38986 94 94 95 95 outcatalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT; 96 97 SetProtect (TRUE); 98 if (!dvo_catalog_save (&outcatalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", outcatalog.filename); exit (1); } 99 if (!dvo_catalog_unlock (&outcatalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", outcatalog.filename); exit (1); } 100 SetProtect (FALSE); 101 96 102 dvo_catalog_save (&outcatalog, VERBOSE); 97 103 dvo_catalog_unlock (&outcatalog); -
trunk/Ohana/src/dvomerge/src/dvomergeContinue.c
r38441 r38986 133 133 // if we receive a signal which would cause us to exit, wait until the full catalog is written 134 134 SetProtect (TRUE); 135 if (!dvo_catalog_save (&outcatalog, VERBOSE)) { 136 fprintf (stderr, "ERROR: failed to save catalog %s\n", outlist[0].filename[j]); 137 exit (1); 138 } 135 if (!dvo_catalog_save (&outcatalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", outcatalog.filename); exit (1); } 136 if (!dvo_catalog_unlock (&outcatalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", outcatalog.filename); exit (1); } 139 137 SetProtect (FALSE); 140 138 141 dvo_catalog_unlock (&outcatalog);142 139 dvo_catalog_free (&outcatalog); 143 140 -
trunk/Ohana/src/dvomerge/src/dvomergeContinue_threaded.c
r38441 r38986 77 77 SetProtect (TRUE); 78 78 if (!dvo_catalog_save (&outcatalog, VERBOSE)) { 79 fprintf (stderr, "ERROR: failed to save catalog %s\n", outlist[0].filename[j]); 79 fprintf (stderr, "ERROR: failed to save catalog %s\n", outcatalog.filename); 80 threadData->state = TS_FAIL; 81 continue; 82 } 83 if (!dvo_catalog_unlock (&outcatalog)) { 84 fprintf (stderr, "ERROR: failed to unlock catalog %s\n", outcatalog.filename); 80 85 threadData->state = TS_FAIL; 81 86 continue; … … 83 88 SetProtect (FALSE); 84 89 85 dvo_catalog_unlock (&outcatalog);86 90 dvo_catalog_free (&outcatalog); 87 91 -
trunk/Ohana/src/dvomerge/src/dvomergeCreate.c
r38441 r38986 178 178 SkyListFree (inlist); 179 179 180 dvo_catalog_save (&outcatalog, VERBOSE); 181 dvo_catalog_unlock (&outcatalog); 180 SetProtect (TRUE); 181 if (!dvo_catalog_save (&outcatalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", outcatalog.filename); exit (1); } 182 if (!dvo_catalog_unlock (&outcatalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", outcatalog.filename); exit (1); } 183 SetProtect (FALSE); 184 182 185 dvo_catalog_free (&outcatalog); 183 186 } -
trunk/Ohana/src/dvomerge/src/dvomergeFromList.c
r38441 r38986 147 147 // if we receive a signal which would cause us to exit, wait until the full catalog is written 148 148 SetProtect (TRUE); 149 if (!dvo_catalog_save (&outcatalog, VERBOSE)) { 150 fprintf (stderr, "ERROR: failed to save catalog %s\n", outputfile); 151 exit (1); 152 } 149 if (!dvo_catalog_save (&outcatalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save catalog %s\n", outcatalog.filename); exit (1); } 150 if (!dvo_catalog_unlock (&outcatalog)) { fprintf (stderr, "ERROR: failed to unlock catalog %s\n", outcatalog.filename); exit (1); } 153 151 SetProtect (FALSE); 154 152 … … 158 156 OutputStatusFree (outstat, 1); 159 157 160 dvo_catalog_unlock (&outcatalog);161 158 dvo_catalog_free (&outcatalog); 162 159 -
trunk/Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c
r38470 r38986 177 177 LoadCatalog (&outcatalog, outlist[0].regions[j], outcatalog.filename, "w", NsecfiltOutput); 178 178 179 // if no catalog already exists, use the input catalog to define the format or the specified format180 179 if (UPDATE_CATFORMAT) { 181 180 outcatalog.catformat = dvo_catalog_catformat (UPDATE_CATFORMAT); 182 181 } else { 183 outcatalog.catformat = incatalog.catformat; 184 } 182 // IF no catalog already exists, use the input catalog to define the format 183 if (outcatalog.Naverage_disk == 0) { 184 outcatalog.catformat = incatalog.catformat; 185 } 186 } 187 185 188 if (UPDATE_CATCOMPRESS) { 186 189 outcatalog.catcompress = dvo_catalog_catcompress (UPDATE_CATCOMPRESS); 187 190 } else { 188 outcatalog.catcompress = incatalog.catcompress; 191 // IF no catalog already exists, use the input catalog to define the compression 192 if (outcatalog.Naverage_disk == 0) { 193 outcatalog.catcompress = incatalog.catcompress; 194 } 195 } 196 197 if (REPAIR_BY_OBJID) { 198 // For gpc1 / PV3, I broke some catalogs with dvomerge -replace: the last object can 199 // contaminate the first set of new measurements 200 repair_catalog_by_objID (&outcatalog); 189 201 } 190 202 … … 195 207 } 196 208 197 if (!dvo_catalog_backup (&outcatalog, TRUE)) {209 if (!dvo_catalog_backup (&outcatalog, "~", TRUE)) { 198 210 fprintf (stderr, "ERROR: failed to make backup for catalog %s\n", outlist[0].filename[j]); 199 211 exit (1); … … 202 214 // if we receive a signal which would cause us to exit, wait until the full catalog is written 203 215 SetProtect (TRUE); 204 if (!dvo_catalog_save (&outcatalog, VERBOSE)) { 205 fprintf (stderr, "ERROR: failed to save catalog %s\n", outlist[0].filename[j]); 206 exit (1); 207 } 216 if (!dvo_catalog_save (&outcatalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save catalog %s\n", outcatalog.filename); exit (1); } 217 if (!dvo_catalog_unlock (&outcatalog)) { fprintf (stderr, "ERROR: failed to unlock catalog %s\n", outcatalog.filename); exit (1); } 208 218 SetProtect (FALSE); 209 219 210 if (!dvo_catalog_unlock (&outcatalog)) { 211 fprintf (stderr, "ERROR: failed to unlock catalog %s\n", outlist[0].filename[j]); 212 exit (1); 213 } 214 215 if (!dvo_catalog_unlink_backup (&outcatalog, TRUE)) { 220 if (!dvo_catalog_unlink_backup (&outcatalog, "~", TRUE)) { 216 221 fprintf (stderr, "WARNING: failed to remove backup for catalog %s\n", outlist[0].filename[j]); 217 222 } … … 282 287 283 288 // options / arguments that can affect relastro_client -update-objects: 284 char command[DVO_MAX_PATH];285 s nprintf (command, DVO_MAX_PATH, "dvomerge_client %s into %s -hostID %d -hostdir %s -region %f %f %f %f -D ADDSTAR_RADIUS %f",286 absinput, absoutput, group->hosts[i][0].hostID, group->hosts[i][0].pathname,287 UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, RADIUS288 ); 289 290 char tmpline[DVO_MAX_PATH];291 if (VER BOSE) { snprintf (tmpline, DVO_MAX_PATH, "%s -v", command); strcpy (command, tmpline); }292 if ( VERIFY) { snprintf (tmpline, DVO_MAX_PATH, "%s -verify", command); strcpy (command, tmpline); }293 if ( VERIFY_CATALOG_ONLY) { snprintf (tmpline, DVO_MAX_PATH, "%s -verify-catalogs", command); strcpy (command, tmpline); }294 if ( REPLACE_BY_PHOTCODE) { snprintf (tmpline, DVO_MAX_PATH, "%s -replace", command); strcpy (command, tmpline); }295 if ( REPLACE_TYCHO) { snprintf (tmpline, DVO_MAX_PATH, "%s -replace-tycho", command); strcpy (command, tmpline); }296 if ( PARALLEL_INPUT) { snprintf (tmpline, DVO_MAX_PATH, "%s -parallel-input", command); strcpy (command, tmpline); }297 if ( FORCE_MERGE) { snprintf (tmpline, DVO_MAX_PATH, "%s -force-merge", command); strcpy (command, tmpline); }298 if ( MATCHED_TABLES) { snprintf (tmpline, DVO_MAX_PATH, "%s -matched-tables", command); strcpy (command, tmpline); }299 if ( UPDATE_CATFORMAT) { snprintf (tmpline, DVO_MAX_PATH, "%s -update-catformat %s", command, UPDATE_CATFORMAT); strcpy (command, tmpline); }289 char *command = NULL; 290 strextend (&command, "dvomerge_client %s into %s -hostID %d -hostdir %s -region %f %f %f %f -D ADDSTAR_RADIUS %f", 291 absinput, absoutput, group->hosts[i][0].hostID, group->hosts[i][0].pathname, 292 UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, RADIUS); 293 294 if (VERBOSE) { strextend (&command, "-v"); } 295 if (VERIFY) { strextend (&command, "-verify"); } 296 if (VERIFY_CATALOG_ONLY) { strextend (&command, "-verify-catalogs"); } 297 if (REPLACE_BY_PHOTCODE) { strextend (&command, "-replace"); } 298 if (REPLACE_TYCHO) { strextend (&command, "-replace-tycho"); } 299 if (PARALLEL_INPUT) { strextend (&command, "-parallel-input"); } 300 if (FORCE_MERGE) { strextend (&command, "-force-merge"); } 301 if (MATCHED_TABLES) { strextend (&command, "-matched-tables"); } 302 if (UPDATE_CATFORMAT) { strextend (&command, "-update-catformat %s", UPDATE_CATFORMAT); } 303 if (UPDATE_CATCOMPRESS) { strextend (&command, "-update-catcompress %s", UPDATE_CATCOMPRESS); } 304 if (REPAIR_BY_OBJID) { strextend (&command, "-repair-by-objid"); } 300 305 301 306 // add some config variables: 302 s nprintf (tmpline, DVO_MAX_PATH, "%s -D CATMODE %s", command, CATMODE); strcpy (command, tmpline);303 s nprintf (tmpline, DVO_MAX_PATH, "%s -D CATFORMAT %s", command, CATFORMAT); strcpy (command, tmpline);304 s nprintf (tmpline, DVO_MAX_PATH, "%s -D SKY_DEPTH %d", command, SKY_DEPTH); strcpy (command, tmpline);307 strextend (&command, "-D CATMODE %s", CATMODE); 308 strextend (&command, "-D CATFORMAT %s", CATFORMAT); 309 strextend (&command, "-D SKY_DEPTH %d", SKY_DEPTH); 305 310 306 311 fprintf (stderr, "command: %s\n", command); -
trunk/Ohana/src/dvomerge/src/dvomergeUpdate_threaded.c
r38441 r38986 75 75 SetProtect (TRUE); 76 76 if (!dvo_catalog_save (&outcatalog, VERBOSE)) { 77 fprintf (stderr, "ERROR: failed to save catalog %s\n", outlist[0].filename[j]); 77 fprintf (stderr, "ERROR: failed to save catalog %s\n", outcatalog.filename); 78 threadData->state = TS_FAIL; 79 continue; 80 } 81 if (!dvo_catalog_unlock (&outcatalog)) { 82 fprintf (stderr, "ERROR: failed to save catalog %s\n", outcatalog.filename); 78 83 threadData->state = TS_FAIL; 79 84 continue; … … 81 86 SetProtect (FALSE); 82 87 83 dvo_catalog_unlock (&outcatalog);84 88 dvo_catalog_free (&outcatalog); 85 89 -
trunk/Ohana/src/dvomerge/src/dvomerge_client.c
r35818 r38986 3 3 int main (int argc, char **argv) { 4 4 5 SetSignals (); 5 6 dvomerge_client_help (argc, argv); 6 7 ConfigInit (&argc, argv); … … 83 84 // loop over the populatable output tables; check for data in input in the corresponding regions 84 85 85 SetPhotcodeTable(NULL);86 86 if (REPLACE_TYCHO) replace_tycho_init(); 87 87 88 dvomergeUpdate_catalogs (input, output, outsky, inlist, NsecfiltInput, NsecfiltOutput, IDmap, secfiltMap); 88 89 -
trunk/Ohana/src/dvomerge/src/dvorepair.c
r37807 r38986 7 7 // exit (2); 8 8 9 SetSignals (); 9 10 dvorepair_help(argc, argv); 10 11 12 if (!strcmp(argv[1], "-fix-warp-ids")) dvorepairFixWarpIDs(argc, argv); 13 11 14 if (!strcmp(argv[1], "-fix-cpt")) dvorepairFixCPT(argc, argv); 15 if (!strcmp(argv[1], "-fix-cpt-by-objID")) dvorepair_by_objID(argc, argv); 12 16 // if (!strcmp(argv[1], "-fix-tables")) dvorepairFixTables(argc, argv); 13 17 if (!strcmp(argv[1], "-images-vs-measures")) dvorepairImagesVsMeasures(argc, argv); -
trunk/Ohana/src/dvomerge/src/dvorepairCPT.c
r38441 r38986 39 39 exit (2); 40 40 } 41 42 SetSignals (); 41 43 42 44 imageFilename = argv[1]; -
trunk/Ohana/src/dvomerge/src/dvorepairDeleteImagesByExternID.c
r38468 r38986 16 16 int SaveImageTable (Image *image, off_t Nimage, char *catdir, FITS_DB *oldDB); 17 17 Image *DeleteSelectedImages (Image *image, off_t Nimage, int *deleteImage, myIndexType *imageIDindex, off_t *NnewImage); 18 int DeleteLensing (Catalog *catalog, myIndexType *imageIDindex, int *deleteImage, int *nDelete); 19 int DeleteMeasure (Catalog *catalog, myIndexType *imageIDindex, int *deleteImage, int *nDelete); 20 int RepairAverage (Catalog *catalog); 18 21 19 22 int dvorepairDeleteImagesByExternID (int argc, char **argv) { … … 21 24 FITS_DB db; // database handle pointing to input image table 22 25 23 int i, j, N, NmeasureNew, Ndelete, Nvalid;24 off_t Nimage , Nmeasure;26 int i, N; 27 off_t Nimage; 25 28 int nPass, raPass; 26 29 27 30 Image *image; 28 Measure *measure;29 Measure *measureNew;30 31 char *cpmFilenameSrc = NULL;32 char *cptFilenameSrc = NULL;33 char *cpsFilenameSrc = NULL;34 char *cpmFilenameTgt = NULL;35 char *cptFilenameTgt = NULL;36 char *cpsFilenameTgt = NULL;37 38 31 char *imageFilename = NULL; 39 40 DVOCatFormat catformat; 32 char filename[DVO_MAX_PATH]; 41 33 42 34 N = get_argument (argc, argv, "-delete-images-by-extern-id"); … … 59 51 char *catdir = argv[1]; 60 52 char *delList = argv[2]; 53 54 sprintf (filename, "%s/Photcodes.dat", catdir); 55 if (!LoadPhotcodes (filename, NULL, FALSE)) { 56 fprintf (stderr, "error reading photcodes from %s\n", catdir); 57 exit (1); 58 } 61 59 62 60 // load the image data … … 196 194 } 197 195 198 ALLOCATE(cpmFilenameSrc, char, strlen(catdir) + 64); 199 ALLOCATE(cptFilenameSrc, char, strlen(catdir) + 64); 200 ALLOCATE(cpsFilenameSrc, char, strlen(catdir) + 64); 201 ALLOCATE(cpmFilenameTgt, char, strlen(catdir) + 64); 202 ALLOCATE(cptFilenameTgt, char, strlen(catdir) + 64); 203 ALLOCATE(cpsFilenameTgt, char, strlen(catdir) + 64); 204 205 int NdeleteTotal = 0; 196 int NmeasureDelTotal = 0; 197 int NlensingDelTotal = 0; 206 198 207 199 for (raPass = 0; raPass < nPass; raPass++) { … … 231 223 232 224 // loop over the populated input regions 233 int Ncheck = 0;234 225 for (i = 0; i < inlist[0].Nregions; i++) { 235 226 if (!inlist[0].regions[i][0].table) continue; 236 227 237 sprintf (cpmFilenameSrc, "%s/%s.cpm", catdir, inlist[0].regions[i][0].name); 238 sprintf (cptFilenameSrc, "%s/%s.cpt", catdir, inlist[0].regions[i][0].name); 239 sprintf (cpsFilenameSrc, "%s/%s.cps", catdir, inlist[0].regions[i][0].name); 240 sprintf (cpmFilenameTgt, "%s/%s.cpm.broken", catdir, inlist[0].regions[i][0].name); 241 sprintf (cptFilenameTgt, "%s/%s.cpt.broken", catdir, inlist[0].regions[i][0].name); 242 sprintf (cpsFilenameTgt, "%s/%s.cps.broken", catdir, inlist[0].regions[i][0].name); 243 244 Header cpmHeaderPHU; 245 Header cpmHeaderTBL; 246 FTable cpmFtable; 247 248 /*** read and examine the CPM file ***/ 249 { 250 if (VERBOSE) fprintf (stderr, "check %s\n", cpmFilenameSrc); 251 252 cpmFtable.header = &cpmHeaderTBL; 253 254 // open cpm file 255 FILE *cpmFile = fopen(cpmFilenameSrc, "r"); 256 if (!cpmFile) continue; 257 // myAssert(cpmFile, "failed to open cpm file"); 258 259 // load the cpm header 260 if (!gfits_fread_header (cpmFile, &cpmHeaderPHU)) { 261 myAbort("failure to cpm header"); 262 } 263 264 // move to TBL header 265 int Nbytes = cpmHeaderPHU.datasize + gfits_data_size (&cpmHeaderPHU); 266 fseeko (cpmFile, Nbytes, SEEK_SET); 267 268 // read cpm TBL header 269 if (!gfits_fread_header (cpmFile, &cpmHeaderTBL)) { 270 myAbort("can't read header for cpm table"); 271 } 272 273 // read Measure table data : format is irrelevant here */ 274 if (!gfits_fread_ftable_data (cpmFile, &cpmFtable, TRUE)) { 275 myAbort("can't read data for cpm table"); 276 } 277 278 int NbytesPerRow; 279 gfits_scan(&cpmHeaderTBL, "NAXIS1", "%d", 1, &NbytesPerRow); 280 281 myAbort ("fix compression"); 282 283 // this function can only handle PS1_V5 and later formats 284 // NOTE: FtableToMeasure (and equivalent) free the data associated with cpmFtable. 285 // We are left with the data in measure. 286 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat, FALSE); 287 myAssert(measure, "failed to convert ftable to measure data"); 288 289 Nvalid = (int)(cpmFtable.validsize / NbytesPerRow); 290 Nvalid = MIN(Nmeasure, Nvalid); 291 292 // close the input cpm file 293 fclose(cpmFile); 294 295 // allocate an output array of measures (to replace, if needed) 296 ALLOCATE (measureNew, Measure, Nvalid); 297 298 NmeasureNew = 0; 299 Ndelete = 0; 300 301 // examine all measurements: find ones that need to be deleted 302 for (j = 0; j < Nvalid; j++) { 303 int imageID = measure[j].imageID; 304 myAssert(imageID, "measure is missing an image ID"); 305 // XXX this case is valid if we have REF detections (no associated image) 306 307 int N = myIndexGetEntry(imageIDindex, imageID); 308 if (N < 0) { 309 // this detection comes from a non-existant image, delete 310 Ndelete ++; 311 continue; 312 } 313 314 if (deleteImage[N]) { 315 Ndelete ++; 316 continue; 317 } 318 measureNew[NmeasureNew] = measure[j]; 319 NmeasureNew ++; 320 } 228 snprintf (filename, DVO_MAX_PATH, "%s/%s.cpt", catdir, inlist[0].regions[i][0].name); 229 230 Catalog catalog; 231 232 // set up the basic catalog info 233 dvo_catalog_init (&catalog, TRUE); 234 catalog.filename = filename; // XXX only allow non-parallel dbs for now 235 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT | DVO_LOAD_LENSING; 236 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 237 238 if (!dvo_catalog_open (&catalog, inlist[0].regions[i], VERBOSE, "w")) { 239 fprintf (stderr, "ERROR: failure reading catalog %s\n", catalog.filename); 240 exit (1); 321 241 } 322 323 NdeleteTotal += Ndelete; 324 325 // if we actually want to delete any measurements, write out a new cpm file 326 if (Ndelete > 0) { 327 328 fprintf (stderr, "deleting %d of %d (keep %d) detections from %s -> %s\n", (int) Ndelete, (int) Nvalid, (int) NmeasureNew, cpmFilenameSrc, cpmFilenameTgt); 242 if (!catalog.Naverage_disk) { 243 if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename); 244 dvo_catalog_unlock (&catalog); 245 dvo_catalog_free (&catalog); 246 continue; 247 } 329 248 330 // the CPT and CPS tables need to be regenerated. This must happen first because, in the process, we also update measure->averef 331 // what about other tables? 332 RepairTableCPT_V1(cptFilenameSrc, cptFilenameTgt, cpsFilenameSrc, cpsFilenameTgt, measureNew, NmeasureNew, image, Nimage, imageIDindex, catformat); 333 334 // convert internal to external format 335 if (!MeasureToFtable (&cpmFtable, NULL, measureNew, NmeasureNew, catformat, TRUE)) { 336 myAbort("trouble converting format"); 337 } 338 339 // rename the old cpm file: 340 if (rename (cpmFilenameSrc, cpmFilenameTgt)) { 341 perror ("tried to rename file"); 342 exit (2); 343 } 344 345 // create and write the output file 346 FILE *cpmFile = fopen(cpmFilenameSrc, "w"); 347 myAssert(cpmFile, "failed to open cpt file"); 348 349 // write PHU header 350 if (!gfits_fwrite_header (cpmFile, &cpmHeaderPHU)) { 351 myAbort("can't write primary header"); 352 } 353 354 Matrix matrix; 355 356 // write the PHU matrix; this is probably a NOP, do I have to keep it in? 357 gfits_create_matrix (&cpmHeaderPHU, &matrix); 358 if (!gfits_fwrite_matrix (cpmFile, &matrix)) { 359 myAbort("can't write primary matrix"); 360 } 361 gfits_free_matrix (&matrix); 362 363 // write the table data 364 if (!gfits_fwrite_ftable_range (cpmFile, &cpmFtable, 0, NmeasureNew, 0, NmeasureNew)) { 365 myAbort("can't write table data"); 366 } 367 fclose (cpmFile); 368 369 gfits_free_table (&cpmFtable); 370 } else { 371 if (VERBOSE) fprintf (stderr, "nothing to delete in %s\n", cpmFilenameSrc); 249 /*** delete the measure and lensing entries matching the list of imageIDs ***/ 250 int NmeasureDel = 0; 251 DeleteMeasure (&catalog, imageIDindex, deleteImage, &NmeasureDel); 252 253 int NlensingDel = 0; 254 DeleteLensing (&catalog, imageIDindex, deleteImage, &NlensingDel); 255 256 fprintf (stderr, "deleting %d measure, %d lensing (keep %d, %d)\n", NmeasureDel, NlensingDel, (int) catalog.Nmeasure, (int) catalog.Nlensing); 257 258 if (!NmeasureDel && !NlensingDel) { 259 if (VERBOSE) fprintf (stderr, "nothing to delete in %s\n", catalog.filename); 260 dvo_catalog_unlock (&catalog); 261 dvo_catalog_free (&catalog); 262 continue; 372 263 } 373 264 374 gfits_free_header (&cpmHeaderPHU); 375 gfits_free_header (&cpmHeaderTBL); 376 free (measure); 377 free (measureNew); 378 379 Ncheck ++; 380 if (Ncheck % 1000 == 0) { 381 fprintf (stderr, "%s...", inlist[0].regions[i][0].name); 265 NmeasureDelTotal += NmeasureDel; 266 NlensingDelTotal += NlensingDel; 267 268 // the CPT and CPS tables need to be regenerated. This must happen first because, in the process, we also update measure->averef 269 // what about other tables? 270 RepairAverage (&catalog); 271 272 if (VERBOSE) fprintf (stderr, "saving catalog %s\n", catalog.filename); 273 274 if (!dvo_catalog_backup (&catalog, ".undel", TRUE)) { 275 fprintf (stderr, "ERROR: failed to make backup for catalog %s\n", catalog.filename); 276 exit (1); 382 277 } 278 279 SetProtect (TRUE); 280 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 281 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 282 SetProtect (FALSE); 283 dvo_catalog_free (&catalog); 383 284 } 384 285 fprintf (stderr, "\n"); … … 386 287 } 387 288 388 fprintf (stderr, "Deleted %d detections\n", NdeleteTotal);289 fprintf (stderr, "Deleted %d measure, %d lensing detections\n", NmeasureDelTotal, NlensingDelTotal); 389 290 390 291 off_t NnewImage; … … 400 301 free (deleteIDs); 401 302 402 free(cpmFilenameSrc);403 free(cptFilenameSrc);404 free(cpsFilenameSrc);405 free(cpmFilenameTgt);406 free(cptFilenameTgt);407 free(cpsFilenameTgt);408 409 303 SkyTableFree(insky); 410 304 411 305 gfits_db_free (&db); 306 307 ohana_memcheck (TRUE); 412 308 413 309 exit (0); … … 661 557 gfits_scan (&cptHeaderPHU, "NSECFILT", "%d", 1, &Nsecfilt); 662 558 663 myAbort ("test for compression"); 559 if (0) { 560 char compressMode[256]; 561 if (gfits_scan (&cptHeaderTBL, "DVO_CMP", "%s", 1, compressMode)) { 562 if (strcmp (compressMode, "NONE")) { 563 myAbort ("fix compression"); 564 } 565 } 566 } 664 567 665 568 /* convert internal to external format */ … … 774 677 } 775 678 679 int RepairAverage (Catalog *catalog) { 680 681 off_t i, j, Nave; 682 683 // average is sorted so averef is valid 684 // secfilt is also sorted so sequence is valid (but this is kind of moot since it will be re-calculated) 685 // average.measureOffset is NOT valid 686 // average.lensingOffset is NOT valid 687 688 Average *average = catalog->average; 689 Measure *measure = catalog->measure; 690 Lensing *lensing = catalog->lensing; 691 692 // reset the values of average.Nmeasure, average.Nlensing 693 for (i = 0; i < catalog->Naverage; i++) { 694 average[i].Nmeasure = 0; 695 average[i].Nlensing = 0; 696 } 697 698 // re-calculate average.Nmeasure 699 for (i = 0; i < catalog->Nmeasure; i++) { 700 Nave = measure[i].averef; 701 myAssert (measure[i].objID == average[Nave].objID, "invalid measure:average match"); 702 average[Nave].Nmeasure ++; 703 } 704 705 // re-calculate average.Nlensing 706 for (i = 0; i < catalog->Nlensing; i++) { 707 Nave = lensing[i].averef; 708 myAssert (lensing[i].objID == average[Nave].objID, "invalid lensing:average match"); 709 average[Nave].Nlensing ++; 710 } 711 712 // create a copy of the average table, keeping only the entries with Nmeasure & Nlensing > 0 713 ALLOCATE_PTR (averageNew, Average, catalog->Naverage); 714 ALLOCATE_PTR (averefNew, int, catalog->Naverage); 715 716 Nave = 0; 717 for (i = 0; i < catalog->Naverage; i++) { 718 averefNew[i] = -1; 719 if (!average[i].Nmeasure && !average[i].Nlensing) continue; 720 721 averageNew[Nave] = average[i]; 722 averefNew[i] = Nave; 723 Nave ++; 724 } 725 off_t NaverageNew = Nave; 726 727 // update measure.averef values 728 for (i = 0; i < catalog->Nmeasure; i++) { 729 Nave = averefNew[measure[i].averef]; 730 myAssert (Nave >= 0, "oops"); 731 measure[i].averef = Nave; 732 } 733 734 // update lensing.averef values 735 for (i = 0; i < catalog->Nlensing; i++) { 736 Nave = averefNew[lensing[i].averef]; 737 myAssert (Nave >= 0, "oops"); 738 lensing[i].averef = Nave; 739 } 740 741 // XXX need to update measureOffset and lensingOffset 742 743 // measure[] should be blocked and sequential: 744 // measure[i+1].averef >= measure[i].averef 745 746 // update average.measureOffset values 747 Nave = -1; 748 for (i = 0; i < catalog->Nmeasure; i++) { 749 if (measure[i].averef == Nave) continue; 750 Nave = measure[i].averef; 751 averageNew[Nave].measureOffset = i; 752 } 753 754 // update average.lensingOffset values 755 Nave = -1; 756 for (i = 0; i < catalog->Nlensing; i++) { 757 if (lensing[i].averef == Nave) continue; 758 Nave = lensing[i].averef; 759 averageNew[Nave].lensingOffset = i; 760 } 761 762 // check the result (measure -> average) 763 for (i = 0; i < catalog->Nmeasure; i++) { 764 Nave = measure[i].averef; 765 myAssert(averageNew[Nave].objID == measure[i].objID, "objIDs do not match"); 766 myAssert(averageNew[Nave].catID == measure[i].catID, "catIDs do not match"); 767 } 768 // check the result (average -> measure) 769 for (i = 0; i < NaverageNew; i++) { 770 int m = averageNew[i].measureOffset; 771 for (j = 0; j < averageNew[i].Nmeasure; j++) { 772 myAssert(averageNew[i].objID == measure[j+m].objID, "objIDs do not match"); 773 myAssert(averageNew[i].catID == measure[j+m].catID, "catIDs do not match"); 774 myAssert(measure[j+m].averef == i, "averef broken"); 775 } 776 } 777 778 // check the result (lensing -> average) 779 for (i = 0; i < catalog->Nlensing; i++) { 780 Nave = lensing[i].averef; 781 myAssert(averageNew[Nave].objID == lensing[i].objID, "objIDs do not match"); 782 myAssert(averageNew[Nave].catID == lensing[i].catID, "catIDs do not match"); 783 } 784 // check the result (average -> lensing) 785 for (i = 0; i < NaverageNew; i++) { 786 int m = averageNew[i].lensingOffset; 787 for (j = 0; j < averageNew[i].Nlensing; j++) { 788 myAssert(averageNew[i].objID == lensing[j+m].objID, "objIDs do not match"); 789 myAssert(averageNew[i].catID == lensing[j+m].catID, "catIDs do not match"); 790 myAssert(lensing[j+m].averef == i, "averef broken"); 791 } 792 } 793 794 free (catalog->secfilt); 795 ALLOCATE (catalog->secfilt, SecFilt, NaverageNew*catalog->Nsecfilt); 796 for (i = 0; i < NaverageNew*catalog->Nsecfilt; i++) { 797 dvo_secfilt_init (&catalog->secfilt[i], SECFILT_RESET_ALL); 798 } 799 800 free (averefNew); 801 free (catalog->average); 802 catalog->average = averageNew; 803 catalog->Naverage = NaverageNew; 804 catalog->Naverage_disk = NaverageNew; 805 806 catalog->Nsecfilt_disk = NaverageNew*catalog->Nsecfilt; 807 808 return (TRUE); 809 } 810 811 // delete measure entries 812 int DeleteMeasure (Catalog *catalog, myIndexType *imageIDindex, int *deleteImage, int *nDelete) { 813 814 int j; 815 816 Measure *measure = catalog->measure; 817 818 // allocate an output array of measures (to replace, if needed) 819 ALLOCATE_PTR (measureNew, Measure, catalog->Nmeasure); 820 821 int NmeasureNew = 0; 822 int NmeasureDel = 0; 823 824 // examine all measurements: find ones that need to be deleted 825 for (j = 0; j < catalog->Nmeasure; j++) { 826 int imageID = measure[j].imageID; 827 myAssert(imageID, "measure is missing an image ID"); 828 // XXX this case is valid if we have REF detections (no associated image) 829 830 int N = myIndexGetEntry(imageIDindex, imageID); 831 if (N < 0) { 832 // this detection comes from a non-existant image; delete 833 NmeasureDel ++; 834 continue; 835 } 836 837 // measure matches a bad image; delete 838 if (deleteImage[N]) { 839 NmeasureDel ++; 840 continue; 841 } 842 843 // keep this measure 844 measureNew[NmeasureNew] = measure[j]; 845 NmeasureNew ++; 846 } 847 848 free (catalog->measure); 849 catalog->measure = measureNew; 850 catalog->Nmeasure = NmeasureNew; 851 catalog->Nmeasure_disk = NmeasureNew; 852 853 *nDelete = NmeasureDel; 854 855 return TRUE; 856 } 857 858 // delete lensing entries 859 int DeleteLensing (Catalog *catalog, myIndexType *imageIDindex, int *deleteImage, int *nDelete) { 860 861 int j; 862 863 Lensing *lensing = catalog->lensing; 864 865 // allocate an output array of measures (to replace, if needed) 866 ALLOCATE_PTR (lensingNew, Lensing, catalog->Nlensing); 867 868 int NlensingNew = 0; 869 int NlensingDel = 0; 870 871 // examine all lensingments: find ones that need to be deleted 872 for (j = 0; j < catalog->Nlensing; j++) { 873 int imageID = lensing[j].imageID; 874 myAssert(imageID, "lensing is missing an image ID"); 875 // XXX this case is valid if we have REF detections (no associated image) 876 877 int N = myIndexGetEntry(imageIDindex, imageID); 878 if (N < 0) { 879 // this detection comes from a non-existant image; delete 880 NlensingDel ++; 881 continue; 882 } 883 884 // lensing matches a bad image; delete 885 if (deleteImage[N]) { 886 NlensingDel ++; 887 continue; 888 } 889 890 // keep this lensing 891 lensingNew[NlensingNew] = lensing[j]; 892 NlensingNew ++; 893 } 894 895 free (catalog->lensing); 896 catalog->lensing = lensingNew; 897 catalog->Nlensing = NlensingNew; 898 catalog->Nlensing_disk = NlensingNew; 899 900 *nDelete = NlensingDel; 901 902 return TRUE; 903 } 904 -
trunk/Ohana/src/dvomerge/src/dvorepairFixImages.c
r38441 r38986 255 255 256 256 /* setup image table format and lock */ 257 gfits_db_init ( oldDB);257 gfits_db_init (&db); 258 258 db.mode = oldDB->mode; 259 259 db.format = oldDB->format; … … 266 266 /* load or create the image table */ 267 267 myAssert (db.dbstate == LCK_EMPTY, "do not overwrite exiting image table"); 268 myAssert (db.format == DVO_FORMAT_PS1_V2, "format mismatch");268 // myAssert (db.format == DVO_FORMAT_PS1_V2, "format mismatch"); 269 269 270 270 dvo_image_create (&db, GetZeroPoint()); 271 gfits_copy_header (&oldDB->header, &db.header); 271 272 272 273 // replace the existing buffer with the image array … … 277 278 nbytes = gfits_data_size (db.ftable.header); 278 279 db.ftable.datasize = nbytes; 279 db.ftable.buffer = (char *) imageOut; 280 REALLOCATE (db.ftable.buffer, char, MAX (nbytes, 1)); 280 281 free (db.ftable.buffer); 282 ALLOCATE (db.ftable.buffer, char, MAX (nbytes, 1)); 283 memcpy (db.ftable.buffer, imageOut, nbytes); 281 284 memset (&db.ftable.buffer[Nx*Nout], ' ', nbytes - Nx*Nout); 282 285 … … 295 298 dvo_image_unlock (&db); 296 299 300 gfits_db_free (&db); 301 297 302 return TRUE; 298 303 } -
trunk/Ohana/src/dvomerge/src/dvorepairImageVsMeasure.c
r38441 r38986 39 39 } 40 40 41 SetSignals (); 41 42 catdir = argv[1]; 42 43 Ntol = atoi(argv[2]); -
trunk/Ohana/src/dvomerge/src/dvosecfilt_catalogs.c
r38471 r38986 82 82 catalog.Nsecfilt_disk = Nsecfilt * catalog.Naverage_disk; 83 83 84 dvo_catalog_save (&catalog, VERBOSE); 85 dvo_catalog_unlock (&catalog); 84 SetProtect (TRUE); 85 if (!dvo_catalog_save (&catalog, VERBOSE)) { fprintf (stderr, "ERROR: failed to save %s\n", catalog.filename); exit (1); } 86 if (!dvo_catalog_unlock (&catalog)) { fprintf (stderr, "ERROR: failed to unlock %s\n", catalog.filename); exit (1); } 87 SetProtect (FALSE); 88 86 89 dvo_catalog_free (&catalog); 87 90 } -
trunk/Ohana/src/dvomerge/src/dvoutils.c
r37807 r38986 4 4 5 5 // check various options 6 SetSignals (); 6 7 dvoutils_args (&argc, argv); 7 8 -
trunk/Ohana/src/dvomerge/src/dvoutils_load_image_index.c
r38441 r38986 2 2 3 3 // load the array of EXTERN_ID from the ImageIndex.fits tables 4 int *dvoutils_load_image_index (char *filename, int *nindex) {4 ImageData *dvoutils_load_image_index (char *filename) { 5 5 6 6 int Ncol; 7 off_t Nrow ;7 off_t Nrow, Nphot; 8 8 Header header; 9 9 Header theader; … … 46 46 fclose (f); 47 47 48 int *externID = gfits_get_bintable_column_data (&theader, &ftable, "EXTERN_ID", type, &Nrow, &Ncol); 48 ImageData *imdata = NULL; 49 ALLOCATE (imdata, ImageData, 1); 50 51 imdata->externID = gfits_get_bintable_column_data (&theader, &ftable, "EXTERN_ID", type, &Nrow, &Ncol); 49 52 myAssert (!strcmp(type, "int"), "wrong column type"); 53 54 imdata->photcode = gfits_get_bintable_column_data (&theader, &ftable, "PHOTCODE", type, &Nphot, &Ncol); 55 myAssert (Nphot == Nrow, "photcode & extern_id mis-match"); 56 57 imdata->Nimages = Nrow; 50 58 51 59 gfits_free_header (&header); … … 54 62 gfits_free_table (&ftable); 55 63 56 *nindex = Nrow; 57 58 return externID; 64 return imdata; 59 65 } 60 66 -
trunk/Ohana/src/dvomerge/src/dvoutils_uniq_images.c
r38441 r38986 40 40 } 41 41 42 int Nimage; 43 // Image *image = dvoutils_load_image_table (imFile, &Nimage); 44 int *extern_id = dvoutils_load_image_index (imFile, &Nimage); 45 if (!extern_id) continue; 42 ImageData *imdata = dvoutils_load_image_index (imFile); 43 if (!imdata) continue; 46 44 47 45 DBlist[Ndb] = strcreate (imFile); … … 57 55 58 56 int i; 59 for (i = 0; i < Nimage; i++) { 60 if (!extern_id[i]) continue; 61 myMaxID = MAX(extern_id[i], myMaxID); 62 myMinID = MIN(extern_id[i], myMinID); 57 int Nbad = 0; 58 for (i = 0; i < imdata->Nimages; i++) { 59 if (!imdata->photcode[i] && imdata->externID[i]) myAbort ("invalid combo"); 60 61 if (!imdata->photcode[i]) continue; 62 if (!imdata->externID[i]) { 63 Nbad ++; 64 continue; 65 } 66 myMaxID = MAX(imdata->externID[i], myMaxID); 67 myMinID = MIN(imdata->externID[i], myMinID); 63 68 } 64 69 65 fprintf (stderr, "read %s, %d images, %d - %d vs %d - %d\n", imFile, (int) Nimage, myMinID, myMaxID, minID, maxID); 70 fprintf (stderr, "read %s, %d images, %d - %d vs %d - %d\n", imFile, (int) imdata->Nimages, myMinID, myMaxID, minID, maxID); 71 72 if (Nbad) { 73 fprintf (stderr, "WARNING: %d images without extern_id set\n", (int) Nbad); 74 } 66 75 67 76 // if this is new, we treat it a bit differently … … 124 133 } 125 134 126 for (i = 0; i < Nimage; i++) {127 if (! extern_id[i]) continue;128 int n = extern_id[i] - minID;135 for (i = 0; i < imdata->Nimages; i++) { 136 if (!imdata->externID[i]) continue; 137 int n = imdata->externID[i] - minID; 129 138 if (IDlist[n] == 0) { 130 139 DBfound[n] = Ndb; … … 133 142 IDlist[n] ++; 134 143 if (VERBOSE && (IDlist[n] > 1)) { 135 fprintf (stderr, "duplicate ext_id %d in file %s\n", extern_id[i], imFile);144 fprintf (stderr, "duplicate ext_id %d in file %s\n", imdata->externID[i], imFile); 136 145 } 137 146 } … … 140 149 fprintf (stderr, "------------ %s ----------\n", imFile); 141 150 142 for (i = 0; i < Nimage; i++) {143 if (! extern_id[i]) continue;144 fprintf (stderr, "%d => %d\n", extern_id[i], extern_id[i] - minID);151 for (i = 0; i < imdata->Nimages; i++) { 152 if (!imdata->externID[i]) continue; 153 fprintf (stderr, "%d => %d\n", imdata->externID[i], imdata->externID[i] - minID); 145 154 } 146 155 … … 165 174 int n = DBfound[i]; 166 175 myAssert (n > -1, "impossible!"); 167 fprintf (stdout, " %d : %d -- in %s (%d) : %d \n", i + minID, IDlist[i], DBlist[n], DBfound[i], DBindex[i]);176 fprintf (stdout, "primary %d : %d -- in %s (%d) : %d \n", i + minID, IDlist[i], DBlist[n], DBfound[i], DBindex[i]); 168 177 } 169 178 -
trunk/Ohana/src/dvomerge/src/dvoverify.c
r38553 r38986 14 14 15 15 // check various options 16 SetSignals (); 16 17 dvoverify_args (&argc, argv); 17 18 CATDIR = argv[1]; … … 78 79 SkyListFree (skylist); 79 80 80 ohana_memcheck ( TRUE);81 ohana_memdump ( TRUE);81 ohana_memcheck (VERBOSE); 82 ohana_memdump (VERBOSE); 82 83 exit (0); 83 84 } -
trunk/Ohana/src/dvomerge/src/dvoverify_args.c
r38553 r38986 24 24 if ((N = get_argument (*argc, argv, "-sorted"))) { 25 25 CHECKSORTED = TRUE; 26 remove_argument (N, argc, argv); 27 } 28 29 // in some cases, the header sorted state can claim F but is actually T 30 IGNORE_SORTED_STATE = FALSE; 31 if ((N = get_argument (*argc, argv, "-ignore-sorted-state"))) { 32 IGNORE_SORTED_STATE = TRUE; 26 33 remove_argument (N, argc, argv); 27 34 } … … 50 57 free (filename); 51 58 52 ohana_memcheck ( TRUE);53 ohana_memdump ( TRUE);59 ohana_memcheck (VERBOSE); 60 ohana_memdump (VERBOSE); 54 61 55 62 if (!isGood) exit (1); … … 204 211 } 205 212 213 // in some cases, the header sorted state can claim F but is actually T 214 IGNORE_SORTED_STATE = FALSE; 215 if ((N = get_argument (*argc, argv, "-ignore-sorted-state"))) { 216 IGNORE_SORTED_STATE = TRUE; 217 remove_argument (N, argc, argv); 218 } 219 206 220 if (!HOST_ID || !HOSTDIR || (*argc != 2)) { 207 221 fprintf (stderr, "USAGE: dvoverify_client (catdir) -results (file) -hostID ID -hostdir DIR [-region Rmin Rmax Dmin Dmax] [-v] [-s]\n\n"); -
trunk/Ohana/src/dvomerge/src/dvoverify_catalogs.c
r38553 r38986 117 117 118 118 // options / arguments that can affect relastro_client -update-objects: 119 char command[DVO_MAX_PATH]; 120 snprintf (command, DVO_MAX_PATH, "dvoverify_client %s -results %s -hostID %d -hostdir %s -region %f %f %f %f", 121 abscatdir, table->hosts[i].results, table->hosts[i].hostID, table->hosts[i].pathname, 122 UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax 123 ); 119 char *command = NULL; 120 strextend (&command, "dvoverify_client %s -results %s -hostID %d -hostdir %s -region %f %f %f %f", 121 abscatdir, table->hosts[i].results, table->hosts[i].hostID, table->hosts[i].pathname, 122 UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax); 124 123 125 char tmpline[DVO_MAX_PATH];126 if ( VERBOSE) { snprintf (tmpline, DVO_MAX_PATH, "%s -v", command); strcpy (command, tmpline); }127 if ( CHECKSORTED) { snprintf (tmpline, DVO_MAX_PATH, "%s -s", command); strcpy (command, tmpline); }128 if (!CHECK_IMAGE_ID) { snprintf (tmpline, DVO_MAX_PATH, "%s -skip-image-ids", command); strcpy (command, tmpline); }129 if (LIST_MISSING) { snprintf (tmpline, DVO_MAX_PATH, "%s -list-missing", command); strcpy (command, tmpline); }124 if (VERBOSE) { strextend (&command, "-v"); } 125 if (CHECKSORTED) { strextend (&command, "-s"); } 126 if (IGNORE_SORTED_STATE) { strextend (&command, "-ignore-sorted-state"); } 127 if (!CHECK_IMAGE_ID) { strextend (&command, "-skip-image-ids"); } 128 if (LIST_MISSING) { strextend (&command, "-list-missing"); } 130 129 131 130 fprintf (stderr, "command: %s\n", command); … … 149 148 table->hosts[i].pid = pid; // save for future reference 150 149 } 150 free (command); 151 151 } 152 152 -
trunk/Ohana/src/dvomerge/src/dvoverify_client.c
r37360 r38986 8 8 9 9 // check various options 10 SetSignals (); 10 11 dvoverify_client_args (&argc, argv); 11 12 CATDIR = argv[1]; -
trunk/Ohana/src/dvomerge/src/dvoverify_utils.c
r38553 r38986 188 188 dvo_catalog_init (&catalog, TRUE); 189 189 catalog.filename = filename; 190 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_LENSING | DVO_LOAD_LENSOBJ ;190 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_LENSING | DVO_LOAD_LENSOBJ | DVO_LOAD_STARPAR | DVO_LOAD_GALPHOT; 191 191 catalog.Nsecfilt = 0; 192 192 … … 214 214 215 215 // if the table is NOT SORTED, do we have a subset of checks we can make? 216 if (!catalog.sorted ) {216 if (!catalog.sorted && !IGNORE_SORTED_STATE) { 217 217 fprintf (stderr, "!"); 218 218 dvo_catalog_unlock (&catalog); … … 222 222 return TRUE; 223 223 } 224 225 int NmeasureTotal = 0; 226 int measureOffsetOK = TRUE; 227 int NlensingTotal = 0; 228 int lensingOffsetOK = TRUE; 229 int NlensobjTotal = 0; 230 int lensobjOffsetOK = TRUE; 231 for (i = 0; i < catalog.Naverage; i++) { 232 NmeasureTotal += catalog.average[i].Nmeasure; 233 if (VERBOSE && !(NmeasureTotal <= catalog.Nmeasure)) { 234 fprintf (stderr, "NmeasureTotal > catalog.Nmeasure: %d %d %d\n", i, catalog.average[i].Nmeasure, (int) catalog.Nmeasure); 235 } 236 measureOffsetOK &= (catalog.average[i].measureOffset < catalog.Nmeasure); 237 if (VERBOSE && !(catalog.average[i].measureOffset < catalog.Nmeasure)) { 238 fprintf (stderr, "measureOffset >= catalog.Nmeasure: %d %d %d\n", i, catalog.average[i].measureOffset, (int) catalog.Nmeasure); 239 } 240 measureOffsetOK &= (catalog.average[i].measureOffset + catalog.average[i].Nmeasure <= catalog.Nmeasure); 241 if (VERBOSE && !(catalog.average[i].measureOffset + catalog.average[i].Nmeasure <= catalog.Nmeasure)) { 242 fprintf (stderr, "measureOffset + Nmeasure > catalog.Nmeasure : %d %d %d\n", i, catalog.average[i].Nmeasure, (int) catalog.Nmeasure); 243 } 244 245 // sum of Nlensing for each object < Nlensing for catalog 246 NlensingTotal += catalog.average[i].Nlensing; 247 if (VERBOSE && !(NlensingTotal <= catalog.Nlensing)) { 248 fprintf (stderr, "NlensingTotal > catalog.Nlensing: %d %d %d\n", i, catalog.average[i].Nlensing, (int) catalog.Nlensing); 249 } 250 // lensingOffset needs to be in range for each object 251 lensingOffsetOK &= (!catalog.Nlensing || (catalog.average[i].lensingOffset < catalog.Nlensing)); 252 if (VERBOSE && catalog.Nlensing && !(catalog.average[i].lensingOffset < catalog.Nlensing)) { 253 fprintf (stderr, "lensingOffset >= catalog.Nlensing: %d %d %d\n", i, catalog.average[i].lensingOffset, (int) catalog.Nlensing); 254 } 255 lensingOffsetOK &= (catalog.average[i].lensingOffset + catalog.average[i].Nlensing <= catalog.Nlensing); 256 if (VERBOSE && !(catalog.average[i].lensingOffset + catalog.average[i].Nlensing <= catalog.Nlensing)) { 257 fprintf (stderr, "lensingOffset + Nlensing > catalog.Nlensing : %d %d %d\n", i, catalog.average[i].Nlensing, (int) catalog.Nlensing); 258 } 259 260 NlensobjTotal += catalog.average[i].Nlensobj; 261 if (VERBOSE && !(NlensobjTotal <= catalog.Nlensobj)) { 262 fprintf (stderr, "NlensobjTotal > catalog.Nlensobj: %d %d %d\n", i, catalog.average[i].Nlensobj, (int) catalog.Nlensobj); 263 } 264 lensobjOffsetOK &= (catalog.average[i].lensobjOffset < catalog.Nlensobj); 265 if (VERBOSE && !(catalog.average[i].lensobjOffset < catalog.Nlensobj)) { 266 fprintf (stderr, "lensobjOffset >= catalog.Nlensobj: %d %d %d\n", i, catalog.average[i].lensobjOffset, (int) catalog.Nlensobj); 267 } 268 lensobjOffsetOK &= (catalog.average[i].lensobjOffset + catalog.average[i].Nlensobj <= catalog.Nlensobj); 269 if (VERBOSE && !(catalog.average[i].lensobjOffset + catalog.average[i].Nlensobj <= catalog.Nlensobj)) { 270 fprintf (stderr, "lensobjOffset + Nlensobj > catalog.Nlensobj : %d %d %d\n", i, catalog.average[i].Nlensobj, (int) catalog.Nlensobj); 271 } 272 } 273 274 if (!measureOffsetOK) { 275 fprintf (stderr, "ERROR: catalog %s has an invalid measureOffset\n", catalog.filename); 276 status = FALSE; 277 } 278 279 if (NmeasureTotal != catalog.Nmeasure) { 280 fprintf (stderr, "ERROR: catalog %s has an invalid Nmeasure\n", catalog.filename); 281 status = FALSE; 282 } 283 284 if (!lensingOffsetOK) { 285 fprintf (stderr, "ERROR: catalog %s has an invalid lensingOffset\n", catalog.filename); 286 status = FALSE; 287 } 288 289 if (NlensingTotal != catalog.Nlensing) { 290 fprintf (stderr, "ERROR: catalog %s has an invalid Nlensing\n", catalog.filename); 291 status = FALSE; 292 } 293 294 if (!lensobjOffsetOK) { 295 fprintf (stderr, "ERROR: catalog %s has an invalid lensobjOffset\n", catalog.filename); 296 status = FALSE; 297 } 298 299 if (NlensobjTotal != catalog.Nlensobj) { 300 fprintf (stderr, "ERROR: catalog %s has an invalid Nlensobj\n", catalog.filename); 301 status = FALSE; 302 } 224 225 # define CHECK_TABLE(NAME) { \ 226 int Ntotal = 0; int offsetOK = TRUE; int isOK = FALSE; \ 227 for (i = 0; i < catalog.Naverage; i++) { \ 228 Ntotal += catalog.average[i].N##NAME; \ 229 if (VERBOSE && !(Ntotal <= catalog.N##NAME)) { \ 230 fprintf (stderr, "Ntotal (%s) > catalog.N##NAME: %d %d : %d > %d\n", #NAME, i, Ntotal, catalog.average[i].N##NAME, (int) catalog.N##NAME); \ 231 } \ 232 isOK = (catalog.average[i].N##NAME == 0) || (catalog.average[i].NAME##Offset < catalog.N##NAME); \ 233 offsetOK &= isOK; \ 234 if (VERBOSE && !isOK) { \ 235 fprintf (stderr, "%sOffset >= catalog.N%s: %d : %d >= %d\n", #NAME, #NAME, i, catalog.average[i].NAME##Offset, (int) catalog.N##NAME); \ 236 } \ 237 isOK = (catalog.average[i].N##NAME == 0) || (catalog.average[i].NAME##Offset + catalog.average[i].N##NAME <= catalog.N##NAME); \ 238 offsetOK &= isOK; \ 239 if (VERBOSE && !isOK) { \ 240 fprintf (stderr, "%sOffset + N%s > catalog.N%s : %d : %d + %d > %d\n", #NAME, #NAME, #NAME, i, catalog.average[i].N##NAME, catalog.average[i].NAME##Offset, (int) catalog.N##NAME); \ 241 } } \ 242 if (!offsetOK) { \ 243 fprintf (stderr, "ERROR: catalog %s has an invalid %sOffset\n", catalog.filename, #NAME); \ 244 status = FALSE; \ 245 } \ 246 if (Ntotal != catalog.N##NAME) { \ 247 fprintf (stderr, "ERROR: catalog %s has an invalid N%s\n", catalog.filename, #NAME); \ 248 status = FALSE; \ 249 } \ 250 } 251 252 CHECK_TABLE(measure); 253 CHECK_TABLE(lensing); 254 CHECK_TABLE(lensobj); 255 CHECK_TABLE(starpar); 256 CHECK_TABLE(galphot); 303 257 304 258 // if we have a problem with Nmeasure and/or measureOffset values, we … … 312 266 // check measure <-> average links 313 267 { 314 int objIDsOK = TRUE;315 int catIDsOK = TRUE;316 int averefOK = TRUE;268 int NobjIDsBAD = 0; 269 int NcatIDsBAD = 0; 270 int NaverefBAD = 0; 317 271 318 272 for (i = 0; i < catalog.Naverage; i++) { 319 273 m = catalog.average[i].measureOffset; 320 274 for (j = 0; j < catalog.average[i].Nmeasure; j++) { 321 objIDsOK &= (catalog.average[i].objID == catalog.measure[m+j].objID); 322 catIDsOK &= (catalog.average[i].catID == catalog.measure[m+j].catID); 323 averefOK &= (catalog.measure[m+j].averef == i); 275 if (catalog.average[i].objID != catalog.measure[m+j].objID) { 276 NobjIDsBAD ++; 277 278 // check if objID matches R,D 279 Measure *measure = &catalog.measure[m+j]; 280 int iTest = measure->objID; 281 if (catalog.average[iTest].objID == iTest) { 282 double dR = 3600.0*(catalog.average[iTest].R - measure->R) * cos (RAD_DEG*measure->D); 283 double dD = 3600.0*(catalog.average[iTest].D - measure->D); 284 double dRad = hypot (dR, dD); 285 char *date = ohana_sec_to_date (measure->t); 286 fprintf (stderr, "matches ave %d = %d, %s : %6.3f %5d : %f, %f = %f\n", iTest, measure->objID, date, measure->M, measure->photcode, dR, dD, dRad); 287 free (date); 288 } else { 289 fprintf (stderr, "cannot find averef\n"); 290 } 291 } 292 if (catalog.average[i].catID != catalog.measure[m+j].catID) { 293 NcatIDsBAD ++; 294 } 295 if (catalog.measure[m+j].averef != i) { 296 NaverefBAD ++; 297 } 324 298 } 325 299 } 326 300 327 if ( !objIDsOK) {328 fprintf (stderr, "ERROR: catalog %s has invalid obj IDs\n", catalog.filename);329 status = FALSE; 330 } 331 if ( !catIDsOK) {332 fprintf (stderr, "ERROR: catalog %s has invalid cat IDs\n", catalog.filename);333 status = FALSE; 334 } 335 if ( !averefOK) {336 fprintf (stderr, "ERROR: catalog %s has invalid averef values\n", catalog.filename);301 if (NobjIDsBAD) { 302 fprintf (stderr, "ERROR: catalog %s has %d invalid obj IDs\n", catalog.filename, NobjIDsBAD); 303 status = FALSE; 304 } 305 if (NcatIDsBAD) { 306 fprintf (stderr, "ERROR: catalog %s has %d invalid cat IDs\n", catalog.filename, NcatIDsBAD); 307 status = FALSE; 308 } 309 if (NaverefBAD) { 310 fprintf (stderr, "ERROR: catalog %s has %d invalid averef values\n", catalog.filename, NaverefBAD); 337 311 status = FALSE; 338 312 } … … 387 361 if (!catIDsOK) { 388 362 fprintf (stderr, "ERROR: catalog %s has invalid lensobj cat IDs\n", catalog.filename); 363 status = FALSE; 364 } 365 } 366 367 // check starpar <-> average links 368 { 369 int objIDsOK = TRUE; 370 int catIDsOK = TRUE; 371 int averefOK = TRUE; 372 373 for (i = 0; i < catalog.Naverage; i++) { 374 m = catalog.average[i].starparOffset; 375 for (j = 0; j < catalog.average[i].Nstarpar; j++) { 376 objIDsOK &= (catalog.average[i].objID == catalog.starpar[m+j].objID); 377 catIDsOK &= (catalog.average[i].catID == catalog.starpar[m+j].catID); 378 averefOK &= (catalog.starpar[m+j].averef == i); 379 } 380 } 381 382 if (!objIDsOK) { 383 fprintf (stderr, "ERROR: catalog %s has invalid starpar obj IDs\n", catalog.filename); 384 status = FALSE; 385 } 386 if (!catIDsOK) { 387 fprintf (stderr, "ERROR: catalog %s has invalid starpar cat IDs\n", catalog.filename); 388 status = FALSE; 389 } 390 if (!averefOK) { 391 fprintf (stderr, "ERROR: catalog %s has invalid starpar averef values\n", catalog.filename); 392 status = FALSE; 393 } 394 } 395 396 // check galphot <-> average links 397 { 398 int objIDsOK = TRUE; 399 int catIDsOK = TRUE; 400 int averefOK = TRUE; 401 402 for (i = 0; i < catalog.Naverage; i++) { 403 m = catalog.average[i].galphotOffset; 404 for (j = 0; j < catalog.average[i].Ngalphot; j++) { 405 objIDsOK &= (catalog.average[i].objID == catalog.galphot[m+j].objID); 406 catIDsOK &= (catalog.average[i].catID == catalog.galphot[m+j].catID); 407 averefOK &= (catalog.galphot[m+j].averef == i); 408 } 409 } 410 411 if (!objIDsOK) { 412 fprintf (stderr, "ERROR: catalog %s has invalid galphot obj IDs\n", catalog.filename); 413 status = FALSE; 414 } 415 if (!catIDsOK) { 416 fprintf (stderr, "ERROR: catalog %s has invalid galphot cat IDs\n", catalog.filename); 417 status = FALSE; 418 } 419 if (!averefOK) { 420 fprintf (stderr, "ERROR: catalog %s has invalid galphot averef values\n", catalog.filename); 389 421 status = FALSE; 390 422 } -
trunk/Ohana/src/dvomerge/src/help.c
r35590 r38986 172 172 173 173 fprintf (stderr, "USAGE\n"); 174 fprintf (stderr, " dvorepair -fix-warp-ids (catdir) (idfile) - regenerate images.dat warp_skyfile_ids (EXTERN_ID) values\n"); 174 175 fprintf (stderr, " dvorepair -fix-cpt (images) (rootlist) - regenerate cpt & cps files from the cpm files\n"); 175 176 fprintf (stderr, " dvorepair -images-vs-measures (catdir) (Ntol) - find images with too many missing detections\n"); -
trunk/Ohana/src/dvomerge/src/merge_catalogs_old.c
r38468 r38986 198 198 int Nreplace = 0; 199 199 if (REPLACE_TYCHO) { 200 int Mout = output[0].average[n].measureOffset;201 200 int Minp = input[0].average[N].measureOffset; 202 Nreplace = replace_tycho (&output[0].average[n], &output[0].measure[Mout], &input[0].average[N], &input[0].measure[Minp]);201 Nreplace = replace_tycho (&output[0].average[n], output[0].measure, next_meas, &input[0].average[N], &input[0].measure[Minp]); 203 202 if (Nreplace == 6) { 204 203 input[0].found_t[N] = Nmeas; … … 216 215 // index to first measure for this object 217 216 // XXX this does not support lensing measurements 218 int Mout = output[0].average[n].measureOffset; 219 if (replace_match(&output[0].average[n], &output[0].measure[Mout], &input[0].average[N], &input[0].measure[offset])) { 220 input[0].found_t[N] = Mout; 217 if (replace_match (&output[0].average[n], output[0].measure, next_meas, &input[0].average[N], &input[0].measure[offset])) { 218 input[0].found_t[N] = output[0].average[n].measureOffset; 221 219 continue; 222 220 } -
trunk/Ohana/src/dvomerge/src/replace_match.c
r37046 r38986 1 1 # include "dvomerge.h" 2 2 3 // XXX this function does not work because it it loops over the average->Nmeasure entries 4 // as if they were sorted, but objects which have had entries added to them have elements 5 // out of sequence. I probably need to step through next_meas to find the sequence. 6 3 7 // average and measure pointers to the objects of interest and their first / current measurement 4 int replace_match (Average *average_out, Measure *measure_out, Average *average_in, Measure *measure_in) {8 int replace_match (Average *average_out, Measure *measure_out, off_t *next_meas, Average *average_in, Measure *measure_in) { 5 9 6 10 int Nout; … … 8 12 unsigned int catID; 9 13 14 off_t m = average_out->measureOffset; 15 10 16 // find the matching photcode in the object's list of measurements 11 17 for (Nout = 0; Nout < average_out[0].Nmeasure; Nout ++) { 12 if (measure_out[Nout].photcode != measure_in[0].photcode) continue; 18 myAssert (m > -1, "oops"); 19 if (measure_out[m].photcode != measure_in[0].photcode) { 20 m = next_meas[m]; 21 continue; 22 } 13 23 14 24 // set the new measurements 15 averef = measure_out[ Nout].averef;16 catID = measure_out[ Nout].catID;17 measure_out[ Nout] = measure_in[0];25 averef = measure_out[m].averef; 26 catID = measure_out[m].catID; 27 measure_out[m] = measure_in[0]; 18 28 19 29 // old code: find R,D using average_in[0], the get offset relative to average_out[0]. no longer … … 24 34 // measure_out[Nout].dD = 3600.0*(average_out[0].D - Din); 25 35 26 measure_out[ Nout].dbFlags = 0; // XXX why reset these?27 measure_out[ Nout].averef = averef;28 measure_out[ Nout].objID = average_out[0].objID;29 measure_out[ Nout].catID = catID;36 measure_out[m].dbFlags = 0; // XXX why reset these? 37 measure_out[m].averef = averef; 38 measure_out[m].objID = average_out[0].objID; 39 measure_out[m].catID = catID; 30 40 31 float dRoff = dvoOffsetR(&measure_out[ Nout], average_out);41 float dRoff = dvoOffsetR(&measure_out[m], average_out); 32 42 33 43 // rationalize dR 34 44 if (dRoff > +180.0*3600.0) { 35 45 // average on high end of boundary, move star up 36 measure_out[ Nout].R += 360.0;46 measure_out[m].R += 360.0; 37 47 dRoff -= 360.0*3600.0; 38 48 } 39 49 if (dRoff < -180.0*3600.0) { 40 50 // average on low end of boundary, move star down 41 measure_out[ Nout].R -= 360.0;51 measure_out[m].R -= 360.0; 42 52 dRoff += 360.0*3600.0; 43 53 } … … 49 59 if (fabs(dRoff*cosD) > 10*RADIUS) { 50 60 fprintf (stderr, "surprisingly distant detection: %10.6f,%10.6f vs %10.6f,%10.6f\n", 51 average_out[0].R, average_out[0].D, measure_out[ Nout].R, measure_out[Nout].D);61 average_out[0].R, average_out[0].D, measure_out[m].R, measure_out[m].D); 52 62 } 53 63 } -
trunk/Ohana/src/dvomerge/src/replace_tycho.c
r38468 r38986 10 10 } 11 11 12 int replace_tycho (Average *averageOut, Measure *measureOut, Average *averageInp, Measure *measureInp) {12 int replace_tycho (Average *averageOut, Measure *measureOut, off_t *next_meas, Average *averageInp, Measure *measureInp) { 13 13 14 14 int i; … … 17 17 int index[6]; 18 18 19 off_t m = averageOut->measureOffset; 20 19 21 // find all tycho measurements 20 22 for (i = 0; (i < averageOut->Nmeasure) && (Nindex < 6); i++) { 21 23 24 myAssert (m > -1, "oops"); 25 22 26 int valid = FALSE; 23 valid = valid || (measureOut[i].photcode == TYCHO_B); 24 valid = valid || (measureOut[i].photcode == TYCHO_V); 25 if (!valid) continue; 26 27 index[Nindex] = i; 28 Nindex ++; 27 valid = valid || (measureOut[m].photcode == TYCHO_B); 28 valid = valid || (measureOut[m].photcode == TYCHO_V); 29 if (valid) { 30 index[Nindex] = m; 31 Nindex ++; 32 } 33 m = next_meas[m]; 29 34 } 30 35
Note:
See TracChangeset
for help on using the changeset viewer.
