- Timestamp:
- 01/18/05 17:29:02 (20 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDMemTable.cc
r164 r206 30 30 //#--------------------------------------------------------------------------- 31 31 32 #include <map> 33 32 34 #include <casa/aips.h> 33 35 #include <casa/iostream.h> … … 38 40 #include <casa/Arrays/ArrayLogical.h> 39 41 #include <casa/Arrays/ArrayAccessor.h> 42 #include <casa/Arrays/Vector.h> 40 43 41 44 #include <tables/Tables/TableParse.h> … … 54 57 #include <casa/Quanta/MVTime.h> 55 58 59 #include "Definitions.h" 56 60 #include "SDMemTable.h" 57 61 #include "SDContainer.h" 62 58 63 59 64 using namespace casa; … … 63 68 IFSel_(0), 64 69 beamSel_(0), 65 polSel_(0) { 70 polSel_(0) 71 { 66 72 setup(); 67 73 } 74 68 75 SDMemTable::SDMemTable(const std::string& name) : 69 76 IFSel_(0), 70 77 beamSel_(0), 71 polSel_(0) { 78 polSel_(0) 79 { 72 80 Table tab(name); 73 81 table_ = tab.copyToMemoryTable("dummy"); 74 } 75 76 SDMemTable::SDMemTable(const SDMemTable& other, Bool clear) { 82 //cerr << "hello from C SDMemTable @ " << this << endl; 83 } 84 85 SDMemTable::SDMemTable(const SDMemTable& other, Bool clear) 86 { 77 87 IFSel_= other.IFSel_; 78 88 beamSel_= other.beamSel_; … … 88 98 polSel_ = other.polSel_; 89 99 } 100 //cerr << "hello from CC SDMemTable @ " << this << endl; 90 101 } 91 102 … … 93 104 IFSel_(0), 94 105 beamSel_(0), 95 polSel_(0) { 106 polSel_(0) 107 { 96 108 Table t = tableCommand(exprs,tab); 97 109 if (t.nrow() == 0) … … 100 112 } 101 113 102 SDMemTable::~SDMemTable(){ 114 SDMemTable::~SDMemTable() 115 { 103 116 //cerr << "goodbye from SDMemTable @ " << this << endl; 104 117 } 105 118 106 SDMemTable SDMemTable::getScan(Int scanID) const { 119 SDMemTable SDMemTable::getScan(Int scanID) const 120 { 107 121 String cond("SELECT * from $1 WHERE SCANID == "); 108 122 cond += String::toString(scanID); … … 110 124 } 111 125 112 SDMemTable &SDMemTable::operator=(const SDMemTable& other) { 126 SDMemTable &SDMemTable::operator=(const SDMemTable& other) 127 { 113 128 if (this != &other) { 114 129 IFSel_= other.IFSel_; … … 118 133 chanMask_ = other.chanMask_; 119 134 table_ = other.table_.copyToMemoryTable(String("dummy")); 120 } 135 } 136 //cerr << "hello from ASS SDMemTable @ " << this << endl; 121 137 return *this; 122 138 } 123 139 124 SDMemTable SDMemTable::getSource(const std::string& source) const { 140 SDMemTable SDMemTable::getSource(const std::string& source) const 141 { 125 142 String cond("SELECT * from $1 WHERE SRCNAME == "); 126 143 cond += source; … … 128 145 } 129 146 130 void SDMemTable::setup() { 147 void SDMemTable::setup() 148 { 131 149 TableDesc td("", "1", TableDesc::Scratch); 132 150 td.comment() = "A SDMemTable"; … … 147 165 td.addColumn(ScalarColumnDesc<Float>("PARANGLE")); 148 166 td.addColumn(ScalarColumnDesc<Int>("REFBEAM")); 167 td.addColumn(ArrayColumnDesc<String>("HISTORY")); 149 168 150 169 // Now create a new table from the description. … … 154 173 } 155 174 156 std::string SDMemTable::getSourceName(Int whichRow) const { 175 std::string SDMemTable::getSourceName(Int whichRow) const 176 { 157 177 ROScalarColumn<String> src(table_, "SRCNAME"); 158 178 String name; … … 161 181 } 162 182 163 std::string SDMemTable::getTime(Int whichRow) const { 183 std::string SDMemTable::getTime(Int whichRow) const 184 { 164 185 ROScalarColumn<Double> src(table_, "TIME"); 165 186 Double tm; … … 172 193 return str; 173 194 } 174 double SDMemTable::getInterval(Int whichRow) const { 195 double SDMemTable::getInterval(Int whichRow) const 196 { 175 197 ROScalarColumn<Double> src(table_, "INTERVAL"); 176 198 Double intval; … … 179 201 } 180 202 181 bool SDMemTable::setIF(Int whichIF) { 203 bool SDMemTable::setIF(Int whichIF) 204 { 182 205 if ( whichIF >= 0 && whichIF < nIF()) { 183 206 IFSel_ = whichIF; … … 187 210 } 188 211 189 bool SDMemTable::setBeam(Int whichBeam) { 212 bool SDMemTable::setBeam(Int whichBeam) 213 { 190 214 if ( whichBeam >= 0 && whichBeam < nBeam()) { 191 215 beamSel_ = whichBeam; … … 195 219 } 196 220 197 bool SDMemTable::setPol(Int whichPol) { 221 bool SDMemTable::setPol(Int whichPol) 222 { 198 223 if ( whichPol >= 0 && whichPol < nPol()) { 199 224 polSel_ = whichPol; … … 203 228 } 204 229 205 bool SDMemTable::setMask(std::vector<int> whichChans) { 230 bool SDMemTable::setMask(std::vector<int> whichChans) 231 { 206 232 ROArrayColumn<uChar> spec(table_, "FLAGTRA"); 207 233 std::vector<int>::iterator it; … … 225 251 Array<uChar> arr; 226 252 spec.get(whichRow, arr); 227 ArrayAccessor<uChar, Axis< 0> > aa0(arr);253 ArrayAccessor<uChar, Axis<asap::BeamAxis> > aa0(arr); 228 254 aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam 229 ArrayAccessor<uChar, Axis< 1> > aa1(aa0);255 ArrayAccessor<uChar, Axis<asap::IFAxis> > aa1(aa0); 230 256 aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF 231 ArrayAccessor<uChar, Axis< 2> > aa2(aa1);257 ArrayAccessor<uChar, Axis<asap::PolAxis> > aa2(aa1); 232 258 aa2.reset(aa2.begin(uInt(polSel_)));// go to pol 233 259 … … 239 265 miter = tmp.begin(); 240 266 241 for (ArrayAccessor<uChar, Axis< 3> > i(aa2); i != i.end(); ++i) {267 for (ArrayAccessor<uChar, Axis<asap::ChanAxis> > i(aa2); i != i.end(); ++i) { 242 268 bool out =!static_cast<bool>(*i); 243 269 if (useUserMask) { … … 249 275 return mask; 250 276 } 251 std::vector<float> SDMemTable::getSpectrum(Int whichRow) const {252 277 std::vector<float> SDMemTable::getSpectrum(Int whichRow) const 278 { 253 279 std::vector<float> spectrum; 254 280 ROArrayColumn<Float> spec(table_, "SPECTRA"); 255 281 Array<Float> arr; 256 282 spec.get(whichRow, arr); 257 ArrayAccessor<Float, Axis< 0> > aa0(arr);283 ArrayAccessor<Float, Axis<asap::BeamAxis> > aa0(arr); 258 284 aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam 259 ArrayAccessor<Float, Axis< 1> > aa1(aa0);285 ArrayAccessor<Float, Axis<asap::IFAxis> > aa1(aa0); 260 286 aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF 261 ArrayAccessor<Float, Axis< 2> > aa2(aa1);287 ArrayAccessor<Float, Axis<asap::PolAxis> > aa2(aa1); 262 288 aa2.reset(aa2.begin(uInt(polSel_)));// go to pol 263 for (ArrayAccessor<Float, Axis< 3> > i(aa2); i != i.end(); ++i) {289 for (ArrayAccessor<Float, Axis<asap::ChanAxis> > i(aa2); i != i.end(); ++i) { 264 290 spectrum.push_back(*i); 265 291 } 266 292 return spectrum; 267 293 } 268 std::vector<string> SDMemTable::getCoordInfo() const { 294 std::vector<string> SDMemTable::getCoordInfo() const 295 { 269 296 String un; 270 297 Table t = table_.keywordSet().asTable("FREQUENCIES"); … … 283 310 } 284 311 285 void SDMemTable::setCoordInfo(std::vector<string> theinfo) {286 312 void SDMemTable::setCoordInfo(std::vector<string> theinfo) 313 { 287 314 std::vector<string>::iterator it; 288 315 String un,rfrm,dpl; … … 291 318 dpl = theinfo[2]; 292 319 293 //String un(theunit);294 320 Table t = table_.rwKeywordSet().asTable("FREQUENCIES"); 295 321 Vector<Double> rstf; … … 321 347 } 322 348 323 std::vector<double> SDMemTable::getAbcissa(Int whichRow) const { 349 std::vector<double> SDMemTable::getAbcissa(Int whichRow) const 350 { 324 351 std::vector<double> absc(nChan()); 325 352 Vector<Double> absc1(nChan()); … … 331 358 SpectralCoordinate spc = getCoordinate(specidx); 332 359 Table t = table_.keywordSet().asTable("FREQUENCIES"); 333 String rf; 334 //t.keywordSet().get("EQUINOX",rf); 335 MDirection::Types mdr; 336 //if (!MDirection::getType(mdr, rf)) { 337 mdr = MDirection::J2000; 338 //cout << "Unknown equinox using J2000" << endl; 339 //} 340 ROArrayColumn<Double> dir(table_, "DIRECTION"); 341 Array<Double> posit; 342 dir.get(whichRow,posit); 343 Vector<Double> wpos(2); 344 wpos[0] = posit(IPosition(2,beamSel_,0)); 345 wpos[1] = posit(IPosition(2,beamSel_,1)); 346 Quantum<Double> lon(wpos[0],Unit(String("rad"))); 347 Quantum<Double> lat(wpos[1],Unit(String("rad"))); 348 MDirection direct(lon, lat, mdr); 360 361 MDirection direct = getDirection(whichRow); 362 349 363 ROScalarColumn<Double> tme(table_, "TIME"); 350 364 Double obstime; 351 365 tme.get(whichRow,obstime); 352 366 MVEpoch tm2(Quantum<Double>(obstime, Unit(String("d")))); 353 MEpoch epoch(tm2); 367 MEpoch::Types met; 368 String ep; 369 table_.keywordSet().get("Epoch",ep); 370 if (!MEpoch::getType(met, ep)) { 371 cerr << "Epoch type uknown - using UTC" << endl; 372 met = MEpoch::UTC; 373 } 374 375 MEpoch epoch(tm2, met); 354 376 355 377 Vector<Double> antpos; … … 448 470 } 449 471 450 void SDMemTable::setSpectrum(std::vector<float> spectrum, int whichRow) { 472 void SDMemTable::setSpectrum(std::vector<float> spectrum, int whichRow) 473 { 451 474 ArrayColumn<Float> spec(table_, "SPECTRA"); 452 475 Array<Float> arr; … … 456 479 } 457 480 458 ArrayAccessor<Float, Axis< 0> > aa0(arr);481 ArrayAccessor<Float, Axis<asap::BeamAxis> > aa0(arr); 459 482 aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam 460 ArrayAccessor<Float, Axis< 1> > aa1(aa0);483 ArrayAccessor<Float, Axis<asap::IFAxis> > aa1(aa0); 461 484 aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF 462 ArrayAccessor<Float, Axis< 2> > aa2(aa1);485 ArrayAccessor<Float, Axis<asap::PolAxis> > aa2(aa1); 463 486 aa2.reset(aa2.begin(uInt(polSel_)));// go to pol 464 487 465 488 std::vector<float>::iterator it = spectrum.begin(); 466 for (ArrayAccessor<Float, Axis< 3> > i(aa2); i != i.end(); ++i) {489 for (ArrayAccessor<Float, Axis<asap::ChanAxis> > i(aa2); i != i.end(); ++i) { 467 490 (*i) = Float(*it); 468 491 it++; … … 471 494 } 472 495 473 void SDMemTable::getSpectrum(Vector<Float>& spectrum, Int whichRow) const { 496 void SDMemTable::getSpectrum(Vector<Float>& spectrum, Int whichRow) const 497 { 474 498 ROArrayColumn<Float> spec(table_, "SPECTRA"); 475 499 Array<Float> arr; 476 500 spec.get(whichRow, arr); 477 501 spectrum.resize(arr.shape()(3)); 478 ArrayAccessor<Float, Axis< 0> > aa0(arr);502 ArrayAccessor<Float, Axis<asap::BeamAxis> > aa0(arr); 479 503 aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam 480 ArrayAccessor<Float, Axis< 1> > aa1(aa0);504 ArrayAccessor<Float, Axis<asap::IFAxis> > aa1(aa0); 481 505 aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF 482 ArrayAccessor<Float, Axis< 2> > aa2(aa1);506 ArrayAccessor<Float, Axis<asap::PolAxis> > aa2(aa1); 483 507 aa2.reset(aa2.begin(uInt(polSel_)));// go to pol 484 508 485 ArrayAccessor<Float, Axis< 0> > va(spectrum);486 for (ArrayAccessor<Float, Axis< 3> > i(aa2); i != i.end(); ++i) {509 ArrayAccessor<Float, Axis<asap::BeamAxis> > va(spectrum); 510 for (ArrayAccessor<Float, Axis<asap::ChanAxis> > i(aa2); i != i.end(); ++i) { 487 511 (*va) = (*i); 488 512 va++; … … 496 520 mask.resize(arr.shape()(3)); 497 521 498 ArrayAccessor<uChar, Axis< 0> > aa0(arr);522 ArrayAccessor<uChar, Axis<asap::BeamAxis> > aa0(arr); 499 523 aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam 500 ArrayAccessor<uChar, Axis< 1> > aa1(aa0);524 ArrayAccessor<uChar, Axis<asap::IFAxis> > aa1(aa0); 501 525 aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF 502 ArrayAccessor<uChar, Axis< 2> > aa2(aa1);526 ArrayAccessor<uChar, Axis<asap::PolAxis> > aa2(aa1); 503 527 aa2.reset(aa2.begin(uInt(polSel_)));// go to pol 504 528 505 529 Bool useUserMask = ( chanMask_.size() == arr.shape()(3) ); 506 530 507 ArrayAccessor<Bool, Axis< 0> > va(mask);531 ArrayAccessor<Bool, Axis<asap::BeamAxis> > va(mask); 508 532 std::vector<bool> tmp; 509 533 tmp = chanMask_; // WHY the fxxx do I have to make a copy here. The … … 512 536 miter = tmp.begin(); 513 537 514 for (ArrayAccessor<uChar, Axis< 3> > i(aa2); i != i.end(); ++i) {538 for (ArrayAccessor<uChar, Axis<asap::ChanAxis> > i(aa2); i != i.end(); ++i) { 515 539 bool out =!static_cast<bool>(*i); 516 540 if (useUserMask) { … … 535 559 MaskedArray<Float> marr; 536 560 if (useSelection) { 537 ArrayAccessor<Float, Axis< 0> > aa0(arr);561 ArrayAccessor<Float, Axis<asap::BeamAxis> > aa0(arr); 538 562 aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam 539 ArrayAccessor<Float, Axis< 1> > aa1(aa0);563 ArrayAccessor<Float, Axis<asap::IFAxis> > aa1(aa0); 540 564 aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF 541 ArrayAccessor<Float, Axis< 2> > aa2(aa1);565 ArrayAccessor<Float, Axis<asap::PolAxis> > aa2(aa1); 542 566 aa2.reset(aa2.begin(uInt(polSel_)));// go to pol 543 567 544 ArrayAccessor<Bool, Axis< 0> > baa0(barr);568 ArrayAccessor<Bool, Axis<asap::BeamAxis> > baa0(barr); 545 569 baa0.reset(baa0.begin(uInt(beamSel_)));//go to beam 546 ArrayAccessor<Bool, Axis< 1> > baa1(baa0);570 ArrayAccessor<Bool, Axis<asap::IFAxis> > baa1(baa0); 547 571 baa1.reset(baa1.begin(uInt(IFSel_)));// go to IF 548 ArrayAccessor<Bool, Axis< 2> > baa2(baa1);572 ArrayAccessor<Bool, Axis<asap::PolAxis> > baa2(baa1); 549 573 baa2.reset(baa2.begin(uInt(polSel_)));// go to pol 550 574 551 575 Vector<Float> a(arr.shape()(3)); 552 576 Vector<Bool> b(barr.shape()(3)); 553 ArrayAccessor<Float, Axis<0> > a0(a); 554 ArrayAccessor<Bool, Axis<0> > b0(b); 555 556 ArrayAccessor<Bool, Axis<3> > j(baa2); 557 for (ArrayAccessor<Float, Axis<3> > i(aa2); i != i.end(); ++i) { 577 ArrayAccessor<Float, Axis<asap::BeamAxis> > a0(a); 578 ArrayAccessor<Bool, Axis<asap::BeamAxis> > b0(b); 579 580 ArrayAccessor<Bool, Axis<asap::ChanAxis> > j(baa2); 581 for (ArrayAccessor<Float, Axis<asap::ChanAxis> > i(aa2); 582 i != i.end(); ++i) { 558 583 (*a0) = (*i); 559 584 (*b0) = !(*j); … … 569 594 } 570 595 571 Float SDMemTable::getTsys(Int whichRow) const { 596 Float SDMemTable::getTsys(Int whichRow) const 597 { 572 598 ROArrayColumn<Float> ts(table_, "TSYS"); 573 599 Array<Float> arr; … … 580 606 } 581 607 582 SpectralCoordinate SDMemTable::getCoordinate(uInt whichIdx) const { 583 608 MDirection SDMemTable::getDirection(Int whichRow) const 609 { 610 Float eq; 611 table_.keywordSet().get("Equinox",eq); 612 std::map<float,string> mp; 613 mp[2000.0] = "J2000"; 614 mp[1950.0] = "B1950"; 615 MDirection::Types mdr; 616 if (!MDirection::getType(mdr, mp[eq])) { 617 mdr = MDirection::J2000; 618 cerr << "Unknown equinox using J2000" << endl; 619 } 620 ROArrayColumn<Double> dir(table_, "DIRECTION"); 621 Array<Double> posit; 622 dir.get(whichRow,posit); 623 Vector<Double> wpos(2); 624 wpos[0] = posit(IPosition(2,beamSel_,0)); 625 wpos[1] = posit(IPosition(2,beamSel_,1)); 626 Quantum<Double> lon(wpos[0],Unit(String("rad"))); 627 Quantum<Double> lat(wpos[1],Unit(String("rad"))); 628 MDirection direct(lon, lat, mdr); 629 return direct; 630 } 631 632 SpectralCoordinate SDMemTable::getCoordinate(uInt whichIdx) const 633 { 634 584 635 Table t = table_.keywordSet().asTable("FREQUENCIES"); 585 636 if (whichIdx > t.nrow() ) { 586 cerr << "SDMemTable::getCoordinate - whichIdx out of range" << endl; 587 return SpectralCoordinate(); 637 throw(AipsError("SDMemTable::getCoordinate - whichIdx out of range")); 588 638 } 589 639 … … 633 683 } 634 684 635 void SDMemTable::setRestFreqs(std::vector<double> freqs, const std::string& theunit) 685 void SDMemTable::setRestFreqs(std::vector<double> freqs, 686 const std::string& theunit) 636 687 { 637 688 Vector<Double> tvec(freqs); … … 643 694 } 644 695 645 bool SDMemTable::putSDFreqTable(const SDFrequencyTable& sdft) { 696 bool SDMemTable::putSDFreqTable(const SDFrequencyTable& sdft) 697 { 646 698 TableDesc td("", "1", TableDesc::Scratch); 647 699 td.addColumn(ScalarColumnDesc<Double>("REFPIX")); … … 667 719 aTable.rwKeywordSet().define("DOPPLER", String("RADIO")); 668 720 Vector<Double> rfvec; 721 String rfunit; 722 sdft.restFrequencies(rfvec,rfunit); 723 Quantum<Vector<Double> > q(rfvec, rfunit); 724 rfvec.resize(); 725 rfvec = q.getValue("Hz"); 669 726 aTable.rwKeywordSet().define("RESTFREQS", rfvec); 670 727 table_.rwKeywordSet().defineTable ("FREQUENCIES", aTable); … … 672 729 } 673 730 674 SDFrequencyTable SDMemTable::getSDFreqTable() const { 731 SDFrequencyTable SDMemTable::getSDFreqTable() const 732 { 675 733 SDFrequencyTable sdft; 676 734 … … 678 736 } 679 737 680 bool SDMemTable::putSDContainer(const SDContainer& sdc) { 738 bool SDMemTable::putSDContainer(const SDContainer& sdc) 739 { 681 740 ScalarColumn<Double> mjd(table_, "TIME"); 682 741 ScalarColumn<String> srcn(table_, "SRCNAME"); … … 695 754 ScalarColumn<Float> el(table_, "ELEVATION"); 696 755 ScalarColumn<Float> para(table_, "PARANGLE"); 756 ArrayColumn<String> hist(table_, "HISTORY"); 697 757 698 758 uInt rno = table_.nrow(); … … 715 775 el.put(rno, sdc.elevation); 716 776 para.put(rno, sdc.parangle); 777 hist.put(rno, sdc.getHistory()); 717 778 718 779 return true; 719 780 } 720 781 721 SDContainer SDMemTable::getSDContainer(uInt whichRow) const { 782 SDContainer SDMemTable::getSDContainer(uInt whichRow) const 783 { 722 784 ROScalarColumn<Double> mjd(table_, "TIME"); 723 785 ROScalarColumn<String> srcn(table_, "SRCNAME"); … … 736 798 ROScalarColumn<Float> el(table_, "ELEVATION"); 737 799 ROScalarColumn<Float> para(table_, "PARANGLE"); 800 ROArrayColumn<String> hist(table_, "HISTORY"); 738 801 739 802 SDContainer sdc(nBeam(),nIF(),nPol(),nChan()); … … 756 819 Vector<uInt> fmap; 757 820 Array<Double> direction; 821 Vector<String> histo; 758 822 spec.get(whichRow, spectrum); 759 823 sdc.putSpectrum(spectrum); … … 766 830 dir.get(whichRow, direction); 767 831 sdc.putDirection(direction); 832 hist.get(whichRow, histo); 833 sdc.putHistory(histo); 768 834 return sdc; 769 835 } 770 836 771 bool SDMemTable::putSDHeader(const SDHeader& sdh) {772 table_.lock(); 837 bool SDMemTable::putSDHeader(const SDHeader& sdh) 838 { 773 839 table_.rwKeywordSet().define("nIF", sdh.nif); 774 840 table_.rwKeywordSet().define("nBeam", sdh.nbeam); … … 785 851 table_.rwKeywordSet().define("Bandwidth", sdh.bandwidth); 786 852 table_.rwKeywordSet().define("UTC", sdh.utc); 787 table_.unlock(); 853 table_.rwKeywordSet().define("FluxUnit", sdh.fluxunit); 854 table_.rwKeywordSet().define("Epoch", sdh.epoch); 788 855 return true; 789 856 } 790 857 791 SDHeader SDMemTable::getSDHeader() const { 858 SDHeader SDMemTable::getSDHeader() const 859 { 792 860 SDHeader sdh; 793 861 table_.keywordSet().get("nBeam",sdh.nbeam); … … 805 873 table_.keywordSet().get("Bandwidth", sdh.bandwidth); 806 874 table_.keywordSet().get("UTC", sdh.utc); 875 table_.keywordSet().get("FluxUnit", sdh.fluxunit); 876 table_.keywordSet().get("Epoch", sdh.epoch); 807 877 return sdh; 808 878 } 809 void SDMemTable::makePersistent(const std::string& filename) { 879 void SDMemTable::makePersistent(const std::string& filename) 880 { 810 881 table_.deepCopy(filename,Table::New); 811 882 } … … 825 896 } 826 897 827 String SDMemTable::formatSec(Double x) { 898 String SDMemTable::formatSec(Double x) 899 { 828 900 Double xcop = x; 829 901 MVTime mvt(xcop/24./3600.); // make days … … 832 904 return mvt.string(MVTime::TIME_CLEAN_NO_H, 7)+" "; 833 905 }; 906 907 std::string SDMemTable::getFluxUnit() const 908 { 909 String tmp; 910 table_.keywordSet().get("FluxUnit", tmp); 911 return tmp; 912 } 834 913 835 914 std::string SDMemTable::summary() { … … 856 935 table_.keywordSet().get("AntennaName", tmp); 857 936 oss << setw(15) << "Antenna Name:" << tmp << endl; 937 table_.keywordSet().get("FluxUnit", tmp); 938 oss << setw(15) << "Flux Unit:" << tmp << endl; 858 939 Table t = table_.rwKeywordSet().asTable("FREQUENCIES"); 859 940 Vector<Double> vec; … … 899 980 } 900 981 901 Int SDMemTable::nBeam() const { 982 Int SDMemTable::nBeam() const 983 { 902 984 Int n; 903 985 table_.keywordSet().get("nBeam",n); … … 919 1001 return n; 920 1002 } 1003 bool SDMemTable::appendHistory(const std::string& hist, int whichRow) 1004 { 1005 ArrayColumn<String> histo(table_, "HISTORY"); 1006 Vector<String> history; 1007 histo.get(whichRow, history); 1008 history.resize(history.nelements()+1,True); 1009 history[history.nelements()-1] = hist; 1010 histo.put(whichRow, history); 1011 } 1012 1013 std::vector<std::string> SDMemTable::history(int whichRow) const 1014 { 1015 ROArrayColumn<String> hist(table_, "HISTORY"); 1016 Vector<String> history; 1017 hist.get(whichRow, history); 1018 std::vector<std::string> stlout; 1019 // there is no Array<String>.tovector(std::vector<std::string>), so 1020 // do it by hand 1021 for (uInt i=0; i<history.nelements(); ++i) { 1022 stlout.push_back(history[i]); 1023 } 1024 return stlout; 1025 } 921 1026 /* 922 1027 void SDMemTable::maskChannels(const std::vector<Int>& whichChans ) { 923 1028 924 1029 std::vector<int>::iterator it; 925 ArrayAccessor<uChar, Axis< 2> > j(flags_);1030 ArrayAccessor<uChar, Axis<asap::PolAxis> > j(flags_); 926 1031 for (it = whichChans.begin(); it != whichChans.end(); it++) { 927 1032 j.reset(j.begin(uInt(*it))); 928 for (ArrayAccessor<uChar, Axis< 0> > i(j); i != i.end(); ++i) {929 for (ArrayAccessor<uChar, Axis< 1> > ii(i); ii != ii.end(); ++ii) {930 for (ArrayAccessor<uChar, Axis< 3> > iii(ii);1033 for (ArrayAccessor<uChar, Axis<asap::BeamAxis> > i(j); i != i.end(); ++i) { 1034 for (ArrayAccessor<uChar, Axis<asap::IFAxis> > ii(i); ii != ii.end(); ++ii) { 1035 for (ArrayAccessor<uChar, Axis<asap::ChanAxis> > iii(ii); 931 1036 iii != iii.end(); ++iii) { 932 1037 (*iii) = … … 938 1043 } 939 1044 */ 940 void SDMemTable::flag(int whichRow) { 1045 void SDMemTable::flag(int whichRow) 1046 { 941 1047 ArrayColumn<uChar> spec(table_, "FLAGTRA"); 942 1048 Array<uChar> arr; 943 1049 spec.get(whichRow, arr); 944 1050 945 ArrayAccessor<uChar, Axis< 0> > aa0(arr);1051 ArrayAccessor<uChar, Axis<asap::BeamAxis> > aa0(arr); 946 1052 aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam 947 ArrayAccessor<uChar, Axis< 1> > aa1(aa0);1053 ArrayAccessor<uChar, Axis<asap::IFAxis> > aa1(aa0); 948 1054 aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF 949 ArrayAccessor<uChar, Axis< 2> > aa2(aa1);1055 ArrayAccessor<uChar, Axis<asap::PolAxis> > aa2(aa1); 950 1056 aa2.reset(aa2.begin(uInt(polSel_)));// go to pol 951 1057 952 for (ArrayAccessor<uChar, Axis< 3> > i(aa2); i != i.end(); ++i) {1058 for (ArrayAccessor<uChar, Axis<asap::ChanAxis> > i(aa2); i != i.end(); ++i) { 953 1059 (*i) = uChar(True); 954 1060 } -
trunk/src/SDMemTable.h
r164 r206 100 100 const std::string& theunit); 101 101 virtual void setCoordInfo(std::vector<string> theinfo); 102 103 std::string getFluxUnit() const; 104 102 105 // set the current value 103 106 virtual bool setIF(casa::Int whichIF=0); … … 114 117 virtual casa::Int getBeam() const { return beamSel_; } 115 118 virtual casa::Int getPol() const { return polSel_; } 116 virtual std::vector<st ring> getCoordInfo() const;119 virtual std::vector<std::string> getCoordInfo() const; 117 120 118 121 // number of scans in table 119 122 virtual casa::Int nScan() const; 120 123 121 // print a summary to stdout124 // get a summary of the table 122 125 virtual std::string summary(); 123 126 127 std::vector<std::string> history(int whichRow=0) const; 128 bool appendHistory(const std::string& hist, int whichRow=0); 124 129 // write to disk as aips++ table 125 130 void makePersistent(const std::string& filename); … … 145 150 // to bool mask 146 151 casa::MaskedArray<casa::Float> rowAsMaskedArray(casa::uInt whichRow, 147 casa::Bool useSelection = casa::False) const; 152 casa::Bool useSelection = 153 casa::False) const; 148 154 149 155 casa::SpectralCoordinate getCoordinate(casa::uInt whichIdx) const; … … 153 159 casa::Int nCoordinates() const; 154 160 161 155 162 std::vector<double> getAbcissa(int whichRow=0) const; 156 163 std::string getAbcissaString(casa::Int whichRow=0) const; 164 165 casa::MDirection getDirection(casa::Int whichRow=0) const; 157 166 158 167 private:
Note:
See TracChangeset
for help on using the changeset viewer.