Changeset 315
- Timestamp:
- 01/28/05 02:09:17 (20 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDMath.cc
r309 r315 809 809 810 810 811 SDMemTable* SDMath::averagePol(const SDMemTable& in, const Vector<Bool>& mask) const 811 SDMemTable* SDMath::averagePol(const SDMemTable& in, const Vector<Bool>& mask, 812 const String& weightStr) const 812 813 // 813 814 // Average all polarizations together, weighted by variance 814 815 // 815 816 { 816 //WeightType wtType = NONE;817 // convertWeightString(wtType, weight);817 WeightType wtType = NONE; 818 convertWeightString(wtType, weightStr); 818 819 819 820 const uInt nRows = in.nRow(); … … 832 833 IPosition shapeOut(shapeIn); 833 834 shapeOut(asap::PolAxis) = 1; // Average all polarizations 835 if (shapeIn(asap::PolAxis)==1) { 836 throw(AipsError("The input has only one polarisation")); 837 } 834 838 // 835 839 const uInt nChan = shapeIn(asap::ChanAxis); … … 874 878 Vector<Bool> t2(nChan); t2 = True; 875 879 MaskedArray<Float> vecSum(t1,t2); 876 Float varSum = 0.0;880 Float norm = 0.0; 877 881 { 878 882 ReadOnlyVectorIterator<Float> itDataVec(itDataPlane.array(), 1); … … 880 884 while (!itDataVec.pastEnd()) { 881 885 882 // Create MA of data & mask (optionally including OTF mask) and get variance 886 // Create MA of data & mask (optionally including OTF mask) and get variance for this spectrum 883 887 884 888 if (useMask) { 885 889 const MaskedArray<Float> spec(itDataVec.vector(),mask&&itMaskVec.vector()); 886 fac = 1.0 / variance(spec);890 if (wtType==VAR) fac = 1.0 / variance(spec); 887 891 } else { 888 892 const MaskedArray<Float> spec(itDataVec.vector(),itMaskVec.vector()); 889 fac = 1.0 / variance(spec);893 if (wtType==VAR) fac = 1.0 / variance(spec); 890 894 } 891 895 … … 894 898 const MaskedArray<Float> spec(fac*itDataVec.vector(), itMaskVec.vector()); 895 899 vecSum += spec; 896 varSum += fac;900 norm += fac; 897 901 898 902 // Next … … 905 909 // Normalize summed spectrum 906 910 907 vecSum /= varSum;911 vecSum /= norm; 908 912 909 913 // FInd position in input data array. We are iterating by pol-channel -
trunk/src/SDMath.h
r309 r315 116 116 117 117 // Average polarizations 118 SDMemTable* averagePol(const SDMemTable& in, const casa::Vector<casa::Bool>& mask) const; 118 SDMemTable* averagePol(const SDMemTable& in, const casa::Vector<casa::Bool>& mask, 119 const casa::String& wtStr) const; 119 120 120 121 private: -
trunk/src/SDMathWrapper.cc
r312 r315 170 170 171 171 void SDMathWrapper::averagePolInSitu(SDMemTableWrapper& in, 172 const std::vector<bool>& mask) 172 const std::vector<bool>& mask, 173 const std::string& weightStr) 173 174 { 174 175 SDMemTable* pIn = in.getPtr(); 175 176 SDMath sdm; 176 177 Vector<Bool> tMask(mask); 177 SDMemTable* pOut = sdm.averagePol (*pIn, tMask );178 SDMemTable* pOut = sdm.averagePol (*pIn, tMask, String(weightStr)); 178 179 *pIn = *pOut; 179 180 delete pOut; … … 181 182 182 183 SDMemTableWrapper SDMathWrapper::averagePol (const SDMemTableWrapper& in, 183 const std::vector<bool>& mask )184 184 const std::vector<bool>& mask, 185 const std::string& weightStr) 185 186 { 186 187 const CountedPtr<SDMemTable>& pIn = in.getCP(); 187 188 SDMath sdm; 188 189 Vector<Bool> tMask(mask); 189 return CountedPtr<SDMemTable>(sdm.averagePol(*pIn, tMask ));190 return CountedPtr<SDMemTable>(sdm.averagePol(*pIn, tMask, String(weightStr))); 190 191 } 191 192 -
trunk/src/SDMathWrapper.h
r312 r315 102 102 103 103 // Average polarizations 104 void averagePolInSitu(SDMemTableWrapper& in, const std::vector<bool>& mask); 104 void averagePolInSitu(SDMemTableWrapper& in, const std::vector<bool>& mask, 105 const std::string& weightStr); 105 106 SDMemTableWrapper averagePol(const SDMemTableWrapper& in, 106 const std::vector<bool>& mask); 107 const std::vector<bool>& mask, 108 const std::string& weightStr); 107 109 108 110 // Statistics
Note:
See TracChangeset
for help on using the changeset viewer.