- Timestamp:
- 01/30/05 01:30:41 (20 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDMemTable.cc
r321 r322 50 50 51 51 #include <tables/Tables/ExprNode.h> 52 #include <tables/Tables/ScalarColumn.h>53 #include <tables/Tables/ArrayColumn.h>54 52 #include <tables/Tables/TableRecord.h> 55 53 #include <measures/Measures/MFrequency.h> … … 73 71 { 74 72 setup(); 73 cerr << "Call SDMemTable::attach" << endl; 74 attach(); 75 75 } 76 76 … … 100 100 polSel_ = other.polSel_; 101 101 } 102 // 103 attach(); 102 104 //cerr << "hello from CC SDMemTable @ " << this << endl; 103 105 } … … 135 137 chanMask_ = other.chanMask_; 136 138 table_ = other.table_.copyToMemoryTable(String("dummy")); 139 attach(); 137 140 } 138 141 //cerr << "hello from ASS SDMemTable @ " << this << endl; … … 151 154 TableDesc td("", "1", TableDesc::Scratch); 152 155 td.comment() = "A SDMemTable"; 156 // 153 157 td.addColumn(ScalarColumnDesc<Double>("TIME")); 154 158 td.addColumn(ScalarColumnDesc<String>("SRCNAME")); … … 175 179 } 176 180 181 void SDMemTable::attach () 182 { 183 timeCol_.attach(table_, "TIME"); 184 srcnCol_.attach(table_, "SRCNAME"); 185 specCol_.attach(table_, "SPECTRA"); 186 flagsCol_.attach(table_, "FLAGTRA"); 187 tsCol_.attach(table_, "TSYS"); 188 scanCol_.attach(table_, "SCANID"); 189 integrCol_.attach(table_, "INTERVAL"); 190 freqidCol_.attach(table_, "FREQID"); 191 dirCol_.attach(table_, "DIRECTION"); 192 fldnCol_.attach(table_, "FIELDNAME"); 193 tcaltCol_.attach(table_, "TCALTIME"); 194 tcalCol_.attach(table_, "TCAL"); 195 azCol_.attach(table_, "AZIMUTH"); 196 elCol_.attach(table_, "ELEVATION"); 197 paraCol_.attach(table_, "PARANGLE"); 198 rbeamCol_.attach(table_, "REFBEAM"); 199 histCol_.attach(table_, "HISTORY"); 200 } 201 202 177 203 std::string SDMemTable::getSourceName(Int whichRow) const 178 204 { 179 ROScalarColumn<String> src(table_, "SRCNAME");180 205 String name; 181 src .get(whichRow, name);206 srcnCol_.get(whichRow, name); 182 207 return name; 183 208 } … … 187 212 Double tm; 188 213 if (whichRow > -1) { 189 ROScalarColumn<Double> src(table_, "TIME"); 190 src.get(whichRow, tm); 214 timeCol_.get(whichRow, tm); 191 215 } else { 192 216 table_.keywordSet().get("UTC",tm); … … 204 228 double SDMemTable::getInterval(Int whichRow) const 205 229 { 206 ROScalarColumn<Double> src(table_, "INTERVAL");207 230 Double intval; 208 src.get(whichRow, intval);231 integrCol_.get(whichRow, intval); 209 232 return intval; 210 233 } … … 246 269 bool SDMemTable::setMask(std::vector<int> whichChans) 247 270 { 248 ROArrayColumn<uChar> spec(table_, "FLAGTRA");249 271 std::vector<int>::iterator it; 250 uInt n = spec.shape(0)(3);272 uInt n = flagsCol_.shape(0)(3); 251 273 if (whichChans.empty()) { 252 274 chanMask_ = std::vector<bool>(n,true); … … 264 286 std::vector<bool> SDMemTable::getMask(Int whichRow) const { 265 287 std::vector<bool> mask; 266 ROArrayColumn<uChar> spec(table_, "FLAGTRA");267 288 Array<uChar> arr; 268 spec.get(whichRow, arr);289 flagsCol_.get(whichRow, arr); 269 290 ArrayAccessor<uChar, Axis<asap::BeamAxis> > aa0(arr); 270 291 aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam … … 294 315 { 295 316 std::vector<float> spectrum; 296 ROArrayColumn<Float> spec(table_, "SPECTRA");297 317 Array<Float> arr; 298 spec .get(whichRow, arr);318 specCol_.get(whichRow, arr); 299 319 ArrayAccessor<Float, Axis<asap::BeamAxis> > aa0(arr); 300 320 aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam … … 412 432 // Continue with km/s or Hz. Get FreqID 413 433 414 ROArrayColumn<uInt> fid(table_, "FREQID");415 434 Vector<uInt> v; 416 f id.get(whichRow, v);435 freqidCol_.get(whichRow, v); 417 436 uInt specidx = v(IFSel_); 418 437 … … 455 474 std::string SDMemTable::getAbcissaString(Int whichRow) const 456 475 { 457 ROArrayColumn<uInt> fid(table_, "FREQID");458 476 Table t = table_.keywordSet().asTable("FREQUENCIES"); 459 477 // … … 464 482 // 465 483 Vector<uInt> v; 466 f id.get(whichRow, v);484 freqidCol_.get(whichRow, v); 467 485 uInt specidx = v(IFSel_); 468 486 … … 485 503 void SDMemTable::setSpectrum(std::vector<float> spectrum, int whichRow) 486 504 { 487 ArrayColumn<Float> spec(table_, "SPECTRA");488 505 Array<Float> arr; 489 spec .get(whichRow, arr);506 specCol_.get(whichRow, arr); 490 507 if (spectrum.size() != arr.shape()(3)) { 491 508 throw(AipsError("Attempting to set spectrum with incorrect length.")); … … 504 521 it++; 505 522 } 506 spec .put(whichRow, arr);523 specCol_.put(whichRow, arr); 507 524 } 508 525 509 526 void SDMemTable::getSpectrum(Vector<Float>& spectrum, Int whichRow) const 510 527 { 511 ROArrayColumn<Float> spec(table_, "SPECTRA");512 528 Array<Float> arr; 513 spec .get(whichRow, arr);529 specCol_.get(whichRow, arr); 514 530 spectrum.resize(arr.shape()(3)); 515 531 ArrayAccessor<Float, Axis<asap::BeamAxis> > aa0(arr); … … 528 544 /* 529 545 void SDMemTable::getMask(Vector<Bool>& mask, Int whichRow) const { 530 ROArrayColumn<uChar> spec(table_, "FLAGTRA");531 546 Array<uChar> arr; 532 spec.get(whichRow, arr);547 flagsCol_.get(whichRow, arr); 533 548 mask.resize(arr.shape()(3)); 534 549 … … 563 578 Bool useSelection) const 564 579 { 565 ROArrayColumn<Float> spec(table_, "SPECTRA");566 580 Array<Float> arr; 567 ROArrayColumn<uChar> flag(table_, "FLAGTRA");568 581 Array<uChar> farr; 569 spec .get(whichRow, arr);570 flag .get(whichRow, farr);582 specCol_.get(whichRow, arr); 583 flagsCol_.get(whichRow, farr); 571 584 Array<Bool> barr(farr.shape());convertArray(barr, farr); 572 585 MaskedArray<Float> marr; … … 609 622 Float SDMemTable::getTsys(Int whichRow) const 610 623 { 611 ROArrayColumn<Float> ts(table_, "TSYS");612 624 Array<Float> arr; 613 ts .get(whichRow, arr);625 tsCol_.get(whichRow, arr); 614 626 Float out; 615 627 IPosition ip(arr.shape()); … … 622 634 { 623 635 MDirection::Types mdr = getDirectionReference(); 624 ROArrayColumn<Double> dir(table_, "DIRECTION");625 636 Array<Double> posit; 626 dir .get(whichRow,posit);637 dirCol_.get(whichRow,posit); 627 638 Vector<Double> wpos(2); 628 639 wpos[0] = posit(IPosition(2,beamSel_,0)); … … 637 648 MEpoch::Types met = getTimeReference(); 638 649 // 639 ROScalarColumn<Double> tme(table_, "TIME");640 650 Double obstime; 641 t me.get(whichRow,obstime);651 timeCol_.get(whichRow,obstime); 642 652 MVEpoch tm2(Quantum<Double>(obstime, Unit(String("d")))); 643 653 return MEpoch(tm2, met); … … 878 888 bool SDMemTable::putSDContainer(const SDContainer& sdc) 879 889 { 880 ScalarColumn<Double> mjd(table_, "TIME");881 ScalarColumn<String> srcn(table_, "SRCNAME");882 ScalarColumn<String> fldn(table_, "FIELDNAME");883 ArrayColumn<Float> spec(table_, "SPECTRA");884 ArrayColumn<uChar> flags(table_, "FLAGTRA");885 ArrayColumn<Float> ts(table_, "TSYS");886 ScalarColumn<Int> scan(table_, "SCANID");887 ScalarColumn<Double> integr(table_, "INTERVAL");888 ArrayColumn<uInt> freqid(table_, "FREQID");889 ArrayColumn<Double> dir(table_, "DIRECTION");890 ScalarColumn<Int> rbeam(table_, "REFBEAM");891 ArrayColumn<Float> tcal(table_, "TCAL");892 ScalarColumn<String> tcalt(table_, "TCALTIME");893 ScalarColumn<Float> az(table_, "AZIMUTH");894 ScalarColumn<Float> el(table_, "ELEVATION");895 ScalarColumn<Float> para(table_, "PARANGLE");896 ArrayColumn<String> hist(table_, "HISTORY");897 898 890 uInt rno = table_.nrow(); 899 891 table_.addRow(); 900 892 901 mjd.put(rno, sdc.timestamp); 902 srcn.put(rno, sdc.sourcename); 903 fldn.put(rno, sdc.fieldname); 904 spec.put(rno, sdc.getSpectrum()); 905 flags.put(rno, sdc.getFlags()); 906 ts.put(rno, sdc.getTsys()); 907 scan.put(rno, sdc.scanid); 908 integr.put(rno, sdc.interval); 909 freqid.put(rno, sdc.getFreqMap()); 910 dir.put(rno, sdc.getDirection()); 911 rbeam.put(rno, sdc.refbeam); 912 tcal.put(rno, sdc.tcal); 913 tcalt.put(rno, sdc.tcaltime); 914 az.put(rno, sdc.azimuth); 915 el.put(rno, sdc.elevation); 916 para.put(rno, sdc.parangle); 917 hist.put(rno, sdc.getHistory()); 893 // mjd.put(rno, sdc.timestamp); 894 timeCol_.put(rno, sdc.timestamp); 895 srcnCol_.put(rno, sdc.sourcename); 896 fldnCol_.put(rno, sdc.fieldname); 897 specCol_.put(rno, sdc.getSpectrum()); 898 flagsCol_.put(rno, sdc.getFlags()); 899 tsCol_.put(rno, sdc.getTsys()); 900 scanCol_.put(rno, sdc.scanid); 901 integrCol_.put(rno, sdc.interval); 902 freqidCol_.put(rno, sdc.getFreqMap()); 903 dirCol_.put(rno, sdc.getDirection()); 904 rbeamCol_.put(rno, sdc.refbeam); 905 tcalCol_.put(rno, sdc.tcal); 906 tcaltCol_.put(rno, sdc.tcaltime); 907 azCol_.put(rno, sdc.azimuth); 908 elCol_.put(rno, sdc.elevation); 909 paraCol_.put(rno, sdc.parangle); 910 histCol_.put(rno, sdc.getHistory()); 918 911 919 912 return true; … … 922 915 SDContainer SDMemTable::getSDContainer(uInt whichRow) const 923 916 { 924 ROScalarColumn<Double> mjd(table_, "TIME");925 ROScalarColumn<String> srcn(table_, "SRCNAME");926 ROScalarColumn<String> fldn(table_, "FIELDNAME");927 ROArrayColumn<Float> spec(table_, "SPECTRA");928 ROArrayColumn<uChar> flags(table_, "FLAGTRA");929 ROArrayColumn<Float> ts(table_, "TSYS");930 ROScalarColumn<Int> scan(table_, "SCANID");931 ROScalarColumn<Double> integr(table_, "INTERVAL");932 ROArrayColumn<uInt> freqid(table_, "FREQID");933 ROArrayColumn<Double> dir(table_, "DIRECTION");934 ROScalarColumn<Int> rbeam(table_, "REFBEAM");935 ROArrayColumn<Float> tcal(table_, "TCAL");936 ROScalarColumn<String> tcalt(table_, "TCALTIME");937 ROScalarColumn<Float> az(table_, "AZIMUTH");938 ROScalarColumn<Float> el(table_, "ELEVATION");939 ROScalarColumn<Float> para(table_, "PARANGLE");940 ROArrayColumn<String> hist(table_, "HISTORY");941 942 917 SDContainer sdc(nBeam(),nIF(),nPol(),nChan()); 943 mjd.get(whichRow, sdc.timestamp);944 srcn .get(whichRow, sdc.sourcename);945 integr .get(whichRow, sdc.interval);946 scan .get(whichRow, sdc.scanid);947 fldn .get(whichRow, sdc.fieldname);948 rbeam .get(whichRow, sdc.refbeam);949 az .get(whichRow, sdc.azimuth);950 el .get(whichRow, sdc.elevation);951 para .get(whichRow, sdc.parangle);918 timeCol_.get(whichRow, sdc.timestamp); 919 srcnCol_.get(whichRow, sdc.sourcename); 920 integrCol_.get(whichRow, sdc.interval); 921 scanCol_.get(whichRow, sdc.scanid); 922 fldnCol_.get(whichRow, sdc.fieldname); 923 rbeamCol_.get(whichRow, sdc.refbeam); 924 azCol_.get(whichRow, sdc.azimuth); 925 elCol_.get(whichRow, sdc.elevation); 926 paraCol_.get(whichRow, sdc.parangle); 952 927 Vector<Float> tc; 953 tcal .get(whichRow, tc);928 tcalCol_.get(whichRow, tc); 954 929 sdc.tcal[0] = tc[0];sdc.tcal[1] = tc[1]; 955 tcalt .get(whichRow, sdc.tcaltime);930 tcaltCol_.get(whichRow, sdc.tcaltime); 956 931 Array<Float> spectrum; 957 932 Array<Float> tsys; … … 960 935 Array<Double> direction; 961 936 Vector<String> histo; 962 spec .get(whichRow, spectrum);937 specCol_.get(whichRow, spectrum); 963 938 sdc.putSpectrum(spectrum); 964 flags .get(whichRow, flagtrum);939 flagsCol_.get(whichRow, flagtrum); 965 940 sdc.putFlags(flagtrum); 966 ts .get(whichRow, tsys);941 tsCol_.get(whichRow, tsys); 967 942 sdc.putTsys(tsys); 968 freqid .get(whichRow, fmap);943 freqidCol_.get(whichRow, fmap); 969 944 sdc.putFreqMap(fmap); 970 dir .get(whichRow, direction);945 dirCol_.get(whichRow, direction); 971 946 sdc.putDirection(direction); 972 hist .get(whichRow, histo);947 histCol_.get(whichRow, histo); 973 948 sdc.putHistory(histo); 974 949 return sdc; … … 1024 999 Int SDMemTable::nScan() const { 1025 1000 Int n = 0; 1026 ROScalarColumn<Int> scans(table_, "SCANID");1027 1001 Int previous = -1;Int current=0; 1028 for (uInt i=0; i< scan s.nrow();i++) {1029 scan s.getScalar(i,current);1002 for (uInt i=0; i< scanCol_.nrow();i++) { 1003 scanCol_.getScalar(i,current); 1030 1004 if (previous != current) { 1031 1005 previous = current; … … 1096 1070 1097 1071 std::string SDMemTable::summary() const { 1098 ROScalarColumn<Int> scans(table_, "SCANID");1099 ROScalarColumn<String> srcs(table_, "SRCNAME");1100 1072 1101 1073 // get number of integrations per scan … … 1104 1076 int scount = 0; 1105 1077 std::vector<int> cycles; 1106 for (uInt i=0; i<scan s.nrow();++i) {1107 while (idx == cIdx && i<scan s.nrow()) {1108 scan s.getScalar(++i,cIdx);1078 for (uInt i=0; i<scanCol_.nrow();++i) { 1079 while (idx == cIdx && i<scanCol_.nrow()) { 1080 scanCol_.getScalar(++i,cIdx); 1109 1081 ++scount; 1110 1082 } … … 1167 1139 1168 1140 std::vector<int>::iterator it = cycles.begin(); 1169 for (uInt i=0; i< scan s.nrow();i++) {1170 scan s.getScalar(i,current);1141 for (uInt i=0; i< scanCol_.nrow();i++) { 1142 scanCol_.getScalar(i,current); 1171 1143 if (previous != current) { 1172 src s.getScalar(i,name);1144 srcnCol_.getScalar(i,name); 1173 1145 previous = current; 1174 1146 String t = formatSec(Double(getInterval(i))); … … 1231 1203 bool SDMemTable::appendHistory(const std::string& hist, int whichRow) 1232 1204 { 1233 ArrayColumn<String> histo(table_, "HISTORY");1234 1205 Vector<String> history; 1235 hist o.get(whichRow, history);1206 histCol_.get(whichRow, history); 1236 1207 history.resize(history.nelements()+1,True); 1237 1208 history[history.nelements()-1] = hist; 1238 hist o.put(whichRow, history);1209 histCol_.put(whichRow, history); 1239 1210 } 1240 1211 1241 1212 std::vector<std::string> SDMemTable::history(int whichRow) const 1242 1213 { 1243 ROArrayColumn<String> hist(table_, "HISTORY");1244 1214 Vector<String> history; 1245 hist .get(whichRow, history);1215 histCol_.get(whichRow, history); 1246 1216 std::vector<std::string> stlout; 1247 1217 // there is no Array<String>.tovector(std::vector<std::string>), so … … 1273 1243 void SDMemTable::flag(int whichRow) 1274 1244 { 1275 ArrayColumn<uChar> spec(table_, "FLAGTRA");1276 1245 Array<uChar> arr; 1277 spec.get(whichRow, arr);1246 flagsCol_.get(whichRow, arr); 1278 1247 1279 1248 ArrayAccessor<uChar, Axis<asap::BeamAxis> > aa0(arr); … … 1288 1257 } 1289 1258 1290 spec.put(whichRow, arr);1259 flagsCol_.put(whichRow, arr); 1291 1260 } 1292 1261 -
trunk/src/SDMemTable.h
r306 r322 37 37 // AIPS++ 38 38 #include <casa/aips.h> 39 #include <casa/Arrays/MaskedArray.h> 39 40 #include <casa/BasicSL/String.h> 41 #include <coordinates/Coordinates/SpectralCoordinate.h> 40 42 #include <tables/Tables/Table.h> 41 #include <casa/Arrays/MaskedArray.h> 43 #include <tables/Tables/ArrayColumn.h> 44 #include <tables/Tables/ScalarColumn.h> 45 42 46 #include "SDDefs.h" 43 47 44 #include <coordinates/Coordinates/SpectralCoordinate.h> 48 45 49 46 50 namespace asap { … … 49 53 class SDHeader; 50 54 class SDFrequencyTable; 55 56 51 57 52 58 … … 210 216 casa::String formatDirection(const casa::MDirection& md) const; 211 217 void setup(); 218 void attach(); 212 219 // the current cursor into the array 213 220 casa::Int IFSel_,beamSel_,polSel_; … … 215 222 // the underlying memory table 216 223 casa::Table table_; 224 225 // Cached Columns to avoid reconstructing them for each row get/put 226 casa::ScalarColumn<casa::Double> timeCol_, integrCol_; 227 casa::ScalarColumn<casa::Float> azCol_, elCol_, paraCol_; 228 casa::ScalarColumn<casa::String> srcnCol_, fldnCol_, tcaltCol_; 229 casa::ScalarColumn<casa::Int> scanCol_, rbeamCol_; 230 casa::ArrayColumn<casa::Float> specCol_, tsCol_, tcalCol_; 231 casa::ArrayColumn<casa::Double> dirCol_; 232 casa::ArrayColumn<casa::uChar> flagsCol_; 233 casa::ArrayColumn<casa::uInt> freqidCol_; 234 casa::ArrayColumn<casa::String> histCol_; 217 235 }; 218 236
Note:
See TracChangeset
for help on using the changeset viewer.