Changeset 405
- Timestamp:
- 02/10/05 15:25:10 (20 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDReader.cc
r404 r405 46 46 SDReader::SDReader() : 47 47 reader_(0), 48 header_(0), 49 frequencies_(0), 48 50 table_(new SDMemTable()) { 49 51 cursor_ = 0; … … 52 54 int whichIF, int whichBeam) : 53 55 reader_(0), 56 header_(0), 57 frequencies_(0), 54 58 table_(new SDMemTable()) { 55 59 cursor_ = 0; … … 59 63 SDReader::SDReader(CountedPtr<SDMemTable> tbl) : 60 64 reader_(0), 65 header_(0), 61 66 table_(tbl) { 62 67 cursor_ = 0; … … 64 69 65 70 SDReader::~SDReader() { 66 if (reader_) delete reader_; reader_ = 0; 71 if (reader_) delete reader_; 72 if (header_) delete header_; 73 if (frequencies_) delete frequencies_; 67 74 } 68 75 … … 70 77 cursor_ = 0; 71 78 table_ = new SDMemTable(); 72 if (reader_) delete reader_; reader_ = 0; 73 // re-create the reader 74 Bool haveBase, haveSpectra, haveXPol; 75 String format; 76 Vector<Bool> beams; 77 if ((reader_ = getPKSreader(filename_, 0, False, format, beams, nIF_, 78 nChan_, nPol_, haveBase, haveSpectra, 79 haveXPol)) == 0) { 80 throw(AipsError("PKSreader failed")); 81 } 82 // re-enter the header 83 table_->putSDHeader(header_); 79 open(filename_,ifOffset_, beamOffset_); 84 80 } 85 81 … … 88 84 cerr << "disabled" << endl; 89 85 } 90 91 92 86 93 87 void SDReader::open(const std::string& filename, … … 95 89 if (reader_) delete reader_; reader_ = 0; 96 90 Bool haveBase, haveSpectra, haveXPol; 97 // 91 98 92 String inName(filename); 99 93 Path path(inName); 100 94 inName = path.expandedName(); 101 // 95 102 96 File file(inName); 103 97 if (!file.exists()) { … … 106 100 filename_ = inName; 107 101 108 // Create reader and fill in values for arguments 109 102 // Create reader and fill in values for arguments 110 103 String format; 111 104 Vector<Bool> beams; … … 113 106 nChan_, nPol_, haveBase, haveSpectra, 114 107 haveXPol)) == 0) { 115 throw(AipsError(" PKSreader failed"));108 throw(AipsError("Creation of PKSreader failed")); 116 109 } 117 110 if (!haveSpectra) { … … 121 114 return; 122 115 } 116 123 117 nBeam_ = beams.nelements(); 124 118 // Get basic parameters. … … 127 121 nPol_--; 128 122 } 129 header_ = SDHeader(); 130 header_.nchan = nChan_; 131 header_.npol = nPol_; 132 header_.nbeam = nBeam_; 133 Int status = reader_->getHeader(header_.observer, header_.project, 134 header_.antennaname, header_.antennaposition, 135 header_.obstype,header_.equinox, 136 header_.freqref, 137 header_.utc, header_.reffreq, 138 header_.bandwidth); 123 if (header_) delete header_; 124 header_ = new SDHeader(); 125 header_->nchan = nChan_; 126 header_->npol = nPol_; 127 header_->nbeam = nBeam_; 128 129 Int status = reader_->getHeader(header_->observer, header_->project, 130 header_->antennaname, header_->antennaposition, 131 header_->obstype,header_->equinox, 132 header_->freqref, 133 header_->utc, header_->reffreq, 134 header_->bandwidth); 135 139 136 if (status) { 140 137 delete reader_; … … 143 140 return; 144 141 } 145 if ((header_ .obstype).matches("*SW*")) {142 if ((header_->obstype).matches("*SW*")) { 146 143 // need robust way here - probably read ahead of next timestamp 147 144 cout << "Header indicates frequency switched observation.\n" … … 150 147 } 151 148 152 // Determine Telescope and set brightness unit149 // Determine Telescope and set brightness unit 153 150 154 151 Bool throwIt = False; 155 Instrument inst = SDMemTable::convertInstrument (header_.antennaname, throwIt); 156 header_.fluxunit = "Jy"; 152 Instrument inst = SDMemTable::convertInstrument(header_->antennaname, 153 throwIt); 154 header_->fluxunit = "Jy"; 157 155 if (inst==ATMOPRA || inst==TIDBINBILLA) { 158 header_ .fluxunit = "K";159 } 160 // 161 header_ .nif = nIF_;162 header_ .epoch = "UTC";156 header_->fluxunit = "K"; 157 } 158 159 header_->nif = nIF_; 160 header_->epoch = "UTC"; 163 161 164 162 // Apply selection criteria. … … 167 165 Vector<Bool> beamSel(nBeam_,True); 168 166 Vector<Bool> IFsel(nIF_,True); 169 // 167 170 168 ifOffset_ = 0; 171 169 if (whichIF>=0) { … … 173 171 IFsel = False; 174 172 IFsel(whichIF) = True; 175 header_ .nif = 1;173 header_->nif = 1; 176 174 nIF_ = 1; 177 175 ifOffset_ = whichIF; … … 180 178 } 181 179 } 182 // 180 183 181 beamOffset_ = 0; 184 182 if (whichBeam>=0) { … … 186 184 beamSel = False; 187 185 beamSel(whichBeam) = True; 188 header_ .nbeam = 1;186 header_->nbeam = 1; 189 187 nBeam_ = 1; 190 188 beamOffset_ = whichBeam; … … 193 191 } 194 192 } 195 //196 193 Vector<Int> start(nIF_, 1); 197 194 Vector<Int> end(nIF_, 0); 198 195 reader_->select(beamSel, IFsel, start, end, ref, True, haveXPol); 199 table_->putSDHeader(header_); 200 frequencies_.setRefFrame(header_.freqref); 201 frequencies_.setRestFrequencyUnit("Hz"); 202 frequencies_.setEquinox(header_.equinox); 196 table_->putSDHeader(*header_); 197 198 if (frequencies_) delete frequencies_; 199 frequencies_ = new SDFrequencyTable(); 200 frequencies_->setRefFrame(header_->freqref); 201 frequencies_->setRestFrequencyUnit("Hz"); 202 frequencies_->setEquinox(header_->equinox); 203 203 } 204 204 … … 220 220 uInt n = seq.size(); 221 221 222 uInt stepsize = header_ .nif*header_.nbeam;222 uInt stepsize = header_->nif*header_->nbeam; 223 223 uInt seqi = 0; 224 224 Bool getAll = False; 225 225 226 if (seq[n-1] == -1) getAll = True; 226 227 while ( (cursor_ <= seq[n-1]) || getAll) { 227 228 // only needs to be create if in seq 228 SDContainer sc(header_ .nbeam,header_.nif,header_.npol,header_.nchan);229 SDContainer sc(header_->nbeam,header_->nif,header_->npol,header_->nchan); 229 230 // iterate over one correlator integration cycle = nBeam*nIF 230 231 for (uInt row=0; row < stepsize; row++) { … … 241 242 spectra, flagtra, xCalFctr, xPol); 242 243 243 // Make sure beam/IF numbers are 0-relative - dealing with possible IF or Beam selection 244 244 // Make sure beam/IF numbers are 0-relative - dealing with 245 // possible IF or Beam selection 245 246 beamNo = beamNo - beamOffset_ - 1; 246 247 IFno = IFno - ifOffset_ - 1; 247 // 248 248 249 if (status) { 249 250 if (status == -1) { … … 251 252 if (row > 0 && row < stepsize-1) 252 253 cerr << "incomplete scan data.\n Probably means not all Beams/IFs/Pols within a scan are present." << endl; 253 //cerr << "EOF" << endl; 254 table_->putSDFreqTable(frequencies_); 254 255 // flush frequency table 256 table_->putSDFreqTable(*frequencies_); 255 257 return status; 256 258 } … … 273 275 // add specific info 274 276 // refPix = nChan/2+1 in 1-rel Integer arith.! 275 Int refPix = header_ .nchan/2;// 0-rel276 uInt freqID = frequencies_ .addFrequency(refPix, refFreq, freqInc);277 uInt restFreqID = frequencies_ .addRestFrequency(restFreq);278 // 277 Int refPix = header_->nchan/2; // 0-rel 278 uInt freqID = frequencies_->addFrequency(refPix, refFreq, freqInc); 279 uInt restFreqID = frequencies_->addRestFrequency(restFreq); 280 279 281 sc.setFrequencyMap(freqID, IFno); 280 282 sc.setRestFrequencyMap(restFreqID, IFno); 283 281 284 sc.tcal[0] = tcal[0];sc.tcal[1] = tcal[1]; 282 285 sc.tcaltime = tcalTime; … … 299 302 300 303 } 301 table_->putSDFreqTable( frequencies_);304 table_->putSDFreqTable(*frequencies_); 302 305 return status; 303 306 } -
trunk/src/SDReader.h
r342 r405 78 78 casa::Int nBeam_,nIF_,nPol_,nChan_; 79 79 PKSreader* reader_; 80 SDHeader header_;81 SDFrequencyTable frequencies_;80 SDHeader* header_; 81 SDFrequencyTable* frequencies_; 82 82 casa::CountedPtr<SDMemTable> table_; 83 83 casa::String filename_; -
trunk/src/python_SDReader.cc
r342 r405 41 41 class_<SDReaderWrapper>("sdreader") 42 42 .def( init < std::string, int, int > () ) 43 .def(" open", &SDReaderWrapper::open)44 .def(" read", &SDReaderWrapper::read)45 .def(" reset", &SDReaderWrapper::reset)46 .def(" getdata", &SDReaderWrapper::getSDMemTable)47 .def(" header", &SDReaderWrapper::pseudoHeader);43 .def("_open", &SDReaderWrapper::open) 44 .def("_read", &SDReaderWrapper::read) 45 .def("_reset", &SDReaderWrapper::reset) 46 .def("_getdata", &SDReaderWrapper::getSDMemTable) 47 .def("_header", &SDReaderWrapper::pseudoHeader); 48 48 ; 49 49 };
Note:
See TracChangeset
for help on using the changeset viewer.