- Timestamp:
- 06/30/04 11:00:23 (20 years ago)
- Location:
- trunk/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDContainer.cc
r14 r16 38 38 using namespace atnf_sd; 39 39 40 SDContainer::SDContainer(uInt nBeam, uInt nIF, uInt n Chan, uInt nPol)40 SDContainer::SDContainer(uInt nBeam, uInt nIF, uInt nPol, uInt nChan) 41 41 : nBeam_(nBeam), 42 nIF_(nIF), 43 nChan_(nChan), 44 nPol_(nPol), 45 spectrum_(IPosition(4,nBeam,nIF,nChan,nPol)), 46 flags_(IPosition(4,nBeam,nIF,nChan,nPol)), 47 tsys_(IPosition(4,nBeam,nIF,nChan,nPol)) { 42 nIF_(nIF), 43 nPol_(nPol), 44 nChan_(nChan), 45 spectrum_(IPosition(4,nBeam,nIF,nPol,nChan)), 46 flags_(IPosition(4,nBeam,nIF,nPol,nChan)), 47 tsys_(IPosition(4,nBeam,nIF,nPol,nChan)) { 48 uChar x = 0; 49 flags_ = ~x; 50 } 51 52 SDContainer::SDContainer(IPosition shp) 53 : nBeam_(shp(0)), 54 nIF_(shp(1)), 55 nPol_(shp(2)), 56 nChan_(shp(3)), 57 spectrum_(shp), 58 flags_(shp), 59 tsys_(shp) { 48 60 uChar x = 0; 49 61 flags_ = ~x; … … 72 84 73 85 //Vector<Float> pols(nPol); 74 ArrayAccessor<Float, Axis< 0> > j(spec);86 ArrayAccessor<Float, Axis<1> > j(spec); 75 87 IPosition shp0 = spectrum_.shape(); 76 88 IPosition shp1 = spec.shape(); 77 if ( (shp0(2) != shp1( 0)) || (shp0(3) != shp1(1)) ) {89 if ( (shp0(2) != shp1(1)) || (shp0(3) != shp1(0)) ) { 78 90 cerr << "Arrays not conformant" << endl; 79 91 return False; 80 92 } 81 //uInt chani = 0;82 //uInt poli = 0;83 93 // assert dimensions are the same.... 84 94 for (ArrayAccessor<Float, Axis<2> > i(aa1);i != i.end(); ++i) { 85 //pols = spec.row(chani); 86 ArrayAccessor<Float, Axis<1> > jj(j); 95 ArrayAccessor<Float, Axis<0> > jj(j); 87 96 for (ArrayAccessor<Float, Axis<3> > ii(i);ii != ii.end(); ++ii) { 88 //(*ii) = pols[poli];89 97 (*ii) = (*jj); 90 //poli++;91 98 jj++; 92 99 } 93 //poli = 0;94 //chani++;95 100 j++; 96 101 } … … 113 118 aa1.reset(aa1.begin(whichIF)); 114 119 115 ArrayAccessor<uChar, Axis< 0> > j(flag);120 ArrayAccessor<uChar, Axis<1> > j(flag); 116 121 IPosition shp0 = flags_.shape(); 117 122 IPosition shp1 = flag.shape(); 118 if ( (shp0(2) != shp1( 0)) || (shp0(3) != shp1(1)) ) {123 if ( (shp0(2) != shp1(1)) || (shp0(3) != shp1(0)) ) { 119 124 cerr << "Arrays not conformant" << endl; 120 125 return False; … … 123 128 // assert dimensions are the same.... 124 129 for (ArrayAccessor<uChar, Axis<2> > i(aa1);i != i.end(); ++i) { 125 ArrayAccessor<uChar, Axis< 1> > jj(j);130 ArrayAccessor<uChar, Axis<0> > jj(j); 126 131 for (ArrayAccessor<uChar, Axis<3> > ii(i);ii != ii.end(); ++ii) { 127 132 (*ii) = (*jj); … … 130 135 j++; 131 136 } 137 return True; 132 138 } 133 139 … … 139 145 aa1.reset(aa1.begin(whichIF)); 140 146 // assert dimensions are the same.... 141 uInt idx = 0; 142 143 144 for (ArrayAccessor<Float, Axis<2> > i(aa1);i != i.end(); ++i) { 145 idx = 0; 147 for (ArrayAccessor<Float, Axis<3> > i(aa1);i != i.end(); ++i) { 146 148 ArrayAccessor<Float, Axis<0> > j(tsys); 147 for (ArrayAccessor<Float, Axis< 3> > ii(i);ii != ii.end(); ++ii) {149 for (ArrayAccessor<Float, Axis<2> > ii(i);ii != ii.end(); ++ii) { 148 150 (*ii) = (*j); 149 151 j++; -
trunk/src/SDContainer.h
r7 r16 64 64 65 65 public: 66 SDContainer(uInt nBeam, uInt nIF, uInt nChan, uInt nPol); 66 SDContainer(uInt nBeam, uInt nIF, uInt nPol, uInt nChan); 67 SDContainer(IPosition shp); 67 68 68 69 virtual ~SDContainer(); … … 94 95 95 96 private: 96 uInt nBeam_,nIF_,n Chan_,nPol_;97 uInt nBeam_,nIF_,nPol_,nChan_; 97 98 98 // (nBeam,nIF,n Channel,nPol)99 // (nBeam,nIF,nPol,nChannel) 99 100 Array<Float> spectrum_; 100 101 Array<uChar> flags_; 101 // (nBeam,nIF, [nChannel],nPol) Tsys is not really a function of102 // (nBeam,nIF,nPol,[nChannel]) Tsys is not really a function of 102 103 // channel, but this makes it easier to work with at the expense of 103 104 // a little memory -
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 */ -
trunk/src/SDMemTable.h
r2 r16 51 51 public: 52 52 SDMemTable(const std::string& name= "SDInputTable.tbl"); 53 SDMemTable(const SDMemTable& other );53 SDMemTable(const SDMemTable& other, Bool clear=False); 54 54 55 55 SDMemTable(const Table& tab, Int scanID); … … 60 60 61 61 virtual std::vector<float> getSpectrum(Int whichRow) const; 62 virtual std::vector<bool> getMask( ) const;62 virtual std::vector<bool> getMask(Int whichRow) const; 63 63 64 MaskedArray<Float> rowAsMaskedArray(uInt whichRow); 64 MaskedArray<Float> rowAsMaskedArray(uInt whichRow, 65 Bool useSelection = False); 65 66 66 67 virtual Float getTsys(Int whichRow) const; … … 77 78 78 79 //sets the mask 79 virtual bool set Channels(const std::vector<int>& whichChans);80 virtual bool setMask(const std::vector<int>& whichChans); 80 81 81 82 virtual void summary() const; -
trunk/src/SDMemTableWrapper.h
r10 r16 61 61 double getTime(int whichRow) {return table_->getTime(whichRow);} 62 62 63 std::vector<bool> getMask() const { return table_->getMask(); } 63 std::vector<bool> getMask(int whichRow) const { 64 return table_->getMask(whichRow); 65 } 66 bool setMask(const std::vector<int> mvals) const { 67 return table_->setMask(mvals); 68 } 64 69 65 70 std::string getSourceName(int whichRow) { … … 111 116 off.getCP())); 112 117 } 118 SDMemTableWrapper multiply(const SDMemTableWrapper& in, 119 Float factor) { 120 return SDMemTableWrapper(SDMath::multiply(in.getCP(),factor)); 121 } 113 122 }; 114 123 -
trunk/src/SDReader.cc
r14 r16 30 30 //#--------------------------------------------------------------------------- 31 31 #include <atnf/PKSIO/PKSreader.h> 32 32 #include <aips/Quanta/MVTime.h> 33 33 #include "SDContainer.h" 34 34 #include "SDReader.h" 35 35 36 36 using namespace atnf_sd; 37 38 void SDHeader::print() const { 39 MVTime mvt(this->utc); 40 41 cout << "Observer: " << this->observer << endl 42 << "Project: " << this->project << endl 43 << "Obstype: " << this->obstype << endl 44 << "Antenna: " << this->antennaname << endl 45 << "Ant. Position: " << this->antennaposition << endl 46 << "Equinox: " << this->equinox << endl 47 << "Freq. ref.: " << this->freqref << endl 48 << "Ref. frequency: " << this->reffreq << endl 49 << "Bandwidth: " << this->bandwidth << endl 50 << "Time (utc): " 51 << mvt.string() 52 << endl; 53 //setprecision(10) << this->utc << endl; 54 } 55 37 56 38 57 SDReader::SDReader() : … … 85 104 86 105 // Get basic parameters. 87 Double bandwidth, refFreq;88 106 header_ = SDHeader(); 89 107 header_.nchan = nChan_; … … 152 170 while ( (cursor_ <= seq[n-1]) || getAll) { 153 171 // only needs to be create if in seq 154 SDContainer sc(header_.nbeam,header_.nif,header_.n chan,header_.npol);172 SDContainer sc(header_.nbeam,header_.nif,header_.npol,header_.nchan); 155 173 156 174 // iterate over one correlator integration cycle = nBeam*nIF 157 175 for (uInt row=0; row < stepsize; row++) { 158 159 //cerr << "SDReader starting reading process row = " << row << endl;160 161 176 // add scanid from GROUP field -- this will remove the need for 162 177 // stepsize as well … … 171 186 tsys, sigma, calFctr, baseLin, baseSub, 172 187 spectra, flagtra, xCalFctr, xPol); 173 174 // cerr << "SDReader row read"<< endl;175 176 188 if (status) { 177 189 if (status == -1) { … … 183 195 } 184 196 // if in the given list 185 if ( cursor_ == seq[seqi]) { 186 187 //cerr << "SDReader cursor == seq[i]" << endl; 188 197 if (cursor_ == seq[seqi]) { 189 198 // add integration cycle 190 199 if (row==0) { … … 193 202 //focusRot, temperature, pressure, humidity, windSpeed, 194 203 //windAz srcDir, srcPM, srcVel 204 sc.timestamp = mjd; 205 sc.interval = interval; 206 sc.sourcename = srcName; 195 207 } 196 197 // cerr << "SDReader::read - before SDContainer" << endl;198 199 208 // add specific info 200 209 // IFno beamNo are 1-relative 201 // refPix = nChan/2+1 in Integer arith.! 202 203 uInt refPix = header_.nchan/2+1; 210 // refPix = nChan/2+1 in Integer arith.! 211 //uInt refPix = header_.nchan/2+1; 204 212 //uInt frqslot = sdft.addFrequency(refPix, refFreq, freqInc); 205 213 … … 208 216 prevName = srcName;//temp 209 217 }//temp 210 211 sc.sourcename = srcName;212 sc.timestamp = mjd;213 sc.interval = interval;214 218 sc.scanid = scanid; 215 219 //sc.setFrequencyMap(frqslot,IFno-1); … … 218 222 sc.setTsys(tsys, beamNo-1, IFno-1); 219 223 //sc.addPointing(direction, beamNo-1); 220 221 // cerr << "SDReader::read - after SDContainer" << endl;222 223 224 } 224 225 } … … 226 227 // insert container into table/list 227 228 table_->putSDContainer(sc); 228 //cout << "Reading integration " << seqi << endl;229 229 seqi++;// next in list 230 230 } 231 cursor_++; 231 cursor_++;// increment position in file 232 232 } 233 233 return status; -
trunk/src/SDReader.h
r2 r16 63 63 Double bandwidth; 64 64 Double utc; 65 void print() { 66 cout << "Observer: " << this->observer << endl 67 << "Project: " << this->project << endl 68 << "Obstype: " << this->obstype << endl 69 << "Antenna: " << this->antennaname << endl 70 << "Ant. Position: " << this->antennaposition << endl 71 << "Equinox: " << this->equinox << endl 72 << "Freq. ref.: " << this->freqref << endl 73 << "Ref. frequency: " << this->reffreq << endl 74 << "Bandwidth: " << this->bandwidth << endl 75 << "Time (utc): " << setprecision(10) << this->utc << endl; 76 }; 65 void print() const ; 77 66 }; 78 67 … … 100 89 101 90 private: 102 Int nBeam_,nIF_,n Chan_,nPol_;91 Int nBeam_,nIF_,nPol_,nChan_; 103 92 Bool getHeader(); 104 93 PKSreader* reader_; -
trunk/src/SDTemplates.cc
r11 r16 55 55 template LogicalArray operator>=(Array<Float> const &, Float const &); 56 56 template Array<Float>& operator/=(Array<Float>&, MaskedArray<Float> const&); 57 //template Array<Float> const& operator*=(Array<Float> const&, MaskedArray<Float>const&);57 template MaskedArray<Float> const& operator*=(MaskedArray<Float> const&, Float const&); 58 58 template MaskedArray<Float> operator-(MaskedArray<Float> const&, MaskedArray<Float> const&); -
trunk/src/python_SDMemTable.cc
r2 r16 32 32 33 33 #include <boost/python.hpp> 34 34 #include <boost/python/args.hpp> 35 35 #include "SDMemTableWrapper.h" 36 36 … … 46 46 .def("getscan", &SDMemTableWrapper::getScan) 47 47 .def("getspectrum", &SDMemTableWrapper::getSpectrum) 48 //.def("getmask", &SDMemTableWrapper::getMask)48 .def("getmask", &SDMemTableWrapper::getMask) 49 49 .def("gettsys", &SDMemTableWrapper::getTsys) 50 50 .def("getsourcename", &SDMemTableWrapper::getSourceName) … … 53 53 .def("getbeam", &SDMemTableWrapper::getBeam) 54 54 .def("getpol", &SDMemTableWrapper::getPol) 55 .def("setif", &SDMemTableWrapper::setIF) 55 .def("setif", &SDMemTableWrapper::setIF, 56 (boost::python::arg("whichIF")=0) ) 56 57 .def("setbeam", &SDMemTableWrapper::setBeam) 57 58 .def("setpol", &SDMemTableWrapper::setPol) 59 .def("setmask", &SDMemTableWrapper::setMask) 58 60 .def("makepersistent", &SDMemTableWrapper::makePersistent) 59 61 .def("summary", &SDMemTableWrapper::summary)
Note:
See TracChangeset
for help on using the changeset viewer.