Changeset 31274
- Timestamp:
- Apr 12, 2011, 3:10:32 PM (15 years ago)
- Location:
- branches/eam_branches/ipp-20110404/Ohana/src/libdvo
- Files:
-
- 2 edited
-
include/dvo.h (modified) (3 diffs)
-
src/dvo_photcode_ops.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20110404/Ohana/src/libdvo/include/dvo.h
r31254 r31274 210 210 } PhotCodeData; 211 211 212 // a reduced-subset structure for relphot 213 typedef struct { 214 double R; 215 double D; 216 unsigned short Nmeasure; 217 int measureOffset; 218 uint32_t flags; 219 } AverageTiny; 220 221 // a reduced-subset structure for relphot 222 typedef struct { 223 float dR; 224 float dD; 225 float M; 226 float Mcal; 227 float dM; 228 float airmass; 229 float Xccd; 230 float Yccd; 231 float dt; 232 int t; 233 unsigned int averef; 234 unsigned int imageID; 235 unsigned int dbFlags; 236 unsigned short photcode; 237 } MeasureTiny; 238 212 239 /* a catalog contains this data */ 213 240 typedef struct Catalog { … … 226 253 off_t Naves_disk, Nmeas_disk, Nmiss_disk, Nsecf_disk; /* current number of each component on disk */ 227 254 off_t Naves_off, Nmeas_off, Nmiss_off, Nsecf_off; /* index of first loaded data value */ 255 256 // note that we use these for the full-sky relphot analysis 257 AverageTiny *averageT; 258 MeasureTiny *measureT; 228 259 229 260 /* the Nsecf_* values above are number of table rows (eg, Naverage*Nsecfilt) */ … … 330 361 int PhotColor (Average *average, SecFilt *secfilt, Measure *measure, int c1, int c2, double *color); 331 362 363 float PhotInstTiny (MeasureTiny *measure); 364 float PhotCatTiny (MeasureTiny *measure); 365 float PhotAperTiny (MeasureTiny *measure); 366 float PhotSysTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt); 367 float PhotRelTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt); 368 float PhotCalTiny (MeasureTiny *thisone, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, PhotCode *code); 369 float PhotAveTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt); 370 float PhotRefTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure); 371 float PhotXmTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt); 372 float PhotdMTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt); 373 374 float PhotColorForCodeTiny (AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, PhotCode *code); 375 int PhotColorTiny (AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, int c1, int c2, double *color); 376 377 332 378 PhotCodeData *GetPhotcodeTable (void); 333 379 void SetPhotcodeTable (PhotCodeData *); -
branches/eam_branches/ipp-20110404/Ohana/src/libdvo/src/dvo_photcode_ops.c
r29938 r31274 536 536 return (TRUE); 537 537 } 538 539 /******** alternate photometry conversion functions using MeasureTiny and AverageTiny *********/ 540 float PhotInstTiny (MeasureTiny *measure) { 541 542 int Np; 543 float M; 544 545 Np = photcodes[0].hashcode[measure[0].photcode]; 546 if (Np == -1) return (NAN); 547 548 if (photcodes[0].code[Np].type == PHOT_REF) { 549 M = measure[0].M; 550 return (M); 551 } 552 553 M = measure[0].M - measure[0].dt - ZERO_POINT; 554 555 return (M); 556 557 } 558 559 float PhotCatTiny (MeasureTiny *measure) { 560 561 int Np; 562 float Mcat; 563 PhotCode *code; 564 565 Np = photcodes[0].hashcode[measure[0].photcode]; 566 if (Np == -1) return (NAN); 567 568 if (photcodes[0].code[Np].type == PHOT_REF) { 569 Mcat = measure[0].M; 570 return (Mcat); 571 } 572 code = &photcodes[0].code[Np]; 573 Mcat = measure[0].M - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 574 575 return (Mcat); 576 } 577 578 # if (0) 579 float PhotAperTiny (MeasureTiny *measure) { 580 581 int Np; 582 float Mcat; 583 PhotCode *code; 584 585 Np = photcodes[0].hashcode[measure[0].photcode]; 586 if (Np == -1) return (NAN); 587 588 if (photcodes[0].code[Np].type == PHOT_REF) { 589 Mcat = measure[0].Map; 590 return (Mcat); 591 } 592 code = &photcodes[0].code[Np]; 593 Mcat = measure[0].Map - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 594 595 return (Mcat); 596 } 597 # endif 598 599 float PhotSysTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt) { 600 601 int i, Np; 602 float Mcat, Mcol, Msys, mc, Mc; 603 PhotCode *code; 604 605 Np = photcodes[0].hashcode[measure[0].photcode]; 606 if (Np == -1) return (NAN); 607 608 if (photcodes[0].code[Np].type == PHOT_REF) { 609 Msys = measure[0].M; 610 return (Msys); 611 } 612 code = &photcodes[0].code[Np]; 613 Mcat = measure[0].M - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 614 615 /* for DEP, color must be made of PRI/SEC */ 616 mc = PhotColorForCodeTiny (average, secfilt, NULL, code); 617 if (isnan(mc)) return (Mcat); 618 mc = mc - SCALE*code[0].dX; 619 620 Mc = mc; 621 Mcol = 0; 622 for (i = 0; i < code[0].Nc; i++) { 623 Mcol += code[0].X[i]*Mc; 624 Mc *= mc; 625 } 626 Msys = Mcat + Mcol; 627 return (Msys); 628 } 629 630 float PhotRelTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt) { 631 632 int i, Np; 633 float Mcat, Mcol, Mrel, mc, Mc; 634 PhotCode *code; 635 636 Np = photcodes[0].hashcode[measure[0].photcode]; 637 if (Np == -1) return (NAN); 638 639 if (photcodes[0].code[Np].type == PHOT_REF) { 640 Mcat = measure[0].M; 641 return (Mcat); 642 } 643 code = &photcodes[0].code[Np]; 644 Mrel = measure[0].M - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C - measure[0].Mcal; 645 646 /* for DEP, color must be made of PRI/SEC */ 647 mc = PhotColorForCodeTiny (average, secfilt, NULL, code); 648 if (isnan(mc)) return (Mrel); 649 mc = mc - SCALE*code[0].dX; 650 651 Mc = mc; 652 Mcol = 0; 653 for (i = 0; i < code[0].Nc; i++) { 654 Mcol += code[0].X[i]*Mc; 655 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */ 656 } 657 Mrel += Mcol; 658 return (Mrel); 659 } 660 661 /* return calibrated magnitude from measure for given photcode */ 662 float PhotCalTiny (MeasureTiny *thisone, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, PhotCode *code) { 663 664 int i, Np; 665 float Mcal, Mrel, Mcol, mc, Mc; 666 667 if (code == NULL) return NAN; 668 669 /* code must be the matching PRI/SEC code for this measurement or an equivalent ALT */ 670 Np = photcodes[0].hashcode[thisone[0].photcode]; 671 if (Np == -1) return (NAN); 672 673 if (photcodes[0].code[Np].type == PHOT_REF) { 674 Mrel = thisone[0].M; 675 return (Mrel); 676 } 677 if (code[0].code != photcodes[0].code[Np].equiv) return (NAN); 678 679 Mcal = PhotRelTiny (thisone, average, secfilt) + SCALE*code[0].C; 680 681 mc = PhotColorForCodeTiny (average, secfilt, measure, code); 682 if (isnan(mc)) return (Mcal); 683 mc = mc - SCALE*code[0].dX; 684 685 Mc = mc; 686 Mcol = 0; 687 for (i = 0; i < code[0].Nc; i++) { 688 Mcol += code[0].X[i]*Mc; 689 Mc *= mc; 690 } 691 Mcal += Mcol; 692 return (Mcal); 693 } 694 695 /* color term may not use DEP magnitude */ 696 float PhotColorForCodeTiny (AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, PhotCode *code) { 697 698 int i, Ns1, Ns2, Ns; 699 float m1, m2, mc; 700 PhotCode *color; 701 702 m1 = m2 = NAN; 703 704 if (measure == NULL) { 705 Ns1 = photcodes[0].hashNsec[code[0].c1]; 706 Ns2 = photcodes[0].hashNsec[code[0].c2]; 707 708 m1 = (Ns1 == -1) ? NAN : secfilt[Ns1].M; 709 m2 = (Ns2 == -1) ? NAN : secfilt[Ns2].M; 710 mc = (isnan(m1) || isnan(m2)) ? NAN : (m1 - m2); 711 return (mc); 712 } 713 714 /* find magnitude matching first color term */ 715 color = GetPhotcodebyCode (code[0].c1); 716 if (color == NULL) return (NAN); 717 if (color[0].type == PHOT_REF) { 718 for (i = 0; (i < average[0].Nmeasure) && (isnan(m1)); i++) { 719 if (measure[i].photcode == color[0].code) { 720 m1 = measure[i].M; 721 } 722 } 723 } else { 724 Ns = photcodes[0].hashNsec[color[0].code]; 725 m1 = (Ns == -1) ? NAN : secfilt[Ns].M; 726 } 727 728 /* find magnitude matching second color term */ 729 color = GetPhotcodebyCode (code[0].c2); 730 if (color == NULL) return (NAN); 731 if (color[0].type == PHOT_REF) { 732 for (i = 0; (i < average[0].Nmeasure) && (isnan(m2)); i++) { 733 if (measure[i].photcode == color[0].code) { 734 m2 = measure[i].M; 735 } 736 } 737 } else { 738 Ns = photcodes[0].hashNsec[color[0].code]; 739 m2 = (Ns == -1) ? NAN : secfilt[Ns].M; 740 } 741 mc = (isnan(m1) || isnan(m2)) ? NAN : (m1 - m2); 742 return (mc); 743 } 744 745 /* return calibrated magnitude from average/secfilt for given photcode */ 746 float PhotRefTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure) { 747 748 int i, Ns; 749 float Mave, Mref, Mcol, mc; 750 double Mc; 751 752 if (code == NULL) return NAN; 753 754 Ns = photcodes[0].hashNsec[code[0].code]; 755 Mave = (Ns == -1) ? NAN : secfilt[Ns].M; 756 Mref = Mave + SCALE*code[0].C; 757 758 mc = PhotColorForCodeTiny (average, secfilt, measure, code); 759 if (isnan(mc)) return (Mref); 760 mc = mc - SCALE*code[0].dX; 761 762 Mc = mc; 763 Mcol = 0; 764 for (i = 0; i < code[0].Nc; i++) { 765 Mcol += code[0].X[i]*Mc; 766 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */ 767 } 768 Mref += Mcol; 769 return (Mref); 770 } 771 772 /***/ 773 float PhotAveTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt) { 774 775 int Ns; 776 float Mave; 777 778 if (code == NULL) return NAN; 779 780 Ns = photcodes[0].hashNsec[code[0].code]; 781 Mave = (Ns == -1) ? NAN : secfilt[Ns].M; 782 return (Mave); 783 } 784 785 float PhotdMTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt) { 786 787 int Ns; 788 float dM; 789 790 if (code == NULL) return NAN; 791 792 Ns = photcodes[0].hashNsec[code[0].code]; 793 dM = (Ns == -1) ? NAN : secfilt[Ns].dM; 794 return (dM); 795 } 796 797 // XXX return NAN or NAN_S_SHORT? (secfilt->Xm is short) 798 float PhotXmTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt) { 799 800 int Ns; 801 short Mi; 802 float Xm; 803 804 if (code == NULL) return NAN; 805 806 Ns = photcodes[0].hashNsec[code[0].code]; 807 Mi = (Ns == -1) ? NAN : secfilt[Ns].Xm; 808 Xm = (isnan(Mi)) ? -1.0 : pow (10.0, 0.01*Mi); 809 return (Xm); 810 } 811 812 /* given a photcode pair c1 & c2, return the color of this star (NaN if not found) */ 813 int PhotColorTiny (AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, int c1, int c2, double *color) { 814 815 int i, Ns; 816 double M1, M2, dM; 817 PhotCode *code; 818 819 code = GetPhotcodebyCode (c1); 820 if (code == NULL) return (FALSE); 821 if (code[0].type == PHOT_REF) { 822 for (i = 0; i < average[0].Nmeasure; i++) { 823 if (measure[i].photcode == c1) { 824 M1 = measure[i].M; 825 goto filter1; 826 } 827 } 828 return (FALSE); 829 } else { 830 Ns = photcodes[0].hashNsec[code[0].code]; 831 M1 = (Ns == -1) ? NAN : secfilt[Ns].M; 832 } 833 834 filter1: 835 code = GetPhotcodebyCode (c2); 836 if (code == NULL) return (FALSE); 837 if (code[0].type == PHOT_REF) { 838 for (i = 0; i < average[0].Nmeasure; i++) { 839 if (measure[i].photcode == c2) { 840 M2 = measure[i].M; 841 goto filter2; 842 } 843 } 844 return (FALSE); 845 } else { 846 Ns = photcodes[0].hashNsec[code[0].code]; 847 M2 = (Ns == -1) ? NAN : secfilt[Ns].M; 848 } 849 850 filter2: 851 852 dM = M1 - M2; 853 *color = dM; 854 855 return (TRUE); 856 } 857 /***********************************************/ 538 858 539 859 // Create a map between the secfilt values from one photcode table to another
Note:
See TracChangeset
for help on using the changeset viewer.
