Changeset 40249
- Timestamp:
- Dec 7, 2017, 5:54:38 AM (9 years ago)
- Location:
- branches/eam_branches/ohana.20170822/src
- Files:
-
- 2 edited
-
libdvo/include/dvo.h (modified) (1 diff)
-
relphot/src/setMrelCatalog.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20170822/src/libdvo/include/dvo.h
r40247 r40249 248 248 249 249 ID_SECF_CHIP_FLAGS = 0x01003f1f, // all chip-related bits (used to reset the correct bits only) 250 ID_SECF_STACK_FLAGS = 0x000 04020, // all stack-related bits (250 ID_SECF_STACK_FLAGS = 0x0003c020, // all stack-related bits ( 251 251 } DVOSecfiltFlags; 252 252 -
branches/eam_branches/ohana.20170822/src/relphot/src/setMrelCatalog.c
r40248 r40249 565 565 int haveStack = FALSE; 566 566 567 off_t stackPrimaryMeasure = -1;568 569 567 int isBad = FALSE; 570 568 int isSuspect = FALSE; … … 572 570 int NstackMeas = 0; // number of stack measurements for this photcode 573 571 int NstackDet = 0; // number of stack detections for this photcode (not forced) 572 573 int primaryLevelMax = 0; 574 off_t primaryEntryMax = -1; 575 float primaryValueMax = 0.0; 574 576 575 577 int bestLevelMax = 0; … … 579 581 int Nprimary = 0; 580 582 583 // reset all stack-related values for this secfilt: 581 584 secfilt[Nsec].stackBestOff = -1; 582 585 secfilt[Nsec].stackPrmryOff = -1; 583 584 off_t meas = measureOffset; 585 for (off_t k = 0; k < Nmeasure; k++, meas++) { 586 secfilt[Nsec].FpsfStk = NAN; 587 secfilt[Nsec].dFpsfStk = NAN; 588 secfilt[Nsec].FkronStk = NAN; 589 secfilt[Nsec].dFkronStk = NAN; 590 secfilt[Nsec].FapStk = NAN; 591 secfilt[Nsec].dFapStk = NAN; 592 secfilt[Nsec].MpsfStk = NAN; 593 secfilt[Nsec].MkronStk = NAN; 594 secfilt[Nsec].MapStk = NAN; 595 secfilt[Nsec].Nstack = 0; 596 secfilt[Nsec].NstackDet = 0; 597 secfilt[Nsec].flags &= ~ID_SECF_STACK_FLAGS; // reset the stack flags 598 599 for (off_t k = 0; k < Nmeasure; k++) { 586 600 587 601 // only examine gpc1 stack data … … 594 608 595 609 NstackMeas ++; 596 if ((measure[k].photFlags2 & 0x00000004) == 0) NstackDet ++; 610 if ((measure[k].photFlags2 & 0x00000004) == 0) NstackDet ++; // 0x04 = PM_SOURCE_MODE2_MATCHED 597 611 598 612 // clear this bit for all measurements … … 603 617 haveStackObject = TRUE; 604 618 605 XXX ???if (measure[k].dbFlags & MEAS_BAD) SKIP_THIS_MEAS_STACK(Nbad);619 // if (measure[k].dbFlags & MEAS_BAD) SKIP_THIS_MEAS_STACK(Nbad); 606 620 607 621 int isPrimary = FALSE; … … 610 624 611 625 // if we request the primary (USE_TREE_FOR_PRIMARY), this is true if the measurement 612 // is from the primary skycell for this position 613 if (MatchImageSkycellID (meas, cat, tessID, projectID, skycellID)) { 626 // is from the primary skycell for this position. (note that MatchImageSkycellID 627 // requires the entry in the full Measure table, not just this object) 628 if (MatchImageSkycellID (measureOffset + k, cat, tessID, projectID, skycellID)) { 614 629 measure[k].dbFlags |= ID_MEAS_STACK_PRIMARY; 615 630 isPrimary = TRUE; … … 617 632 } 618 633 619 int psfQFperfAboveLimit = isfinite(measure[k].psfQFperf) && (measure[k].psfQFperf > 0.95); 634 // soften the error floor (can dM be 0.0?) 635 int SNvalue = isfinite(measure[k].dM) ? 1.0 / hypot (measure[k].dM, MIN_ERROR) : NAN; 636 int psfQFperfAboveLimit = isfinite(SNvalue) && isfinite(measure[k].psfQFperf) && (measure[k].psfQFperf > 0.95); 620 637 621 638 // ** determine the BEST level … … 627 644 628 645 // here is the rule for choosing the best value: 629 // XXX what if dM = 0.0 or NAN? (treat as bestLevel 1 or 2?) 630 bestValue = (bestLevel > 2) ? 1.0 / measure[k].dM : measure[k].psfQFperf; 646 float bestValue = (bestLevel > 2) ? SNvalue : measure[k].psfQFperf; 631 647 632 648 // if we have not reached this level before, set the new level … … 649 665 650 666 // here is the rule for choosing the PRIMARY value: 651 // XXX what if dM = 0.0 or NAN? (treat as bestLevel 1 or 2?) 652 primaryValue = 0.0; 667 float primaryValue = 0.0; 653 668 if (primaryLevel == 1) { primaryValue = measure[k].psfQFperf; } 654 if (primaryLevel == 2) { primaryValue = 1.0 / measure[k].dM; }669 if (primaryLevel == 2) { primaryValue = SNvalue; } 655 670 656 671 // if we have not reached this level before, set the new level … … 672 687 // now we have a BEST and a PRIMARY entry (may be the same entry) 673 688 674 secfilt[Nsec].stackPrmryOff = (primaryEntryMax == -1) ? -1 : primaryEntryMax + measureOffset; 675 myAssert (secfilt[Nsec].stackPrmryOff <= catalog[0].Nmeasure, "stackPrmryOff out of range"); 676 677 meas = bestEntryMax; 689 off_t meas = bestEntryMax; 678 690 myAssert (meas >= 0, "this should not happen"); 679 691 … … 687 699 // data for which the associated image has not been loaded (probably because of 688 700 // overlaps). Msys + measure.Mcal is our best guess of the true magnitude 689 Mmos = Mgrid = 0; 690 McalPSF = measure[meas].McalPSF; // check that this is zero for loaded REF value 701 McalPSF = measure[meas].McalPSF; // check that this is zero for loaded REF value 691 702 McalAPER = McalPSF; // check that this is zero for loaded REF value 703 Mmos = 0.0; 704 Mgrid = 0.0; 692 705 } else { 693 McalPSF = getMcal (meas, cat, MAG_CLASS_PSF); 694 if (isnan(McalPSF)) SKIP_THIS_MEAS_STACK(Ncal); // XXX really skip? 695 706 McalPSF = getMcal (meas, cat, MAG_CLASS_PSF); 696 707 McalAPER = getMcal (meas, cat, MAG_CLASS_KRON); 697 if (isnan(McalAPER)) SKIP_THIS_MEAS_STACK(Ncal); // XXX really skip? 698 699 Mmos = getMmos (meas, cat); 700 if (isnan(Mmos)) SKIP_THIS_MEAS_STACK(Nmos); 701 Mgrid = getMgrid (meas, cat); 702 if (isnan(Mgrid)) SKIP_THIS_MEAS_STACK(Ngrid); 708 Mmos = getMmos (meas, cat); 709 Mgrid = getMgrid (meas, cat); 703 710 } 704 711 705 // NOTE: negative and insignificant flux values are allowed, but not NAN flux values706 float Finst = PhotFluxInst (&measure[meas], MAG_CLASS_PSF);707 if (isnan(Finst)) SKIP_THIS_MEAS_STACK(Ninst);708 709 // data quality assessment710 isBad |= (measure[meas].photFlags & code->photomBadMask);711 isBad |= (measure[meas].psfQF < 0.85);712 isBad |= isnan(measure[meas].psfQF);713 isBad |= measure[meas].dM > 0.2; // S/N < 5.0714 715 isSuspect |= (measure[meas].photFlags & code->photomPoorMask);716 isSuspect |= (measure[meas].psfQFperf < 0.85);717 718 if (!isSuspect && !isBad) {719 NstackGood ++;720 }721 if (isSuspect && !isBad) {722 NstackSuspect ++;723 }724 725 // we are now populating stackDetectID not stack Image ID in secfilt726 // ID = (stackPrimaryMeasureMin >= 0) ? stackPrimaryIDmin : stackCenterIDmin;727 // ID = measure[meas].extID; // for the stack, this is the stackDetectID728 729 712 // ** Here is the math to relate mag,zp to flux 730 713 … … 780 763 781 764 // Jy to AB mags 782 secfilt[Nsec].MpsfStk = (measure[meas].FluxPSF > 0.0) ? 8.9 - 2.5*log10(secfilt[Nsec].FpsfStk) : NAN;765 secfilt[Nsec].MpsfStk = (measure[meas].FluxPSF > 0.0) ? 8.9 - 2.5*log10(secfilt[Nsec].FpsfStk) : NAN; 783 766 secfilt[Nsec].MkronStk = (measure[meas].FluxKron > 0.0) ? 8.9 - 2.5*log10(secfilt[Nsec].FkronStk) : NAN; 784 secfilt[Nsec].MapStk = (measure[meas].FluxAp > 0.0) ? 8.9 - 2.5*log10(secfilt[Nsec].FapStk) : NAN;767 secfilt[Nsec].MapStk = (measure[meas].FluxAp > 0.0) ? 8.9 - 2.5*log10(secfilt[Nsec].FapStk) : NAN; 785 768 786 769 // record the measurement which gave the best value 787 secfilt[Nsec].stackBestOff = (bestEntryMax > -1) ? bestEntryMax + measureOffset;770 secfilt[Nsec].stackBestOff = (bestEntryMax > -1) ? -1 : bestEntryMax + measureOffset; 788 771 myAssert (secfilt[Nsec].stackBestOff <= catalog[0].Nmeasure, "stackBestOff out of range"); 789 772 790 secfilt[Nsec].Nstack = NstackMeas; 791 secfilt[Nsec].NstackDet = NstackDet; 792 793 // this is the measurement used by secfilt[] 773 // record the selected primary measurement 774 secfilt[Nsec].stackPrmryOff = (primaryEntryMax == -1) ? -1 : primaryEntryMax + measureOffset; 775 myAssert (secfilt[Nsec].stackPrmryOff <= catalog[0].Nmeasure, "stackPrmryOff out of range"); 776 777 // this is the selected measurement used by secfilt[] 794 778 measure[meas].dbFlags |= ID_MEAS_STACK_PHOT_SRC; 795 779 if (Nprimary) { … … 801 785 802 786 // stack measurement used for 'best' was a detection (not forced from the other bands) 803 if ((measure[ meas].photFlags2 & 0x00000004) == 0) {787 if ((measure[bestEntryMax].photFlags2 & 0x00000004) == 0) { 804 788 secfilt[Nsec].flags |= ID_SECF_STACK_BESTDET; 805 789 } 790 806 791 // stack measurement used for 'primary' was a detection (not forced from the other bands) 807 792 if ((primaryEntryMax >= 0) && ((measure[primaryEntryMax].photFlags2 & 0x00000004) == 0)) { … … 810 795 811 796 secfilt[Nsec].flags |= ID_SECF_HAS_PS1_STACK; 797 798 // NOTE: negative and insignificant flux values are allowed, but not NAN flux values 799 // float Finst = PhotFluxInst (&measure[meas], MAG_CLASS_PSF); 800 801 // data quality assessment 802 isBad |= (measure[meas].photFlags & photcodes[Ns][0].photomBadMask); 803 isBad |= (measure[meas].psfQF < 0.85); 804 isBad |= isnan(measure[meas].psfQF); 805 isBad |= measure[meas].dM > 0.2; // S/N < 5.0 806 807 isSuspect |= (measure[meas].photFlags & photcodes[Ns][0].photomPoorMask); 808 isSuspect |= (measure[meas].psfQFperf < 0.85); 809 810 if (!isSuspect && !isBad) { 811 NstackGood ++; 812 } 813 if (isSuspect && !isBad) { 814 NstackSuspect ++; 815 } 816 817 secfilt[Nsec].Nstack = NstackMeas; 818 secfilt[Nsec].NstackDet = NstackDet; 819 812 820 } // Nsecfilt loop 813 821 … … 820 828 821 829 int PrimaryIsBest = TRUE; 822 for ( Ns = 0; Ns < Nphotcodes; Ns++) {830 for (int Ns = 0; Ns < Nphotcodes; Ns++) { 823 831 if (!(secfilt[Ns].flags & ID_SECF_HAS_PS1_STACK)) continue; // no stack detection in PS1, nothing is best 824 832 if (secfilt[Ns].flags & ID_SECF_STACK_PRIMARY) continue; // primary stack detection is best
Note:
See TracChangeset
for help on using the changeset viewer.
