Changeset 1994 for trunk/src/Scantable.cpp
- Timestamp:
- 02/16/11 14:59:40 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/Scantable.cpp
r1987 r1994 778 778 } 779 779 780 void Scantable::flag(const std::vector<bool>& msk, bool unflag) 781 {780 781 void Scantable::flag( int whichrow, const std::vector<bool>& msk, bool unflag ) { 782 782 std::vector<bool>::const_iterator it; 783 783 uInt ntrue = 0; 784 if (whichrow >= int(table_.nrow()) ) { 785 throw(AipsError("Invalid row number")); 786 } 784 787 for (it = msk.begin(); it != msk.end(); ++it) { 785 788 if ( *it ) { … … 787 790 } 788 791 } 789 if ( selector_.empty() && (msk.size() == 0 || msk.size() == ntrue) ) 792 //if ( selector_.empty() && (msk.size() == 0 || msk.size() == ntrue) ) 793 if ( whichrow == -1 && !unflag && selector_.empty() && (msk.size() == 0 || msk.size() == ntrue) ) 790 794 throw(AipsError("Trying to flag whole scantable.")); 795 uChar userflag = 1 << 7; 796 if ( unflag ) { 797 userflag = 0 << 7; 798 } 799 if (whichrow > -1 ) { 800 applyChanFlag(uInt(whichrow), msk, userflag); 801 } else { 802 for ( uInt i=0; i<table_.nrow(); ++i) { 803 applyChanFlag(i, msk, userflag); 804 } 805 } 806 } 807 808 void Scantable::applyChanFlag( uInt whichrow, const std::vector<bool>& msk, uChar flagval ) 809 { 810 if (whichrow >= table_.nrow() ) { 811 throw( casa::indexError<int>( whichrow, "asap::Scantable::applyChanFlag: Invalid row number" ) ); 812 } 813 Vector<uChar> flgs = flagsCol_(whichrow); 791 814 if ( msk.size() == 0 ) { 792 uChar userflag = 1 << 7; 793 if ( unflag ) { 794 userflag = 0 << 7; 795 } 796 for ( uInt i=0; i<table_.nrow(); ++i) { 797 Vector<uChar> flgs = flagsCol_(i); 798 flgs = userflag; 799 flagsCol_.put(i, flgs); 800 } 815 flgs = flagval; 816 flagsCol_.put(whichrow, flgs); 801 817 return; 802 818 } … … 804 820 throw(AipsError("Mask has incorrect number of channels.")); 805 821 } 806 for ( uInt i=0; i<table_.nrow(); ++i) { 807 Vector<uChar> flgs = flagsCol_(i); 808 if ( flgs.nelements() != msk.size() ) { 809 throw(AipsError("Mask has incorrect number of channels." 810 " Probably varying with IF. Please flag per IF")); 811 } 812 std::vector<bool>::const_iterator it; 813 uInt j = 0; 814 uChar userflag = 1 << 7; 815 if ( unflag ) { 816 userflag = 0 << 7; 817 } 818 for (it = msk.begin(); it != msk.end(); ++it) { 819 if ( *it ) { 820 flgs(j) = userflag; 821 } 822 ++j; 823 } 824 flagsCol_.put(i, flgs); 825 } 822 if ( flgs.nelements() != msk.size() ) { 823 throw(AipsError("Mask has incorrect number of channels." 824 " Probably varying with IF. Please flag per IF")); 825 } 826 std::vector<bool>::const_iterator it; 827 uInt j = 0; 828 for (it = msk.begin(); it != msk.end(); ++it) { 829 if ( *it ) { 830 flgs(j) = flagval; 831 } 832 ++j; 833 } 834 flagsCol_.put(whichrow, flgs); 826 835 } 827 836
Note: See TracChangeset
for help on using the changeset viewer.