Changeset 1514 for branches/alma
- Timestamp:
- 02/23/09 20:55:35 (16 years ago)
- Location:
- branches/alma/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/alma/src/MathUtils.cpp
r1446 r1514 76 76 } 77 77 78 IPosition mathutil::minMaxPos(const String& which, 79 const MaskedArray<Float>& data) 80 { 81 Float minVal, maxVal; 82 IPosition minPos(data.ndim(), 0), maxPos(data.ndim(), 0); 83 minMax(minVal, maxVal, minPos, maxPos, data); 84 String str(which); 85 str.upcase(); 86 if (str.matches(String("MINPOS"))) { 87 return minPos; 88 } else if (str.matches(String("MAXPOS"))) { 89 return maxPos; 90 } else { 91 String msg = str + " is not a valid type of statistics"; 92 throw(AipsError(msg)); 93 } 94 //return 0.0; 95 } 78 96 79 97 void mathutil::replaceMaskByZero(Vector<Float>& data, const Vector<Bool>& mask) -
branches/alma/src/MathUtils.h
r1446 r1514 37 37 #include <casa/Arrays/Vector.h> 38 38 #include <casa/BasicSL/String.h> 39 #include <casa/Arrays/IPosition.h> 39 40 40 41 namespace mathutil { … … 77 78 const casa::MaskedArray<casa::Float>& data); 78 79 80 // Return a position of min or max value 81 casa::IPosition minMaxPos(const casa::String& which, 82 const casa::MaskedArray<casa::Float>& data); 83 79 84 // Replace masked value by zero 80 85 void replaceMaskByZero(casa::Vector<casa::Float>& data, -
branches/alma/src/STMath.cpp
r1459 r1514 1093 1093 } 1094 1094 out.push_back(outstat); 1095 } 1096 return out; 1097 } 1098 1099 std::vector< int > STMath::minMaxPos( const CountedPtr< Scantable > & in, 1100 const std::vector< bool > & mask, 1101 const std::string& which ) 1102 { 1103 1104 Vector<Bool> m(mask); 1105 const Table& tab = in->table(); 1106 ROArrayColumn<Float> specCol(tab, "SPECTRA"); 1107 ROArrayColumn<uChar> flagCol(tab, "FLAGTRA"); 1108 std::vector<int> out; 1109 for (uInt i=0; i < tab.nrow(); ++i ) { 1110 Vector<Float> spec; specCol.get(i, spec); 1111 Vector<uChar> flag; flagCol.get(i, flag); 1112 MaskedArray<Float> ma = maskedArray(spec, flag); 1113 if (ma.ndim() != 1) { 1114 throw (ArrayError( 1115 "std::vector<int> STMath::minMaxPos(" 1116 "ContedPtr<Scantable> &in, std::vector<bool> &mask, " 1117 " std::string &which)" 1118 " - MaskedArray is not 1D")); 1119 } 1120 IPosition outpos(1,0); 1121 if ( spec.nelements() == m.nelements() ) { 1122 outpos = mathutil::minMaxPos(which, ma(m)); 1123 } else { 1124 outpos = mathutil::minMaxPos(which, ma); 1125 } 1126 out.push_back(outpos[0]); 1095 1127 } 1096 1128 return out; -
branches/alma/src/STMath.h
r1446 r1514 207 207 const std::string& which); 208 208 209 std::vector< int > minMaxPos(const casa::CountedPtr<Scantable>& in, 210 const std::vector<bool>& mask, 211 const std::string& which); 212 209 213 casa::CountedPtr<Scantable> bin( const casa::CountedPtr<Scantable>& in, 210 214 int width=5); -
branches/alma/src/STMathWrapper.h
r1446 r1514 121 121 { return STMath::statistic(in.getCP(), mask, which); } 122 122 123 std::vector<int> minMaxPos(const ScantableWrapper& in, 124 const std::vector<bool>& mask, 125 const std::string& which) 126 { return STMath::minMaxPos(in.getCP(), mask, which); } 127 123 128 ScantableWrapper bin( const ScantableWrapper& in, int width=5) 124 129 { return ScantableWrapper(STMath::bin(in.getCP(), width)); } -
branches/alma/src/python_STMath.cpp
r1446 r1514 57 57 .def("_dofs", &STMathWrapper::dofs) 58 58 .def("_stats", &STMathWrapper::statistic) 59 .def("_minmaxpos", &STMathWrapper::minMaxPos) 59 60 .def("_freqswitch", &STMathWrapper::freqSwitch) 60 61 .def("_bin", &STMathWrapper::bin)
Note:
See TracChangeset
for help on using the changeset viewer.