- Timestamp:
- 02/08/05 12:31:24 (20 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDMemTable.cc
r367 r380 111 111 polSel_(0) 112 112 { 113 cout << exprs << endl; 113 114 Table t = tableCommand(exprs,tab); 114 115 if (t.nrow() == 0) … … 116 117 table_ = t.copyToMemoryTable("dummy"); 117 118 attach(); 119 renumber(); 118 120 } 119 121 … … 181 183 } 182 184 183 void SDMemTable::attach 185 void SDMemTable::attach() 184 186 { 185 187 timeCol_.attach(table_, "TIME"); … … 262 264 } 263 265 264 void SDMemTable::resetCursor 266 void SDMemTable::resetCursor() 265 267 { 266 268 polSel_ = 0; … … 639 641 dirCol_.get(whichRow,posit); 640 642 Vector<Double> wpos(2); 643 Int rb; 644 rbeamCol_.get(whichRow,rb); 641 645 wpos[0] = posit(IPosition(2,beamSel_,0)); 642 646 wpos[1] = posit(IPosition(2,beamSel_,1)); 647 if (refBeam && rb > -1) { // use refBeam instead if it exists 648 wpos[0] = posit(IPosition(2,rb,0)); 649 wpos[1] = posit(IPosition(2,rb,1)); 650 } 651 643 652 Quantum<Double> lon(wpos[0],Unit(String("rad"))); 644 653 Quantum<Double> lat(wpos[1],Unit(String("rad"))); … … 646 655 } 647 656 648 MEpoch SDMemTable::getEpoch 657 MEpoch SDMemTable::getEpoch(Int whichRow) const 649 658 { 650 659 MEpoch::Types met = getTimeReference(); … … 697 706 698 707 699 SpectralCoordinate SDMemTable::getSpectralCoordinate(uInt freqID, uInt whichRow) const 708 SpectralCoordinate SDMemTable::getSpectralCoordinate(uInt freqID, 709 uInt whichRow) const 700 710 { 701 711 // Create basic SC … … 1041 1051 MVAngle mvLat(t[1]); 1042 1052 String sLat = mvLat.string(MVAngle::ANGLE+MVAngle::DIG2,prec); 1043 1044 return sLon + String(" ") + sLat; 1053 return sLon + String(" ") + sLat; 1045 1054 } 1046 1055 … … 1074 1083 } 1075 1084 1076 std::string SDMemTable::summary( ) const {1085 std::string SDMemTable::summary(bool verbose) const { 1077 1086 1078 1087 ostringstream oss; 1079 1088 oss << endl; 1080 oss << "-------------------------------------------------- " << endl;1089 oss << "--------------------------------------------------------------------------------" << endl; 1081 1090 oss << " Scan Table Summary" << endl; 1082 oss << "-------------------------------------------------- " << endl;1091 oss << "--------------------------------------------------------------------------------" << endl; 1083 1092 oss.flags(std::ios_base::left); 1084 1093 oss << setw(15) << "Beams:" << setw(4) << nBeam() << endl … … 1116 1125 MDirection::showType(getDirectionReference())+ 1117 1126 ")"; 1118 oss << setw( 6) << "Scan"1127 oss << setw(5) << "Scan" 1119 1128 << setw(15) << "Source" 1120 << setw(2 6) << dirtype1129 << setw(24) << dirtype 1121 1130 << setw(10) << "Time" 1122 1131 << setw(18) << "Integration" 1123 << setw( 10) << "FreqIDs" << endl;1124 oss << "-------------------------------------------------------------------------------- --" << endl;1132 << setw(7) << "FreqIDs" << endl; 1133 oss << "--------------------------------------------------------------------------------" << endl; 1125 1134 1126 1135 // … … 1147 1156 if (i==nRow-1 &&scanID==lastScanID) nInt++; 1148 1157 if (nInt==1 && i>1) { 1149 for (uInt j=0; j<freqIDs.nelements(); j++) mathutil::addEntry(listFQ, freqIDs(j)); 1158 for (uInt j=0; j<freqIDs.nelements(); j++) 1159 mathutil::addEntry(listFQ, freqIDs(j)); 1150 1160 } 1151 // 1152 oss << setw(6) << scanNo 1161 oss << setw(3) << std::right << scanNo << std::left << setw(2) << " " 1153 1162 << setw(15) << name 1154 << setw(2 6) << posit1163 << setw(24) << posit 1155 1164 << setw(10) << getTime(firstRow,False) 1156 << setw(3) << nInt << setw(3) << " x " << setw(6) << t 1165 << setw(3) << std::right << nInt << setw(3) << " x " << std::left 1166 << setw(6) << t 1157 1167 << " " << listFQ << endl; 1158 1168 // … … 1169 1179 1170 1180 // Frequency Table 1171 1172 std::vector<string> info = getCoordInfo(); 1173 SDFrequencyTable sdft = getSDFreqTable(); 1174 oss << endl << endl; 1175 oss << "FreqID Frame RefFreq(Hz) RefPix Increment(Hz)" << endl; 1176 oss << "----------------------------------------------------------------------------------" << endl; 1177 for (uInt i=0; i<sdft.length(); i++) { 1178 oss << setw(8) << i << setw(8) 1179 << info[3] << setw(16) << setprecision (8) 1180 << sdft.referenceValue(i) << setw(10) 1181 << sdft.referencePixel(i) << setw(12) 1182 << sdft.increment(i) << endl; 1183 } 1184 oss << "----------------------------------------------------------------------------------" << endl; 1181 if (verbose) { 1182 std::vector<string> info = getCoordInfo(); 1183 SDFrequencyTable sdft = getSDFreqTable(); 1184 oss << endl << endl; 1185 oss << "FreqID Frame RefFreq(Hz) RefPix Increment(Hz)" << endl; 1186 oss << "--------------------------------------------------------------------------------" << endl; 1187 for (uInt i=0; i<sdft.length(); i++) { 1188 oss << setw(8) << i << setw(8) 1189 << info[3] << setw(16) << setprecision(8) 1190 << sdft.referenceValue(i) << setw(10) 1191 << sdft.referencePixel(i) << setw(12) 1192 << sdft.increment(i) << endl; 1193 } 1194 oss << "--------------------------------------------------------------------------------" << endl; 1195 } 1185 1196 return String(oss); 1186 1197 } … … 1282 1293 } 1283 1294 1284 MEpoch::Types SDMemTable::getTimeReference 1295 MEpoch::Types SDMemTable::getTimeReference() const 1285 1296 { 1286 1297 MEpoch::Types met; … … 1296 1307 1297 1308 1298 Instrument SDMemTable::convertInstrument 1299 1309 Instrument SDMemTable::convertInstrument(const String& instrument, 1310 Bool throwIt) 1300 1311 { 1301 1312 String t(instrument); … … 1319 1330 inst = HOBART; 1320 1331 } else { 1321 1322 1323 1332 if (throwIt) { 1333 throw AipsError("Unrecognized instrument - use function scan.set_instrument to set"); 1334 } 1324 1335 } 1325 1336 return inst; 1326 1337 } 1327 1338 1339 void SDMemTable::renumber() 1340 { 1341 uInt nRow = scanCol_.nrow(); 1342 Int newscanid = 0; 1343 Int cIdx;// the current scanid 1344 // get the first scanid 1345 scanCol_.getScalar(0,cIdx); 1346 Int pIdx = cIdx;// the scanid of the previous row 1347 for (uInt i=0; i<nRow;++i) { 1348 scanCol_.getScalar(i,cIdx); 1349 if (pIdx == cIdx) { 1350 // renumber 1351 scanCol_.put(i,newscanid); 1352 } else { 1353 ++newscanid; 1354 pIdx = cIdx; // store scanid 1355 --i; // don't increment next loop 1356 } 1357 } 1358 } -
trunk/src/SDMemTable.h
r322 r380 150 150 151 151 // get a summary of the table 152 virtual std::string summary( ) const;152 virtual std::string summary(bool verbose=false) const; 153 153 154 154 std::vector<std::string> history(int whichRow=0) const; … … 217 217 void setup(); 218 218 void attach(); 219 void renumber(); 219 220 // the current cursor into the array 220 221 casa::Int IFSel_,beamSel_,polSel_; -
trunk/src/SDMemTableWrapper.h
r260 r380 34 34 #include <vector> 35 35 #include <string> 36 #include <casa/Arrays/Vector.h> 36 37 37 38 #include "SDMemTable.h" … … 60 61 } 61 62 62 SDMemTableWrapper getScan(int scan) { 63 casa::String cond("SELECT * from $1 WHERE SCANID == "); 64 cond += casa::String::toString(scan); 63 //SDMemTableWrapper getScan(int scan) { 64 SDMemTableWrapper getScan(std::vector<int> scan) { 65 casa::String cond("SELECT FROM $1 WHERE SCANID IN "); 66 casa::Vector<casa::Int> v(scan); 67 casa::ostringstream oss; 68 oss << v; 69 cond += casa::String(oss); 65 70 return SDMemTableWrapper(*this, cond); 66 71 } … … 157 162 casa::CountedPtr<SDMemTable> getCP() const {return table_;} 158 163 SDMemTable* getPtr() {return &(*table_);} 159 std::string summary() const { return table_->summary(); } 164 165 std::string summary(bool verbose=false) const { 166 return table_->summary(verbose); 167 } 160 168 161 169 std::vector<std::string> history(int whichRow=0) {
Note:
See TracChangeset
for help on using the changeset viewer.