Changeset 716
- Timestamp:
- 11/17/05 14:37:33 (19 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDMath.cc
r701 r716 31 31 #include <vector> 32 32 33 33 34 #include <casa/aips.h> 34 35 #include <casa/iostream.h> 36 #include <casa/sstream.h> 35 37 #include <casa/iomanip.h> 36 38 #include <casa/BasicSL/String.h> … … 89 91 90 92 SDMath::SDMath() 91 {;} 93 { 94 } 92 95 93 96 SDMath::SDMath(const SDMath& other) … … 113 116 const String& refTime, 114 117 const String& method, 115 Bool perFreqID) const118 Bool perFreqID) 116 119 { 117 120 // Get frame info from Table … … 136 139 SDMath::average(const std::vector<CountedPtr<SDMemTable> >& in, 137 140 const Vector<Bool>& mask, Bool scanAv, 138 const String& weightStr, Bool alignFreq) const141 const String& weightStr, Bool alignFreq) 139 142 // Weighted averaging of spectra from one or more Tables. 140 143 { … … 365 368 SDMath::binaryOperate(const CountedPtr<SDMemTable>& left, 366 369 const CountedPtr<SDMemTable>& right, 367 const String& op, Bool preserve, Bool doTSys) const370 const String& op, Bool preserve, Bool doTSys) 368 371 { 369 372 … … 509 512 IPosition start, end; 510 513 Bool doAll = False; 511 setCursorSlice 514 setCursorSlice(start, end, doAll, *in); 512 515 513 516 // Loop over rows … … 554 557 555 558 556 SDMemTable* SDMath::bin(const SDMemTable& in, Int width) const559 SDMemTable* SDMath::bin(const SDMemTable& in, Int width) 557 560 { 558 561 SDHeader sh = in.getSDHeader(); … … 615 618 616 619 SDMemTable* SDMath::resample(const SDMemTable& in, const String& methodStr, 617 Float width) const620 Float width) 618 621 // 619 622 // Should add the possibility of width being specified in km/s. This means … … 729 732 730 733 SDMemTable* SDMath::unaryOperate(const SDMemTable& in, Float val, Bool doAll, 731 uInt what, Bool doTSys) const734 uInt what, Bool doTSys) 732 735 // 733 736 // what = 0 Multiply … … 776 779 777 780 SDMemTable* SDMath::averagePol(const SDMemTable& in, const Vector<Bool>& mask, 778 const String& weightStr) const781 const String& weightStr) 779 782 // 780 783 // Average all polarizations together, weighted by variance … … 973 976 SDMemTable* SDMath::smooth(const SDMemTable& in, 974 977 const casa::String& kernelType, 975 casa::Float width, Bool doAll) const978 casa::Float width, Bool doAll) 976 979 // 977 980 // Should smooth TSys as well … … 1047 1050 1048 1051 SDMemTable* SDMath::convertFlux(const SDMemTable& in, Float D, Float etaAp, 1049 Float JyPerK, Bool doAll) const1052 Float JyPerK, Bool doAll) 1050 1053 // 1051 1054 // etaAp = aperture efficiency (-1 means find) … … 1066 1069 Bool toKelvin = True; 1067 1070 Double cFac = 1.0; 1071 1068 1072 if (fluxUnit==JY) { 1069 cout << "Converting to K" << endl; 1070 1073 pushLog("Converting to K"); 1071 1074 Quantum<Double> t(1.0,fluxUnit); 1072 1075 Quantum<Double> t2 = t.get(JY); … … 1076 1079 sh.fluxunit = "K"; 1077 1080 } else if (fluxUnit==K) { 1078 cout << "Converting to Jy" << endl; 1079 1081 pushLog("Converting to Jy"); 1080 1082 Quantum<Double> t(1.0,fluxUnit); 1081 1083 Quantum<Double> t2 = t.get(K); … … 1087 1089 throw(AipsError("Unrecognized brightness units in Table - must be consistent with Jy or K")); 1088 1090 } 1091 1089 1092 pTabOut->putSDHeader(sh); 1090 1093 … … 1096 1099 factor *= JyPerK; 1097 1100 if (toKelvin) factor = 1.0 / JyPerK; 1098 cout << "Jy/K = " << JyPerK << endl; 1101 ostringstream oss; 1102 oss << "Jy/K = " << JyPerK; 1103 pushLog(String(oss)); 1099 1104 Vector<Float> factors(in.nRow(), factor); 1100 1105 scaleByVector(pTabOut, in, doAll, factors, False); 1101 1106 } else if (etaAp>0.0) { 1102 1107 Bool throwIt = True; 1103 Instrument inst = SDAttr::convertInstrument 1108 Instrument inst = SDAttr::convertInstrument(sh.antennaname, throwIt); 1104 1109 SDAttr sda; 1105 1110 if (D < 0) D = sda.diameter(inst); 1106 Float JyPerK = SDAttr::findJyPerK (etaAp,D); 1107 cout << "Jy/K = " << JyPerK << endl; 1111 Float JyPerK = SDAttr::findJyPerK(etaAp,D); 1112 ostringstream oss; 1113 oss << "Jy/K = " << JyPerK; 1114 pushLog(String(oss)); 1108 1115 factor *= JyPerK; 1109 1116 if (toKelvin) { … … 1120 1127 // change per integration. 1121 1128 1122 cout << "Looking up conversion factors" << endl;1129 pushLog("Looking up conversion factors"); 1123 1130 convertBrightnessUnits (pTabOut, in, toKelvin, cFac, doAll); 1124 1131 } 1125 1126 1132 return pTabOut; 1127 1133 } … … 1131 1137 const Vector<Float>& coeffs, 1132 1138 const String& fileName, 1133 const String& methodStr, Bool doAll) const1139 const String& methodStr, Bool doAll) 1134 1140 { 1135 1141 … … 1176 1182 throw(AipsError("There is no known gain-elevation polynomial known for this instrument")); 1177 1183 } 1178 cout << "Making polynomial correction with " << msg << " coefficients" << endl;1184 pushLog("Making polynomial correction with "+msg+" coefficients"); 1179 1185 const uInt nRow = in.nRow(); 1180 1186 Vector<Float> factor(nRow); … … 1193 1199 // Read and correct 1194 1200 1195 cout << "Making correction from ascii Table" << endl;1201 pushLog("Making correction from ascii Table"); 1196 1202 scaleFromAsciiTable (pTabOut, in, fileName, col0, col1, 1197 1203 methodStr, doAll, x, True); … … 1202 1208 1203 1209 1204 SDMemTable* SDMath::opacity(const SDMemTable& in, Float tau, Bool doAll) const1210 SDMemTable* SDMath::opacity(const SDMemTable& in, Float tau, Bool doAll) 1205 1211 { 1206 1212 … … 1245 1251 1246 1252 SDHeader sh = in.getSDHeader(); 1247 Instrument inst = SDAttr::convertInstrument 1253 Instrument inst = SDAttr::convertInstrument(sh.antennaname, False); 1248 1254 SDAttr sdAtt; 1249 1255 if (sdAtt.feedPolType(inst) != LINEAR) { … … 1299 1305 // 1300 1306 SDHeader sh = in.getSDHeader(); 1301 Instrument inst = SDAttr::convertInstrument 1307 Instrument inst = SDAttr::convertInstrument(sh.antennaname, False); 1302 1308 SDAttr sdAtt; 1303 1309 if (sdAtt.feedPolType(inst) != LINEAR) { … … 1378 1384 1379 1385 void SDMath::convertBrightnessUnits (SDMemTable* pTabOut, const SDMemTable& in, 1380 Bool toKelvin, Float cFac, Bool doAll) const1386 Bool toKelvin, Float cFac, Bool doAll) 1381 1387 { 1382 1388 … … 1389 1395 1390 1396 Bool throwIt = True; 1391 Instrument inst = SDAttr::convertInstrument 1397 Instrument inst = SDAttr::convertInstrument(sh.antennaname, throwIt); 1392 1398 1393 1399 // Get Diameter (m) 1394 1400 1395 1401 SDAttr sdAtt; 1396 1397 1402 // Get epoch of first row 1398 1403 … … 1410 1415 // 1411 1416 Vector<Float> JyPerK = sdAtt.JyPerK(inst, dateObs, freqs); 1412 cout << "Jy/K = " << JyPerK << endl; 1417 ostringstream oss; 1418 oss << "Jy/K = " << JyPerK; 1419 pushLog(String(oss)); 1413 1420 Vector<Float> factors = cFac * JyPerK; 1414 1421 if (toKelvin) factors = Float(1.0) / factors; … … 1474 1481 const String& refTime, 1475 1482 const String& methodStr, 1476 Bool perFreqID) const1483 Bool perFreqID) 1477 1484 { 1478 1485 // Get Header … … 1511 1518 refEpoch = in.getEpoch(0); 1512 1519 } 1513 cout << "Aligning at reference Epoch " <<formatEpoch(refEpoch)1514 << " in frame " << MFrequency::showType(freqSystem) << endl;1520 pushLog("Aligning at reference Epoch "+formatEpoch(refEpoch) 1521 +" in frame "+MFrequency::showType(freqSystem)); 1515 1522 1516 1523 // Get Reference Position … … 1561 1568 // New output Table 1562 1569 1563 cout << "Create output table" << endl;1570 pushLog("Create output table"); 1564 1571 SDMemTable* pTabOut = new SDMemTable(in,True); 1565 1572 pTabOut->putSDFreqTable(freqTabOut); … … 1580 1587 for (uInt iRow=0; iRow<nRows; ++iRow) { 1581 1588 if (iRow%10==0) { 1582 cout << "Processing row " << iRow << endl;1589 pushLog("Processing row "+iRow); 1583 1590 } 1584 1591 … … 1688 1695 1689 1696 1690 SDMemTable* SDMath::frequencySwitch(const SDMemTable& in) const1697 SDMemTable* SDMath::frequencySwitch(const SDMemTable& in) 1691 1698 { 1692 1699 if (in.nIF() != 2) { … … 1748 1755 Int scanID, Double timeStamp, 1749 1756 Double interval, const String& sourceName, 1750 const Vector<uInt>& freqID) const1757 const Vector<uInt>& freqID) 1751 1758 { 1752 1759 // Data and mask … … 1777 1784 uInt iTab, uInt iRow, uInt axis, 1778 1785 uInt nAxesSub, Bool useMask, 1779 WeightType wtType) const1786 WeightType wtType) 1780 1787 { 1781 1788 … … 1886 1893 Double intSum, 1887 1894 WeightType wtType, Int axis, 1888 Int nAxesSub) const1895 Int nAxesSub) 1889 1896 { 1890 1897 IPosition pos2(nAxesSub,0); … … 1964 1971 1965 1972 void SDMath::convertWeightString(WeightType& wtType, const String& weightStr, 1966 Bool listType) const1973 Bool listType) 1967 1974 { 1968 1975 String tStr(weightStr); … … 1989 1996 } 1990 1997 // 1991 if (listType) cout << msg << endl;1998 if (listType) pushLog(msg); 1992 1999 } 1993 2000 1994 2001 1995 2002 void SDMath::convertInterpString(casa::InterpolateArray1D<Double,Float>::InterpolationMethod& type, 1996 const casa::String& interp) const2003 const casa::String& interp) 1997 2004 { 1998 2005 String tStr(interp); … … 2012 2019 2013 2020 void SDMath::putDataInSDC(SDContainer& sc, const Array<Float>& data, 2014 const Array<Bool>& mask) const2021 const Array<Bool>& mask) 2015 2022 { 2016 2023 sc.putSpectrum(data); … … 2021 2028 } 2022 2029 2023 Table SDMath::readAsciiFile 2030 Table SDMath::readAsciiFile(const String& fileName) const 2024 2031 { 2025 2032 String formatString; … … 2034 2041 const String& col0, const String& col1, 2035 2042 const String& methodStr, Bool doAll, 2036 const Vector<Float>& xOut, Bool doTSys) const2043 const Vector<Float>& xOut, Bool doTSys) 2037 2044 { 2038 2045 … … 2048 2055 const String& col1, 2049 2056 const String& methodStr, Bool doAll, 2050 const Vector<Float>& xOut, Bool doTsys) const2057 const Vector<Float>& xOut, Bool doTsys) 2051 2058 { 2052 2059 … … 2078 2085 void SDMath::scaleByVector(SDMemTable* pTabOut, const SDMemTable& in, 2079 2086 Bool doAll, const Vector<Float>& factor, 2080 Bool doTSys) const2087 Bool doTSys) 2081 2088 { 2082 2089 … … 2131 2138 const ROScalarColumn<String>& srcCol, 2132 2139 const ROArrayColumn<uInt>& fqIDCol, 2133 Bool perFreqID) const2140 Bool perFreqID) 2134 2141 { 2135 2142 const uInt nRows = tabIn.nrow(); … … 2165 2172 2166 2173 2167 MEpoch SDMath::epochFromString(const String& str, MEpoch::Types timeRef) const2174 MEpoch SDMath::epochFromString(const String& str, MEpoch::Types timeRef) 2168 2175 { 2169 2176 Quantum<Double> qt; … … 2192 2199 const MPosition& refPos, 2193 2200 const MEpoch& refEpoch, 2194 Bool perFreqID) const2201 Bool perFreqID) 2195 2202 { 2196 2203 for (uInt i=0; i<dDesc.length(); i++) { -
trunk/src/SDMath.h
r653 r716 39 39 40 40 #include "SDDefs.h" 41 #include "SDLog.h" 41 42 42 43 class casa::Table; … … 48 49 template<class T> class casa::ROArrayColumn; 49 50 50 51 52 51 namespace asap { 53 52 54 53 class SDMemTable; 55 54 class SDDataDesc; 56 57 class SDMath { 58 59 public: 60 61 // Default constructor 62 SDMath(); 63 64 // Copy Constructor (copy semantics) 65 SDMath (const SDMath& other); 66 67 // Assignment (copy semantics) 68 SDMath &operator=(const SDMath& other); 69 70 // Destructor 71 ~SDMath(); 72 73 // Binary Table operators. op=ADD, SUB, MUL, DIV, QUOTIENT 74 casa::CountedPtr<SDMemTable> binaryOperate (const casa::CountedPtr<SDMemTable>& left, 75 const casa::CountedPtr<SDMemTable>& right, 76 const casa::String& op, casa::Bool preserve, 77 casa::Bool tSys) const; 78 79 // Average in time 80 casa::CountedPtr<SDMemTable> 81 average(const std::vector<casa::CountedPtr<SDMemTable> >& in, 82 const casa::Vector<casa::Bool>& mask, 83 casa::Bool scanAverage, 84 const casa::String& weightStr, 85 casa::Bool align=casa::False) const; 86 87 // Statistics. If row<0, all rows are done otherwise, just the 88 // specified row. 89 std::vector<float> statistic(const casa::CountedPtr<SDMemTable>& in, 90 const casa::Vector<casa::Bool>& mask, 91 const casa::String& which, casa::Int row) const; 92 55 56 class SDMath : private SDLog { 57 58 public: 59 60 // Default constructor 61 SDMath(); 62 63 // Copy Constructor (copy semantics) 64 SDMath(const SDMath& other); 65 66 // Assignment (copy semantics) 67 SDMath &operator=(const SDMath& other); 68 69 // Destructor 70 ~SDMath(); 71 72 // Binary Table operators. op=ADD, SUB, MUL, DIV, QUOTIENT 73 casa::CountedPtr<SDMemTable> binaryOperate(const casa::CountedPtr<SDMemTable>& left, 74 const casa::CountedPtr<SDMemTable>& right, 75 const casa::String& op, casa::Bool preserve, 76 casa::Bool tSys); 77 78 // Average in time 79 casa::CountedPtr<SDMemTable> average(const std::vector<casa::CountedPtr<SDMemTable> >& in, 80 const casa::Vector<casa::Bool>& mask, 81 casa::Bool scanAverage, 82 const casa::String& weightStr, 83 casa::Bool align=casa::False); 84 85 // Statistics. If row<0, all rows are done otherwise, just the 86 // specified row. 87 std::vector<float> statistic(const casa::CountedPtr<SDMemTable>& in, 88 const casa::Vector<casa::Bool>& mask, 89 const casa::String& which, casa::Int row) const; 90 93 91 // Bin up spectra 94 SDMemTable* bin(const SDMemTable& in, casa::Int width) const;95 96 // Resample spectra92 SDMemTable* bin(const SDMemTable& in, casa::Int width); 93 94 // Resample spectra 97 95 SDMemTable* resample(const SDMemTable& in, const casa::String& method, 98 casa::Float factor) const;96 casa::Float factor); 99 97 100 98 // Smooth 101 SDMemTable* smooth(const SDMemTable& in, const casa::String& kernel,102 casa::Float width, casa::Bool doAll) const;99 SDMemTable* smooth(const SDMemTable& in, const casa::String& kernel, 100 casa::Float width, casa::Bool doAll); 103 101 104 102 // Flux conversion between Jansky and Kelvin 105 SDMemTable* convertFlux (const SDMemTable& in, casa::Float D, casa::Float etaAp, 106 casa::Float JyPerK, casa::Bool doAll) const; 103 SDMemTable* convertFlux(const SDMemTable& in, casa::Float D, 104 casa::Float etaAp, 105 casa::Float JyPerK, casa::Bool doAll); 107 106 108 107 // Gain-elevation correction 109 SDMemTable* gainElevation (const SDMemTable& in, const casa::Vector<casa::Float>& coeffs, 110 const casa::String& fileName, 111 const casa::String& method, casa::Bool doAll) const; 108 SDMemTable* gainElevation(const SDMemTable& in, 109 const casa::Vector<casa::Float>& coeffs, 110 const casa::String& fileName, 111 const casa::String& method, 112 casa::Bool doAll); 112 113 113 114 // Frequency Alignment 114 SDMemTable* frequencyAlignment 115 const casa::String& method, casa::Bool perFreqID) const;115 SDMemTable* frequencyAlignment(const SDMemTable& in, const casa::String& refTime, 116 const casa::String& method, casa::Bool perFreqID); 116 117 117 118 // Opacity correction 118 SDMemTable* opacity (const SDMemTable& in, casa::Float tau, casa::Bool doAll) const;119 SDMemTable* opacity(const SDMemTable& in, casa::Float tau, casa::Bool doAll); 119 120 120 121 // Simple unary mathematical operations. what=0 (mul) or 1 (add) 121 122 SDMemTable* unaryOperate(const SDMemTable& in, casa::Float offset, 122 casa::Bool doAll, casa::uInt what, casa::Bool tSys) const; 123 124 // Average polarizations. 125 SDMemTable* averagePol(const SDMemTable& in, const casa::Vector<casa::Bool>& mask, 126 const casa::String& wtStr) const; 123 casa::Bool doAll, casa::uInt what, casa::Bool tSys); 124 125 // Average polarizations. 126 SDMemTable* averagePol(const SDMemTable& in, 127 const casa::Vector<casa::Bool>& mask, 128 const casa::String& wtStr); 129 130 SDMemTable* frequencySwitch(const SDMemTable& in); 131 127 132 128 133 // Rotate XY phase. Value in degrees. 129 void rotateXYPhase 134 void rotateXYPhase(SDMemTable& in, casa::Float value, casa::Bool doAll); 130 135 131 136 // Rotate Q & U by operating on the raw correlations.Value in degrees. 132 void rotateLinPolPhase 133 134 137 void rotateLinPolPhase(SDMemTable& in, casa::Float value, casa::Bool doAll); 138 139 135 140 private: 136 141 … … 155 160 casa::uInt iTab, casa::uInt iRow, 156 161 casa::uInt axis, casa::uInt nAxesSub, 157 casa::Bool useMask, WeightType wtType) const;162 casa::Bool useMask, WeightType wtType); 158 163 159 164 // Work out conversion factor for converting Jy<->K per IF per row and apply 160 void convertBrightnessUnits(SDMemTable* pTabOut, const SDMemTable& in,161 casa::Bool toKelvin, casa::Float sFac, casa::Bool doAll) const;165 void convertBrightnessUnits(SDMemTable* pTabOut, const SDMemTable& in, 166 casa::Bool toKelvin, casa::Float sFac, casa::Bool doAll); 162 167 163 168 // Convert weight string to enum value 164 169 165 void convertWeightString 166 casa::Bool listType) const;170 void convertWeightString(WeightType& wt, const casa::String& weightStr, 171 casa::Bool listType);; 167 172 168 173 // Convert interpolation type string 169 // void convertInterpString(casa::Int& type, const casa::String& interp) const;174 // void convertInterpString(casa::Int& type, const casa::String& interp); 170 175 void convertInterpString(casa::InterpolateArray1D<casa::Double,casa::Float>::InterpolationMethod& method, 171 const casa::String& interp) const;176 const casa::String& interp); 172 177 173 178 // Scale data with values from an ascii Table … … 176 181 const casa::String& col0, const casa::String& col1, 177 182 const casa::String& methodStr, casa::Bool doAll, 178 const casa::Vector<casa::Float>& xOut, casa::Bool doTSys) const;183 const casa::Vector<casa::Float>& xOut, casa::Bool doTSys); 179 184 180 185 // Scale data with values from a Table … … 182 187 const casa::String& col0, const casa::String& col1, 183 188 const casa::String& methodStr, casa::Bool doAll, 184 const casa::Vector<casa::Float>& xOut, casa::Bool doTSys) const;189 const casa::Vector<casa::Float>& xOut, casa::Bool doTSys); 185 190 186 191 // Scale data and optionally TSys by values in a Vector 187 void scaleByVector 192 void scaleByVector(SDMemTable* pTabOut, const SDMemTable& in, 188 193 casa::Bool doAll, const casa::Vector<casa::Float>& factor, 189 casa::Bool doTSys) const;194 casa::Bool doTSys); 190 195 191 196 // Convert time String to Epoch 192 casa::MEpoch epochFromString (const casa::String& str, casa::MEpoch::Types timeRef) const;197 casa::MEpoch epochFromString(const casa::String& str, casa::MEpoch::Types timeRef); 193 198 194 199 // Function to fill Scan Container when averaging in time 195 200 196 void fillSDC 201 void fillSDC(SDContainer& sc, const casa::Array<casa::Bool>& mask, 197 202 const casa::Array<casa::Float>& data, 198 203 const casa::Array<casa::Float>& tSys, 199 204 casa::Int scanID, casa::Double timeStamp, 200 205 casa::Double interval, const casa::String& sourceName, 201 const casa::Vector<casa::uInt>& freqID) const;206 const casa::Vector<casa::uInt>& freqID); 202 207 203 208 // Format EPoch 204 casa::String formatEpoch(const casa::MEpoch& epoch) const;209 casa::String formatEpoch(const casa::MEpoch& epoch) const; 205 210 206 211 // Align in Frequency 207 SDMemTable* frequencyAlign 212 SDMemTable* frequencyAlign(const SDMemTable& in, 208 213 casa::MFrequency::Types system, 209 214 const casa::String& timeRef, 210 215 const casa::String& method, 211 casa::Bool perIF) const;216 casa::Bool perIF); 212 217 213 218 // Generate frequency aligners 214 void generateFrequencyAligners 219 void generateFrequencyAligners(casa::PtrBlock<casa::FrequencyAligner<casa::Float>* >& a, 215 220 const SDDataDesc& dDesc, 216 221 const SDMemTable& in, casa::uInt nChan, … … 218 223 const casa::MPosition& refPos, 219 224 const casa::MEpoch& refEpoch, 220 casa::Bool perFreqID) const;221 222 // Generate data description table (combines source and freqID)223 void generateDataDescTable 225 casa::Bool perFreqID); 226 227 // Generate data description table(combines source and freqID); 228 void generateDataDescTable(casa::Matrix<casa::uInt>& ddIdx, 224 229 SDDataDesc& dDesc, 225 230 casa::uInt nIF, … … 228 233 const casa::ROScalarColumn<casa::String>& srcCol, 229 234 const casa::ROArrayColumn<casa::uInt>& fqIDCol, 230 casa::Bool perFreqID) const;235 casa::Bool perFreqID); 231 236 232 237 // Get row range from SDMemTable state 233 casa::Vector<casa::uInt> getRowRange(const SDMemTable& in) const;238 casa::Vector<casa::uInt> getRowRange(const SDMemTable& in) const; 234 239 235 240 // Is row in the row range ? 236 casa::Bool rowInRange(casa::uInt i, const casa::Vector<casa::uInt>& range) const;241 casa::Bool rowInRange(casa::uInt i, const casa::Vector<casa::uInt>& range) const; 237 242 238 243 // Set slice to cursor or all axes 239 void setCursorSlice 240 244 void setCursorSlice(casa::IPosition& start, casa::IPosition& end, 245 casa::Bool doAll, const SDMemTable& in) const; 241 246 242 247 // Function to normalize data when averaging in time 243 248 244 void normalize 249 void normalize(casa::MaskedArray<casa::Float>& data, 245 250 const casa::Array<casa::Float>& sumSq, 246 251 const casa::Array<casa::Float>& tSysSumSq, 247 252 const casa::Array<casa::Float>& nPts, 248 253 casa::Double intSum, 249 WeightType wtType, casa::Int axis, casa::Int nAxes) const;254 WeightType wtType, casa::Int axis, casa::Int nAxes); 250 255 251 256 // Put the data and mask into the SDContainer 252 void putDataInSDC 253 const casa::Array<casa::Bool>& mask) const;257 void putDataInSDC(SDContainer& sc, const casa::Array<casa::Float>& data, 258 const casa::Array<casa::Bool>& mask); 254 259 255 260 // Read ascii file into a Table 256 261 257 casa::Table readAsciiFile (const casa::String& fileName) const; 258 }; 259 260 261 262 casa::Table readAsciiFile(const casa::String& fileName) const; 263 264 }; // class 262 265 263 266 } // namespace -
trunk/src/SDMathWrapper.cc
r502 r716 30 30 //#--------------------------------------------------------------------------- 31 31 32 33 32 #include "SDMathWrapper.h" 34 #include "SDMath.h"35 36 33 37 34 using namespace asap; 38 35 using namespace casa; 36 39 37 40 38 SDMemTableWrapper SDMathWrapper::quotient(const SDMemTableWrapper& on, … … 42 40 Bool preserveContinuum) 43 41 { 44 SDMath sdm;42 45 43 Bool doTSys = True; 46 return SDMemTableWrapper(sdm.binaryOperate(on.getCP(), off.getCP(), 47 String("QUOTIENT"), preserveContinuum, doTSys)); 44 return SDMemTableWrapper(sdmath.binaryOperate(on.getCP(), off.getCP(), 45 String("QUOTIENT"), 46 preserveContinuum, doTSys)); 48 47 } 49 48 … … 51 50 SDMemTableWrapper SDMathWrapper::binaryOperate(const SDMemTableWrapper& left, 52 51 const SDMemTableWrapper& right, 53 const std::string& op, bool doTSys) 54 { 55 SDMath sdm; 56 return SDMemTableWrapper(sdm.binaryOperate(left.getCP(), right.getCP(), 57 String(op), False, Bool(doTSys))); 58 } 59 60 61 void SDMathWrapper::scaleInSitu(SDMemTableWrapper& in, float factor, bool doAll, bool doTSys) 52 const std::string& op, 53 bool doTSys) 54 { 55 56 return SDMemTableWrapper(sdmath.binaryOperate(left.getCP(), right.getCP(), 57 String(op), False, 58 Bool(doTSys))); 59 } 60 61 62 void SDMathWrapper::scaleInSitu(SDMemTableWrapper& in, float factor, 63 bool doAll, bool doTSys) 62 64 { 63 65 SDMemTable* pIn = in.getPtr(); 64 66 const uInt what = 0; 65 // 66 SDMath sdm; 67 SDMemTable* pOut = sdm.unaryOperate (*pIn, Float(factor), 67 68 SDMemTable* pOut = sdmath.unaryOperate (*pIn, Float(factor), 68 69 Bool(doAll), what, Bool(doTSys)); 69 70 *pIn = *pOut; … … 76 77 const CountedPtr<SDMemTable>& pIn = in.getCP(); 77 78 const uInt what = 0; 78 SDMath sdm;79 return CountedPtr<SDMemTable>(sdm .unaryOperate(*pIn, Float(factor), Bool(doAll),79 80 return CountedPtr<SDMemTable>(sdmath.unaryOperate(*pIn, Float(factor), Bool(doAll), 80 81 what, Bool (doTSys))); 81 82 } … … 86 87 SDMemTable* pIn = in.getPtr(); 87 88 const uInt what = 1; 88 // 89 SDMath sdm; 89 90 90 Bool doTSys = False; 91 SDMemTable* pOut = sdm .unaryOperate (*pIn, Float(offset),91 SDMemTable* pOut = sdmath.unaryOperate (*pIn, Float(offset), 92 92 Bool(doAll), what, doTSys); 93 93 *pIn = *pOut; … … 100 100 const CountedPtr<SDMemTable>& pIn = in.getCP(); 101 101 const uInt what = 1; 102 SDMath sdm;102 103 103 Bool doTSys = False; 104 return CountedPtr<SDMemTable>(sdm .unaryOperate(*pIn, Float(offset),104 return CountedPtr<SDMemTable>(sdmath.unaryOperate(*pIn, Float(offset), 105 105 Bool(doAll), what, doTSys)); 106 106 } … … 112 112 { 113 113 SDMemTable* pIn = in.getPtr(); 114 SDMath sdm;115 SDMemTable* pOut = sdm .smooth(*pIn, String(kernel),114 115 SDMemTable* pOut = sdmath.smooth(*pIn, String(kernel), 116 116 Float(width), Bool(doAll)); 117 117 *pIn = *pOut; … … 125 125 { 126 126 const CountedPtr<SDMemTable>& pIn = in.getCP(); 127 SDMath sdm;128 return CountedPtr<SDMemTable>(sdm .smooth(*pIn, String(kernel),127 128 return CountedPtr<SDMemTable>(sdmath.smooth(*pIn, String(kernel), 129 129 Float(width), Bool(doAll))); 130 130 } … … 135 135 { 136 136 SDMemTable* pIn = in.getPtr(); 137 SDMath sdm;138 SDMemTable* pOut = sdm .bin (*pIn, Int(width));137 138 SDMemTable* pOut = sdmath.bin (*pIn, Int(width)); 139 139 *pIn = *pOut; 140 140 delete pOut; … … 145 145 { 146 146 const CountedPtr<SDMemTable>& pIn = in.getCP(); 147 SDMath sdm;148 return CountedPtr<SDMemTable>(sdm .bin(*pIn, Int(width)));147 148 return CountedPtr<SDMemTable>(sdmath.bin(*pIn, Int(width))); 149 149 } 150 150 … … 153 153 { 154 154 SDMemTable* pIn = in.getPtr(); 155 SDMath sdm;156 SDMemTable* pOut = sdm .resample(*pIn, String(method), Float(width));155 156 SDMemTable* pOut = sdmath.resample(*pIn, String(method), Float(width)); 157 157 *pIn = *pOut; 158 158 delete pOut; … … 163 163 { 164 164 const CountedPtr<SDMemTable>& pIn = in.getCP(); 165 SDMath sdm;166 return CountedPtr<SDMemTable>(sdm .resample(*pIn, String(method), Float(width)));165 166 return CountedPtr<SDMemTable>(sdmath.resample(*pIn, String(method), Float(width))); 167 167 } 168 168 … … 173 173 { 174 174 SDMemTable* pIn = in.getPtr(); 175 SDMath sdm;175 176 176 Vector<Bool> tMask(mask); 177 SDMemTable* pOut = sdm .averagePol (*pIn, tMask, String(weightStr));177 SDMemTable* pOut = sdmath.averagePol (*pIn, tMask, String(weightStr)); 178 178 *pIn = *pOut; 179 179 delete pOut; … … 185 185 { 186 186 const CountedPtr<SDMemTable>& pIn = in.getCP(); 187 SDMath sdm;187 188 188 Vector<Bool> tMask(mask); 189 return CountedPtr<SDMemTable>(sdm .averagePol(*pIn, tMask, String(weightStr)));189 return CountedPtr<SDMemTable>(sdmath.averagePol(*pIn, tMask, String(weightStr))); 190 190 } 191 191 … … 195 195 const std::string& which, int row) 196 196 { 197 SDMath sdm;197 198 198 Vector<Bool> tMask(mask); 199 return sdm .statistic(in.getCP(), tMask, String(which), Int(row));199 return sdmath.statistic(in.getCP(), tMask, String(which), Int(row)); 200 200 } 201 201 … … 205 205 { 206 206 SDMemTable* pIn = in.getPtr(); 207 SDMath sdm;208 SDMemTable* pOut = sdm .convertFlux (*pIn, Float(D), Float(eta), Float(JyPerK), Bool(doAll));207 208 SDMemTable* pOut = sdmath.convertFlux (*pIn, Float(D), Float(eta), Float(JyPerK), Bool(doAll)); 209 209 *pIn = *pOut; 210 210 delete pOut; … … 216 216 { 217 217 const CountedPtr<SDMemTable>& pIn = in.getCP(); 218 SDMath sdm;219 return CountedPtr<SDMemTable>(sdm .convertFlux(*pIn, Float(D), Float(eta), Float(JyPerK), Bool(doAll)));218 219 return CountedPtr<SDMemTable>(sdmath.convertFlux(*pIn, Float(D), Float(eta), Float(JyPerK), Bool(doAll))); 220 220 } 221 221 … … 228 228 SDMemTable* pIn = in.getPtr(); 229 229 Vector<Float> tCoeffs(coeffs); 230 SDMath sdm;231 SDMemTable* pOut = sdm .gainElevation(*pIn, tCoeffs, String(fileName),230 231 SDMemTable* pOut = sdmath.gainElevation(*pIn, tCoeffs, String(fileName), 232 232 String(method), Bool(doAll)); 233 233 *pIn = *pOut; … … 243 243 const CountedPtr<SDMemTable>& pIn = in.getCP(); 244 244 Vector<Float> tCoeffs(coeffs); 245 SDMath sdm;246 return CountedPtr<SDMemTable>(sdm .gainElevation(*pIn, tCoeffs, String(fileName),245 246 return CountedPtr<SDMemTable>(sdmath.gainElevation(*pIn, tCoeffs, String(fileName), 247 247 String(method), Bool(doAll))); 248 248 } … … 252 252 { 253 253 SDMemTable* pIn = in.getPtr(); 254 SDMath sdm;255 SDMemTable* pOut = sdm .frequencyAlignment(*pIn, String(refTime), String(method),254 255 SDMemTable* pOut = sdmath.frequencyAlignment(*pIn, String(refTime), String(method), 256 256 Bool(perFreqID)); 257 257 *pIn = *pOut; … … 266 266 { 267 267 const CountedPtr<SDMemTable>& pIn = in.getCP(); 268 SDMath sdm;269 return CountedPtr<SDMemTable>(sdm .frequencyAlignment(*pIn, String(refTime),268 269 return CountedPtr<SDMemTable>(sdmath.frequencyAlignment(*pIn, String(refTime), 270 270 String(method), Bool(perFreqID))); 271 271 } … … 274 274 { 275 275 SDMemTable* pIn = in.getPtr(); 276 SDMath sdm;277 sdm .rotateXYPhase(*pIn, Float(angle), Bool(doAll));276 277 sdmath.rotateXYPhase(*pIn, Float(angle), Bool(doAll)); 278 278 } 279 279 … … 282 282 { 283 283 SDMemTable* pIn = in.getPtr(); 284 SDMath sdm;285 sdm .rotateLinPolPhase(*pIn, Float(angle), Bool(doAll));284 285 sdmath.rotateLinPolPhase(*pIn, Float(angle), Bool(doAll)); 286 286 } 287 287 … … 292 292 { 293 293 SDMemTable* pIn = in.getPtr(); 294 SDMath sdm; 295 SDMemTable* pOut = sdm.opacity(*pIn, Float(tau), Bool(doAll)); 296 *pIn = *pOut; 297 delete pOut; 298 } 299 294 295 SDMemTable* pOut = sdmath.opacity(*pIn, Float(tau), Bool(doAll)); 296 *pIn = *pOut; 297 delete pOut; 298 } 300 299 301 300 SDMemTableWrapper SDMathWrapper::opacity(const SDMemTableWrapper& in, … … 303 302 { 304 303 const CountedPtr<SDMemTable>& pIn = in.getCP(); 304 305 return CountedPtr<SDMemTable>(sdmath.opacity(*pIn, Float(tau), Bool(doAll))); 306 } 307 308 void SDMathWrapper::frequencySwitchInSitu(SDMemTableWrapper& in) 309 { 310 SDMemTable* pIn = in.getPtr(); 305 311 SDMath sdm; 306 return CountedPtr<SDMemTable>(sdm.opacity(*pIn, Float(tau), Bool(doAll))); 307 } 308 312 SDMemTable* pOut = sdm.frequencySwitch(*pIn); 313 *pIn = *pOut; 314 delete pOut; 315 } 316 317 SDMemTableWrapper SDMathWrapper::frequencySwitch(const SDMemTableWrapper& in) 318 { 319 const CountedPtr<SDMemTable>& pIn = in.getCP(); 320 SDMath sdm; 321 return CountedPtr<SDMemTable>(sdm.frequencySwitch(*pIn)); 322 } -
trunk/src/SDMathWrapper.h
r503 r716 38 38 39 39 #include "SDMemTableWrapper.h" 40 #include "SDMath.h" 40 41 41 42 namespace asap { … … 43 44 namespace SDMathWrapper { 44 45 45 // Quotient 46 47 static SDMath sdmath; 48 // Quotient 46 49 SDMemTableWrapper quotient(const SDMemTableWrapper& on, 47 50 const SDMemTableWrapper& off, 48 51 casa::Bool preserveContinuum); 49 52 50 // Simple binary operations 51 SDMemTableWrapper binaryOperate (const SDMemTableWrapper& left, 52 const SDMemTableWrapper& right, 53 const std::string& op, bool doTSys); 54 55 // Multiply 56 void scaleInSitu(SDMemTableWrapper& in, float factor, bool doAll, bool doTSys); 57 SDMemTableWrapper scale(const SDMemTableWrapper& in, float factor, bool all, bool doTSys); 58 59 // Add 53 // Simple binary operations 54 SDMemTableWrapper binaryOperate(const SDMemTableWrapper& left, 55 const SDMemTableWrapper& right, 56 const std::string& op, bool doTSys); 57 58 // Multiply 59 void scaleInSitu(SDMemTableWrapper& in, float factor, bool doAll, 60 bool doTSys); 61 SDMemTableWrapper scale(const SDMemTableWrapper& in, float factor, 62 bool all, bool doTSys); 63 64 // Add 60 65 void addInSitu(SDMemTableWrapper& in, float offset, bool doAall); 61 66 SDMemTableWrapper add(const SDMemTableWrapper& in, float offset, bool all); … … 72 77 73 78 // Resample 74 void resampleInSitu(SDMemTableWrapper& in, const std::string& method, float width); 75 SDMemTableWrapper resample(const SDMemTableWrapper& in, const std::string& method, 79 void resampleInSitu(SDMemTableWrapper& in, const std::string& method, 80 float width); 81 SDMemTableWrapper resample(const SDMemTableWrapper& in, 82 const std::string& method, 76 83 float width); 77 84 78 85 // Convert brightness between Jy and K 79 void convertFluxInSitu(SDMemTableWrapper& in, float D, float eta, float JyPerK, bool doAll); 80 SDMemTableWrapper convertFlux(const SDMemTableWrapper& in, float D, float eta, float JyPerK, bool doAll); 86 void convertFluxInSitu(SDMemTableWrapper& in, float D, float eta, 87 float JyPerK, bool doAll); 88 SDMemTableWrapper convertFlux(const SDMemTableWrapper& in, float D, 89 float eta, float JyPerK, bool doAll); 81 90 82 91 // Apply gain elevation correction … … 101 110 102 111 // Apply opacity correction 103 void opacityInSitu (SDMemTableWrapper& in, float tau, bool doAll); 104 SDMemTableWrapper opacity (const SDMemTableWrapper& in, float tau, bool doAll); 112 void opacityInSitu(SDMemTableWrapper& in, float tau, bool doAll); 113 SDMemTableWrapper opacity(const SDMemTableWrapper& in, float tau, 114 bool doAll); 105 115 106 116 // Average in time … … 116 126 const std::string& weightStr); 117 127 118 // Statistics 128 // Frequency Switching 129 void SDMathWrapper::frequencySwitchInSitu(SDMemTableWrapper& in); 130 131 SDMemTableWrapper 132 SDMathWrapper::frequencySwitch(const SDMemTableWrapper& in); 133 134 // Statistics 119 135 std::vector<float> statistic(const SDMemTableWrapper& in, 120 136 const std::vector<bool>& mask, 121 137 const std::string& which, int row); 138 122 139 }; 123 140 -
trunk/src/python_SDMath.cc
r653 r716 58 58 } 59 59 Vector<Bool> msk(mask); 60 // 61 SDMath sdm; 62 return SDMemTableWrapper(sdm.average(b, msk, Bool(scanAv), weightStr)); 60 61 return SDMemTableWrapper(sdmath.average(b, msk, Bool(scanAv), weightStr)); 63 62 }; 64 63 } // namespace SDMathWrapper … … 67 66 void python_SDMath() { 68 67 def("b_operate", &SDMathWrapper::binaryOperate); 69 //68 70 69 def("quotient", &SDMathWrapper::quotient); 71 // 70 72 71 def("scale", &SDMathWrapper::scale); 73 72 def("scale_insitu", &SDMathWrapper::scaleInSitu); 74 // 73 75 74 def("add", &SDMathWrapper::add); 76 75 def("add_insitu", &SDMathWrapper::addInSitu); 77 // 76 78 77 def("smooth", &SDMathWrapper::smooth); 79 78 def("smooth_insitu", &SDMathWrapper::smoothInSitu); 80 // 79 81 80 def("convertflux", &SDMathWrapper::convertFlux); 82 81 def("convertflux_insitu", &SDMathWrapper::convertFluxInSitu); 83 // 82 84 83 def("gainel", &SDMathWrapper::gainElevation); 85 84 def("gainel_insitu", &SDMathWrapper::gainElevationInSitu); 86 // 85 87 86 def("freq_align", &SDMathWrapper::frequencyAlignment); 88 87 def("freq_align_insitu", &SDMathWrapper::frequencyAlignmentInSitu); 89 // 88 90 89 def("opacity", &SDMathWrapper::opacity); 91 90 def("opacity_insitu", &SDMathWrapper::opacityInSitu); 92 // 91 93 92 def("average", &SDMathWrapper::average); 94 // 93 95 94 def("averagepol", &SDMathWrapper::averagePol); 96 95 def("averagepol_insitu", &SDMathWrapper::averagePolInSitu); 97 // 96 98 97 def("bin", &SDMathWrapper::bin); 99 98 def("bin_insitu", &SDMathWrapper::binInSitu); 100 // 99 101 100 def("resample", &SDMathWrapper::resample); 102 101 def("resample_insitu", &SDMathWrapper::resampleInSitu); 103 // 102 104 103 def("stats", &SDMathWrapper::statistic); 105 // 106 def ("_rotate_xyphase", &SDMathWrapper::rotateXYPhaseInSitu); 107 def ("_rotate_linpolphase", &SDMathWrapper::rotateLinPolPhaseInSitu); 104 105 def("_rotate_xyphase", &SDMathWrapper::rotateXYPhaseInSitu); 106 def("_rotate_linpolphase", &SDMathWrapper::rotateLinPolPhaseInSitu); 107 108 def("_frequency_switch", &SDMathWrapper::frequencySwitch); 108 109 }; 109 110
Note:
See TracChangeset
for help on using the changeset viewer.