Changeset 2952
- Timestamp:
- 06/24/14 19:59:46 (11 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asapmath.py
r2904 r2952 1025 1025 1026 1026 @asaplog_post_dec 1027 def _array2dOp( scan, value, mode="ADD", tsys=False, insitu=None ):1027 def _array2dOp( scan, value, mode="ADD", tsys=False, insitu=None, skip_flaggedrow=False): 1028 1028 """ 1029 1029 This function is workaround on the basic operation of scantable … … 1036 1036 insitu: if False, a new scantable is returned. 1037 1037 Otherwise, the array operation is done in-sitsu. 1038 skip_flaggedrow: skip operation for row-flagged spectra. 1038 1039 """ 1039 1040 if insitu is None: insitu = rcParams['insitu'] … … 1044 1045 stm._setinsitu(insitu) 1045 1046 if len( value ) == 1: 1046 s = scantable( stm._arrayop( scan, value[0], mode, tsys ) )1047 s = scantable( stm._arrayop( scan, value[0], mode, tsys, skip_flaggedrow ) ) 1047 1048 elif len( value ) != nrow: 1048 1049 raise ValueError( 'len(value) must be 1 or conform to scan.nrow()' ) … … 1062 1063 s.set_selection( sel ) 1063 1064 if len( value[irow] ) == 1: 1064 stm._unaryop( s, value[irow][0], mode, tsys )1065 stm._unaryop( s, value[irow][0], mode, tsys, skip_flaggedrow ) 1065 1066 else: 1066 1067 #stm._arrayop( s, value[irow], mode, tsys, 'channel' ) 1067 stm._arrayop( s, value[irow], mode, tsys )1068 stm._arrayop( s, value[irow], mode, tsys, skip_flaggedrow ) 1068 1069 s.set_selection(basesel) 1069 1070 return s -
trunk/python/scantable.py
r2937 r2952 4797 4797 4798 4798 @asaplog_post_dec 4799 def scale(self, factor, tsys=True, insitu=None ):4799 def scale(self, factor, tsys=True, insitu=None, skip_flaggedrow=False): 4800 4800 """\ 4801 4801 … … 4813 4813 as well as the data 4814 4814 4815 skip_flaggedrow: if True, scaling is NOT executed for 4816 row-flagged spectra. default is False. 4815 4817 """ 4816 4818 if insitu is None: insitu = rcParams['insitu'] … … 4823 4825 numpy.ndarray): 4824 4826 from asapmath import _array2dOp 4825 s = _array2dOp( self, factor, "MUL", tsys, insitu )4827 s = _array2dOp( self, factor, "MUL", tsys, insitu, skip_flaggedrow ) 4826 4828 else: 4827 4829 s = scantable( self._math._arrayop( self, factor, 4828 "MUL", tsys ) )4830 "MUL", tsys, skip_flaggedrow ) ) 4829 4831 else: 4830 s = scantable(self._math._unaryop(self, factor, "MUL", tsys ))4832 s = scantable(self._math._unaryop(self, factor, "MUL", tsys, skip_flaggedrow)) 4831 4833 s._add_history("scale", varlist) 4832 4834 if insitu: -
trunk/src/STMath.cpp
r2950 r2952 618 618 float val, 619 619 const std::string& mode, 620 bool tsys ) 620 bool tsys, 621 bool skip_flaggedrow ) 621 622 { 622 623 CountedPtr< Scantable > out = getScantable(in, false); … … 624 625 ArrayColumn<Float> specCol(tab,"SPECTRA"); 625 626 ArrayColumn<Float> tsysCol(tab,"TSYS"); 627 ScalarColumn<uInt> flagrowCol(tab, "FLAGROW"); 626 628 if (mode=="DIV") val = 1.0/val ; 627 629 else if (mode=="SUB") val *= -1.0 ; … … 629 631 Vector<Float> spec; 630 632 Vector<Float> ts; 633 uInt flagrow; 631 634 specCol.get(i, spec); 632 635 tsysCol.get(i, ts); 636 flagrowCol.get(i, flagrow); 637 if (skip_flaggedrow && (flagrow > 0)) continue; 633 638 if (mode == "MUL" || mode == "DIV") { 634 639 //if (mode == "DIV") val = 1.0/val; … … 656 661 const std::string& mode, 657 662 const std::string& opmode, 658 bool tsys ) 663 bool tsys, 664 bool skip_flaggedrow ) 659 665 { 660 666 CountedPtr< Scantable > out ; 661 667 if ( opmode == "channel" ) { 662 out = arrayOperateChannel( in, val, mode, tsys ) ;668 out = arrayOperateChannel( in, val, mode, tsys, skip_flaggedrow ) ; 663 669 } 664 670 else if ( opmode == "row" ) { 665 out = arrayOperateRow( in, val, mode, tsys ) ;671 out = arrayOperateRow( in, val, mode, tsys, skip_flaggedrow ) ; 666 672 } 667 673 else { … … 674 680 const std::vector<float> val, 675 681 const std::string& mode, 676 bool tsys ) 682 bool tsys, 683 bool skip_flaggedrow ) 677 684 { 678 685 if ( val.size() == 1 ){ … … 721 728 ArrayColumn<Float> specCol(tab,"SPECTRA"); 722 729 ArrayColumn<Float> tsysCol(tab,"TSYS"); 730 ScalarColumn<uInt> flagrowCol(tab, "FLAGROW"); 723 731 if (mode == "DIV") fact = (float)1.0 / fact; 724 732 else if (mode == "SUB") fact *= (float)-1.0 ; … … 726 734 Vector<Float> spec; 727 735 Vector<Float> ts; 736 uInt flagrow; 728 737 specCol.get(i, spec); 729 738 tsysCol.get(i, ts); 739 flagrowCol.get(i, flagrow); 740 if (skip_flaggedrow && (flagrow > 0)) continue; 730 741 if (mode == "MUL" || mode == "DIV") { 731 742 //if (mode == "DIV") fact = (float)1.0 / fact; … … 752 763 const std::vector<float> val, 753 764 const std::string& mode, 754 bool tsys ) 765 bool tsys, 766 bool skip_flaggedrow ) 755 767 { 756 768 if ( val.size() == 1 ) { … … 788 800 ArrayColumn<Float> specCol(tab,"SPECTRA"); 789 801 ArrayColumn<Float> tsysCol(tab,"TSYS"); 802 ScalarColumn<uInt> flagrowCol(tab, "FLAGROW"); 790 803 if (mode == "DIV") fact = (float)1.0 / fact; 791 804 if (mode == "SUB") fact *= (float)-1.0 ; … … 793 806 Vector<Float> spec; 794 807 Vector<Float> ts; 808 uInt flagrow; 795 809 specCol.get(i, spec); 796 810 tsysCol.get(i, ts); 811 flagrowCol.get(i, flagrow); 812 if (skip_flaggedrow && (flagrow > 0)) continue; 797 813 if (mode == "MUL" || mode == "DIV") { 798 814 spec *= fact[i]; -
trunk/src/STMath.h
r2919 r2952 15 15 #include <map> 16 16 #include <string> 17 #include <iostream> 17 18 18 19 #include <casa/aips.h> … … 117 118 casa::CountedPtr<Scantable> 118 119 unaryOperate( const casa::CountedPtr<Scantable>& in, float val, 119 const std::string& mode, bool tsys=false ); 120 const std::string& mode, bool tsys=false, 121 bool skip_flaggedrow=false ); 120 122 121 123 // array operation … … 125 127 const std::string& mode, 126 128 const std::string& opmode="channel", 127 bool tsys=false ); 129 bool tsys=false, 130 bool skip_flaggedrow=false ); 128 131 129 132 // channel operation … … 131 134 arrayOperateChannel( const casa::CountedPtr<Scantable>& in, 132 135 const std::vector<float> val, 133 const std::string& mode, bool tsys=false ); 136 const std::string& mode, bool tsys=false, 137 bool skip_flaggedrow=false ); 134 138 135 139 // row operation … … 137 141 arrayOperateRow( const casa::CountedPtr<Scantable>& in, 138 142 const std::vector<float> val, 139 const std::string& mode, bool tsys=false ); 143 const std::string& mode, bool tsys=false, 144 bool skip_flaggedrow=false ); 140 145 141 146 // 2d array operation -
trunk/src/STMathWrapper.h
r2900 r2952 70 70 ScantableWrapper 71 71 unaryOperate( const ScantableWrapper& in, float val, 72 const std::string& mode, bool tsys=false ) 73 { return ScantableWrapper(STMath::unaryOperate(in.getCP(), val, mode, tsys)); } 72 const std::string& mode, bool tsys=false, 73 bool skip_flaggedrow=false ) 74 { return ScantableWrapper(STMath::unaryOperate(in.getCP(), val, mode, tsys, skip_flaggedrow)); } 74 75 75 76 ScantableWrapper arrayOperate( const ScantableWrapper& in, 76 77 const std::vector<float> val, 77 78 const std::string& mode, 78 bool tsys=false ) 79 { return ScantableWrapper(STMath::arrayOperateChannel(in.getCP(), val, mode, tsys)); } 79 bool tsys=false, 80 bool skip_flaggedrow=false ) 81 { return ScantableWrapper(STMath::arrayOperateChannel(in.getCP(), val, mode, tsys, skip_flaggedrow)); } 80 82 81 83 ScantableWrapper array2dOperate( const ScantableWrapper& in,
Note:
See TracChangeset
for help on using the changeset viewer.