- Timestamp:
- 11/12/04 12:08:27 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDReader.cc
r83 r87 30 30 //#--------------------------------------------------------------------------- 31 31 #include <atnf/PKSIO/PKSreader.h> 32 32 #include <casa/Exceptions.h> 33 33 #include "SDReader.h" 34 34 … … 59 59 void SDReader::reset() { 60 60 cursor_ = 0; 61 open(filename_); 61 table_ = new SDMemTable(); 62 if (reader_) delete reader_; reader_ = 0; 63 // re-create the reader 64 Bool haveBase, haveSpectra, haveXPol; 65 String format; 66 Vector<Bool> beams; 67 if ((reader_ = getPKSreader(filename_, 0, False, format, beams, nIF_, 68 nChan_, nPol_, haveBase, haveSpectra, 69 haveXPol)) == 0) { 70 throw(AipsError("PKSreader failed")); 71 } 72 // re-enter the header 73 table_->putSDHeader(header_); 62 74 } 63 75 … … 70 82 Bool haveBase, haveSpectra, haveXPol; 71 83 String inName(filename); 84 filename_ = inName; 72 85 String format; 73 86 Vector<Bool> beams; … … 75 88 nChan_, nPol_, haveBase, haveSpectra, 76 89 haveXPol)) == 0) { 77 cerr << "PKSreader failed" << endl; 90 throw(AipsError("PKSreader failed")); 91 //cerr << "PKSreader failed" << endl; 78 92 } 79 93 if (!haveSpectra) { 80 94 delete reader_; 81 95 reader_ = 0; 82 cerr << "Spectral data absent." << endl;96 throw(AipsError("No spectral data in file.")); 83 97 return; 84 98 } … … 89 103 header_.npol = nPol_; 90 104 header_.nbeam = nBeam_; 91 92 Int status = reader_->getHeader(header_.observer, header_.project, 93 header_.antennaname, header_.antennaposition, 94 header_.obstype,header_.equinox, 95 header_.freqref, 96 header_.utc, header_.reffreq, 105 Int status = reader_->getHeader(header_.observer, header_.project, 106 header_.antennaname, header_.antennaposition, 107 header_.obstype,header_.equinox, 108 header_.freqref, 109 header_.utc, header_.reffreq, 97 110 header_.bandwidth); 98 111 if (status) { 99 112 delete reader_; 100 113 reader_ = 0; 101 cerr << "Failed to get data description." << endl;114 throw(AipsError("Failed to get header.")); 102 115 return; 103 116 } 104 //header_.print();105 117 if ((header_.obstype).matches("*SW*")) { 106 118 // need robust way here - probably read ahead of next timestamp … … 123 135 124 136 int SDReader::read(const std::vector<int>& seq) { 125 int status = 0; 126 137 int status = 0; 138 127 139 Int beamNo, IFno, refBeam, scanNo, cycleNo; 128 Float azimuth, elevation, focusAxi, focusRot, focusTan, 140 Float azimuth, elevation, focusAxi, focusRot, focusTan, 129 141 humidity, parAngle, pressure, temperature, windAz, windSpeed; 130 142 Double bandwidth, freqInc, interval, mjd, refFreq, restFreq, srcVel; … … 152 164 // stepsize as well 153 165 // spectra(nChan,nPol)!!! 154 status = reader_->read(scanNo, cycleNo, mjd, interval, fieldName, 155 156 bandwidth, freqInc, restFreq, tcal, tcalTime, 157 azimuth, elevation, parAngle, focusAxi, 158 focusTan, focusRot, temperature, pressure, 159 humidity, windSpeed, windAz, refBeam, 160 161 tsys, sigma, calFctr, baseLin, baseSub, 162 spectra, flagtra, xCalFctr, xPol); 166 status = reader_->read(scanNo, cycleNo, mjd, interval, fieldName, 167 srcName, srcDir, srcPM, srcVel, IFno, refFreq, 168 bandwidth, freqInc, restFreq, tcal, tcalTime, 169 azimuth, elevation, parAngle, focusAxi, 170 focusTan, focusRot, temperature, pressure, 171 humidity, windSpeed, windAz, refBeam, 172 beamNo, direction, scanRate, 173 tsys, sigma, calFctr, baseLin, baseSub, 174 spectra, flagtra, xCalFctr, xPol); 163 175 if (status) { 164 165 166 167 168 169 170 171 } 176 if (status == -1) { 177 // EOF. 178 if (row < stepsize-1) cerr << "incomplete integration data." << endl; 179 //cerr << "EOF" << endl; 180 table_->putSDFreqTable(frequencies_); 181 return status; 182 } 183 } 172 184 // if in the given list 173 185 if (cursor_ == seq[seqi] || getAll) { 174 175 176 177 178 179 180 181 sc.interval = interval; 182 183 184 185 186 // refPix = nChan/2+1 in Integer arith.! 187 Int refPix = header_.nchan/2+1; 188 189 190 191 192 193 194 195 186 // add integration cycle 187 if (row==0) { 188 //add invariant info: scanNo, mjd, interval, fieldName, 189 //srcName, azimuth, elevation, parAngle, focusAxi, focusTan, 190 //focusRot, temperature, pressure, humidity, windSpeed, 191 //windAz srcDir, srcPM, srcVel 192 sc.timestamp = mjd; 193 sc.interval = interval; 194 sc.sourcename = srcName; 195 } 196 // add specific info 197 // IFno beamNo are 1-relative 198 // refPix = nChan/2+1 in Integer arith.! 199 Int refPix = header_.nchan/2+1; 200 Int frqslot = frequencies_.addFrequency(refPix, refFreq, freqInc); 201 sc.setFrequencyMap(frqslot,IFno-1); 202 203 sc.scanid = scanNo-1;//make it 0-based 204 sc.setSpectrum(spectra, beamNo-1, IFno-1); 205 sc.setFlags(flagtra, beamNo-1, IFno-1); 206 sc.setTsys(tsys, beamNo-1, IFno-1); 207 sc.setDirection(direction, beamNo-1); 196 208 } 197 209 }
Note:
See TracChangeset
for help on using the changeset viewer.