Changeset 332
- Timestamp:
- 01/31/05 18:17:22 (20 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDReader.cc
r290 r332 44 44 cursor_ = 0; 45 45 } 46 SDReader::SDReader(const std::string& filename ) :46 SDReader::SDReader(const std::string& filename, int whichIF, int whichBeam) : 47 47 reader_(0), 48 48 table_(new SDMemTable()) { 49 49 cursor_ = 0; 50 open(filename );50 open(filename, whichIF, whichBeam); 51 51 } 52 52 … … 78 78 } 79 79 80 80 81 void SDReader::close() { 81 82 cerr << "disabled" << endl; 82 83 } 83 84 84 void SDReader::open(const std::string& filename) { 85 86 87 void SDReader::open(const std::string& filename, int whichIF, int whichBeam) { 85 88 if (reader_) delete reader_; reader_ = 0; 86 89 Bool haveBase, haveSpectra, haveXPol; … … 95 98 } 96 99 filename_ = inName; 97 // 100 101 // Create reader and fill in values for arguments 102 98 103 String format; 99 104 Vector<Bool> beams; … … 137 142 nIF_ = 1; 138 143 } 144 // 139 145 header_.nif = nIF_; 140 146 header_.fluxunit = "K"; 141 147 header_.epoch = "UTC"; 148 142 149 // Apply selection criteria. 143 Vector<Int> start(nIF_, 1); 144 Vector<Int> end(nIF_, 0); 150 145 151 Vector<Int> ref; 146 152 Vector<Bool> beamSel(nBeam_,True); 147 153 Vector<Bool> IFsel(nIF_,True); 154 // 155 ifOffset_ = 0; 156 if (whichIF>=0) { 157 if (whichIF>=0 && whichIF<nIF_) { 158 IFsel = False; 159 IFsel(whichIF) = True; 160 header_.nif = 1; 161 nIF_ = 1; 162 ifOffset_ = whichIF; 163 } else { 164 throw(AipsError("Illegal IF selection")); 165 } 166 } 167 // 168 beamOffset_ = 0; 169 if (whichBeam>=0) { 170 if (whichBeam>=0 && whichBeam<nBeam_) { 171 beamSel = False; 172 beamSel(whichBeam) = True; 173 header_.nbeam = 1; 174 nBeam_ = 1; 175 beamOffset_ = whichBeam; 176 } else { 177 throw(AipsError("Illegal Beam selection")); 178 } 179 } 180 // 181 Vector<Int> start(nIF_, 1); 182 Vector<Int> end(nIF_, 0); 148 183 reader_->select(beamSel, IFsel, start, end, ref, True, haveXPol); 149 184 table_->putSDHeader(header_); … … 190 225 tsys, sigma, calFctr, baseLin, baseSub, 191 226 spectra, flagtra, xCalFctr, xPol); 227 228 // Make sure beam/IF numbers are 0-relative 229 230 beamNo = beamNo - beamOffset_ - 1; 231 IFno = IFno - ifOffset_ - 1; 232 // 192 233 if (status) { 193 234 if (status == -1) { … … 216 257 } 217 258 // add specific info 218 // IFno beamNo are 1-relative219 259 // refPix = nChan/2+1 in Integer arith.! 220 260 Int refPix = header_.nchan/2+1; 221 Int frqslot = frequencies_.addFrequency(refPix, refFreq, freqInc); 222 frequencies_.addRestFrequency(restFreq); 223 sc.setFrequencyMap(frqslot,IFno-1); 261 uInt frqslot = frequencies_.addFrequency(refPix, refFreq, freqInc); 262 uInt restFrqSlot = frequencies_.addRestFrequency(restFreq); 263 // 264 sc.setFrequencyMap(frqslot,IFno); 265 sc.setRestFrequencyMap(restFrqSlot,IFno); 224 266 sc.tcal[0] = tcal[0];sc.tcal[1] = tcal[1]; 225 267 sc.tcaltime = tcalTime; … … 227 269 sc.refbeam = refBeam; 228 270 sc.scanid = scanNo-1;//make it 0-based 229 sc.setSpectrum(spectra, beamNo -1, IFno-1);230 sc.setFlags(flagtra, beamNo -1, IFno-1);231 sc.setTsys(tsys, beamNo -1, IFno-1);232 sc.setDirection(direction, beamNo -1);271 sc.setSpectrum(spectra, beamNo, IFno); 272 sc.setFlags(flagtra, beamNo, IFno); 273 sc.setTsys(tsys, beamNo, IFno); 274 sc.setDirection(direction, beamNo); 233 275 } 234 276 } -
trunk/src/SDReader.h
r125 r332 51 51 public: 52 52 SDReader(); 53 SDReader(const std::string& filename); 53 SDReader(const std::string& filename, int whichIF=-1, 54 int whichBeam=-1); 54 55 SDReader(casa::CountedPtr<SDMemTable> tbl); 55 56 virtual ~SDReader(); 56 57 57 void open(const std::string& filename); 58 void open(const std::string& filename, 59 int whichIF=-1, 60 int whichBeam=-1); 58 61 void close(); 59 62 int read(const std::vector<int>& seq); … … 81 84 casa::uInt cursor_; 82 85 casa::Double timestamp_; 86 casa::uInt beamOffset_, ifOffset_; 83 87 }; 84 88 -
trunk/src/SDReaderWrapper.h
r125 r332 43 43 public: 44 44 SDReaderWrapper() {;} 45 SDReaderWrapper(const std::string& filename ) : SDReader(filename) {;}45 SDReaderWrapper(const std::string& filename, int ifSel=-1, int beamSel=-1) : SDReader(filename,ifSel,beamSel) {;} 46 46 SDReaderWrapper(SDMemTableWrapper tbl) : 47 47 SDReader(tbl.getCP()){;} -
trunk/src/python_SDReader.cc
r125 r332 40 40 void python_SDReader() { 41 41 class_<SDReaderWrapper>("sdreader") 42 .def( init < std::string > () )42 .def( init < std::string, int, int > () ) 43 43 .def("open", &SDReaderWrapper::open) 44 44 .def("read", &SDReaderWrapper::read)
Note:
See TracChangeset
for help on using the changeset viewer.