- Timestamp:
- 01/30/05 18:01:46 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDWriter.cc
r199 r324 39 39 #include <atnf/PKSIO/PKSMS2writer.h> 40 40 #include <atnf/PKSIO/PKSSDwriter.h> 41 42 #include <tables/Tables/ArrayColumn.h> 43 41 44 42 45 #include "SDContainer.h" … … 107 110 // finished. 108 111 109 Int SDWriter::write(const CountedPtr<SDMemTable> table,112 Int SDWriter::write(const CountedPtr<SDMemTable> in, 110 113 const std::string &filename) 111 114 { … … 116 119 Bool verbose = True; 117 120 SDFITSImageWriter iw; 118 if (iw.write(* table, filename, verbose)) {121 if (iw.write(*in, filename, verbose)) { 119 122 return 0; 120 123 } else { … … 123 126 } else if (cFormat=="ASCII") { 124 127 SDAsciiWriter iw; 125 if (iw.write(* table, filename)) {128 if (iw.write(*in, filename)) { 126 129 return 0; 127 130 } else { … … 133 136 134 137 // Extract the header from the table. 135 SDHeader hdr = table->getSDHeader(); 136 Int nPol = hdr.npol; 137 Int nChan = hdr.nchan; 138 SDHeader hdr = in->getSDHeader(); 139 const Int nPol = hdr.npol; 140 const Int nChan = hdr.nchan; 141 142 // Get Freq table 143 144 SDFrequencyTable sdft = in->getSDFreqTable(); 145 Vector<Double> restFreqs; 146 String restFreqUnit; 147 sdft.restFrequencies(restFreqs, restFreqUnit); 148 Double restFreq = 0.0; 149 if (restFreqs.nelements()>0) { 150 Quantum<Double> rF(restFreqs(0), Unit(restFreqUnit)); 151 restFreq = rF.getValue(Unit("Hz")); 152 } 153 154 // Table columns 155 156 const Table table = in->table(); 157 ROArrayColumn<uInt> freqIDCol(table, "FREQID"); 158 Vector<uInt> freqIDs; 138 159 139 160 // Create the output file and write static data. … … 152 173 153 174 Int count = 0; 154 for (Int iRow = 0; iRow < table->nRow(); iRow++) {175 for (Int iRow = 0; iRow < in->nRow(); iRow++) { 155 176 // Extract the next integration from the table. 156 SDContainer sd = table->getSDContainer(iRow);177 SDContainer sd = in->getSDContainer(iRow); 157 178 if (sd.scanid != scanNo) { 158 179 scanNo = sd.scanid; … … 163 184 } 164 185 186 // Get FreqID vector 187 freqIDCol.get(iRow, freqIDs); 188 165 189 // Write it out beam by beam. 166 190 for (Int iBeam = 0; iBeam < hdr.nbeam; iBeam++) { … … 168 192 // Write it out IF by IF. 169 193 for (Int iIF = 0; iIF < hdr.nif; iIF++) { 194 uInt freqID = freqIDs(iIF); 195 170 196 // None of these are stored in SDMemTable by SDReader. 171 197 //String fieldName = ""; … … 173 199 Vector<Double> srcPM(2, 0.0); 174 200 Double srcVel = 0.0; 175 Double freqInc = 0.0; 176 Double restFreq = 0.0; 201 202 // The writer will assume refPix = nChan/2 + 1. So recompute 203 // the frequency at this location. 204 205 Double cdelt = sdft.increment(freqID); 206 Double crval = sdft.referenceValue(freqID); 207 Double crpix = sdft.referencePixel(freqID); 208 Double pixel = nChan/2 + 1; 209 Double refFreqNew = (pixel-crpix)*cdelt + crval; 210 // 177 211 //Vector<Float> tcal(2, 0.0f); 178 212 //String tcalTime = ""; … … 197 231 Complex xCalFctr; 198 232 Vector<Complex> xPol; 233 // 199 234 if (status = cWriter->write(sd.scanid, cycleNo, sd.timestamp, 200 235 sd.interval, sd.fieldname, sd.sourcename, 201 236 sd.getDirection(iBeam), 202 srcPM, srcVel, iIF+1, hdr.reffreq,203 hdr.bandwidth, freqInc, restFreq, sd.tcal,237 srcPM, srcVel, iIF+1, refFreqNew, 238 nChan*abs(cdelt), cdelt, restFreq, sd.tcal, 204 239 sd.tcaltime, sd.azimuth, sd.elevation, 205 240 sd.parangle,
Note:
See TracChangeset
for help on using the changeset viewer.