- Timestamp:
- 07/05/04 18:09:31 (20 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDMemTable.cc
r18 r21 206 206 return mask; 207 207 } 208 std::vector<float> SDMemTable::getSpectrum(Int whichRow) const{208 std::vector<float> SDMemTable::getSpectrum(Int whichRow) { 209 209 210 210 std::vector<float> spectrum; … … 222 222 } 223 223 return spectrum; 224 } 225 void SDMemTable::getSpectrum(Vector<Float>& spectrum, Int whichRow=0) { 226 ROArrayColumn<Float> spec(table_, "SPECTRA"); 227 Array<Float> arr; 228 spec.get(whichRow, arr); 229 spectrum.resize(arr.shape()(3)); 230 ArrayAccessor<Float, Axis<0> > aa0(arr); 231 aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam 232 ArrayAccessor<Float, Axis<1> > aa1(aa0); 233 aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF 234 ArrayAccessor<Float, Axis<2> > aa2(aa1); 235 aa2.reset(aa2.begin(uInt(polSel_)));// go to pol 236 237 ArrayAccessor<Float, Axis<0> > va(spectrum); 238 for (ArrayAccessor<Float, Axis<3> > i(aa2); i != i.end(); ++i) { 239 (*va) = (*i); 240 va++; 241 } 242 } 243 244 void SDMemTable::getMask(Vector<Bool>& mask, Int whichRow=0) const { 245 ROArrayColumn<uChar> spec(table_, "FLAGTRA"); 246 Array<uChar> arr; 247 spec.get(whichRow, arr); 248 mask.resize(arr.shape()(3)); 249 250 ArrayAccessor<uChar, Axis<0> > aa0(arr); 251 aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam 252 ArrayAccessor<uChar, Axis<1> > aa1(aa0); 253 aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF 254 ArrayAccessor<uChar, Axis<2> > aa2(aa1); 255 aa2.reset(aa2.begin(uInt(polSel_)));// go to pol 256 257 Bool useUserMask = ( chanMask_.size() == arr.shape()(3) ); 258 259 ArrayAccessor<Bool, Axis<0> > va(mask); 260 std::vector<bool> tmp; 261 tmp = chanMask_; // WHY the fxxx do I have to make a copy here. The 262 // iterator should work on chanMask_?? 263 std::vector<bool>::iterator miter; 264 miter = tmp.begin(); 265 266 for (ArrayAccessor<uChar, Axis<3> > i(aa2); i != i.end(); ++i) { 267 bool out =!static_cast<bool>(*i); 268 if (useUserMask) { 269 out = out && (*miter); 270 miter++; 271 } 272 (*va) = out; 273 va++; 274 } 224 275 } 225 276 … … 303 354 } 304 355 356 SDContainer SDMemTable::getSDContainer(uInt whichRow) const { 357 ROScalarColumn<Double> mjd(table_, "TIME"); 358 ROScalarColumn<String> srcn(table_, "SRCNAME"); 359 ROArrayColumn<Float> spec(table_, "SPECTRA"); 360 ROArrayColumn<uChar> flags(table_, "FLAGTRA"); 361 ROArrayColumn<Float> ts(table_, "TSYS"); 362 ROScalarColumn<Int> scan(table_, "SCANID"); 363 ROScalarColumn<Double> integr(table_, "INTERVAL"); 364 365 SDContainer sdc(nBeam(),nIF(),nPol(),nChan()); 366 mjd.get(whichRow, sdc.timestamp); 367 srcn.get(whichRow, sdc.sourcename); 368 integr.get(whichRow, sdc.interval); 369 scan.get(whichRow, sdc.scanid); 370 Array<Float> spectrum; 371 Array<Float> tsys; 372 Array<uChar> flagtrum; 373 spec.get(whichRow, spectrum); 374 sdc.putSpectrum(spectrum); 375 flags.get(whichRow, flagtrum); 376 sdc.putFlags(flagtrum); 377 ts.get(whichRow, tsys); 378 sdc.putTsys(tsys); 379 return sdc; 380 } 305 381 bool SDMemTable::putSDHeader(const SDHeader& sdh) { 306 382 table_.lock(); … … 322 398 cerr << "Table Header set" << endl; 323 399 return true; 324 } 325 400 }\ 401 402 SDHeader SDMemTable::getSDHeader() const { 403 SDHeader sdh; 404 table_.keywordSet().get("nBeam",sdh.nbeam); 405 table_.keywordSet().get("nIF",sdh.nif); 406 table_.keywordSet().get("nPol",sdh.npol); 407 table_.keywordSet().get("nChan",sdh.nchan); 408 table_.keywordSet().get("Observer", sdh.observer); 409 table_.keywordSet().get("Project", sdh.project); 410 table_.keywordSet().get("Obstype", sdh.obstype); 411 table_.keywordSet().get("AntennaName", sdh.antennaname); 412 table_.keywordSet().get("AntennaPosition", sdh.antennaposition); 413 table_.keywordSet().get("Equinox", sdh.equinox); 414 table_.keywordSet().get("FreqRefFrame", sdh.freqref); 415 table_.keywordSet().get("FreqRefVal", sdh.reffreq); 416 table_.keywordSet().get("Bandwidth", sdh.bandwidth); 417 table_.keywordSet().get("UTC", sdh.utc); 418 return sdh; 419 } 326 420 void SDMemTable::makePersistent(const std::string& filename) { 327 421 table_.deepCopy(filename,Table::New); … … 376 470 return n; 377 471 } 378 379 472 /* 380 473 void SDMemTable::maskChannels(const std::vector<Int>& whichChans ) { -
trunk/src/SDMemTable.h
r19 r21 69 69 virtual bool putSDHeader(const SDHeader& sdh); 70 70 virtual bool putSDFreqTable(const SDFrequencyTable& sdft) {;} 71 72 //get the dat wrapped up in a meta container 73 virtual SDContainer getSDContainer(uInt whichRow=0) const; 74 virtual SDHeader getSDHeader() const; 71 75 72 76 // get spectrum,mask and tsys for the given row, at the selected 73 // cursor 74 virtual std::vector<float> getSpectrum(Int whichRow) const;77 // cursor - all as stl vectors 78 virtual std::vector<float> getSpectrum(Int whichRow); 75 79 virtual std::vector<bool> getMask(Int whichRow) const; 80 76 81 virtual Float getTsys(Int whichRow) const; 82 // get all as aips++ Vectors 83 virtual void getSpectrum(Vector<Float>& spectrum, Int whichRow=0); 84 virtual void getMask(Vector<Bool>& mask,Int whichRow=0) const; 77 85 78 // get info f rocurrent row86 // get info for current row 79 87 virtual Double getTime(Int whichRow) const ; 80 88 virtual std::string getSourceName(Int whichRow) const; … … 104 112 SDMemTable getScan(Int scanID); 105 113 106 const TableRecord& getHeader() const { ;}114 const TableRecord& getHeader() const {return table_.keywordSet();} 107 115 // get a handle to the "raw" aips++ table 108 116 const Table& table() { return table_; }
Note:
See TracChangeset
for help on using the changeset viewer.