Changeset 16 for trunk/src/SDMemTable.cc
- Timestamp:
- 06/30/04 11:00:23 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDMemTable.cc
r8 r16 30 30 //#--------------------------------------------------------------------------- 31 31 32 32 33 #include <aips/iostream.h> 33 34 #include <aips/Arrays/Array.h> … … 60 61 } 61 62 62 SDMemTable::SDMemTable(const SDMemTable& other ) {63 SDMemTable::SDMemTable(const SDMemTable& other, Bool clear) { 63 64 this->IFSel_= other.IFSel_; 64 65 this->beamSel_= other.beamSel_; … … 68 69 this->table_ = other.table_.copyToMemoryTable(String("dummy")); 69 70 // clear all rows() 70 this->table_.removeRow(this->table_.rowNumbers()); 71 if (clear) { 72 this->table_.removeRow(this->table_.rowNumbers()); 73 } else { 74 this->IFSel_ = other.IFSel_; 75 this->beamSel_ = other.beamSel_; 76 this->polSel_ = other.polSel_; 77 } 71 78 } 72 79 … … 101 108 td.addColumn(ArrayColumnDesc<Float>("TSYS")); 102 109 td.addColumn(ScalarColumnDesc<Int>("SCANID")); 110 td.addColumn(ScalarColumnDesc<Double>("INTERVAL")); 103 111 // Now create a new table from the description. 104 112 SetupNewTable aNewTab(name_, td, Table::New); … … 147 155 } 148 156 149 bool SDMemTable::setChannels(const std::vector<int>& whichChans) { 150 //std::vector<bool>::iterator it; 151 //std::fill(chanMask_.begin(), chanMask_.end(), false); 152 //for (it = whichChans.begin(); it != whichChans.end(); it++) { 153 //chanMask_[*it] = true; 154 //} 155 cout << "SDMemTable::setChannels() disabled" << endl; 157 bool SDMemTable::setMask(const std::vector<int>& whichChans) { 158 ROArrayColumn<uChar> spec(table_, "FLAGTRA"); 159 160 std::vector<int>::iterator it; 161 uInt n = spec.shape(0)(3); 162 chanMask_.resize(n,true); 163 for (it = whichChans.begin(); it != whichChans.end(); it++) { 164 if (*it < n) 165 chanMask_[*it] = false; 166 } 156 167 return true; 157 168 } 158 169 159 std::vector<bool> SDMemTable::getMask() const { 160 return chanMask_; 170 std::vector<bool> SDMemTable::getMask(Int whichRow) const { 171 std::vector<bool> mask; 172 ROArrayColumn<uChar> spec(table_, "FLAGTRA"); 173 Array<uChar> arr; 174 spec.get(whichRow, arr); 175 ArrayAccessor<uChar, Axis<0> > aa0(arr); 176 aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam 177 ArrayAccessor<uChar, Axis<1> > aa1(aa0); 178 aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF 179 ArrayAccessor<uChar, Axis<2> > aa2(aa1); 180 aa2.reset(aa2.begin(uInt(polSel_)));// go to pol 181 182 Bool useUserMask = ( chanMask_.size() == arr.shape()(3) ); 183 184 std::vector<bool> tmp; 185 tmp = chanMask_; // WHY the fxxx do I have to make a copy here 186 std::vector<bool>::iterator miter; 187 miter = tmp.begin(); 188 189 for (ArrayAccessor<uChar, Axis<3> > i(aa2); i != i.end(); ++i) { 190 bool out =!static_cast<bool>(*i); 191 if (useUserMask) { 192 out = out && (*miter); 193 miter++; 194 } 195 mask.push_back(out); 196 } 197 return mask; 161 198 } 162 199 std::vector<float> SDMemTable::getSpectrum(Int whichRow) const { … … 170 207 ArrayAccessor<Float, Axis<1> > aa1(aa0); 171 208 aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF 172 for (ArrayAccessor<Float, Axis<2> > i(aa1); i != i.end(); ++i) {173 ArrayAccessor<Float, Axis<3> > aa2(i);174 aa2.reset(aa2.begin(uInt(polSel_)));// go to pol175 spectrum.push_back(* aa2);209 ArrayAccessor<Float, Axis<2> > aa2(aa1); 210 aa2.reset(aa2.begin(uInt(polSel_)));// go to pol 211 for (ArrayAccessor<Float, Axis<3> > i(aa2); i != i.end(); ++i) { 212 spectrum.push_back(*i); 176 213 } 177 214 return spectrum; 178 215 } 179 216 180 MaskedArray<Float> SDMemTable::rowAsMaskedArray(uInt whichRow) { 217 MaskedArray<Float> SDMemTable::rowAsMaskedArray(uInt whichRow, 218 Bool useSelection) { 181 219 ROArrayColumn<Float> spec(table_, "SPECTRA"); 182 220 Array<Float> arr; … … 185 223 spec.get(whichRow, arr); 186 224 flag.get(whichRow, farr); 187 IPosition test(4,0,0,100,0);188 225 Array<Bool> barr(farr.shape());convertArray(barr, farr); 189 226 MaskedArray<Float> marr; 190 marr.setData(arr,!barr); 227 if (useSelection) { 228 ArrayAccessor<Float, Axis<0> > aa0(arr); 229 aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam 230 ArrayAccessor<Float, Axis<1> > aa1(aa0); 231 aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF 232 ArrayAccessor<Float, Axis<2> > aa2(aa1); 233 aa2.reset(aa2.begin(uInt(polSel_)));// go to pol 234 235 ArrayAccessor<Bool, Axis<0> > baa0(barr); 236 baa0.reset(baa0.begin(uInt(beamSel_)));//go to beam 237 ArrayAccessor<Bool, Axis<1> > baa1(baa0); 238 baa1.reset(baa1.begin(uInt(IFSel_)));// go to IF 239 ArrayAccessor<Bool, Axis<2> > baa2(baa1); 240 baa2.reset(baa2.begin(uInt(polSel_)));// go to pol 241 242 Vector<Float> a(arr.shape()(3)); 243 Vector<Bool> b(barr.shape()(3)); 244 ArrayAccessor<Float, Axis<0> > a0(a); 245 ArrayAccessor<Bool, Axis<0> > b0(b); 246 247 ArrayAccessor<Bool, Axis<3> > j(baa2); 248 for (ArrayAccessor<Float, Axis<3> > i(aa2); i != i.end(); ++i) { 249 (*a0) = (*i); 250 (*b0) = !(*j); 251 j++; 252 a0++; 253 b0++; 254 } 255 marr.setData(a,b); 256 } else { 257 marr.setData(arr,!barr); 258 } 191 259 return marr; 192 260 } 193 194 261 195 262 Float SDMemTable::getTsys(Int whichRow) const { … … 199 266 Float out; 200 267 IPosition ip(arr.shape()); 201 ip(0) = beamSel_;ip(1) = IFSel_;ip(2) =0;ip(3) = polSel_;268 ip(0) = beamSel_;ip(1) = IFSel_;ip(2) = polSel_;ip(3)=0; 202 269 out = arr(ip); 203 270 return out; … … 211 278 ArrayColumn<Float> ts(table_, "TSYS"); 212 279 ScalarColumn<Int> scan(table_, "SCANID"); 280 ScalarColumn<Double> integr(table_, "INTERVAL"); 213 281 214 282 uInt rno = table_.nrow(); … … 221 289 ts.put(rno, sdc.getTsys()); 222 290 scan.put(rno, sdc.scanid); 291 integr.put(rno, sdc.interval); 292 223 293 return true; 224 294 } … … 241 311 previous = current; 242 312 count++; 243 cout << count << "\t" << name << endl; 313 cout << count << "\t" 314 << name 315 << endl; 244 316 } 245 317 } … … 247 319 cout << "in " << count << "scans." << endl; 248 320 } 249 321 /* 322 void maskChannels(const std::vector<Int>& whichChans ) { 323 324 std::vector<int>::iterator it; 325 ArrayAccessor<uChar, Axis<2> > j(flags_); 326 for (it = whichChans.begin(); it != whichChans.end(); it++) { 327 j.reset(j.begin(uInt(*it))); 328 for (ArrayAccessor<uChar, Axis<0> > i(j); i != i.end(); ++i) { 329 for (ArrayAccessor<uChar, Axis<1> > ii(i); ii != ii.end(); ++ii) { 330 for (ArrayAccessor<uChar, Axis<3> > iii(ii); 331 iii != iii.end(); ++iii) { 332 (*iii) = 333 } 334 } 335 } 336 } 337 338 } 339 */
Note: See TracChangeset
for help on using the changeset viewer.