- Timestamp:
- Sep 19, 2014, 4:05:27 PM (12 years ago)
- Location:
- branches/eam_branches/ps2-tc3-20130727
- Files:
-
- 30 edited
-
. (modified) (1 prop)
-
Ohana (modified) (1 prop)
-
Ohana/src/dvomerge/include/dvomerge.h (modified) (1 diff)
-
Ohana/src/dvomerge/include/dvoverify.h (modified) (1 diff)
-
Ohana/src/dvomerge/src/IDmapIO.c (modified) (1 diff)
-
Ohana/src/dvomerge/src/LoadCatalog.c (modified) (1 diff)
-
Ohana/src/dvomerge/src/build_links.c (modified) (13 diffs)
-
Ohana/src/dvomerge/src/dvo_image_merge_dbs.c (modified) (2 diffs)
-
Ohana/src/dvomerge/src/dvomergeContinue.c (modified) (1 diff)
-
Ohana/src/dvomerge/src/dvomergeContinue_threaded.c (modified) (1 diff)
-
Ohana/src/dvomerge/src/dvomergeCreate.c (modified) (1 diff)
-
Ohana/src/dvomerge/src/dvomergeFromList.c (modified) (1 diff)
-
Ohana/src/dvomerge/src/dvomergeImageIDs.c (modified) (2 diffs)
-
Ohana/src/dvomerge/src/dvomergeUpdate.c (modified) (2 diffs)
-
Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c (modified) (2 diffs)
-
Ohana/src/dvomerge/src/dvomergeUpdate_threaded.c (modified) (5 diffs)
-
Ohana/src/dvomerge/src/dvorepair.c (modified) (1 diff)
-
Ohana/src/dvomerge/src/dvorepairCPT.c (modified) (2 diffs)
-
Ohana/src/dvomerge/src/dvorepairDeleteImageList.c (modified) (3 diffs)
-
Ohana/src/dvomerge/src/dvorepairFixCPT.c (modified) (2 diffs)
-
Ohana/src/dvomerge/src/dvorepairFixTables.c (modified) (3 diffs)
-
Ohana/src/dvomerge/src/dvorepairImageVsMeasure.c (modified) (1 diff)
-
Ohana/src/dvomerge/src/dvorepairImagesVsMeasures.c (modified) (1 diff)
-
Ohana/src/dvomerge/src/dvoverify_args.c (modified) (2 diffs)
-
Ohana/src/dvomerge/src/dvoverify_catalogs.c (modified) (2 diffs)
-
Ohana/src/dvomerge/src/dvoverify_client.c (modified) (1 diff)
-
Ohana/src/dvomerge/src/dvoverify_utils.c (modified) (7 diffs)
-
Ohana/src/dvomerge/src/merge_catalogs_new.c (modified) (4 diffs)
-
Ohana/src/dvomerge/src/merge_catalogs_old.c (modified) (23 diffs)
-
Ohana/src/dvomerge/src/replace_match.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ps2-tc3-20130727
- Property svn:mergeinfo changed
-
branches/eam_branches/ps2-tc3-20130727/Ohana
- Property svn:mergeinfo changed
-
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/include/dvomerge.h
r35765 r37403 129 129 int merge_catalogs_old PROTO((SkyRegion *region, Catalog *output, Catalog *input, double RADIUS, int *secflitMap)); 130 130 131 off_t *build_measure_links PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure)); 131 132 off_t *init_measure_links PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure)); 133 int add_meas_link PROTO((Average *average, off_t *next, off_t Nmeasure, off_t NMEASURE)); 134 Measure *sort_measure PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next)); 135 136 off_t *build_lensing_links PROTO((Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing)); 137 off_t *init_lensing_links PROTO((Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing)); 138 int add_lens_link PROTO((Average *average, off_t *next, off_t Nlensing, off_t NLENSING)); 139 Lensing *sort_lensing PROTO((Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing, off_t *next)); 140 132 141 off_t *init_missing_links PROTO((Average *average, off_t Naverage, Missing *missing, off_t Nmissing)); 133 off_t *build_measure_links PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure));134 int add_meas_link PROTO((Average *average, off_t *next, off_t Nmeasure, off_t NMEASURE));135 142 int add_miss_link PROTO((Average *average, off_t *next, off_t Nmissing)); 136 Measure *sort_measure PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next));137 143 Missing *sort_missing PROTO((Average *average, off_t Naverage, Missing *missing, off_t Nmissing, off_t *next_miss)); 138 144 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/include/dvoverify.h
r34405 r37403 56 56 int LoadImageIDs (char *catdir); 57 57 int CheckImageID (Catalog *catalog); 58 59 int SaveImageIDsSmall(char *filename); 60 int LoadImageIDsSmall (char *filename); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/IDmapIO.c
r34277 r37403 27 27 gfits_create_table_header (&theader, "BINTABLE", "IMAGE_ID_MAP"); 28 28 29 gfits_define_bintable_column (&theader, "J", "OLD_IDS", "old image IDs", NULL, 1.0, 1.0*0x8000);30 gfits_define_bintable_column (&theader, "J", "NEW_IDS", "new image IDs", NULL, 1.0, 1.0*0x8000);29 gfits_define_bintable_column (&theader, "J", "OLD_IDS", "old image IDs", NULL, 1.0, FT_BZERO_INT32); 30 gfits_define_bintable_column (&theader, "J", "NEW_IDS", "new image IDs", NULL, 1.0, FT_BZERO_INT32); 31 31 32 32 // generate the output array that carries the data -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/LoadCatalog.c
r29938 r37403 8 8 9 9 // always load all of the data (if any exists) 10 catalog[0].catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF ;10 catalog[0].catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF | LOAD_LENSING | LOAD_LENSOBJ; 11 11 12 12 catalog[0].catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/build_links.c
r27435 r37403 1 1 # include "dvomerge.h" 2 3 /* 4 5 There are two modes for the measure table: sorted and unsorted. 6 7 In sorted mode, all measures associated with a given average are in a single block. The block 8 is pointed to by average->measureOffset and the range is average->Nmeasure 9 10 In unsorted mode, it is not possible to go directly from average to measure without scanning. 11 In this case, it is necessary to use the value measure->averef to find the corresponding 12 average entry. 13 14 Note that average->measureOffset and measure->averef are only valid for a given load of the 15 data: they refer to the sequence number in the data blocks. 16 17 next_meas is a list of the equivalent sequence of the measure block as if it were sorted. 18 19 to find the sequence of measurements for a given average: 20 n_0 = average->measureOffset 21 n_1 = next_meas[n_0] 22 n_i = next_meas[n_i-1] 23 24 */ 2 25 3 26 /* build the initial links assuming the table is sorted, … … 6 29 7 30 off_t i, j, N; 8 off_t *next ;31 off_t *next_meas; 9 32 10 33 N = 0; 11 34 12 ALLOCATE (next , off_t, Nmeasure);35 ALLOCATE (next_meas, off_t, Nmeasure); 13 36 for (i = 0; i < Naverage; i++, N++) { 14 37 for (j = 0; j < average[i].Nmeasure - 1; j++, N++) { 15 next [N] = N + 1;38 next_meas[N] = N + 1; 16 39 if (N >= Nmeasure) { 17 40 fprintf (stderr, "WARNING: N out of bounds (1)\n"); 18 41 } 19 42 } 20 next [N] = -1;43 next_meas[N] = -1; 21 44 if (N >= Nmeasure) { 22 45 fprintf (stderr, "WARNING: N out of bounds (2)\n"); … … 28 51 } 29 52 } 30 return (next); 31 } 32 33 /* average[].measureOffset, average[].Nmeasure are valid within an addstar run */ 34 int add_meas_link (Average *average, off_t *next, off_t Nmeasure, off_t NMEASURE) { 35 36 off_t k, m; 37 38 /* if we have trouble, check validity of next[m] : m < Nmeasure */ 39 m = average[0].measureOffset; 40 41 for (k = 0; k < average[0].Nmeasure - 1; k++) { 42 m = next[m]; 43 if (m >= NMEASURE) { 44 fprintf (stderr, "WARNING: m out of bounds (3)\n"); 45 } 46 } 47 48 /* set up references */ 49 next[Nmeasure] = -1; 50 if (Nmeasure >= NMEASURE) { 51 fprintf (stderr, "WARNING: Nmeasure out of bounds (1)\n"); 52 } 53 54 if (m == -1) { 55 average[0].measureOffset = Nmeasure; 56 } else { 57 next[m] = Nmeasure; 58 if (m >= NMEASURE) { 59 fprintf (stderr, "WARNING: m out of bounds (4)\n"); 60 } 61 } 62 63 return (TRUE); 64 } 65 66 Measure *sort_measure (Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next) { 67 68 off_t i, k, n, N; 69 Measure *tmpmeasure; 70 71 /* fix order of Measure (memory intensive, but fast) */ 72 N = 0; 73 ALLOCATE (tmpmeasure, Measure, Nmeasure); 74 for (i = 0; i < Naverage; i++) { 75 n = average[i].measureOffset; 76 average[i].measureOffset = N; 77 for (k = 0; k < average[i].Nmeasure; k++, N++) { 78 tmpmeasure[N] = measure[n]; 79 tmpmeasure[N].averef = i; 80 n = next[n]; 81 } 82 } 83 free (measure); 84 return (tmpmeasure); 53 return (next_meas); 85 54 } 86 55 … … 95 64 96 65 off_t i, m, k, Nm, averef; 97 off_t *next ;98 99 ALLOCATE (next , off_t, Nmeasure);66 off_t *next_meas; 67 68 ALLOCATE (next_meas, off_t, Nmeasure); 100 69 101 70 /* reset the Nm, offset values for average */ … … 108 77 averef = measure[Nm].averef; 109 78 m = average[averef].measureOffset; 110 next [Nm] = -1;79 next_meas[Nm] = -1; 111 80 112 81 if (m == -1) { /* no links yet for source */ … … 116 85 } 117 86 118 for (k = 0; next [m] != -1; k++) {119 m = next [m];87 for (k = 0; next_meas[m] != -1; k++) { 88 m = next_meas[m]; 120 89 if (m >= Nmeasure) { 121 90 fprintf (stderr, "WARNING: m out of bounds (1)\n"); … … 124 93 125 94 average[averef].Nmeasure = k + 2; 126 next [m] = Nm;95 next_meas[m] = Nm; 127 96 if (m >= Nmeasure) { 128 97 fprintf (stderr, "WARNING: m out of bounds (2)\n"); 129 98 } 130 99 } 131 return (next); 132 } 100 return (next_meas); 101 } 102 103 /* average[].measureOffset, average[].Nmeasure are valid within an addstar run */ 104 int add_meas_link (Average *average, off_t *next_meas, off_t Nmeasure, off_t NMEASURE) { 105 106 off_t k, m; 107 108 /* if we have trouble, check validity of next_meas[m] : m < Nmeasure */ 109 m = average[0].measureOffset; 110 111 for (k = 0; k < average[0].Nmeasure - 1; k++) { 112 m = next_meas[m]; 113 if (m >= NMEASURE) { 114 fprintf (stderr, "WARNING: m out of bounds (3)\n"); 115 } 116 } 117 118 /* set up references */ 119 next_meas[Nmeasure] = -1; 120 if (Nmeasure >= NMEASURE) { 121 fprintf (stderr, "WARNING: Nmeasure out of bounds (1)\n"); 122 } 123 124 if (m == -1) { 125 average[0].measureOffset = Nmeasure; 126 } else { 127 next_meas[m] = Nmeasure; 128 if (m >= NMEASURE) { 129 fprintf (stderr, "WARNING: m out of bounds (4)\n"); 130 } 131 } 132 133 return (TRUE); 134 } 135 136 Measure *sort_measure (Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next_meas) { 137 138 off_t i, k, n, N; 139 Measure *tmpmeasure; 140 141 /* fix order of Measure (memory intensive, but fast) */ 142 N = 0; 143 ALLOCATE (tmpmeasure, Measure, Nmeasure); 144 for (i = 0; i < Naverage; i++) { 145 n = average[i].measureOffset; 146 average[i].measureOffset = N; 147 for (k = 0; k < average[i].Nmeasure; k++, N++) { 148 if (n == -1) abort(); 149 tmpmeasure[N] = measure[n]; 150 if (measure[n].averef != i) abort(); 151 tmpmeasure[N].averef = i; 152 n = next_meas[n]; 153 } 154 } 155 free (measure); 156 return (tmpmeasure); 157 } 158 159 /*******************************************************************************************/ 133 160 134 161 /* build the initial links assuming the table is sorted */ … … 136 163 137 164 off_t i, j, N; 138 off_t *next ;165 off_t *next_miss; 139 166 140 167 N = 0; 141 168 142 ALLOCATE (next , off_t, Nmissing);169 ALLOCATE (next_miss, off_t, Nmissing); 143 170 for (i = 0; i < Naverage; i++) { 144 171 for (j = 0; j < average[i].Nmissing - 1; j++, N++) { 145 next [N] = N + 1;172 next_miss[N] = N + 1; 146 173 } 147 174 if (average[i].Nmissing > 0) { 148 next [N] = -1;175 next_miss[N] = -1; 149 176 if (N >= Nmissing) { 150 177 fprintf (stderr, "overflow in init_missing_links"); … … 155 182 156 183 } 157 return (next );158 } 159 160 int add_miss_link (Average *average, off_t *next , off_t Nmissing) {184 return (next_miss); 185 } 186 187 int add_miss_link (Average *average, off_t *next_miss, off_t Nmissing) { 161 188 162 189 off_t k, m; … … 165 192 if (average[0].Nmissing < 1) { 166 193 average[0].missingOffset = Nmissing; 167 next [Nmissing] = -1;194 next_miss[Nmissing] = -1; 168 195 return (TRUE); 169 196 } 170 197 171 198 m = average[0].missingOffset; 172 for (k = 0; k < average[0].Nmissing - 1; k++) m = next [m];199 for (k = 0; k < average[0].Nmissing - 1; k++) m = next_miss[m]; 173 200 /* set up references */ 174 next [Nmissing] = -1;175 next [m] = Nmissing;201 next_miss[Nmissing] = -1; 202 next_miss[m] = Nmissing; 176 203 return (TRUE); 177 204 } … … 180 207 we must always save the missing table, if it exists */ 181 208 182 Missing *sort_missing (Average *average, off_t Naverage, Missing *missing, off_t Nmissing, off_t *next ) {209 Missing *sort_missing (Average *average, off_t Naverage, Missing *missing, off_t Nmissing, off_t *next_miss) { 183 210 184 211 off_t i, k, n, N; … … 193 220 for (k = 0; k < average[i].Nmissing; k++, N++) { 194 221 tmpmissing[N] = missing[n]; 195 n = next [n];222 n = next_miss[n]; 196 223 } 197 224 } … … 199 226 return (tmpmissing); 200 227 } 228 229 /*******************************************************************************************/ 230 231 /* build the initial links assuming the table is sorted, 232 not partial, and has a correct set of average[].lensingOffset,Nlensing values */ 233 off_t *init_lensing_links (Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing) { 234 235 off_t i, j, N; 236 off_t *next_lens; 237 238 N = 0; 239 240 ALLOCATE (next_lens, off_t, Nlensing); 241 for (i = 0; i < Naverage; i++) { 242 if (!average[i].Nlensing) continue; 243 for (j = 0; j < average[i].Nlensing - 1; j++, N++) { 244 next_lens[N] = N + 1; 245 if (N >= Nlensing) { 246 fprintf (stderr, "WARNING: N out of bounds (1)\n"); 247 } 248 } 249 next_lens[N] = -1; 250 if (N >= Nlensing) { 251 fprintf (stderr, "WARNING: N out of bounds (2)\n"); 252 } 253 254 if (N >= Nlensing) { 255 fprintf (stderr, "overflow in init_lensing_links\n"); 256 abort (); 257 } 258 N++; 259 } 260 return (next_lens); 261 } 262 263 /* construct lensing links which are valid FOR THIS LOAD 264 * - if we have a full load, we will get links which can 265 * be used by other programs (eg, relphot, etc) 266 * - if we have a partial load, the links are only valid 267 * for that partial load 268 */ 269 270 off_t *build_lensing_links (Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing) { 271 272 off_t i, m, k, Nm, averef; 273 off_t *next_lens; 274 275 ALLOCATE (next_lens, off_t, Nlensing); 276 277 /* reset the Nm, offset values for average */ 278 for (i = 0; i < Naverage; i++) { 279 average[i].lensingOffset = -1; 280 average[i].Nlensing = 0; 281 } 282 283 for (Nm = 0; Nm < Nlensing; Nm++) { 284 averef = lensing[Nm].averef; 285 m = average[averef].lensingOffset; 286 next_lens[Nm] = -1; 287 288 if (m == -1) { /* no links yet for source */ 289 average[averef].lensingOffset = Nm; 290 average[averef].Nlensing = 1; 291 continue; 292 } 293 294 for (k = 0; next_lens[m] != -1; k++) { 295 m = next_lens[m]; 296 if (m >= Nlensing) { 297 fprintf (stderr, "WARNING: m out of bounds (1)\n"); 298 } 299 } 300 301 average[averef].Nlensing = k + 2; 302 next_lens[m] = Nm; 303 if (m >= Nlensing) { 304 fprintf (stderr, "WARNING: m out of bounds (2)\n"); 305 } 306 } 307 return (next_lens); 308 } 309 310 /* average[].lensingOffset, average[].Nlensing are valid within an addstar run */ 311 int add_lens_link (Average *average, off_t *next_lens, off_t Nlensing, off_t NLENSING) { 312 313 off_t k, m; 314 315 /* if we have trouble, check validity of next_lens[m] : m < Nlensing */ 316 m = average[0].lensingOffset; 317 318 for (k = 0; k < average[0].Nlensing - 1; k++) { 319 m = next_lens[m]; 320 if (m >= NLENSING) { 321 fprintf (stderr, "WARNING: m out of bounds (3)\n"); 322 } 323 } 324 325 /* set up references */ 326 next_lens[Nlensing] = -1; 327 if (Nlensing >= NLENSING) { 328 fprintf (stderr, "WARNING: Nlensing out of bounds (1)\n"); 329 } 330 331 if (m == -1) { 332 average[0].lensingOffset = Nlensing; 333 } else { 334 next_lens[m] = Nlensing; 335 if (m >= NLENSING) { 336 fprintf (stderr, "WARNING: m out of bounds (4)\n"); 337 } 338 } 339 340 return (TRUE); 341 } 342 343 Lensing *sort_lensing (Average *average, off_t Naverage, Lensing *lensing, off_t Nlensing, off_t *next_lens) { 344 345 off_t i, k, n, np, N; 346 Lensing *tmplensing; 347 348 /* 349 for (i = 0; i < Naverage; i++) { 350 if (average[i].Nlensing != 4) { 351 fprintf (stderr, "check %d %d %d\n", (int) i, (int) average[i].Nlensing, (int) average[i].lensingOffset); 352 } 353 } 354 */ 355 356 /* fix order of Lensing (memory intensive, but fast) */ 357 N = 0; 358 ALLOCATE (tmplensing, Lensing, Nlensing); 359 for (i = 0; i < Naverage; i++) { 360 if (!average[i].Nlensing) continue; 361 n = average[i].lensingOffset; 362 average[i].lensingOffset = N; 363 for (k = 0; k < average[i].Nlensing; k++, N++) { 364 if (n == -1) { 365 fprintf (stderr, "entry after %d has a problem\n", (int) np); 366 abort(); 367 } 368 tmplensing[N] = lensing[n]; 369 if (lensing[n].averef != i) abort(); 370 tmplensing[N].averef = i; 371 np = n; 372 n = next_lens[n]; 373 } 374 } 375 free (lensing); 376 return (tmplensing); 377 } 378 379 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c
r36680 r37403 172 172 } 173 173 174 if (!IDmap->Nmap) { 175 fprintf (stderr, "input database has image IDs, but no Image table\n"); 176 return FALSE; 177 } 178 174 179 off_t lastID = IDmap->old[IDmap->Nmap-1]; 175 180 181 // update measure.imageID 176 182 for (i = 0; i < catalog[0].Nmeasure; i++) { 177 183 oldID = catalog[0].measure[i].imageID; … … 195 201 catalog[0].measure[i].imageID = newID; 196 202 } 203 204 // also update lensing.imageID if lensing exists 205 for (i = 0; i < catalog[0].Nlensing; i++) { 206 oldID = catalog[0].lensing[i].imageID; 207 if (oldID == 0) continue; 208 209 newID = dvo_map_image_ID (IDmap, oldID); 210 if (newID == 0) { 211 if (oldID > lastID) { 212 fprintf (stderr, "problem with image IDs : input out of range\n"); 213 fprintf (stderr, "old ID: "OFF_T_FMT", last ID: "OFF_T_FMT"\n", oldID, lastID); 214 exit (2); 215 } 216 if (!IDmap->notFound[oldID]) { 217 fprintf (stderr, "cannot find image ID "OFF_T_FMT"\n", oldID); 218 IDmap->notFound[oldID] = TRUE; 219 // once we discover an imageID is not found, record that fact so we do not complain for every detection 220 } 221 // optionally exit here? or wait until end to report an error? 222 // exit (2); 223 } 224 catalog[0].lensing[i].imageID = newID; 225 } 197 226 return TRUE; 198 227 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvomergeContinue.c
r34260 r37403 131 131 merge_catalogs_old (&outsky[0].regions[j], &outcatalog, &incatalog, RADIUS, secfiltMap); 132 132 133 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;134 135 133 // if we receive a signal which would cause us to exit, wait until the full catalog is written 136 134 SetProtect (TRUE); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvomergeContinue_threaded.c
r34260 r37403 74 74 merge_catalogs_old (&threadData->outsky->regions[j], &outcatalog, &incatalog, RADIUS, threadData->secfiltMap); 75 75 76 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;77 78 76 // if we receive a signal which would cause us to exit, wait until the full catalog is written 79 77 SetProtect (TRUE); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvomergeCreate.c
r33963 r37403 178 178 SkyListFree (inlist); 179 179 180 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;181 180 dvo_catalog_save (&outcatalog, VERBOSE); 182 181 dvo_catalog_unlock (&outcatalog); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvomergeFromList.c
r35590 r37403 143 143 merge_catalogs_old (&skyregion, &outcatalog, &incatalog, RADIUS, secfiltMap); 144 144 145 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;146 147 145 dmhObjectAdd (outstat[0].history, &outcatalog.header, inStats); 148 146 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvomergeImageIDs.c
r35765 r37403 18 18 if (inDB.dbstate == LCK_EMPTY) { 19 19 dvo_image_unlock (&inDB); // unlock input 20 IDmap->old = NULL; 21 IDmap->new = NULL; 20 22 IDmap->Nmap = 0; 21 23 return TRUE; … … 99 101 if (inDB.dbstate == LCK_EMPTY) { 100 102 dvo_image_unlock (&inDB); // unlock input 103 IDmap->old = NULL; 104 IDmap->new = NULL; 101 105 IDmap->Nmap = 0; 102 106 return TRUE; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvomergeUpdate.c
r36680 r37403 13 13 int NsecfiltInput, NsecfiltOutput; 14 14 15 double dtime; 16 struct timeval start, stop; 17 gettimeofday (&start, NULL); 15 INITTIME; 18 16 19 17 CONTINUE = FALSE; … … 121 119 } 122 120 123 gettimeofday (&stop, NULL);124 dtime = DTIME (stop, start);125 126 121 if (!status) { 127 fprintf (stderr,"ERROR: elapsed time %9.4f sec\n", dtime);122 MARKTIME ("ERROR: elapsed time %9.4f sec\n", dtime); 128 123 exit (3); 129 124 } 130 125 131 fprintf (stderr,"SUCCESS: elapsed time %9.4f sec\n", dtime);126 MARKTIME ("SUCCESS: elapsed time %9.4f sec\n", dtime); 132 127 exit (0); 133 128 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c
r36680 r37403 140 140 } 141 141 142 if (!incatalog.sorted) { 143 fprintf (stderr, "ERROR: input catalog %s is not sorted (and must be for dvomerge)\n", filename_input); 144 exit (1); 145 } 146 142 147 dvo_update_image_IDs (IDmap, &incatalog); 143 148 … … 158 163 LoadCatalog (&outcatalog, outlist[0].regions[j], outcatalog.filename, "w", NsecfiltOutput); 159 164 165 // if no catalog already exists, use the input catalog to define the format 166 if (outcatalog.Naves_disk == 0) { 167 outcatalog.catformat = incatalog.catformat; 168 } 169 160 170 merge_catalogs_old (outlist[0].regions[j], &outcatalog, &incatalog, RADIUS, secfiltMap); 161 162 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;163 171 164 172 if (outstat[j].missed) { -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvomergeUpdate_threaded.c
r35765 r37403 72 72 merge_catalogs_old (&threadData->outsky->regions[j], &outcatalog, &incatalog, RADIUS, threadData->secfiltMap); 73 73 74 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;75 76 74 // if we receive a signal which would cause us to exit, wait until the full catalog is written 77 75 SetProtect (TRUE); … … 115 113 int NsecfiltInput, NsecfiltOutput; 116 114 117 double dtime; 118 struct timeval start, stop; 119 gettimeofday (&start, NULL); 115 INITTIME; 120 116 121 117 CONTINUE = FALSE; … … 134 130 135 131 fprintf (stderr, "WARNING / ERROR : multi-threaded dvomerge does not handle merge tracking yet\n"); 132 fprintf (stderr, "WARNING / ERROR : multi-threaded dvomerge does work in a parallel context\n"); 136 133 exit (2); 137 134 … … 293 290 } 294 291 295 gettimeofday (&stop, NULL); 296 dtime = DTIME (stop, start); 297 fprintf (stderr, "SUCCESS: elapsed time %9.4f sec\n", dtime); 298 292 MARKTIME ("SUCCESS: elapsed time %9.4f sec\n", dtime); 299 293 exit (0); 300 294 … … 318 312 } 319 313 } 314 MARKTIME ("ERROR: elapsed time %9.4f sec\n", dtime); 320 315 exit (1); 321 316 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvorepair.c
r29938 r37403 2 2 3 3 int main (int argc, char **argv) { 4 5 fprintf (stderr, "this program needs to be updated to load old format Measure tables (pre PV1_V5) in which dR,dD are saved, not R,D\n"); 6 fprintf (stderr, "reminder: relastro can re-construct R,D from X,Y; FtableToMeasure and vice versa could just NAN those values\n"); 7 exit (2); 4 8 5 9 dvorepair_help(argc, argv); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvorepairCPT.c
r33657 r37403 76 76 } 77 77 78 measure = FtableToMeasure (&cpmFtable, &Nmeasure, &catformat);78 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat); 79 79 myAssert(measure, "failed to convert ftable to measure data"); 80 80 … … 126 126 average[Nave].measureOffset = -1; 127 127 average[Nave].missingOffset = -1; 128 average[Nave].extendOffset = -1; 128 average[Nave].refColorBlue = NAN; 129 average[Nave].refColorRed = NAN; 129 130 130 131 average[Nave].objID = measure[i].objID; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvorepairDeleteImageList.c
r29938 r37403 250 250 gfits_scan(&cpmHeaderTBL, "NAXIS1", "%d", 1, &NbytesPerRow); 251 251 252 measure = FtableToMeasure (&cpmFtable, &Nmeasure, &catformat);252 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat); 253 253 myAssert(measure, "failed to convert ftable to measure data"); 254 254 … … 288 288 289 289 // convert internal to external format 290 if (!MeasureToFtable (&cpmFtable, measureNew, NmeasureNew, catformat)) {290 if (!MeasureToFtable (&cpmFtable, NULL, measureNew, NmeasureNew, catformat)) { 291 291 myAbort("trouble converting format"); 292 292 } … … 411 411 average[Nave].measureOffset = -1; 412 412 average[Nave].missingOffset = -1; 413 average[Nave].extendOffset = -1; 413 average[Nave].refColorBlue = NAN; 414 average[Nave].refColorRed = NAN; 414 415 415 416 average[Nave].objID = measure[i].objID; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvorepairFixCPT.c
r29938 r37403 120 120 } 121 121 122 measure = FtableToMeasure (&cpmFtable, &Nmeasure, &catformat);122 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat); 123 123 myAssert(measure, "failed to convert ftable to measure data"); 124 124 … … 127 127 128 128 // convert internal to external format 129 if (!MeasureToFtable (&cpmFtable, measure, Nmeasure, catformat)) {129 if (!MeasureToFtable (&cpmFtable, NULL, measure, Nmeasure, catformat)) { 130 130 myAbort("trouble converting format"); 131 131 } -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvorepairFixTables.c
r29938 r37403 103 103 104 104 // convert internal to external format 105 if (!MeasureToFtable (&cpmFtable, measureNew, NmeasureNew, catformat)) {105 if (!MeasureToFtable (&cpmFtable, NULL, measureNew, NmeasureNew, catformat)) { 106 106 myAbort("trouble converting format"); 107 107 } … … 183 183 gfits_scan(&cpmHeaderTBL, "NAXIS2", "%d", 1, &Nrows); 184 184 185 measure = FtableToMeasure (&cpmFtable, &Nmeasure, &catformat);185 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat); 186 186 myAssert(measure, "failed to convert ftable to measure data"); 187 187 … … 266 266 average[Nave].measureOffset = -1; 267 267 average[Nave].missingOffset = -1; 268 average[Nave].extendOffset = -1; 268 average[Nave].refColorBlue = NAN; 269 average[Nave].refColorRef = NAN; 269 270 270 271 average[Nave].objID = measure[i].objID; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvorepairImageVsMeasure.c
r33657 r37403 128 128 gfits_scan(&cpmHeaderTBL, "NAXIS1", "%d", 1, &NbytesPerRow); 129 129 130 measure = FtableToMeasure (&cpmFtable, &Nmeasure, &catformat);130 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat); 131 131 myAssert(measure, "failed to convert ftable to measure data"); 132 132 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvorepairImagesVsMeasures.c
r29938 r37403 134 134 gfits_scan(&cpmHeaderTBL, "NAXIS1", "%d", 1, &NbytesPerRow); 135 135 136 measure = FtableToMeasure (&cpmFtable, &Nmeasure, &catformat);136 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat); 137 137 myAssert(measure, "failed to convert ftable to measure data"); 138 138 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvoverify_args.c
r36680 r37403 56 56 } 57 57 58 /*** dvoverify -parallel (dvoverify_client, actually) ignores this argument 59 dvoverify should save a subset table of just the IDs, and dvoverify_client should load it 60 dvoverify -cpt should have CHECK_IMAGE_ID = F as default ***/ 58 /*** dvoverify -cpt should have CHECK_IMAGE_ID = F as default ***/ 61 59 62 60 CHECK_IMAGE_ID = TRUE; … … 150 148 } 151 149 150 CHECK_IMAGE_ID = TRUE; 151 if ((N = get_argument (*argc, argv, "-skip-image-ids"))) { 152 CHECK_IMAGE_ID = FALSE; 153 remove_argument (N, argc, argv); 154 } 155 152 156 // restrict to a portion of the sky 153 157 UserPatch.Rmin = 0; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvoverify_catalogs.c
r36680 r37403 47 47 } 48 48 49 sprintf (filename, "%s/%s.cpx", mycatdir, skylist[0].regions[i][0].name); 50 if (!VerifyTableFile (filename)) { 51 Nbad ++; 52 skipIndexCheck = TRUE; 53 AddFailures (filename); 54 } 55 56 sprintf (filename, "%s/%s.cpy", mycatdir, skylist[0].regions[i][0].name); 57 if (!VerifyTableFile (filename)) { 58 Nbad ++; 59 skipIndexCheck = TRUE; 60 AddFailures (filename); 61 } 62 49 63 sprintf (filename, "%s/%s.cpt", mycatdir, skylist[0].regions[i][0].name); 50 64 if (!skipIndexCheck) { … … 80 94 exit (1); 81 95 } 96 97 // save the IDlist as a smaller FITS table 98 if (CHECK_IMAGE_ID) { 99 char filename[DVO_MAX_PATH]; 100 snprintf (filename, DVO_MAX_PATH, "%s/ImageIDs.fits", CATDIR); 101 if (!SaveImageIDsSmall (filename)) { 102 fprintf (stderr, "ERROR: failure to save image IDs\n"); 103 exit (2); 104 } 105 } 82 106 83 107 int i; -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvoverify_client.c
r34405 r37403 22 22 // XXX in client mode, we should be reading a reduced table generated by the calling 23 23 // serial program 24 LoadImageIDs (CATDIR); 24 char filename[DVO_MAX_PATH]; 25 snprintf (filename, DVO_MAX_PATH, "%s/ImageIDs.fits", CATDIR); 26 if (!LoadImageIDsSmall (filename)) { 27 fprintf (stderr, "ERROR: failure to load image IDs\n"); 28 exit (2); 29 } 25 30 } 26 31 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/dvoverify_utils.c
r36680 r37403 178 178 catalog.catformat = DVO_FORMAT_UNDEF; // read-only,do not set the catformat 179 179 catalog.catmode = DVO_MODE_UNDEF; // read-only, do not set the catmode 180 catalog.catflags = LOAD_AVES | LOAD_MEAS ;180 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_LENSING | LOAD_LENSOBJ; 181 181 catalog.Nsecfilt = 0; 182 182 … … 214 214 int NmeasureTotal = 0; 215 215 int measureOffsetOK = TRUE; 216 int NlensingTotal = 0; 217 int lensingOffsetOK = TRUE; 218 int NlensobjTotal = 0; 219 int lensobjOffsetOK = TRUE; 216 220 for (i = 0; i < catalog.Naverage; i++) { 217 221 NmeasureTotal += catalog.average[i].Nmeasure; … … 227 231 fprintf (stderr, "measureOffset + Nmeasure > catalog.Nmeasure : %d %d %d\n", i, catalog.average[i].Nmeasure, (int) catalog.Nmeasure); 228 232 } 233 234 // sum of Nlensing for each object < Nlensing for catalog 235 NlensingTotal += catalog.average[i].Nlensing; 236 if (VERBOSE && !(NlensingTotal <= catalog.Nlensing)) { 237 fprintf (stderr, "NlensingTotal > catalog.Nlensing: %d %d %d\n", i, catalog.average[i].Nlensing, (int) catalog.Nlensing); 238 } 239 // lensingOffset needs to be in range for each object 240 lensingOffsetOK &= (catalog.average[i].lensingOffset < catalog.Nlensing); 241 if (VERBOSE && !(catalog.average[i].lensingOffset < catalog.Nlensing)) { 242 fprintf (stderr, "lensingOffset >= catalog.Nlensing: %d %d %d\n", i, catalog.average[i].lensingOffset, (int) catalog.Nlensing); 243 } 244 lensingOffsetOK &= (catalog.average[i].lensingOffset + catalog.average[i].Nlensing <= catalog.Nlensing); 245 if (VERBOSE && !(catalog.average[i].lensingOffset + catalog.average[i].Nlensing <= catalog.Nlensing)) { 246 fprintf (stderr, "lensingOffset + Nlensing > catalog.Nlensing : %d %d %d\n", i, catalog.average[i].Nlensing, (int) catalog.Nlensing); 247 } 248 249 NlensobjTotal += catalog.average[i].Nlensobj; 250 if (VERBOSE && !(NlensobjTotal <= catalog.Nlensobj)) { 251 fprintf (stderr, "NlensobjTotal > catalog.Nlensobj: %d %d %d\n", i, catalog.average[i].Nlensobj, (int) catalog.Nlensobj); 252 } 253 lensobjOffsetOK &= (catalog.average[i].lensobjOffset < catalog.Nlensobj); 254 if (VERBOSE && !(catalog.average[i].lensobjOffset < catalog.Nlensobj)) { 255 fprintf (stderr, "lensobjOffset >= catalog.Nlensobj: %d %d %d\n", i, catalog.average[i].lensobjOffset, (int) catalog.Nlensobj); 256 } 257 lensobjOffsetOK &= (catalog.average[i].lensobjOffset + catalog.average[i].Nlensobj <= catalog.Nlensobj); 258 if (VERBOSE && !(catalog.average[i].lensobjOffset + catalog.average[i].Nlensobj <= catalog.Nlensobj)) { 259 fprintf (stderr, "lensobjOffset + Nlensobj > catalog.Nlensobj : %d %d %d\n", i, catalog.average[i].Nlensobj, (int) catalog.Nlensobj); 260 } 229 261 } 230 262 … … 236 268 if (NmeasureTotal != catalog.Nmeasure) { 237 269 fprintf (stderr, "ERROR: catalog %s has an invalid Nmeasure\n", catalog.filename); 270 status = FALSE; 271 } 272 273 if (!lensingOffsetOK) { 274 fprintf (stderr, "ERROR: catalog %s has an invalid lensingOffset\n", catalog.filename); 275 status = FALSE; 276 } 277 278 if (NlensingTotal != catalog.Nlensing) { 279 fprintf (stderr, "ERROR: catalog %s has an invalid Nlensing\n", catalog.filename); 280 status = FALSE; 281 } 282 283 if (!lensobjOffsetOK) { 284 fprintf (stderr, "ERROR: catalog %s has an invalid lensobjOffset\n", catalog.filename); 285 status = FALSE; 286 } 287 288 if (NlensobjTotal != catalog.Nlensobj) { 289 fprintf (stderr, "ERROR: catalog %s has an invalid Nlensobj\n", catalog.filename); 238 290 status = FALSE; 239 291 } … … 247 299 } 248 300 249 int objIDsOK = TRUE; 250 int catIDsOK = TRUE; 251 int averefOK = TRUE; 252 253 for (i = 0; i < catalog.Naverage; i++) { 254 m = catalog.average[i].measureOffset; 255 for (j = 0; j < catalog.average[i].Nmeasure; j++) { 256 objIDsOK &= (catalog.average[i].objID == catalog.measure[m+j].objID); 257 catIDsOK &= (catalog.average[i].catID == catalog.measure[m+j].catID); 258 averefOK &= (catalog.measure[m+j].averef == i); 259 } 260 } 301 // check measure <-> average links 302 { 303 int objIDsOK = TRUE; 304 int catIDsOK = TRUE; 305 int averefOK = TRUE; 306 307 for (i = 0; i < catalog.Naverage; i++) { 308 m = catalog.average[i].measureOffset; 309 for (j = 0; j < catalog.average[i].Nmeasure; j++) { 310 objIDsOK &= (catalog.average[i].objID == catalog.measure[m+j].objID); 311 catIDsOK &= (catalog.average[i].catID == catalog.measure[m+j].catID); 312 averefOK &= (catalog.measure[m+j].averef == i); 313 } 314 } 261 315 262 if (!objIDsOK) { 263 fprintf (stderr, "ERROR: catalog %s has invalid obj IDs\n", catalog.filename); 264 status = FALSE; 265 } 266 if (!catIDsOK) { 267 fprintf (stderr, "ERROR: catalog %s has invalid cat IDs\n", catalog.filename); 268 status = FALSE; 269 } 270 if (!averefOK) { 271 fprintf (stderr, "ERROR: catalog %s has invalid averef values\n", catalog.filename); 272 status = FALSE; 316 if (!objIDsOK) { 317 fprintf (stderr, "ERROR: catalog %s has invalid obj IDs\n", catalog.filename); 318 status = FALSE; 319 } 320 if (!catIDsOK) { 321 fprintf (stderr, "ERROR: catalog %s has invalid cat IDs\n", catalog.filename); 322 status = FALSE; 323 } 324 if (!averefOK) { 325 fprintf (stderr, "ERROR: catalog %s has invalid averef values\n", catalog.filename); 326 status = FALSE; 327 } 328 } 329 330 // check lensing <-> average links 331 { 332 int objIDsOK = TRUE; 333 int catIDsOK = TRUE; 334 int averefOK = TRUE; 335 336 for (i = 0; i < catalog.Naverage; i++) { 337 m = catalog.average[i].lensingOffset; 338 for (j = 0; j < catalog.average[i].Nlensing; j++) { 339 objIDsOK &= (catalog.average[i].objID == catalog.lensing[m+j].objID); 340 catIDsOK &= (catalog.average[i].catID == catalog.lensing[m+j].catID); 341 averefOK &= (catalog.lensing[m+j].averef == i); 342 } 343 } 344 345 if (!objIDsOK) { 346 fprintf (stderr, "ERROR: catalog %s has invalid lensing obj IDs\n", catalog.filename); 347 status = FALSE; 348 } 349 if (!catIDsOK) { 350 fprintf (stderr, "ERROR: catalog %s has invalid lensing cat IDs\n", catalog.filename); 351 status = FALSE; 352 } 353 if (!averefOK) { 354 fprintf (stderr, "ERROR: catalog %s has invalid lensing averef values\n", catalog.filename); 355 status = FALSE; 356 } 357 } 358 359 // check lensobj <-> average links 360 { 361 int objIDsOK = TRUE; 362 int catIDsOK = TRUE; 363 364 for (i = 0; i < catalog.Naverage; i++) { 365 m = catalog.average[i].lensobjOffset; 366 for (j = 0; j < catalog.average[i].Nlensobj; j++) { 367 objIDsOK &= (catalog.average[i].objID == catalog.lensobj[m+j].objID); 368 catIDsOK &= (catalog.average[i].catID == catalog.lensobj[m+j].catID); 369 } 370 } 371 372 if (!objIDsOK) { 373 fprintf (stderr, "ERROR: catalog %s has invalid lensobj obj IDs\n", catalog.filename); 374 status = FALSE; 375 } 376 if (!catIDsOK) { 377 fprintf (stderr, "ERROR: catalog %s has invalid lensobj cat IDs\n", catalog.filename); 378 status = FALSE; 379 } 273 380 } 274 381 … … 321 428 } 322 429 } 430 431 for (i = 0; i < catalog[0].Naverage; i++) { 432 m = catalog[0].average[i].lensingOffset; 433 for (j = 0; j < catalog[0].average[i].Nlensing; j++) { 434 id = catalog[0].lensing[m+j].imageID; 435 if (id == 0) continue; // detections from ref photcodes can (should) have unset image IDs 436 if (id > maxID) { 437 Nfail ++; 438 continue; 439 // is this sufficient to catch IDs set without an image table? 440 } 441 if (IDlist) { 442 if (IDlist[id] < 0) { 443 Nfail ++; 444 continue; 445 } 446 } else { 447 if (id > 0) { 448 Nfail ++; 449 continue; 450 } 451 } 452 } 453 } 454 323 455 return Nfail; 324 456 } … … 382 514 return TRUE; 383 515 } 516 517 # define GET_COLUMN(OUT,NAME,TYPE) \ 518 OUT = gfits_get_bintable_column_data (&theader, &ftable, NAME, type, &Nrow, &Ncol); \ 519 myAssert (!strcmp(type, #TYPE), "wrong column type"); 520 521 // STATUS is value expected for success 522 # define CHECK_STATUS(STATUS,MSG,...) \ 523 if (!(STATUS)) { \ 524 fprintf (stderr, MSG, __VA_ARGS__); \ 525 return FALSE; \ 526 } 527 528 // write out the IDmap data for clients to read 529 int SaveImageIDsSmall(char *filename) { 530 531 Header header; 532 Header theader; 533 Matrix matrix; 534 FTable ftable; 535 536 gfits_init_header (&header); 537 header.extend = TRUE; 538 gfits_create_header (&header); 539 gfits_create_matrix (&header, &matrix); 540 541 gfits_create_table_header (&theader, "BINTABLE", "IMAGE_IDS"); 542 543 gfits_define_bintable_column (&theader, "J", "IMAGE_IDS", "image IDs", NULL, 1.0, FT_BZERO_INT32); 544 545 // generate the output array that carries the data 546 gfits_create_table (&theader, &ftable); 547 548 // add the columns to the output array 549 gfits_set_bintable_column (&theader, &ftable, "IMAGE_IDS", IDlist, maxID + 1); 550 551 FILE *f = fopen (filename, "w"); 552 if (!f) { 553 fprintf (stderr, "ERROR: cannot open image ID file for output %s\n", filename); 554 return FALSE; 555 } 556 557 int status; 558 status = gfits_fwrite_header (f, &header); 559 CHECK_STATUS (status, "ERROR: cannot write header for image ID file %s\n", filename); 560 561 status = gfits_fwrite_matrix (f, &matrix); 562 CHECK_STATUS (status, "ERROR: cannot write matrix for image ID file %s\n", filename); 563 564 status = gfits_fwrite_Theader (f, &theader); 565 CHECK_STATUS (status, "ERROR: cannot write table header for image ID file %s\n", filename); 566 567 status = gfits_fwrite_table (f, &ftable); 568 CHECK_STATUS (status, "ERROR: cannot write table data for image ID file %s\n", filename); 569 570 gfits_free_header (&header); 571 gfits_free_matrix (&matrix); 572 gfits_free_header (&theader); 573 gfits_free_table (&ftable); 574 575 int fd = fileno (f); 576 577 status = fflush (f); 578 CHECK_STATUS (!status, "ERROR: cannot flush file image ID file %s\n", filename); 579 580 status = fsync (fd); 581 CHECK_STATUS (!status, "ERROR: cannot flush file image ID file %s\n", filename); 582 583 status = fclose (f); 584 CHECK_STATUS (!status, "ERROR: problem closing image ID file file %s\n", filename); 585 586 return TRUE; 587 } 588 589 int LoadImageIDsSmall (char *filename) { 590 591 int Ncol; 592 off_t Nrow; 593 Header header; 594 Header theader; 595 Matrix matrix; 596 FTable ftable; 597 598 FILE *f = fopen (filename, "r"); 599 if (!f) { 600 fprintf (stderr, "ERROR: cannot open image subset file %s\n", filename); 601 return FALSE; 602 } 603 604 /* load in PHU segment (ignore) */ 605 if (!gfits_fread_header (f, &header)) { 606 if (VERBOSE) fprintf (stderr, "can't read image subset header\n"); 607 fclose (f); 608 return FALSE; 609 } 610 if (!gfits_fread_matrix (f, &matrix, &header)) { 611 if (VERBOSE) fprintf (stderr, "can't read image subset matrix\n"); 612 gfits_free_header (&header); 613 fclose (f); 614 return FALSE; 615 } 616 617 ftable.header = &theader; 618 619 // load data for this header 620 if (!gfits_load_header (f, &theader)) { 621 fclose (f); 622 return FALSE; 623 } 624 625 // read the fits table bytes 626 if (!gfits_fread_ftable_data (f, &ftable, FALSE)) { 627 fclose (f); 628 return FALSE; 629 } 630 fclose (f); 631 632 char type[16]; 633 634 GET_COLUMN (IDlist, "IMAGE_IDS", int); 635 maxID = Nrow - 1; 636 fprintf (stderr, "loaded data for %lld images\n", (long long) Nrow); 637 638 return TRUE; 639 } 640 -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/merge_catalogs_new.c
r28855 r37403 8 8 // input entries always define new objects 9 9 10 #define notyet 111 12 10 int merge_catalogs_new (SkyRegion *region, Catalog *output, Catalog *input, int *secfiltMap) { 13 11 14 12 off_t i, j, offset; 15 off_t NAVERAGE, NMEASURE, N average, Nmeasure, NsecfiltIn, NsecfiltOut, Nm;13 off_t NAVERAGE, NMEASURE, NLENSING, Naverage, Nmeasure, Nlensing, NsecfiltIn, NsecfiltOut, Nm; 16 14 17 15 Naverage = output[0].Naverage; … … 63 61 } 64 62 output[0].average[Naverage].Nmeasure = Nm; 63 64 Nm = 0; 65 for (j = 0; j < input[0].average[i].Nlensing; j++) { 66 offset = input[0].average[i].lensingOffset + j; 67 68 output[0].lensing[Nlensing] = input[0].lensing[offset]; 69 output[0].lensing[Nlensing].averef = Naverage; 70 71 Nlensing ++; 72 Nm ++; 73 if (Nlensing == NLENSING) { 74 NLENSING += 1000; 75 REALLOCATE (output[0].lensing, Lensing, NLENSING); 76 } 77 } 78 output[0].average[Naverage].Nlensing = Nm; 79 65 80 Naverage ++; 66 81 if (Naverage == NAVERAGE) { … … 72 87 REALLOCATE (output[0].average, Average, MAX (Naverage, 1)); 73 88 REALLOCATE (output[0].measure, Measure, MAX (Nmeasure, 1)); 89 REALLOCATE (output[0].lensing, Lensing, MAX (Nlensing, 1)); 74 90 REALLOCATE (output[0].secfilt, SecFilt, NsecfiltOut*MAX (Naverage, 1)); 75 91 output[0].Naverage = Naverage; 76 output[0].N measure = Nmeasure;92 output[0].Nlensing = Nlensing; 77 93 output[0].Nsecf_mem = Naverage * NsecfiltOut; 78 94 … … 84 100 85 101 if (VERBOSE) { 86 fprintf (stderr, OFF_T_FMT": using "OFF_T_FMT" stars ("OFF_T_FMT" measures ) for catalog\n",102 fprintf (stderr, OFF_T_FMT": using "OFF_T_FMT" stars ("OFF_T_FMT" measures, "OFF_T_FMT" lensing) for catalog\n", 87 103 i, 88 104 output[0].Naverage, 89 output[0].Nmeasure); 105 output[0].Nmeasure, 106 output[0].Nlensing); 90 107 } 91 108 return (TRUE); -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/merge_catalogs_old.c
r36680 r37403 1 1 # include "dvomerge.h" 2 2 # define PSPS_ID TRUE 3 4 # define MARKTIME(MSG,...) { \5 float dtime; \6 gettimeofday (&stop, (void *) NULL); \7 dtime = DTIME (stop, start); \8 fprintf (stderr, MSG, __VA_ARGS__); \9 gettimeofday (&start, (void *) NULL); \10 }11 3 12 4 # define IN_REGION(R,D) ( \ … … 19 11 20 12 off_t i, j, k, Nin, offset, J, Jmin, status, Nstars; 21 double RADIUS2, Rmin , Rin, Din;13 double RADIUS2, Rmin; 22 14 double *X1, *Y1, *X2, *Y2; 23 15 double dX, dY, dR; 24 off_t *N1, *N2, *next_meas;25 off_t Nave, NAVE, Nmeas, NMEAS, Nmatch ;16 off_t *N1, *N2, *next_meas, *next_lens; 17 off_t Nave, NAVE, Nmeas, NMEAS, Nmatch, Nlens, NLENS; 26 18 int NsecfiltIn; 27 19 int NsecfiltOut; … … 29 21 Coords tcoords; 30 22 31 // struct timeval start, stop; 32 // gettimeofday (&start, (void *) NULL); 23 // INITTIME; 33 24 34 25 NsecfiltOut = output[0].Nsecfilt; … … 40 31 ALLOCATE (Y1, double, input[0].Naverage); 41 32 ALLOCATE (N1, off_t, input[0].Naverage); 42 ALLOCATE (input[0].found, off_t, input[0].Naverage); 33 if (!input[0].found_t) { 34 ALLOCATE (input[0].found_t, off_t, input[0].Naverage); 35 } else { 36 REALLOCATE (input[0].found_t, off_t, input[0].Naverage); 37 } 43 38 44 39 /** allocate local arrays (catalog) **/ … … 47 42 ALLOCATE (Y2, double, NAVE); 48 43 ALLOCATE (N2, off_t, NAVE); 49 ALLOCATE (output[0].found, off_t, NAVE); 44 if (!output[0].found_t) { 45 ALLOCATE (output[0].found_t, off_t, NAVE); 46 } else { 47 REALLOCATE (output[0].found_t, off_t, NAVE); 48 } 50 49 /* for secfilt j and star i, secfilt[i*Nsecfilt+j] */ 51 50 … … 53 52 Nmatch = 0; 54 53 NMEAS = Nmeas = output[0].Nmeasure; 54 NLENS = Nlens = output[0].Nlensing; 55 55 56 56 // current max obj ID for this catalog … … 87 87 N1[Nstars] = i; 88 88 Nstars ++; 89 input[0].found [i] = -1;89 input[0].found_t[i] = -1; 90 90 } 91 91 if (Nstars < 1) { 92 92 if (VERBOSE) fprintf (stderr, "skipping %s, no overlapping stars\n", output[0].filename); 93 free (output[0].found);94 free (input[0].found);95 93 free (X1); 96 94 free (Y1); … … 106 104 for (i = 0; i < Nave; i++) { 107 105 RD_to_XY (&X2[i], &Y2[i], output[0].average[i].R, output[0].average[i].D, &tcoords); 108 output[0].found [i] = -1;106 output[0].found_t[i] = -1; 109 107 N2[i] = i; 110 108 } … … 115 113 exit (3); 116 114 } 117 118 115 119 116 /* set up pointers for linked list of measure */ … … 122 119 // is sorted while processed 123 120 next_meas = init_measure_links (output[0].average, Nave, output[0].measure, Nmeas); 121 next_lens = init_lensing_links (output[0].average, Nave, output[0].lensing, Nlens); 124 122 } else { 125 123 next_meas = build_measure_links (output[0].average, Nave, output[0].measure, Nmeas); 124 next_lens = build_lensing_links (output[0].average, Nave, output[0].lensing, Nlens); 126 125 } 127 126 … … 185 184 REALLOCATE (output[0].measure, Measure, NMEAS); 186 185 } 186 if (Nlens + input[0].average[N].Nmeasure >= NLENS) { 187 NLENS = Nlens + input[0].average[N].Nmeasure + 1000; 188 REALLOCATE (next_lens, off_t, NLENS); 189 REALLOCATE (output[0].lensing, Lensing, NLENS); 190 } 187 191 188 192 // 4) average properties from the input and the output db need to be properly merged. … … 194 198 if (REPLACE_BY_PHOTCODE) { 195 199 // index to first measure for this object 200 // XXX this does not support lensing measurements 196 201 int Mout = output[0].average[n].measureOffset; 197 202 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;203 input[0].found_t[N] = Mout; 199 204 continue; 200 205 } … … 206 211 output[0].measure[Nmeas] = input[0].measure[offset]; 207 212 208 Rin = input[0].average[N].R - input[0].measure[offset].dR / 3600.0; 209 Din = input[0].average[N].D - input[0].measure[offset].dD / 3600.0; 210 211 /** dR,dD now represent arcsec **/ 212 output[0].measure[Nmeas].dR = 3600.0*(output[0].average[n].R - Rin); // XXX update these based on choice of astromety 213 output[0].measure[Nmeas].dD = 3600.0*(output[0].average[n].D - Din); // XXX update these based on choice of astromety 213 // old code: find R,D using average_in[0], the get offset relative to average_out[0]. no longer 214 // needed since we carry around R,D 215 // Rin = input[0].average[N].R - input[0].measure[offset].dR / 3600.0; 216 // Din = input[0].average[N].D - input[0].measure[offset].dD / 3600.0; 217 // output[0].measure[Nmeas].dR = 3600.0*(output[0].average[n].R - Rin); 218 // output[0].measure[Nmeas].dD = 3600.0*(output[0].average[n].D - Din); 219 214 220 output[0].measure[Nmeas].dbFlags = 0; // XXX why reset these? 215 221 output[0].measure[Nmeas].averef = n; … … 221 227 // fprintf (stderr, "Nave : "OFF_T_FMT", Nmeas : "OFF_T_FMT", dR: %f, dD: %f, catID: %d\n", n, Nmeas, output[0].measure[Nmeas].dR, output[0].measure[Nmeas].dD, output[0].measure[i].catID); 222 228 223 // rationalize dR 224 if (output[0].measure[Nmeas].dR > +180.0*3600.0) { 229 float dRoff = dvoOffsetR(&output[0].measure[Nmeas], &output[0].average[n]); 230 231 // rationalize R 232 if (dRoff > +180.0*3600.0) { 225 233 // average on high end of boundary, move star up 226 Rin+= 360.0;227 output[0].measure[Nmeas].dR = 3600.0*(output[0].average[n].R - Rin);228 } 229 if ( output[0].measure[Nmeas].dR< -180.0*3600.0) {234 output[0].measure[Nmeas].R += 360.0; 235 dRoff -= 360.0*3600.0; 236 } 237 if (dRoff < -180.0*3600.0) { 230 238 // average on low end of boundary, move star down 231 Rin -= 360.0; 232 output[0].measure[Nmeas].dR = 3600.0*(output[0].average[n].R - Rin); 233 } 234 if (fabs(output[0].measure[Nmeas].dR) > 10*RADIUS) { 235 // ok take declination into account and check again. 236 double cosD = cos(RAD_DEG*Din); 237 if (fabs(output[0].measure[Nmeas].dR*cosD) > 10*RADIUS) { 238 239 fprintf (stderr, "error: %10.6f,%10.6f vs %10.6f,%10.6f (%f,%f vs %f,%f)\n", 240 output[0].average[n].R, output[0].average[n].D, Rin, Din, 241 X1[i], X2[Jmin], Y1[i], Y2[Jmin]); 242 243 // XXX abort on this? -- this is a bad failure... 239 output[0].measure[Nmeas].R -= 360.0; 240 dRoff += 360.0*3600.0; 241 } 242 if (fabs(dRoff) > 10*RADIUS) { 243 // take declination into account and check again. 244 double cosD = cos(RAD_DEG*output[0].average[n].D); 245 if (fabs(dRoff*cosD) > 10*RADIUS) { 246 fprintf (stderr, "error: %10.6f,%10.6f vs %10.6f,%10.6f (%f,%f vs %f,%f)\n", 247 output[0].average[n].R, output[0].average[n].D, 248 output[0].measure[Nmeas].R, output[0].measure[Nmeas].D, 249 X1[i], X2[Jmin], Y1[i], Y2[Jmin]); 250 // XXX abort on this? -- this is a bad failure... 244 251 } 245 252 } 246 input[0].found [N] = Nmeas;253 input[0].found_t[N] = Nmeas; 247 254 output[0].average[n].Nmeasure ++; 248 255 Nmeas ++; 256 } 257 258 // if lensing measurements exist, add them too 259 if (output[0].lensing) { 260 for (Nin = 0; Nin < input[0].average[N].Nlensing; Nin++) { 261 /* add to end of lensing list */ 262 add_lens_link (&output[0].average[n], next_lens, Nlens, NLENS); 263 264 // set the new lensing 265 off_t lensoff = input[0].average[N].lensingOffset + Nin; 266 output[0].lensing[Nlens] = input[0].lensing[lensoff]; 267 268 output[0].lensing[Nlens].averef = n; 269 output[0].lensing[Nlens].objID = output[0].average[n].objID; 270 output[0].lensing[Nlens].catID = output[0].catID; 271 output[0].average[n].Nlensing ++; 272 Nlens ++; 273 } 249 274 } 250 275 … … 273 298 /* Nm is updated, but not written out in -update mode (for existing entries) 274 299 Nm is recalculated in build_meas_links if loaded table is not sorted */ 275 output[0].found [n] = Nmeas;300 output[0].found_t[n] = Nmeas; 276 301 i++; 277 302 } … … 289 314 REALLOCATE (output[0].measure, Measure, NMEAS); 290 315 } 316 if (Nlens + input[0].average[N].Nlensing >= NLENS) { 317 NLENS = Nlens + input[0].average[N].Nlensing + 1000; 318 REALLOCATE (next_lens, off_t, NLENS); 319 REALLOCATE (output[0].lensing, Lensing, NLENS); 320 } 291 321 if (Nave >= NAVE) { 292 322 NAVE = Nave + 1000; … … 295 325 } 296 326 297 if (input[0].found [N] >= 0) continue;327 if (input[0].found_t[N] >= 0) continue; 298 328 if (!IN_REGION (input[0].average[N].R, input[0].average[N].D)) continue; 299 329 … … 348 378 349 379 /* we set next[Nmeas] to -1 here, and update correctly below */ 350 input[0].found [N] = Nmeas;380 input[0].found_t[N] = Nmeas; 351 381 next_meas[Nmeas] = -1; 352 382 Nmeas ++; … … 356 386 next_meas[Nmeas - Ngroup + j] = Nmeas - Ngroup + j + 1; 357 387 } 388 389 /** add lensing for this input average object **/ 390 if (output[0].lensing) { 391 output[0].average[Nave].lensingOffset = Nlens; 392 for (Nin = 0; Nin < input[0].average[N].Nlensing; Nin ++) { 393 // supply the lensing values from this detection 394 off_t lensoff = input[0].average[N].lensingOffset + Nin; 395 output[0].lensing[Nlens] = input[0].lensing[lensoff]; 396 397 // the following lensing elements cannot be set until here: 398 output[0].lensing[Nlens].averef = Nave; 399 output[0].lensing[Nlens].objID = output[0].average[Nave].objID; 400 output[0].lensing[Nlens].catID = output[0].catID; 401 402 // as we add lensing, update Nlensing to match 403 output[0].average[Nave].Nlensing ++; 404 405 /* we set next[Nlens] to -1 here, and update correctly below */ 406 next_lens[Nlens] = -1; 407 Nlens ++; 408 } 409 int Ngroup = input[0].average[N].Nlensing; 410 for (j = 0; j < Ngroup - 1; j++) { 411 next_lens[Nlens - Ngroup + j] = Nlens - Ngroup + j + 1; 412 } 413 } 414 358 415 Nave ++; 359 416 } … … 363 420 REALLOCATE (output[0].average, Average, Nave); 364 421 REALLOCATE (output[0].measure, Measure, Nmeas); 422 REALLOCATE (output[0].lensing, Lensing, Nlens); 365 423 366 424 # define NOSORT 0 … … 370 428 output[0].sorted = TRUE; 371 429 output[0].measure = sort_measure (output[0].average, Nave, output[0].measure, Nmeas, next_meas); 430 output[0].lensing = sort_lensing (output[0].average, Nave, output[0].lensing, Nlens, next_lens); 372 431 } 373 432 374 433 /* note stars which have been found in this catalog */ 375 434 for (i = 0; i < input[0].Naverage; i++) { 376 if (input[0].found [i] > -1) {377 input[0].found [i] = -2;435 if (input[0].found_t[i] > -1) { 436 input[0].found_t[i] = -2; 378 437 } else { 379 input[0].found [i] = -3;438 input[0].found_t[i] = -3; 380 439 } 381 440 } … … 385 444 output[0].Naverage = Nave; 386 445 output[0].Nmeasure = Nmeas; 446 output[0].Nlensing = Nlens; 387 447 output[0].Nsecf_mem = Nave*NsecfiltOut; 388 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas : "OFF_T_FMT" "OFF_T_FMT" "OFF_T_FMT", ("OFF_T_FMT" matches)\n", Nstars, Nave, Nmeas,Nmatch);448 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas, Nlens: "OFF_T_FMT" "OFF_T_FMT" "OFF_T_FMT" "OFF_T_FMT", ("OFF_T_FMT" matches)\n", Nstars, Nave, Nmeas, Nlens, Nmatch); 389 449 390 450 free (next_meas); 391 392 free (output[0].found); 451 free (next_lens); 452 393 453 free (X2); 394 454 free (Y2); 395 455 free (N2); 396 free (input[0].found);397 456 free (X1); 398 457 free (Y1); … … 411 470 images have boundaries which are lines in pixels coords, but curve in RA and DEC 412 471 413 output[0].found [Ncat] but stars[Nstar].found472 output[0].found_t[Ncat] but stars[Nstar].found 414 473 415 474 */ -
branches/eam_branches/ps2-tc3-20130727/Ohana/src/dvomerge/src/replace_match.c
r33963 r37403 7 7 unsigned int averef; 8 8 unsigned int catID; 9 double Rin, Din;10 9 11 10 // find the matching photcode in the object's list of measurements … … 18 17 measure_out[Nout] = measure_in[0]; 19 18 20 Rin = average_in[0].R - measure_in[0].dR / 3600.0; 21 Din = average_in[0].D - measure_in[0].dD / 3600.0; 19 // old code: find R,D using average_in[0], the get offset relative to average_out[0]. no longer 20 // needed since we carry around R,D 21 // double Rin = average_in[0].R - measure_in[0].dR / 3600.0; 22 // double Din = average_in[0].D - measure_in[0].dD / 3600.0; 23 // measure_out[Nout].dR = 3600.0*(average_out[0].R - Rin); 24 // measure_out[Nout].dD = 3600.0*(average_out[0].D - Din); 22 25 23 /** dR,dD now represent arcsec **/24 measure_out[Nout].dR = 3600.0*(average_out[0].R - Rin);25 measure_out[Nout].dD = 3600.0*(average_out[0].D - Din);26 26 measure_out[Nout].dbFlags = 0; // XXX why reset these? 27 27 measure_out[Nout].averef = averef; … … 29 29 measure_out[Nout].catID = catID; 30 30 31 float dRoff = dvoOffsetR(&measure_out[Nout], average_out); 32 31 33 // rationalize dR 32 if ( measure_out[Nout].dR> +180.0*3600.0) {34 if (dRoff > +180.0*3600.0) { 33 35 // average on high end of boundary, move star up 34 Rin+= 360.0;35 measure_out[Nout].dR = 3600.0*(average_out[0].R - Rin);36 measure_out[Nout].R += 360.0; 37 dRoff -= 360.0*3600.0; 36 38 } 37 if ( measure_out[Nout].dR< -180.0*3600.0) {39 if (dRoff < -180.0*3600.0) { 38 40 // average on low end of boundary, move star down 39 Rin-= 360.0;40 measure_out[Nout].dR = 3600.0*(average_out[0].R - Rin);41 measure_out[Nout].R -= 360.0; 42 dRoff += 360.0*3600.0; 41 43 } 42 44 43 45 // warn on surprisingly distant detections 44 if (fabs( measure_out[Nout].dR) > 10*RADIUS) {46 if (fabs(dRoff) > 10*RADIUS) { 45 47 // ok take declination into account and check again. 46 double cosD = cos(RAD_DEG*Din); 47 if (fabs(measure_out[Nout].dR*cosD) > 10*RADIUS) { 48 48 double cosD = cos(RAD_DEG*average_out[0].D); 49 if (fabs(dRoff*cosD) > 10*RADIUS) { 49 50 fprintf (stderr, "surprisingly distant detection: %10.6f,%10.6f vs %10.6f,%10.6f\n", 50 average_out[0].R, average_out[0].D, Rin, Din);51 average_out[0].R, average_out[0].D, measure_out[Nout].R, measure_out[Nout].D); 51 52 } 52 53 }
Note:
See TracChangeset
for help on using the changeset viewer.
