- Timestamp:
- 07/15/04 15:58:02 (20 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDMemTable.cc
r39 r50 32 32 33 33 #include <aips/iostream.h> 34 #include <aips/iomanip.h> 34 35 #include <aips/Arrays/Array.h> 35 36 #include <aips/Arrays/ArrayMath.h> … … 49 50 #include <aips/Tables/TableRecord.h> 50 51 #include <aips/Measures/MFrequency.h> 52 #include <aips/Quanta/MVTime.h> 51 53 52 54 #include "SDMemTable.h" … … 65 67 beamSel_(0), 66 68 polSel_(0) { 67 Table tab( "dummy");69 Table tab(name); 68 70 table_ = tab.copyToMemoryTable("dummy"); 69 71 } … … 91 93 String exprs = String("select * from $1 where SCANID == ") 92 94 +String::toString(scanID); 93 cerr << exprs << endl;95 //cerr << exprs << endl; 94 96 Table t = tableCommand(exprs,tab); 95 97 table_ = t.copyToMemoryTable("dummy"); … … 97 99 98 100 SDMemTable::~SDMemTable(){ 99 cerr << "goodbye from SDMemTable @ " << this << endl;101 //cerr << "goodbye from SDMemTable @ " << this << endl; 100 102 } 101 103 … … 128 130 } 129 131 130 DoubleSDMemTable::getTime(Int whichRow) const {132 std::string SDMemTable::getTime(Int whichRow) const { 131 133 ROScalarColumn<Double> src(table_, "TIME"); 132 134 Double tm; 133 135 src.get(whichRow, tm); 134 return tm; 136 MVTime mvt(tm); 137 mvt.setFormat(MVTime::YMD); 138 ostringstream oss; 139 oss << mvt; 140 String str(oss); 141 return str; 142 } 143 double SDMemTable::getInterval(Int whichRow) const { 144 ROScalarColumn<Double> src(table_, "INTERVAL"); 145 Double intval; 146 src.get(whichRow, intval); 147 return intval; 135 148 } 136 149 137 150 bool SDMemTable::setIF(Int whichIF) { 138 //if ( whichIF >= 0 && whichIF < nIF_) {151 if ( whichIF >= 0 && whichIF < nIF()) { 139 152 IFSel_ = whichIF; 140 153 return true; 141 //} 142 //return false; 143 } 154 } 155 return false; 156 } 157 144 158 bool SDMemTable::setBeam(Int whichBeam) { 145 //if ( whichBeam >= 0 && whichBeam < nBeam_) {159 if ( whichBeam >= 0 && whichBeam < nBeam()) { 146 160 beamSel_ = whichBeam; 147 161 return true; 148 //}149 //return false;150 151 } 162 } 163 return false; 164 } 165 152 166 bool SDMemTable::setPol(Int whichPol) { 153 //if ( whichPol >= 0 && whichPol < nPol_) {167 if ( whichPol >= 0 && whichPol < nPol()) { 154 168 polSel_ = whichPol; 155 169 return true; 156 //}157 //return false;170 } 171 return false; 158 172 } 159 173 … … 200 214 return mask; 201 215 } 202 std::vector<float> SDMemTable::getSpectrum(Int whichRow) {216 std::vector<float> SDMemTable::getSpectrum(Int whichRow) const { 203 217 204 218 std::vector<float> spectrum; … … 228 242 fid.get(whichRow, v); 229 243 uInt specidx = v(IFSel_); 230 cerr << "specidx = " << specidx << endl;231 244 Unit u; 232 245 if (whichUnit == "") { … … 236 249 } 237 250 SpectralCoordinate spc = getCoordinate(specidx); 238 cerr << "debug" << endl;239 251 if ( u == Unit("km/s") ) { 240 cerr << "vel ??? " << restfreq << endl;241 252 if (Double(restfreq) > Double(0.000001)) { 242 253 cerr << "converting to velocities"<< endl; … … 259 270 Double tmp; 260 271 uInt i = 0; 261 for (it = absc.begin(); it != absc.end(); ++it) { 262 272 for (it = absc.begin(); it != absc.end(); ++it) { 263 273 spc.toWorld(tmp,absc1[i]); 264 274 (*it) = tmp; 265 275 i++; 266 276 } 267 cerr << "converted all pic to world" << endl; 268 } 269 cerr << "exiting getAbscissa" << endl; 277 } 270 278 return absc; 271 279 } … … 401 409 rvc.get(whichIdx, rv); 402 410 incc.get(whichIdx, inc); 403 cerr << "creating speccord from " << whichIdx << ": "404 << rp <<", " << rv << ", " << inc << ", " << mft <<endl;411 //cerr << "creating speccord from " << whichIdx << ": " 412 // << rp <<", " << rv << ", " << inc << ", " << mft <<endl; 405 413 SpectralCoordinate spec(mft,rv,inc,rp); 406 cerr << "debugit" << endl;407 414 return spec; 408 415 } 416 417 Bool SDMemTable::setCoordinate(const SpectralCoordinate& speccord, 418 uInt whichIdx) { 419 Table t = table_.rwKeywordSet().asTable("FREQUENCIES"); 420 if (whichIdx > t.nrow() ) { 421 cerr << "SDMemTable::setCoordinate - whichIdx out of range" << endl; 422 return; 423 } 424 ScalarColumn<Double> rpc(t, "REFPIX"); 425 ScalarColumn<Double> rvc(t, "REFVAL"); 426 ScalarColumn<Double> incc(t, "INCREMENT"); 427 428 rpc.put(whichIdx, speccord.referencePixel()[0]); 429 rvc.put(whichIdx, speccord.referenceValue()[0]); 430 incc.put(whichIdx, speccord.increment()[0]); 431 432 return True; 433 } 434 409 435 410 436 bool SDMemTable::putSDFreqTable(const SDFrequencyTable& sdft) { … … 427 453 aTable.rwKeywordSet().define("Unit", String("kms-1")); 428 454 table_.rwKeywordSet().defineTable ("FREQUENCIES", aTable); 429 cerr << "debug - putSDFreqTable" << endl;430 455 return True; 431 456 } … … 508 533 table_.rwKeywordSet().define("UTC", sdh.utc); 509 534 table_.unlock(); 510 cerr << "Table Header set" << endl;511 535 return true; 512 } \536 } 513 537 514 538 SDHeader SDMemTable::getSDHeader() const { … … 534 558 } 535 559 560 Int SDMemTable::nScans() const { 561 Int n = 0; 562 ROScalarColumn<Int> scans(table_, "SCANID"); 563 Int previous = -1;Int current=0; 564 for (uInt i=0; i< scans.nrow();i++) { 565 scans.getScalar(i,current); 566 if (previous != current) { 567 previous = current; 568 n++; 569 } 570 } 571 return n; 572 } 573 536 574 void SDMemTable::summary() const { 537 575 ROScalarColumn<Int> scans(table_, "SCANID"); … … 546 584 String name; 547 585 Int previous = -1;Int current=0; 548 cout << "Scan\tSource " << endl;586 cout << "Scan\tSource\t\tTime\t\tIntegration" << endl; 549 587 for (uInt i=0; i< scans.nrow();i++) { 550 588 scans.getScalar(i,current); 551 589 if (previous != current) { 552 590 srcs.getScalar(i,name); 553 previous = current; 591 previous = current; 592 Double t = getInterval(); 593 String unit("sec"); 594 if (t/60.0 > 1.0) { 595 t/=60.0;unit = "min"; 596 } 597 cout << count << "\t" 598 << name << "\t" 599 << getTime() << "\t" 600 << setprecision(2) << setiosflags(std::ios_base::fixed) 601 << t << " " << unit << endl 602 << endl; 554 603 count++; 555 cout << count << "\t"556 << name557 << endl;558 604 } 559 605 } -
trunk/src/SDMemTable.h
r39 r50 54 54 // create a new (empty) SDMemTable 55 55 SDMemTable(); 56 // create a SDMemTable from a )aips++) table on disk56 // create a SDMemTable from an (aips++) table on disk 57 57 SDMemTable(const std::string& name); 58 58 … … 78 78 // get spectrum,mask and tsys for the given row, at the selected 79 79 // cursor - all as stl vectors 80 virtual std::vector<float> getSpectrum(Int whichRow );81 virtual std::vector<bool> getMask(Int whichRow ) const;80 virtual std::vector<float> getSpectrum(Int whichRow=0) const; 81 virtual std::vector<bool> getMask(Int whichRow=0) const; 82 82 83 virtual Float getTsys(Int whichRow ) const;83 virtual Float getTsys(Int whichRow=0) const; 84 84 // get all as aips++ Vectors 85 85 virtual void getSpectrum(Vector<Float>& spectrum, Int whichRow=0); … … 87 87 88 88 // get info for current row 89 virtual Double getTime(Int whichRow) const ; 90 virtual std::string getSourceName(Int whichRow) const; 91 89 std::string getTime(Int whichRow=0) const ; 90 std::string getSourceName(Int whichRow=0) const; 91 double getInterval(Int whichRow=0) const; 92 92 93 // set the current value 93 94 virtual bool setIF(Int whichIF=0); … … 102 103 virtual Int getPol() { return polSel_; } 103 104 105 // number of scans in table 106 virtual Int nScans() const; 107 104 108 // print a summary to stdout 105 109 virtual void summary() const; … … 130 134 131 135 SpectralCoordinate getCoordinate(uInt whichIdx) const; 136 Bool setCoordinate(const SpectralCoordinate& speccord, uInt whichIdx); 137 132 138 std::vector<double> getAbscissa(int whichRow, 133 139 const std::string& whichUnit="GHz", … … 139 145 Int IFSel_,beamSel_,polSel_; 140 146 std::vector<bool> chanMask_; 141 String name_; 142 // the unerlying memory table 147 // the underlying memory table 143 148 Table table_; 144 149 };
Note:
See TracChangeset
for help on using the changeset viewer.