Changeset 829
- Timestamp:
- 02/17/06 15:04:14 (19 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/MathUtils.cc
r465 r829 41 41 using namespace casa; 42 42 43 float mathutil::statistics(const String& which, 43 float mathutil::statistics(const String& which, 44 44 const MaskedArray<Float>& data) 45 45 { … … 47 47 str.upcase(); 48 48 if (str.contains(String("MIN"))) { 49 return min(data); 49 return min(data); 50 50 } else if (str.contains(String("MAX"))) { 51 51 return max(data); … … 57 57 return mean(data); 58 58 } else if (str.contains(String("VAR"))) { 59 return variance(data); 59 return variance(data); 60 60 } else if (str.contains(String("STDDEV"))) { 61 61 return stddev(data); … … 69 69 } 70 70 } 71 71 72 72 73 73 void mathutil::replaceMaskByZero(Vector<Float>& data, const Vector<Bool>& mask) … … 79 79 80 80 81 void mathutil::scanBoundaries(Vector<uInt>& startInt, 82 Vector<uInt>& endInt, 83 const Vector<Int>& scanIDs) 84 // Find integrations start and end for each Scan 85 { 86 uInt nInt = scanIDs.nelements(); 87 startInt.resize(nInt); 88 endInt.resize(nInt); 89 90 startInt(0) = 0; 91 uInt j = 0; 92 Int currScanID = scanIDs(0); 93 for (uInt i=0; i<nInt; i++) { 94 if (scanIDs(i) != currScanID) { 95 endInt(j) = i-1; 96 currScanID = scanIDs(i); 97 98 j += 1; 99 startInt(j) = i; 100 if (i==nInt-1) { 101 endInt(j) = i; 102 } 103 } else { 104 if (i==nInt-1) endInt(j) = i; 105 } 106 } 107 startInt.resize(j+1,True); 108 endInt.resize(j+1,True); 109 } 110 111 std::vector<std::string> mathutil::tovectorstring(const Vector<String>& in) 81 std::vector<std::string> mathutil::tovectorstring(const Vector<String>& in) 112 82 { 113 83 std::vector<std::string> out; … … 119 89 } 120 90 121 Vector<String> mathutil::toVectorString(const std::vector<std::string>& in) 91 Vector<String> mathutil::toVectorString(const std::vector<std::string>& in) 122 92 { 123 93 Vector<String> out(in.size()); -
trunk/src/MathUtils.h
r465 r829 40 40 namespace mathutil { 41 41 42 // Add new entry to list43 template <class T>44 casa::uInt addEntry(casa::Vector<T>& list, T val);45 46 // Find the scan boundaries from a list of ScanIDs47 void scanBoundaries(casa::Vector<casa::uInt>& startInt,48 casa::Vector<casa::uInt>& endInt,49 const casa::Vector<casa::Int>& scanIDs);50 51 42 // Hanning smoothing 52 43 template <class T> 53 void hanning(casa::Vector<T>& out, casa::Vector<casa::Bool>& outmask, 54 const casa::Vector<T>& in, const casa::Vector<casa::Bool>& mask, 55 casa::Bool relaxed=casa::False, 44 void hanning(casa::Vector<T>& out, casa::Vector<casa::Bool>& outmask, 45 const casa::Vector<T>& in, const casa::Vector<casa::Bool>& mask, 46 casa::Bool relaxed=casa::False, 56 47 casa::Bool ignoreOther=casa::False); 57 48 58 49 // Generate specified statistic 59 float statistics(const casa::String& which, 50 float statistics(const casa::String& which, 60 51 const casa::MaskedArray<casa::Float>& data); 61 52 62 53 // Replace masked value by zero 63 void replaceMaskByZero(casa::Vector<casa::Float>& data, 54 void replaceMaskByZero(casa::Vector<casa::Float>& data, 64 55 const casa::Vector<casa::Bool>& mask); 65 56 66 // Extend the67 template <class T>68 void extendLastArrayAxis(casa::Array<T>& out, const casa::Array<T>& in,69 const T& initVal);70 71 57 std::vector<std::string> tovectorstring(const casa::Vector<casa::String>& in); 72 58 -
trunk/src/MathUtils2.cc
r452 r829 41 41 42 42 template <class T> 43 void mathutil::hanning(Vector<T>& out, Vector<Bool>& outmask, 44 const Vector<T>& in, const Vector<Bool>& mask, 43 void mathutil::hanning(Vector<T>& out, Vector<Bool>& outmask, 44 const Vector<T>& in, const Vector<Bool>& mask, 45 45 Bool relaxed, Bool ignoreOther) { 46 46 … … 54 54 vals[0] = 0.5; vals[1] = 0.0; vals[2] = 0.5; weights[5] = vals;// TFT 55 55 vals[0] = 0.0; vals[1] = 2.0/3.0; vals[2] = 1.0/3.0; weights[6] = vals;// FTT 56 vals[0] = 0.25; vals[1] = 0.5; vals[2] = 0.25; weights[7] = vals;// TTT 56 vals[0] = 0.25; vals[1] = 0.5; vals[2] = 0.25; weights[7] = vals;// TTT 57 57 // Chris' case 58 Vector<Bool> weighted(8); 58 Vector<Bool> weighted(8); 59 59 if (relaxed) { 60 60 weighted = False; … … 65 65 weighted[0] = False; 66 66 } 67 67 68 68 out.resize(in.nelements()); 69 69 outmask.resize(mask.nelements()); … … 91 91 } 92 92 } 93 94 template <class T>95 uInt mathutil::addEntry (Vector<T>& list, T val)96 {97 uInt n = list.nelements();98 if (n>0) {99 for (uInt i=0; i<n; i++) {100 if (near(list[i],val)) {101 return i;102 }103 }104 }105 //106 n++;107 list.resize(n,True);108 list(n-1) = val;109 return n-1;110 }111 112 template <class T>113 void mathutil::extendLastArrayAxis(casa::Array<T>& out,114 const casa::Array<T>& in,115 const T& initVal)116 {117 118 IPosition ipin = in.shape();119 IPosition ipout = ipin; // copy?120 // extend the axis by 1121 uInt axis = in.ndim()-1;122 ipout[axis] = ipin[axis]+1;123 out.resize(ipout);124 out = initVal;125 ArrayIterator<T> itout(out,axis);126 ReadOnlyArrayIterator<T> itin(in,axis);127 while ( !itin.pastEnd() ) {128 itout.array() = itin.array(); // copy vector by vector129 itin.next(); itout.next();130 }131 }
Note:
See TracChangeset
for help on using the changeset viewer.