Changeset 1452 for trunk/external/atnf/PKSIO/PKSSDwriter.cc
- Timestamp:
- 11/19/08 20:41:16 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/external/atnf/PKSIO/PKSSDwriter.cc
r1399 r1452 2 2 //# PKSSDwriter.cc: Class to write Parkes multibeam data to an SDFITS file. 3 3 //#--------------------------------------------------------------------------- 4 //# Copyright (C) 2000-200 74 //# Copyright (C) 2000-2008 5 5 //# Associated Universities, Inc. Washington DC, USA. 6 6 //# … … 26 26 //# Charlottesville, VA 22903-2475 USA 27 27 //# 28 //# $Id: PKSSDwriter.cc,v 19.1 3 2007/11/12 03:37:56cal103 Exp $28 //# $Id: PKSSDwriter.cc,v 19.15 2008-11-17 06:56:50 cal103 Exp $ 29 29 //#--------------------------------------------------------------------------- 30 30 31 #include <atnf/PKSIO/ PKSMBrecord.h>31 #include <atnf/PKSIO/MBrecord.h> 32 32 #include <atnf/PKSIO/PKSSDwriter.h> 33 33 34 #include <casa/stdio.h> 34 35 #include <casa/Quanta/MVTime.h> 35 36 36 37 37 //--------------------------------------------------- PKSSDwriter::PKSSDwriter 38 38 … … 41 41 PKSSDwriter::PKSSDwriter() 42 42 { 43 // By default, messages are written to stderr. 44 initMsg(); 43 45 } 44 46 … … 50 52 { 51 53 close(); 54 } 55 56 //-------------------------------------------------------- PKSSDwriter::setMsg 57 58 // Set message disposition. If fd is non-zero messages will be written 59 // to that file descriptor, else stored for retrieval by getMsg(). 60 61 Int PKSSDwriter::setMsg(FILE *fd) 62 { 63 PKSmsg::setMsg(fd); 64 cSDwriter.setMsg(fd); 65 66 return 0; 52 67 } 53 68 … … 71 86 const Bool haveBase) 72 87 { 88 // Clear the message stack. 89 clearMsg(); 90 73 91 double antPos[3]; 74 92 antPos[0] = antPosition(0); … … 107 125 (int *)cNPol.getStorage(deleteIt), 108 126 (int *)cHaveXPol.getStorage(deleteIt), (int)cHaveBase, 1); 127 logMsg(cSDwriter.getMsg()); 128 cSDwriter.clearMsg(); 109 129 if (status) { 110 cSDwriter.reportError();111 130 cSDwriter.deleteFile(); 112 131 close(); … … 121 140 122 141 Int PKSSDwriter::write( 123 const Int scanNo, 124 const Int cycleNo, 125 const Double mjd, 126 const Double interval, 127 const String fieldName, 128 const String srcName, 129 const Vector<Double> srcDir, 130 const Vector<Double> srcPM, 131 const Double srcVel, 132 const String obsMode, 133 const Int IFno, 134 const Double refFreq, 135 const Double bandwidth, 136 const Double freqInc, 137 const Double restFreq, 138 const Vector<Float> tcal, 139 const String tcalTime, 140 const Float azimuth, 141 const Float elevation, 142 const Float parAngle, 143 const Float focusAxi, 144 const Float focusTan, 145 const Float focusRot, 146 const Float temperature, 147 const Float pressure, 148 const Float humidity, 149 const Float windSpeed, 150 const Float windAz, 151 const Int refBeam, 152 const Int beamNo, 153 const Vector<Double> direction, 154 const Vector<Double> scanRate, 155 const Vector<Float> tsys, 156 const Vector<Float> sigma, 157 const Vector<Float> calFctr, 158 const Matrix<Float> baseLin, 159 const Matrix<Float> baseSub, 160 const Matrix<Float> &spectra, 161 const Matrix<uChar> &flagged, 162 const Complex xCalFctr, 163 const Vector<Complex> &xPol) 142 const PKSrecord &pksrec) 164 143 { 165 144 // Do basic checks. 145 Int IFno = pksrec.IFno; 166 146 uInt iIF = IFno - 1; 167 147 if (IFno < 1 || Int(cNIF) < IFno) { … … 172 152 } 173 153 174 uInt nChan = spectra.nrow();154 uInt nChan = pksrec.spectra.nrow(); 175 155 if (nChan != cNChan(iIF)) { 176 156 cerr << "PKSDwriter::write: " … … 181 161 } 182 162 183 uInt nPol = spectra.ncolumn();163 uInt nPol = pksrec.spectra.ncolumn(); 184 164 if (nPol != cNPol(iIF)) { 185 165 cerr << "PKSDwriter::write: " … … 191 171 192 172 // Extract calendar information from mjd. 193 MVTime time( mjd);173 MVTime time(pksrec.mjd); 194 174 Int year = time.year(); 195 175 Int month = time.month(); 196 176 Int day = time.monthday(); 197 177 198 // Transfer data to a single-IF PKSMBrecord.199 PKSMBrecord mbrec(1);178 // Transfer data to a single-IF MBrecord. 179 MBrecord mbrec(1); 200 180 201 181 // Start with basic beam- and IF-independent bookkeeping information. 202 mbrec.scanNo = scanNo;203 mbrec.cycleNo = cycleNo;182 mbrec.scanNo = pksrec.scanNo; 183 mbrec.cycleNo = pksrec.cycleNo; 204 184 205 185 sprintf(mbrec.datobs, "%4.4d-%2.2d-%2.2d", year, month, day); 206 mbrec.utc = fmod( mjd, 1.0) * 86400.0;207 mbrec.exposure = float( interval);208 209 strncpy(mbrec.srcName, (char *) srcName.chars(), 17);210 mbrec.srcRA = srcDir(0);211 mbrec.srcDec = srcDir(1);212 213 mbrec.restFreq = restFreq;214 215 strncpy(mbrec.obsType, (char *) obsMode.chars(), 16);186 mbrec.utc = fmod(pksrec.mjd, 1.0) * 86400.0; 187 mbrec.exposure = float(pksrec.interval); 188 189 strncpy(mbrec.srcName, (char *)pksrec.srcName.chars(), 17); 190 mbrec.srcRA = pksrec.srcDir(0); 191 mbrec.srcDec = pksrec.srcDir(1); 192 193 mbrec.restFreq = pksrec.restFreq; 194 195 strncpy(mbrec.obsType, (char *)pksrec.obsType.chars(), 16); 216 196 217 197 // Now beam-dependent parameters. 218 mbrec.beamNo = beamNo;219 mbrec.ra = direction(0);220 mbrec.dec = direction(1);221 mbrec.raRate = scanRate(0);222 mbrec.decRate = scanRate(1);198 mbrec.beamNo = pksrec.beamNo; 199 mbrec.ra = pksrec.direction(0); 200 mbrec.dec = pksrec.direction(1); 201 mbrec.raRate = pksrec.scanRate(0); 202 mbrec.decRate = pksrec.scanRate(1); 223 203 224 204 // Now IF-dependent parameters. … … 229 209 230 210 mbrec.fqRefPix[0] = (nChan/2) + 1; 231 mbrec.fqRefVal[0] = refFreq;232 mbrec.fqDelt[0] = freqInc;211 mbrec.fqRefVal[0] = pksrec.refFreq; 212 mbrec.fqDelt[0] = pksrec.freqInc; 233 213 234 214 // Now the data itself. 235 for (uInt i = 0; i < tsys.nelements(); i++) {236 mbrec.tsys[0][i] = tsys(i);215 for (uInt i = 0; i < pksrec.tsys.nelements(); i++) { 216 mbrec.tsys[0][i] = pksrec.tsys(i); 237 217 } 238 218 239 219 for (uInt ipol = 0; ipol < nPol; ipol++) { 240 mbrec.calfctr[0][ipol] = calFctr(ipol);220 mbrec.calfctr[0][ipol] = pksrec.calFctr(ipol); 241 221 } 242 222 243 223 if (cHaveXPol(iIF)) { 244 mbrec.xcalfctr[0][0] = xCalFctr.real();245 mbrec.xcalfctr[0][1] = xCalFctr.imag();224 mbrec.xcalfctr[0][0] = pksrec.xCalFctr.real(); 225 mbrec.xcalfctr[0][1] = pksrec.xCalFctr.imag(); 246 226 } else { 247 227 mbrec.xcalfctr[0][0] = 0.0f; … … 253 233 254 234 for (uInt ipol = 0; ipol < nPol; ipol++) { 255 mbrec.baseLin[0][ipol][0] = baseLin(0,ipol);256 mbrec.baseLin[0][ipol][1] = baseLin(1,ipol);257 258 for (uInt j = 0; j < baseSub.nrow(); j++) {259 mbrec.baseSub[0][ipol][j] = baseSub(j,ipol);235 mbrec.baseLin[0][ipol][0] = pksrec.baseLin(0,ipol); 236 mbrec.baseLin[0][ipol][1] = pksrec.baseLin(1,ipol); 237 238 for (uInt j = 0; j < pksrec.baseSub.nrow(); j++) { 239 mbrec.baseSub[0][ipol][j] = pksrec.baseSub(j,ipol); 260 240 } 261 for (uInt j = baseSub.nrow(); j < 9; j++) {241 for (uInt j = pksrec.baseSub.nrow(); j < 9; j++) { 262 242 mbrec.baseSub[0][ipol][j] = 0.0f; 263 243 } … … 269 249 270 250 Bool delSpectra = False; 271 const Float *specstor = spectra.getStorage(delSpectra);251 const Float *specstor = pksrec.spectra.getStorage(delSpectra); 272 252 mbrec.spectra[0] = (float *)specstor; 273 253 274 254 Bool delFlagged = False; 275 const uChar *flagstor = flagged.getStorage(delFlagged);255 const uChar *flagstor = pksrec.flagged.getStorage(delFlagged); 276 256 mbrec.flagged[0] = (unsigned char *)flagstor; 277 257 … … 279 259 const Complex *xpolstor; 280 260 if (cHaveXPol(iIF)) { 281 xpolstor = xPol.getStorage(delXPol);261 xpolstor = pksrec.xPol.getStorage(delXPol); 282 262 } else { 283 263 xpolstor = 0; … … 287 267 // Finish off with system calibration parameters. 288 268 mbrec.extraSysCal = 1; 289 mbrec.refBeam = refBeam;290 for (uInt i = 0; i < tcal.nelements(); i++) {291 mbrec.tcal[0][i] = tcal(i);292 } 293 strncpy(mbrec.tcalTime, (char *) tcalTime.chars(), 16);294 mbrec.azimuth = azimuth;295 mbrec.elevation = elevation;296 mbrec.parAngle = p arAngle;297 mbrec.focusAxi = focusAxi;298 mbrec.focusTan = focusTan;299 mbrec.focusRot = focusRot;300 mbrec.temp = temperature;301 mbrec.pressure = p ressure;302 mbrec.humidity = humidity;303 mbrec.windSpeed = windSpeed;304 mbrec.windAz = windAz;269 mbrec.refBeam = pksrec.refBeam; 270 for (uInt i = 0; i < pksrec.tcal.nelements(); i++) { 271 mbrec.tcal[0][i] = pksrec.tcal(i); 272 } 273 strncpy(mbrec.tcalTime, (char *)pksrec.tcalTime.chars(), 16); 274 mbrec.azimuth = pksrec.azimuth; 275 mbrec.elevation = pksrec.elevation; 276 mbrec.parAngle = pksrec.parAngle; 277 mbrec.focusAxi = pksrec.focusAxi; 278 mbrec.focusTan = pksrec.focusTan; 279 mbrec.focusRot = pksrec.focusRot; 280 mbrec.temp = pksrec.temperature; 281 mbrec.pressure = pksrec.pressure; 282 mbrec.humidity = pksrec.humidity; 283 mbrec.windSpeed = pksrec.windSpeed; 284 mbrec.windAz = pksrec.windAz; 305 285 306 286 Int status = cSDwriter.write(mbrec); 287 logMsg(cSDwriter.getMsg()); 288 cSDwriter.clearMsg(); 307 289 if (status) { 308 cSDwriter.reportError();309 290 status = 1; 310 291 } 311 292 312 spectra.freeStorage(specstor, delSpectra);313 flagged.freeStorage(flagstor, delFlagged);314 xPol.freeStorage(xpolstor, delXPol);293 pksrec.spectra.freeStorage(specstor, delSpectra); 294 pksrec.flagged.freeStorage(flagstor, delFlagged); 295 pksrec.xPol.freeStorage(xpolstor, delXPol); 315 296 316 297 return status; … … 338 319 { 339 320 cSDwriter.close(); 340 } 321 logMsg(cSDwriter.getMsg()); 322 cSDwriter.clearMsg(); 323 }
Note: See TracChangeset
for help on using the changeset viewer.