Changeset 227
- Timestamp:
- 01/19/05 19:31:46 (20 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDMath.cc
r221 r227 49 49 #include <scimath/Mathematics/VectorKernel.h> 50 50 #include <scimath/Mathematics/Convolver.h> 51 #include <scimath/Mathematics/InterpolateArray1D.h> 51 52 52 53 #include <tables/Tables/Table.h> 53 54 #include <tables/Tables/ScalarColumn.h> 54 55 #include <tables/Tables/ArrayColumn.h> 56 #include <tables/Tables/ReadAsciiTable.h> 55 57 56 58 #include <lattices/Lattices/LatticeUtilities.h> … … 96 98 CountedPtr<SDMemTable> SDMath::average(const Block<CountedPtr<SDMemTable> >& in, 97 99 const Vector<Bool>& mask, Bool scanAv, 98 const std::string& weightStr)100 const String& weightStr) 99 101 //Bool alignVelocity) 100 102 // … … 327 329 oldScanID = scanID; 328 330 outScanID += 1; // Scan ID for next accumulation period 329 330 } 331 } 331 332 332 333 // Accumulate … … 948 949 949 950 951 SDMemTable* SDMath::gainElevation (const SDMemTable& in, const String& fileName, 952 const String& methodStr, Bool doAll) 953 { 954 SDHeader sh = in.getSDHeader(); 955 SDMemTable* pTabOut = new SDMemTable(in, True); 956 const uInt nRow = in.nRow(); 957 958 // Get elevation column from data 959 960 const Table& tab = in.table(); 961 ROScalarColumn<Float> elev(tab, "ELEVATION"); 962 963 // Read gain-elevation ascii file data into a Table. 964 965 Table geTable = readAsciiFile (fileName); 966 ROScalarColumn<Float> geElCol(geTable, "ELEVATION"); 967 ROScalarColumn<Float> geFacCol(geTable, "FACTOR"); 968 Vector<Float> xIn = geElCol.getColumn(); 969 Vector<Float> yIn = geFacCol.getColumn(); 970 Vector<Bool> maskIn(xIn.nelements(),True); 971 972 // Get elevation vector from data 973 974 Vector<Float> xOut = elev.getColumn(); 975 xOut *= Float(180 / C::pi); 976 977 // Interpolate (and extrapolate) with desired method 978 979 Int method = 0; 980 convertInterpString(method, methodStr); 981 // 982 Vector<Float> yOut; 983 Vector<Bool> maskOut; 984 InterpolateArray1D<Float,Float>::interpolate(yOut, maskOut, xOut, 985 xIn, yIn, maskIn, method, 986 True, True); 987 988 // For operations only on specified cursor location 989 990 IPosition start, end; 991 getCursorLocation(start, end, in); 992 993 // Loop over rows and interpolate correction factor 994 995 const uInt axis = asap::ChanAxis; 996 for (uInt i=0; i < in.nRow(); ++i) { 997 998 // Get data 999 1000 MaskedArray<Float> dataIn(in.rowAsMaskedArray(i)); 1001 Array<Float>& valuesIn = dataIn.getRWArray(); // writable reference 1002 const Array<Bool>& maskIn = dataIn.getMask(); 1003 1004 // Apply factor 1005 1006 if (doAll) { 1007 VectorIterator<Float> itValues(valuesIn, asap::ChanAxis); 1008 while (!itValues.pastEnd()) { 1009 itValues.vector() *= yOut(i); // Writes back into dataIn 1010 // 1011 itValues.next(); 1012 } 1013 } else { 1014 Array<Float> valuesIn2 = valuesIn(start,end); 1015 valuesIn2 *= yOut(i); 1016 valuesIn(start,end) = valuesIn2; 1017 } 1018 1019 // Write out 1020 1021 SDContainer sc = in.getSDContainer(i); 1022 putDataInSDC(sc, valuesIn, maskIn); 1023 // 1024 pTabOut->putSDContainer(sc); 1025 } 1026 1027 // Delete temporary gain/el Table 1028 1029 geTable.markForDelete(); 1030 // 1031 return pTabOut; 1032 } 1033 1034 1035 950 1036 // 'private' functions 951 1037 … … 956 1042 Int scanID, Double timeStamp, 957 1043 Double interval, const String& sourceName, 958 const Vector<uInt>& freqID) 1044 const Vector<uInt>& freqID) const 959 1045 { 960 1046 // Data and mask … … 980 1066 const Array<Float>& nPts, 981 1067 WeightType wtType, Int axis, 982 Int nAxesSub) 1068 Int nAxesSub) const 983 1069 { 984 1070 IPosition pos2(nAxesSub,0); … … 1017 1103 uInt iTab, uInt iRow, uInt axis, 1018 1104 uInt nAxesSub, Bool useMask, 1019 WeightType wtType) 1105 WeightType wtType) const 1020 1106 { 1021 1107 … … 1085 1171 1086 1172 void SDMath::getCursorLocation(IPosition& start, IPosition& end, 1087 const SDMemTable& in) 1173 const SDMemTable& in) const 1088 1174 { 1089 1175 const uInt nDim = 4; … … 1107 1193 1108 1194 1109 void SDMath::convertWeightString(WeightType& wtType, const std::string& weightStr)1195 void SDMath::convertWeightString(WeightType& wtType, const String& weightStr) const 1110 1196 { 1111 1197 String tStr(weightStr); … … 1123 1209 } 1124 1210 1211 void SDMath::convertInterpString(Int& type, const String& interp) const 1212 { 1213 String tStr(interp); 1214 tStr.upcase(); 1215 if (tStr.contains(String("NEAR"))) { 1216 type = InterpolateArray1D<Float,Float>::nearestNeighbour; 1217 } else if (tStr.contains(String("LIN"))) { 1218 type = InterpolateArray1D<Float,Float>::linear; 1219 } else if (tStr.contains(String("CUB"))) { 1220 type = InterpolateArray1D<Float,Float>::cubic; 1221 } else if (tStr.contains(String("SPL"))) { 1222 type = InterpolateArray1D<Float,Float>::spline; 1223 } else { 1224 throw(AipsError("Unrecognized interpolation type")); 1225 } 1226 } 1227 1125 1228 void SDMath::putDataInSDC(SDContainer& sc, const Array<Float>& data, 1126 const Array<Bool>& mask) 1229 const Array<Bool>& mask) const 1127 1230 { 1128 1231 sc.putSpectrum(data); … … 1132 1235 sc.putFlags(outflags); 1133 1236 } 1237 1238 Table SDMath::readAsciiFile (const String& fileName) const 1239 { 1240 String tableName("___asap_temp.tbl"); 1241 readAsciiTable (fileName, "", tableName); 1242 Table tbl(tableName); 1243 return tbl; 1244 } -
trunk/src/SDMath.h
r221 r227 37 37 #include <casa/Utilities/CountedPtr.h> 38 38 39 class casa::Table; 40 39 41 namespace asap { 40 42 … … 64 66 casa::CountedPtr<SDMemTable> average(const casa::Block<casa::CountedPtr<SDMemTable> >& in, 65 67 const casa::Vector<casa::Bool>& mask, 66 casa::Bool scanAverage, const std::string& weightStr);68 casa::Bool scanAverage, const casa::String& weightStr); 67 69 // casa::Bool alignVelocity); 68 70 … … 81 83 SDMemTable* convertFlux (const SDMemTable& in, casa::Float area, 82 84 casa::Float eta, casa::Bool doAll); 85 86 // Gain-elevation correction 87 SDMemTable* gainElevation (const SDMemTable& in, const casa::String& fileName, 88 const casa::String& method, casa::Bool doAll); 83 89 84 90 // Simple mathematical operations. what=0 (mul) or 1 (add) … … 104 110 const casa::Block<casa::CountedPtr<SDMemTable> >& in, 105 111 casa::uInt iTab, casa::uInt iRow, casa::uInt axis, casa::uInt nAxesSub, 106 casa::Bool useMask, WeightType wtType) ;112 casa::Bool useMask, WeightType wtType) const; 107 113 108 114 // Function to fill Scan Container when averaging in time … … 113 119 casa::Int scanID, casa::Double timeStamp, 114 120 casa::Double interval, const casa::String& sourceName, 115 const casa::Vector<casa::uInt>& freqID) ;121 const casa::Vector<casa::uInt>& freqID) const; 116 122 117 123 // Put the data and mask into the SDContainer 118 124 void putDataInSDC (SDContainer& sc, const casa::Array<casa::Float>& data, 119 const casa::Array<casa::Bool>& mask) ;125 const casa::Array<casa::Bool>& mask) const; 120 126 121 127 // Function to normalize data when averaging in time … … 124 130 const casa::Array<casa::Float>& sumSq, 125 131 const casa::Array<casa::Float>& nPts, 126 WeightType wtType, casa::Int axis, casa::Int nAxes) ;132 WeightType wtType, casa::Int axis, casa::Int nAxes) const; 127 133 128 134 // Function to get the current cursor location 129 135 void getCursorLocation (casa::IPosition& start, casa::IPosition& end, 130 const SDMemTable& in) ;136 const SDMemTable& in) const; 131 137 132 138 // Convert weight string to enum value 133 139 134 void convertWeightString (WeightType& wt, const std::string& weightStr); 140 void convertWeightString (WeightType& wt, const casa::String& weightStr) const; 141 142 // Convert interpolation type string 143 void convertInterpString(casa::Int& type, const casa::String& interp) const; 144 145 // Read ascii file 146 147 casa::Table readAsciiFile (const casa::String& fileName) const; 148 135 149 }; 136 150 -
trunk/src/SDMathWrapper.cc
r222 r227 162 162 { 163 163 SDMath sdm; 164 return sdm.statistic(in.getCP(), mask, which);164 return sdm.statistic(in.getCP(), mask, String(which)); 165 165 } 166 166 … … 185 185 } 186 186 187 188 void SDMathWrapper::gainElevationInSitu(SDMemTableWrapper& in, const string& fileName, 189 const string& method, bool doAll) 190 { 191 SDMemTable* pIn = in.getPtr(); 192 SDMath sdm; 193 SDMemTable* pOut = sdm.gainElevation(*pIn, String(fileName), String(method), Bool(doAll)); 194 *pIn = *pOut; 195 delete pOut; 196 } 197 198 199 SDMemTableWrapper SDMathWrapper::gainElevation(const SDMemTableWrapper& in, 200 const string& fileName, 201 const string& method, bool doAll) 202 { 203 const CountedPtr<SDMemTable>& pIn = in.getCP(); 204 SDMath sdm; 205 return CountedPtr<SDMemTable>(sdm.gainElevation(*pIn, String(fileName), 206 String(method), Bool(doAll))); 207 } 208 -
trunk/src/python_SDMath.cc
r223 r227 78 78 def("convertflux_insitu", &SDMathWrapper::convertFluxInSitu); 79 79 // 80 def("gainel", &SDMathWrapper::gainElevation); 81 def("gainel_insitu", &SDMathWrapper::gainElevationInSitu); 82 // 80 83 def("average", &SDMathWrapper::average); 81 84 //
Note:
See TracChangeset
for help on using the changeset viewer.