Changeset 716 for trunk/src/SDMath.cc
- Timestamp:
- 11/17/05 14:37:33 (19 years ago)
- File:
-
- 1 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++) {
Note: See TracChangeset
for help on using the changeset viewer.