Changeset 38636
- Timestamp:
- Jul 24, 2015, 8:26:59 AM (11 years ago)
- Location:
- trunk/Ohana/src/addstar
- Files:
-
- 7 edited
-
Makefile (modified) (4 diffs)
-
include/addstar.h (modified) (1 diff)
-
src/find_matches_galphot.c (modified) (2 diffs)
-
src/find_matches_starpar.c (modified) (1 diff)
-
src/resort_catalog.c (modified) (13 diffs)
-
src/resort_threaded.c (modified) (1 diff)
-
src/resort_unthreaded.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/addstar/Makefile
r38553 r38636 40 40 # programs in 'SERVER' use the client-server concept and are out of date 41 41 42 INSTALL = addstar sedstar load starpar loadstarpar_client loadICRF loadICRF_client skycells mkcmf dumpskycells findskycell42 INSTALL = addstar sedstar loadgalphot loadstarpar loadstarpar_client loadICRF loadICRF_client skycells mkcmf dumpskycells findskycell 43 43 OTHERS = load2mass loadwise loadtycho loadsupercos 44 44 SERVER = addstar_client addstarc addstard addstart … … 271 271 $(SRC)/loadgalphot_join.$(ARCH).o \ 272 272 $(SRC)/loadgalphot_table.$(ARCH).o \ 273 $(SRC)/resort_catalog.$(ARCH).o \ 273 274 $(SRC)/strhash.$(ARCH).o \ 274 275 $(SRC)/sortIDs.$(ARCH).o \ … … 295 296 $(SRC)/loadstarpar_save_remote.$(ARCH).o \ 296 297 $(SRC)/loadstarpar_table.$(ARCH).o \ 298 $(SRC)/resort_catalog.$(ARCH).o \ 297 299 $(SRC)/psps_ids.$(ARCH).o 298 300 … … 312 314 $(SRC)/loadstarpar_save_remote.$(ARCH).o \ 313 315 $(SRC)/loadstarpar_table.$(ARCH).o \ 316 $(SRC)/resort_catalog.$(ARCH).o \ 314 317 $(SRC)/psps_ids.$(ARCH).o 315 318 -
trunk/Ohana/src/addstar/include/addstar.h
r38553 r38636 359 359 Catalog *addstar_catalog_init (int Nstars); 360 360 361 void resort_catalog_measure (Catalog *catalog); 362 void resort_catalog_lensing (Catalog *catalog); 363 void resort_catalog_starpar (Catalog *catalog); 364 void resort_catalog_galphot (Catalog *catalog); 365 361 366 /** 362 367 there is an inconsistency to be resolved: fixed structures (like Image) -
trunk/Ohana/src/addstar/src/find_matches_galphot.c
r38553 r38636 199 199 REALLOCATE (catalog[0].galphot, GalPhot, Ngalphot); 200 200 201 catalog[0].sorted = FALSE;202 203 201 /* check if the catalog has changed? if no change, no need to write */ 204 202 catalog[0].objID = objID; // new max value, save on catalog close … … 206 204 catalog[0].Ngalphot = Ngalphot; 207 205 catalog[0].Nsecfilt_mem = Nave*Nsecfilt; 206 207 // we need to for 208 catalog[0].sorted = FALSE; 209 resort_catalog_galphot (catalog); 210 catalog[0].sorted = TRUE; 211 208 212 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Ngalphot: %d "OFF_T_FMT" "OFF_T_FMT" ("OFF_T_FMT" matches)\n", Nstars, Nave, Ngalphot, Nmatch); 209 213 -
trunk/Ohana/src/addstar/src/find_matches_starpar.c
r38467 r38636 199 199 REALLOCATE (catalog[0].starpar, StarPar, Nstarpar); 200 200 201 catalog[0].sorted = FALSE; 201 resort_catalog_starpar (catalog); 202 catalog[0].sorted = TRUE; 202 203 203 204 /* check if the catalog has changed? if no change, no need to write */ -
trunk/Ohana/src/addstar/src/resort_catalog.c
r38153 r38636 2 2 3 3 void SortAveMatch (off_t *MEAS, off_t *AVE, off_t N); 4 void resort_catalog_measure (Catalog *catalog);5 void resort_catalog_lensing (Catalog *catalog);6 void resort_catalog_starpar (Catalog *catalog);7 8 void resort_catalog_old (Catalog *catalog) {9 10 off_t *next_meas, *next_lens;11 off_t Naves, Nmeas, Nlens;12 13 if (catalog[0].sorted == TRUE) return;14 15 INITTIME;16 17 /* internal counters */18 Nmeas = catalog[0].Nmeasure;19 Nlens = catalog[0].Nlensing;20 Naves = catalog[0].Naverage;21 22 /* set up pointers for linked list of measure, missing */23 next_meas = build_measure_links (catalog[0].average, Naves, catalog[0].measure, Nmeas);24 next_lens = build_lensing_links (catalog[0].average, Naves, catalog[0].lensing, Nlens);25 26 catalog[0].sorted = TRUE;27 catalog[0].measure = sort_measure (catalog[0].average, Naves, catalog[0].measure, Nmeas, next_meas);28 catalog[0].lensing = sort_lensing (catalog[0].average, Naves, catalog[0].lensing, Nlens, next_lens);29 30 MARKTIME (" match time %9.4f sec for %7lld measures, %6lld average\n", dtime, (long long) Nmeas, (long long) Naves);31 32 return;33 }34 4 35 5 void resort_catalog (Catalog *catalog) { … … 40 10 resort_catalog_lensing (catalog); 41 11 resort_catalog_starpar (catalog); 42 43 // XXX somehow need to set the value of lensing->measure offset here 44 45 12 resort_catalog_galphot (catalog); 13 catalog[0].sorted = TRUE; 46 14 } 47 15 … … 88 56 myAssert(average[averageSeq[i]].catID == measure[measureSeq[i]].catID, "object / detection mismatch"); 89 57 # if (1) 58 myAssert (average[averageSeq[i]].objID == measure[measureSeq[i]].objID, "object ID mismatch?"); 59 # endif 60 # if (0) 90 61 // myAssert(average[averageSeq[i]].objID == measure[measureSeq[i]].objID, "object / detection mismatch"); 91 62 // check if the objID is correct. if not, check if it is byte-swapped (this has happened) and repair if so. … … 110 81 } 111 82 } 112 # else 83 # endif 84 # if (0) 113 85 // for reasons I do not understand, the mini dvodbs generated on stsci1X had a handful of detections with an inconsistency between averef and objID. 114 86 // this happened for 28 detections in the dbs on /data/stsci1?.0/eugene/dvo3pi.20130616, but not at all (as far as I know) in the rest of LAP DVO … … 196 168 // MARKTIME(" match time %9.4f sec for %7lld measures, %6lld average\n", dtime, (long long) Nmeasure, (long long) Naverage); 197 169 198 catalog[0].sorted = TRUE;199 200 170 FREE (measureSeq); 201 171 FREE (averageSeq); … … 245 215 // earlier formats did not carry the objID or catID, so they are not available (we could assign on load, but we don't) 246 216 myAssert(average[averageSeq[i]].catID == lensing[lensingSeq[i]].catID, "object / detection mismatch"); 247 # if (1)248 217 myAssert(average[averageSeq[i]].objID == lensing[lensingSeq[i]].objID, "object / detection mismatch"); 249 # else 250 // for reasons I do not understand, the mini dvodbs generated on stsci1X had a handful of detections with an inconsistency between averef and objID. 251 // this happened for 28 detections in the dbs on /data/stsci1?.0/eugene/dvo3pi.20130616, but not at all (as far as I know) in the rest of LAP DVO 252 if (average[averageSeq[i]].objID != lensing[lensingSeq[i]].objID) { 253 fprintf (stderr, "R"); 254 lensing[lensingSeq[i]].objID = average[averageSeq[i]].objID; // XXX I don't really like this... 255 } 256 # endif 257 } 258 } 259 260 // check that averageSeq is now in order 261 // for (i = 1; i < Nlensing; i++) { 262 // if (averageSeq[i] < averageSeq[i-1]) { 263 // fprintf (stderr, "%d ", (int) i); 264 // } 265 // } 266 // fprintf (stderr, "\n"); 267 218 } 219 } 220 268 221 SortAveMatch(lensingSeq, averageSeq, Nlensing); 269 // MARKTIME("sort : %f sec\n", dtime);270 271 // check that averageSeq is now in order272 // for (i = 1; i < Nlensing; i++) {273 // if (averageSeq[i] < averageSeq[i-1]) {274 // fprintf (stderr, "%d ", (int) i);275 // }276 // }277 // fprintf (stderr, "\n");278 222 279 223 // copy the lensing entries in the sorted order … … 283 227 lensingTMP[i] = lensing[j]; 284 228 } 285 // MARKTIME("assign lensing : %f sec\n", dtime);286 229 287 230 // update the values of average.lensingOffset and average.Nlensing … … 302 245 N++; 303 246 } 304 // N++;305 247 average[currentAve].Nlensing = N; 306 // MARKTIME("update Nlensing : %f sec\n", dtime);307 248 308 249 int NlensingTotal = 0; … … 330 271 fprintf (stderr, "ERROR: catalog %s has an invalid Nlensing\n", catalog[0].filename); 331 272 } 332 333 // MARKTIME(" match time %9.4f sec for %7lld lensings, %6lld average\n", dtime, (long long) Nlensing, (long long) Naverage);334 335 catalog[0].sorted = TRUE;336 273 337 274 FREE (lensingSeq); … … 382 319 // earlier formats did not carry the objID or catID, so they are not available (we could assign on load, but we don't) 383 320 myAssert(average[averageSeq[i]].catID == starpar[starparSeq[i]].catID, "object / detection mismatch"); 384 # if (1)385 321 myAssert(average[averageSeq[i]].objID == starpar[starparSeq[i]].objID, "object / detection mismatch"); 386 # else 387 // for reasons I do not understand, the mini dvodbs generated on stsci1X had a handful of detections with an inconsistency between averef and objID. 388 // this happened for 28 detections in the dbs on /data/stsci1?.0/eugene/dvo3pi.20130616, but not at all (as far as I know) in the rest of LAP DVO 389 if (average[averageSeq[i]].objID != starpar[starparSeq[i]].objID) { 390 fprintf (stderr, "R"); 391 starpar[starparSeq[i]].objID = average[averageSeq[i]].objID; // XXX I don't really like this... 392 } 393 # endif 394 } 395 } 396 397 // check that averageSeq is now in order 398 // for (i = 1; i < Nstarpar; i++) { 399 // if (averageSeq[i] < averageSeq[i-1]) { 400 // fprintf (stderr, "%d ", (int) i); 401 // } 402 // } 403 // fprintf (stderr, "\n"); 404 322 } 323 } 324 405 325 SortAveMatch(starparSeq, averageSeq, Nstarpar); 406 // MARKTIME("sort : %f sec\n", dtime);407 408 // check that averageSeq is now in order409 // for (i = 1; i < Nstarpar; i++) {410 // if (averageSeq[i] < averageSeq[i-1]) {411 // fprintf (stderr, "%d ", (int) i);412 // }413 // }414 // fprintf (stderr, "\n");415 326 416 327 // copy the starpar entries in the sorted order … … 420 331 starparTMP[i] = starpar[j]; 421 332 } 422 // MARKTIME("assign starpar : %f sec\n", dtime);423 333 424 334 // update the values of average.starparOffset and average.Nstarpar … … 439 349 N++; 440 350 } 441 // N++;442 351 average[currentAve].Nstarpar = N; 443 // MARKTIME("update Nstarpar : %f sec\n", dtime);444 352 445 353 int NstarparTotal = 0; … … 468 376 } 469 377 470 // MARKTIME(" match time %9.4f sec for %7lld starpars, %6lld average\n", dtime, (long long) Nstarpar, (long long) Naverage);471 472 catalog[0].sorted = TRUE;473 474 378 FREE (starparSeq); 379 FREE (averageSeq); 380 381 return; 382 } 383 384 void resort_catalog_galphot (Catalog *catalog) { 385 386 off_t Naverage, Ngalphot; 387 GalPhot *galphot; 388 Average *average; 389 off_t i, j, N, currentAve; 390 391 off_t *galphotSeq = NULL; 392 off_t *averageSeq = NULL; 393 GalPhot *galphotTMP = NULL; 394 395 // struct timeval start, stop; 396 // gettimeofday (&start, NULL); 397 398 /* internal counters */ 399 Ngalphot = catalog[0].Ngalphot; 400 Naverage = catalog[0].Naverage; 401 402 if (!Ngalphot) return; 403 404 galphot = catalog[0].galphot; 405 average = catalog[0].average; 406 407 myAbort("relphot_catalog_galphot needs to handle average entries with Ngalphot = 0"); 408 409 // we have a table of average objects and an unsorted table of measurements. each measurement 410 // has a reference to the average object sequence (as well as an ID) 411 // galphot[i].averef -> average[averef] 412 // galphot[i].objID = average[averef].objID 413 // galphot[i].catID = average[averef].catID 414 415 // we want a sorted galphot array with all averef entries in sequence 416 417 ALLOCATE (galphotSeq, off_t, Ngalphot); 418 ALLOCATE (averageSeq, off_t, Ngalphot); 419 420 for (i = 0; i < Ngalphot; i++) { 421 galphotSeq[i] = i; 422 averageSeq[i] = galphot[i].averef; 423 424 if (catalog[0].catformat >= DVO_FORMAT_PS1_V1) { 425 // earlier formats did not carry the objID or catID, so they are not available (we could assign on load, but we don't) 426 myAssert(average[averageSeq[i]].catID == galphot[galphotSeq[i]].catID, "object / detection mismatch"); 427 myAssert(average[averageSeq[i]].objID == galphot[galphotSeq[i]].objID, "object / detection mismatch"); 428 } 429 } 430 431 SortAveMatch(galphotSeq, averageSeq, Ngalphot); 432 433 // copy the galphot entries in the sorted order 434 ALLOCATE (galphotTMP, GalPhot, Ngalphot); 435 for (i = 0; i < Ngalphot; i++) { 436 j = galphotSeq[i]; 437 galphotTMP[i] = galphot[j]; 438 } 439 440 // update the values of average.galphotOffset and average.Ngalphot 441 FREE(galphot); 442 catalog[0].galphot = galphotTMP; 443 444 N = 0; 445 currentAve = averageSeq[0]; 446 average[currentAve].galphotOffset = 0; 447 for (i = 0; i < Ngalphot; i++) { 448 if (averageSeq[i] != currentAve) { 449 // we have hit the next entry in the list 450 average[currentAve].Ngalphot = N; 451 N = 0; 452 currentAve = averageSeq[i]; 453 average[currentAve].galphotOffset = i; 454 } 455 N++; 456 } 457 average[currentAve].Ngalphot = N; 458 459 int NgalphotTotal = 0; 460 int galphotOffsetOK = TRUE; 461 for (i = 0; i < Naverage; i++) { 462 NgalphotTotal += catalog[0].average[i].Ngalphot; 463 if (VERBOSE && !(NgalphotTotal <= catalog[0].Ngalphot)) { 464 fprintf (stderr, "too few galphot: %d %d %d\n", (int) i, NgalphotTotal, (int) catalog[0].Ngalphot); 465 } 466 galphotOffsetOK &= (catalog[0].average[i].galphotOffset < catalog[0].Ngalphot); 467 if (VERBOSE && !(catalog[0].average[i].galphotOffset < catalog[0].Ngalphot)) { 468 fprintf (stderr, "offset too large: %d %d %d\n", (int) i, catalog[0].average[i].Ngalphot, (int) catalog[0].Ngalphot); 469 } 470 galphotOffsetOK &= (catalog[0].average[i].galphotOffset + catalog[0].average[i].Ngalphot <= catalog[0].Ngalphot); 471 if (VERBOSE && !(catalog[0].average[i].galphotOffset + catalog[0].average[i].Ngalphot <= catalog[0].Ngalphot)) { 472 fprintf (stderr, "orrset + Ngalphot too large: %d + %d > %d %d\n", (int) i, catalog[0].average[i].galphotOffset, catalog[0].average[i].Ngalphot, (int) catalog[0].Ngalphot); 473 } 474 } 475 476 if (!galphotOffsetOK) { 477 fprintf (stderr, "ERROR: catalog %s has an invalid galphotOffset\n", catalog[0].filename); 478 } 479 480 if (NgalphotTotal != catalog[0].Ngalphot) { 481 fprintf (stderr, "ERROR: catalog %s has an invalid Ngalphot\n", catalog[0].filename); 482 } 483 484 FREE (galphotSeq); 475 485 FREE (averageSeq); 476 486 -
trunk/Ohana/src/addstar/src/resort_threaded.c
r38471 r38636 72 72 // this is an overloaded value to mean 'force sort' 73 73 if (threadData->forcesort) catalog.sorted = FALSE; 74 75 if (OLD_RESORT) { 76 resort_catalog_old (&catalog); 77 } else { 78 resort_catalog (&catalog); 79 } 74 resort_catalog (&catalog); 80 75 81 76 /* report total updated values */ -
trunk/Ohana/src/addstar/src/resort_unthreaded.c
r38471 r38636 42 42 } 43 43 44 // t his is an overloaded value to mean 'force sort'44 // to force the sort, we need to set sorted 'false' 45 45 if (ForceSort) catalog.sorted = FALSE; 46 47 if (OLD_RESORT) { 48 resort_catalog_old (&catalog); 49 } else { 50 resort_catalog (&catalog); 51 } 46 resort_catalog (&catalog); 52 47 53 48 // report total updated values
Note:
See TracChangeset
for help on using the changeset viewer.
