- Timestamp:
- 02/16/11 14:59:40 (14 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/scantable.py
r1992 r1994 1014 1014 1015 1015 @asaplog_post_dec 1016 def flag(self, mask=None, unflag=False):1016 def flag(self, row=-1, mask=None, unflag=False): 1017 1017 """\ 1018 1018 Flag the selected data using an optional channel mask. … … 1020 1020 Parameters: 1021 1021 1022 row: an optional row number in the scantable. 1023 Default -1 flags all rows 1024 1022 1025 mask: an optional channel mask, created with create_mask. Default 1023 1026 (no mask) is all channels. … … 1028 1031 varlist = vars() 1029 1032 mask = mask or [] 1030 self._flag( mask, unflag)1033 self._flag(row, mask, unflag) 1031 1034 self._add_history("flag", varlist) 1032 1035 -
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 -
trunk/src/Scantable.h
r1947 r1994 230 230 */ 231 231 //void flag( const std::vector<bool>& msk = std::vector<bool>()); 232 void flag( const std::vector<bool>& msk = std::vector<bool>(), bool unflag=false); 232 //void flag( const std::vector<bool>& msk = std::vector<bool>(), bool unflag=false); 233 234 void flag( int whichrow = -1, const std::vector<bool>& msk = std::vector<bool>(), bool unflag=false); 233 235 234 236 /** … … 607 609 608 610 void doPolyBaseline(const std::vector<bool>& mask, int order, int rowno, Fitter& fitter); 611 612 void applyChanFlag( casa::uInt whichrow, const std::vector<bool>& msk, casa::uChar flagval); 613 614 609 615 }; 610 616 611 612 617 } // namespace 613 618 -
trunk/src/ScantableWrapper.h
r1947 r1994 109 109 { table_->flag(msk); } 110 110 **/ 111 /** 111 112 void flag(const std::vector<bool>& msk=std::vector<bool>(), bool unflag=false) 112 113 { table_->flag(msk, unflag); } 114 **/ 115 void flag(int whichrow=-1, const std::vector<bool>& msk=std::vector<bool>(), bool unflag=false) 116 { table_->flag(whichrow, msk, unflag); } 113 117 114 118 void flagRow(const std::vector<casa::uInt>& rows=std::vector<casa::uInt>(), bool unflag=false)
Note:
See TracChangeset
for help on using the changeset viewer.