- Timestamp:
- Nov 15, 2015, 10:13:54 AM (11 years ago)
- Location:
- trunk/Ohana/src/dvomerge
- Files:
-
- 5 edited
-
include/dvomerge.h (modified) (1 diff)
-
src/build_links.c (modified) (5 diffs)
-
src/dvo_image_merge_dbs.c (modified) (1 diff)
-
src/merge_catalogs_new.c (modified) (7 diffs)
-
src/merge_catalogs_old.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/dvomerge/include/dvomerge.h
r38986 r39142 164 164 StarPar *sort_starpar PROTO((Average *average, off_t Naverage, StarPar *starpar, off_t Nstarpar, off_t *next)); 165 165 166 off_t *build_galphot_links PROTO((Average *average, off_t Naverage, GalPhot *galphot, off_t Ngalphot)); 167 off_t *init_galphot_links PROTO((Average *average, off_t Naverage, GalPhot *galphot, off_t Ngalphot)); 168 int add_galp_link PROTO((Average *average, off_t *next, off_t Ngalphot, off_t NGALPHOT)); 169 GalPhot *sort_galphot PROTO((Average *average, off_t Naverage, GalPhot *galphot, off_t Ngalphot, off_t *next)); 170 166 171 off_t *init_missing_links PROTO((Average *average, off_t Naverage, Missing *missing, off_t Nmissing)); 167 172 int add_miss_link PROTO((Average *average, off_t *next, off_t Nmissing)); -
trunk/Ohana/src/dvomerge/src/build_links.c
r38986 r39142 23 23 24 24 */ 25 26 /*** Measure ****************************************************************************************/ 25 27 26 28 /* build the initial links assuming the table is sorted, … … 159 161 } 160 162 161 /*** ****************************************************************************************/163 /*** Missing ****************************************************************************************/ 162 164 163 165 /* build the initial links assuming the table is sorted */ … … 229 231 } 230 232 231 /*** ****************************************************************************************/233 /*** Lensing ****************************************************************************************/ 232 234 233 235 /* build the initial links assuming the table is sorted, … … 384 386 } 385 387 386 /*** *****StarPar ********************************************************************************/388 /*** StarPar ********************************************************************************/ 387 389 388 390 /* build the initial links assuming the table is sorted, … … 535 537 } 536 538 537 539 /*** GalPhot ****************************************************************************************/ 540 541 /* build the initial links assuming the table is sorted, 542 not partial, and has a correct set of average[].galphotOffset,Ngalphot values */ 543 off_t *init_galphot_links (Average *average, off_t Naverage, GalPhot *galphot, off_t Ngalphot) { 544 545 off_t i, j, N; 546 off_t *next_galp; 547 548 N = 0; 549 550 ALLOCATE (next_galp, off_t, Ngalphot); 551 for (i = 0; i < Naverage; i++) { 552 if (!average[i].Ngalphot) continue; 553 off_t m = average[i].galphotOffset; 554 myAssert (galphot[m].averef == i, "not sorted"); 555 for (j = 0; j < average[i].Ngalphot - 1; j++, N++) { 556 myAssert (galphot[m+j+1].averef == i, "not sorted"); 557 next_galp[N] = N + 1; 558 if (N >= Ngalphot) { 559 fprintf (stderr, "WARNING: N out of bounds (1)\n"); 560 } 561 } 562 next_galp[N] = -1; 563 if (N >= Ngalphot) { 564 fprintf (stderr, "WARNING: N out of bounds (2)\n"); 565 } 566 567 if (N >= Ngalphot) { 568 fprintf (stderr, "overflow in init_galphot_links\n"); 569 abort (); 570 } 571 N++; 572 } 573 return (next_galp); 574 } 575 576 /* construct galphot links which are valid FOR THIS LOAD 577 * - if we have a full load, we will get links which can 578 * be used by other programs (eg, relphot, etc) 579 * - if we have a partial load, the links are only valid 580 * for that partial load 581 */ 582 583 off_t *build_galphot_links (Average *average, off_t Naverage, GalPhot *galphot, off_t Ngalphot) { 584 585 off_t i, m, k, Nm, averef; 586 off_t *next_galp; 587 588 ALLOCATE (next_galp, off_t, Ngalphot); 589 590 /* reset the Nm, offset values for average */ 591 for (i = 0; i < Naverage; i++) { 592 average[i].galphotOffset = -1; 593 average[i].Ngalphot = 0; 594 } 595 596 for (Nm = 0; Nm < Ngalphot; Nm++) { 597 averef = galphot[Nm].averef; 598 m = average[averef].galphotOffset; 599 next_galp[Nm] = -1; 600 601 if (m == -1) { /* no links yet for source */ 602 average[averef].galphotOffset = Nm; 603 average[averef].Ngalphot = 1; 604 continue; 605 } 606 607 for (k = 0; next_galp[m] != -1; k++) { 608 m = next_galp[m]; 609 if (m >= Ngalphot) { 610 fprintf (stderr, "WARNING: m out of bounds (1)\n"); 611 } 612 } 613 614 average[averef].Ngalphot = k + 2; 615 next_galp[m] = Nm; 616 if (m >= Ngalphot) { 617 fprintf (stderr, "WARNING: m out of bounds (2)\n"); 618 } 619 } 620 return (next_galp); 621 } 622 623 /* average[].galphotOffset, average[].Ngalphot are valid within an addstar run */ 624 int add_galp_link (Average *average, off_t *next_galp, off_t Ngalphot, off_t NGALPHOT) { 625 626 off_t k, m; 627 628 /* if we have trouble, check validity of next_galp[m] : m < Ngalphot */ 629 m = average[0].galphotOffset; 630 631 for (k = 0; k < average[0].Ngalphot - 1; k++) { 632 m = next_galp[m]; 633 if (m >= NGALPHOT) { 634 fprintf (stderr, "WARNING: m out of bounds (3)\n"); 635 } 636 } 637 638 /* set up references */ 639 next_galp[Ngalphot] = -1; 640 if (Ngalphot >= NGALPHOT) { 641 fprintf (stderr, "WARNING: Ngalphot out of bounds (1)\n"); 642 } 643 644 // if Ngalphot is 0, m may have been mis-set; add to the end 645 if ((average[0].Ngalphot == 0) || (m == -1)) { 646 average[0].galphotOffset = Ngalphot; 647 } else { 648 next_galp[m] = Ngalphot; 649 if (m >= NGALPHOT) { 650 fprintf (stderr, "WARNING: m out of bounds (4)\n"); 651 } 652 } 653 654 return (TRUE); 655 } 656 657 GalPhot *sort_galphot (Average *average, off_t Naverage, GalPhot *galphot, off_t Ngalphot, off_t *next_galp) { 658 659 off_t i, k, n, np, N; 660 GalPhot *tmpgalphot; 661 662 /* 663 for (i = 0; i < Naverage; i++) { 664 if (average[i].Ngalphot != 4) { 665 fprintf (stderr, "check %d %d %d\n", (int) i, (int) average[i].Ngalphot, (int) average[i].galphotOffset); 666 } 667 } 668 */ 669 670 /* fix order of GalPhot (memory intensive, but fast) */ 671 np = -1; 672 N = 0; 673 ALLOCATE (tmpgalphot, GalPhot, Ngalphot); 674 for (i = 0; i < Naverage; i++) { 675 if (!average[i].Ngalphot) continue; 676 n = average[i].galphotOffset; 677 average[i].galphotOffset = N; 678 for (k = 0; k < average[i].Ngalphot; k++, N++) { 679 if (n == -1) { 680 fprintf (stderr, "entry after %d has a problem\n", (int) np); 681 abort(); 682 } 683 tmpgalphot[N] = galphot[n]; 684 if (galphot[n].averef != i) abort(); 685 tmpgalphot[N].averef = i; 686 np = n; 687 n = next_galp[n]; 688 } 689 } 690 free (galphot); 691 return (tmpgalphot); 692 } 693 -
trunk/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c
r38553 r39142 234 234 catalog[0].lensing[i].imageID = newID; 235 235 } 236 237 // NOTE galphot also carries an imageID, but it is actually the EXTERNAL image ID reference. Do NOT update it. 238 236 239 return TRUE; 237 240 } -
trunk/Ohana/src/dvomerge/src/merge_catalogs_new.c
r38441 r39142 11 11 12 12 off_t i, j, offset; 13 off_t NAVERAGE, NMEASURE, NLENSING, NSTARPAR, N average, Nmeasure, Nlensing, Nstarpar, NsecfiltIn, NsecfiltOut, Nm;13 off_t NAVERAGE, NMEASURE, NLENSING, NSTARPAR, NGALPHOT, Naverage, Nmeasure, Nlensing, Nstarpar, Ngalphot, NsecfiltIn, NsecfiltOut, Nm; 14 14 15 15 Naverage = output[0].Naverage; … … 17 17 Nlensing = output[0].Nlensing; 18 18 Nstarpar = output[0].Nstarpar; 19 Ngalphot = output[0].Ngalphot; 19 20 20 21 NsecfiltOut = output[0].Nsecfilt; … … 25 26 NLENSING = Nlensing + 1000; 26 27 NSTARPAR = Nstarpar + 1000; 28 NGALPHOT = Ngalphot + 1000; 27 29 28 30 REALLOCATE (output[0].average, Average, NAVERAGE); … … 31 33 REALLOCATE (output[0].lensing, Lensing, NLENSING); 32 34 REALLOCATE (output[0].starpar, StarPar, NSTARPAR); 35 REALLOCATE (output[0].galphot, GalPhot, NGALPHOT); 33 36 34 37 // add all of these entries to the existing catalog … … 100 103 output[0].average[Naverage].Nstarpar = Nm; 101 104 105 Nm = 0; 106 for (j = 0; j < input[0].average[i].Ngalphot; j++) { 107 offset = input[0].average[i].galphotOffset + j; 108 109 output[0].galphot[Ngalphot] = input[0].galphot[offset]; 110 output[0].galphot[Ngalphot].averef = Naverage; 111 112 Ngalphot ++; 113 Nm ++; 114 if (Ngalphot == NGALPHOT) { 115 NGALPHOT += 1000; 116 REALLOCATE (output[0].galphot, GalPhot, NGALPHOT); 117 } 118 } 119 output[0].average[Naverage].Ngalphot = Nm; 120 102 121 Naverage ++; 103 122 if (Naverage == NAVERAGE) { … … 111 130 REALLOCATE (output[0].lensing, Lensing, MAX (Nlensing, 1)); 112 131 REALLOCATE (output[0].starpar, StarPar, MAX (Nstarpar, 1)); 132 REALLOCATE (output[0].galphot, GalPhot, MAX (Ngalphot, 1)); 113 133 REALLOCATE (output[0].secfilt, SecFilt, NsecfiltOut*MAX (Naverage, 1)); 114 134 output[0].Naverage = Naverage; 115 135 output[0].Nlensing = Nlensing; 116 136 output[0].Nstarpar = Nstarpar; 137 output[0].Ngalphot = Ngalphot; 117 138 output[0].Nsecfilt_mem = Naverage * NsecfiltOut; 118 139 … … 124 145 125 146 if (VERBOSE) { 126 fprintf (stderr, OFF_T_FMT": using "OFF_T_FMT" stars ("OFF_T_FMT" measures, "OFF_T_FMT" lensing ) for catalog\n",147 fprintf (stderr, OFF_T_FMT": using "OFF_T_FMT" stars ("OFF_T_FMT" measures, "OFF_T_FMT" lensing, "OFF_T_FMT" starpar, "OFF_T_FMT" galphot) for catalog\n", 127 148 i, 128 149 output[0].Naverage, 129 150 output[0].Nmeasure, 130 output[0].Nlensing); 151 output[0].Nlensing, 152 output[0].Nstarpar, 153 output[0].Ngalphot); 131 154 } 132 155 return (TRUE); -
trunk/Ohana/src/dvomerge/src/merge_catalogs_old.c
r39139 r39142 14 14 double *X1, *Y1, *X2, *Y2; 15 15 double dX, dY, dR; 16 off_t *N1, *N2, *next_meas, *next_lens, *next_star ;17 off_t Nave, NAVE, Nmeas, NMEAS, Nmatch, Nlens, NLENS, Nstar, NSTAR ;16 off_t *N1, *N2, *next_meas, *next_lens, *next_star, *next_galp; 17 off_t Nave, NAVE, Nmeas, NMEAS, Nmatch, Nlens, NLENS, Nstar, NSTAR, Ngalp, NGALP; 18 18 int NsecfiltIn; 19 19 int NsecfiltOut; … … 199 199 NGALP = Ngalp + input[0].average[N].Ngalphot + 1000; 200 200 REALLOCATE (next_galp, off_t, NGALP); 201 REALLOCATE (output[0].galphot, Gal phot, NGALP);201 REALLOCATE (output[0].galphot, GalPhot, NGALP); 202 202 } 203 203 … … 222 222 if (REPLACE_BY_PHOTCODE) { 223 223 // index to first measure for this object 224 // XXX this does not support lensing measurements224 // XXX this does not support lensing, starpar, or galphot measurements 225 225 if (replace_match (&output[0].average[n], output[0].measure, next_meas, &input[0].average[N], &input[0].measure[offset])) { 226 226 input[0].found_t[N] = output[0].average[n].measureOffset; … … 315 315 } 316 316 317 // if galphot measurements exist, add them too 318 if (output[0].galphot) { 319 for (Nin = 0; Nin < input[0].average[N].Ngalphot; Nin++) { 320 /* add to end of galphot list */ 321 add_galp_link (&output[0].average[n], next_galp, Ngalp, NGALP); 322 323 // set the new galphot 324 off_t galpoff = input[0].average[N].galphotOffset + Nin; 325 output[0].galphot[Ngalp] = input[0].galphot[galpoff]; 326 327 output[0].galphot[Ngalp].averef = n; 328 output[0].galphot[Ngalp].objID = output[0].average[n].objID; 329 output[0].galphot[Ngalp].catID = output[0].catID; 330 output[0].average[n].Ngalphot ++; 331 Ngalp ++; 332 } 333 } 334 317 335 // update the average properties to reflect the incoming entries: 318 336 // if the original value is NAN but the input value is not, accept the input: … … 365 383 REALLOCATE (output[0].starpar, StarPar, NSTAR); 366 384 } 385 if (Ngalp + input[0].average[N].Ngalphot >= NGALP) { 386 NGALP = Ngalp + input[0].average[N].Ngalphot + 1000; 387 REALLOCATE (next_galp, off_t, NGALP); 388 REALLOCATE (output[0].galphot, GalPhot, NGALP); 389 } 367 390 if (Nave >= NAVE) { 368 391 NAVE = Nave + 1000; … … 488 511 } 489 512 513 /** add galphot for this input average object **/ 514 if (output[0].galphot) { 515 output[0].average[Nave].galphotOffset = Ngalp; 516 for (Nin = 0; Nin < input[0].average[N].Ngalphot; Nin ++) { 517 // supply the galphot values from this detection 518 off_t galpoff = input[0].average[N].galphotOffset + Nin; 519 output[0].galphot[Ngalp] = input[0].galphot[galpoff]; 520 521 // the following galphot elements cannot be set until here: 522 output[0].galphot[Ngalp].averef = Nave; 523 output[0].galphot[Ngalp].objID = output[0].average[Nave].objID; 524 output[0].galphot[Ngalp].catID = output[0].catID; 525 526 // as we add galphot, update Ngalphot to match 527 output[0].average[Nave].Ngalphot ++; 528 529 /* we set next[Ngalp] to -1 here, and update correctly below */ 530 next_galp[Ngalp] = -1; 531 Ngalp ++; 532 } 533 int Ngroup = input[0].average[N].Ngalphot; 534 for (j = 0; j < Ngroup - 1; j++) { 535 next_galp[Ngalp - Ngroup + j] = Ngalp - Ngroup + j + 1; 536 } 537 } 538 490 539 Nave ++; 491 540 } … … 497 546 REALLOCATE (output[0].lensing, Lensing, Nlens); 498 547 REALLOCATE (output[0].starpar, StarPar, Nstar); 548 REALLOCATE (output[0].galphot, GalPhot, Ngalp); 499 549 500 550 # define NOSORT 0 … … 506 556 output[0].lensing = sort_lensing (output[0].average, Nave, output[0].lensing, Nlens, next_lens); 507 557 output[0].starpar = sort_starpar (output[0].average, Nave, output[0].starpar, Nstar, next_star); 558 output[0].galphot = sort_galphot (output[0].average, Nave, output[0].galphot, Ngalp, next_galp); 508 559 } 509 560 … … 523 574 output[0].Nlensing = Nlens; 524 575 output[0].Nstarpar = Nstar; 576 output[0].Ngalphot = Ngalp; 525 577 output[0].Nsecfilt_mem = Nave*NsecfiltOut; 526 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);578 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas, Nlens, Ngalp: "OFF_T_FMT" "OFF_T_FMT" "OFF_T_FMT" "OFF_T_FMT" "OFF_T_FMT", ("OFF_T_FMT" matches)\n", Nstars, Nave, Nmeas, Nlens, Ngalp, Nmatch); 527 579 528 580 free (next_meas); 529 581 free (next_lens); 530 582 free (next_star); 583 free (next_galp); 531 584 532 585 free (X2);
Note:
See TracChangeset
for help on using the changeset viewer.
