Changeset 1757 for branches/alma/external/atnf/PKSIO/PKSSDwriter.cc
- Timestamp:
- 06/09/10 19:03:06 (14 years ago)
- Location:
- branches/alma
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/alma
-
Property
svn:ignore
set to
.sconf_temp
.sconsign.dblite
-
Property
svn:mergeinfo
set to
/branches/asap-3.x merged eligible
-
Property
svn:ignore
set to
-
branches/alma/external/atnf/PKSIO/PKSSDwriter.cc
r1453 r1757 2 2 //# PKSSDwriter.cc: Class to write Parkes multibeam data to an SDFITS file. 3 3 //#--------------------------------------------------------------------------- 4 //# Copyright (C) 2000-2006 5 //# Associated Universities, Inc. Washington DC, USA. 6 //# 7 //# This library is free software; you can redistribute it and/or modify it 8 //# under the terms of the GNU Library General Public License as published by 9 //# the Free Software Foundation; either version 2 of the License, or (at your 10 //# option) any later version. 11 //# 12 //# This library is distributed in the hope that it will be useful, but 13 //# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 //# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 15 //# License for more details. 16 //# 17 //# You should have received a copy of the GNU Library General Public License 18 //# along with this library; if not, write to the Free Software Foundation, 19 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 20 //# 21 //# Correspondence concerning AIPS++ should be addressed as follows: 22 //# Internet email: aips2-request@nrao.edu. 23 //# Postal address: AIPS++ Project Office 24 //# National Radio Astronomy Observatory 25 //# 520 Edgemont Road 26 //# Charlottesville, VA 22903-2475 USA 27 //# 28 //# $Id$ 4 //# livedata - processing pipeline for single-dish, multibeam spectral data. 5 //# Copyright (C) 2000-2009, Australia Telescope National Facility, CSIRO 6 //# 7 //# This file is part of livedata. 8 //# 9 //# livedata is free software: you can redistribute it and/or modify it under 10 //# the terms of the GNU General Public License as published by the Free 11 //# Software Foundation, either version 3 of the License, or (at your option) 12 //# any later version. 13 //# 14 //# livedata is distributed in the hope that it will be useful, but WITHOUT 15 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 17 //# more details. 18 //# 19 //# You should have received a copy of the GNU General Public License along 20 //# with livedata. If not, see <http://www.gnu.org/licenses/>. 21 //# 22 //# Correspondence concerning livedata may be directed to: 23 //# Internet email: mcalabre@atnf.csiro.au 24 //# Postal address: Dr. Mark Calabretta 25 //# Australia Telescope National Facility, CSIRO 26 //# PO Box 76 27 //# Epping NSW 1710 28 //# AUSTRALIA 29 //# 30 //# http://www.atnf.csiro.au/computing/software/livedata.html 31 //# $Id: PKSSDwriter.cc,v 19.17 2009-09-29 07:33:38 cal103 Exp $ 29 32 //#--------------------------------------------------------------------------- 30 33 31 #include <atnf/PKSIO/ PKSMBrecord.h>34 #include <atnf/PKSIO/MBrecord.h> 32 35 #include <atnf/PKSIO/PKSSDwriter.h> 33 36 37 #include <casa/Logging/LogIO.h> 38 39 #include <casa/stdio.h> 34 40 #include <casa/Quanta/MVTime.h> 35 41 42 #include <string> 43 #include <cstring> 44 45 // Class name 46 const string className = "PKSSDwriter" ; 36 47 37 48 //--------------------------------------------------- PKSSDwriter::PKSSDwriter … … 63 74 const Vector<Double> antPosition, 64 75 const String obsMode, 76 const String bunit, 65 77 const Float equinox, 66 78 const String dopplerFrame, … … 68 80 const Vector<uInt> nPol, 69 81 const Vector<Bool> haveXPol, 70 const Bool haveBase, 71 const String fluxUnit) 72 { 82 const Bool haveBase) 83 { 84 const string methodName = "create()" ; 85 LogIO os( LogOrigin( className, methodName, WHERE ) ) ; 86 73 87 double antPos[3]; 74 88 antPos[0] = antPosition(0); … … 78 92 cNIF = nChan.nelements(); 79 93 if (nPol.nelements() != cNIF || haveXPol.nelements() != cNIF) { 80 cerr << "PKSSDwriter::create: " 81 << "Inconsistent number of IFs for nChan, nPol, and/or haveXPol." 82 << endl; 94 os << LogIO::SEVERE << "Inconsistent number of IFs for nChan, nPol, and/or haveXPol." << LogIO::POST ; 83 95 return 1; 84 96 } … … 102 114 Int status = cSDwriter.create((char *)sdName.chars(), 103 115 (char *)observer.chars(), (char *)project.chars(), 104 (char *)antName.chars(), antPos, (char *)obsMode.chars(), equinox,105 (char *) dopplerFrame.chars(), cNIF,116 (char *)antName.chars(), antPos, (char *)obsMode.chars(), 117 (char *)bunit.chars(), equinox, (char *)dopplerFrame.chars(), cNIF, 106 118 (int *)cNChan.getStorage(deleteIt), 107 119 (int *)cNPol.getStorage(deleteIt), 108 120 (int *)cHaveXPol.getStorage(deleteIt), (int)cHaveBase, 1); 121 //logMsg(cSDwriter.getMsg()); 122 //cSDwriter.clearMsg(); 109 123 if (status) { 110 cSDwriter.reportError();111 124 cSDwriter.deleteFile(); 112 125 close(); … … 121 134 122 135 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<Double> restFreq, 139 const Vector<Float> tcal, 140 const String tcalTime, 141 const Float azimuth, 142 const Float elevation, 143 const Float parAngle, 144 const Float focusAxi, 145 const Float focusTan, 146 const Float focusRot, 147 const Float temperature, 148 const Float pressure, 149 const Float humidity, 150 const Float windSpeed, 151 const Float windAz, 152 const Int refBeam, 153 const Int beamNo, 154 const Vector<Double> direction, 155 const Vector<Double> scanRate, 156 const Vector<Float> tsys, 157 const Vector<Float> sigma, 158 const Vector<Float> calFctr, 159 const Matrix<Float> baseLin, 160 const Matrix<Float> baseSub, 161 const Matrix<Float> &spectra, 162 const Matrix<uChar> &flagged, 163 const Complex xCalFctr, 164 const Vector<Complex> &xPol) 165 { 136 const PKSrecord &pksrec) 137 { 138 const string methodName = "write()" ; 139 LogIO os( LogOrigin( className, methodName, WHERE ) ) ; 140 166 141 // Do basic checks. 142 Int IFno = pksrec.IFno; 167 143 uInt iIF = IFno - 1; 168 144 if (IFno < 1 || Int(cNIF) < IFno) { 169 cerr << "PKSDwriter::write: "170 171 << " (maximum " << cNIF << ")." << endl;145 os << LogIO::SEVERE 146 << "Invalid IF number " << IFno 147 << " (maximum " << cNIF << ")." << LogIO::POST ; 172 148 return 1; 173 149 } 174 150 175 uInt nChan = spectra.nrow();151 uInt nChan = pksrec.spectra.nrow(); 176 152 if (nChan != cNChan(iIF)) { 177 cerr << "PKSDwriter::write: " 178 << "Wrong number of channels for IF " << IFno << "," << endl 179 << " " 153 os << LogIO::SEVERE << "Wrong number of channels for IF " << IFno << "," << endl 180 154 << "got " << nChan << " should be " << cNChan(iIF) << "." << endl; 155 os << LogIO::POST ; 181 156 return 1; 182 157 } 183 158 184 uInt nPol = spectra.ncolumn();159 uInt nPol = pksrec.spectra.ncolumn(); 185 160 if (nPol != cNPol(iIF)) { 186 cerr << "PKSDwriter::write: " 187 << "Wrong number of polarizations for IF " << IFno << "," << endl 188 << " " 189 << "got " << nPol << " should be " << cNPol(iIF) << "." << endl; 161 os << LogIO::SEVERE << "Wrong number of polarizations for IF " << IFno << "," << endl 162 << "got " << nPol << " should be " << cNPol(iIF) << "." << endl; 163 os << LogIO::POST ; 190 164 return 1; 191 165 } 192 166 193 // Extract calendar information fr om mjd.194 MVTime time( mjd);167 // Extract calendar information frrom mjd. 168 MVTime time(pksrec.mjd); 195 169 Int year = time.year(); 196 170 Int month = time.month(); 197 171 Int day = time.monthday(); 198 172 199 // Transfer data to a single-IF PKSMBrecord.200 PKSMBrecord mbrec(1);173 // Transfer data to a single-IF MBrecord. 174 MBrecord mbrec(1); 201 175 202 176 // Start with basic beam- and IF-independent bookkeeping information. 203 mbrec.scanNo = scanNo;204 mbrec.cycleNo = cycleNo;177 mbrec.scanNo = pksrec.scanNo; 178 mbrec.cycleNo = pksrec.cycleNo; 205 179 206 180 sprintf(mbrec.datobs, "%4.4d-%2.2d-%2.2d", year, month, day); 207 mbrec.utc = fmod(mjd, 1.0) * 86400.0; 208 mbrec.exposure = float(interval); 209 210 strncpy(mbrec.srcName, (char *)srcName.chars(), 17); 211 mbrec.srcRA = srcDir(0); 212 mbrec.srcDec = srcDir(1); 213 214 //mbrec.restFreq = restFreq; 215 mbrec.restFreq = restFreq(0); 216 217 strncpy(mbrec.obsType, (char *)obsMode.chars(), 16); 181 mbrec.utc = fmod(pksrec.mjd, 1.0) * 86400.0; 182 mbrec.exposure = float(pksrec.interval); 183 184 strncpy(mbrec.srcName, (char *)pksrec.srcName.chars(), 17); 185 mbrec.srcRA = pksrec.srcDir(0); 186 mbrec.srcDec = pksrec.srcDir(1); 187 if (pksrec.restFreq.shape()==0) { 188 mbrec.restFreq = 0; 189 } 190 else { 191 mbrec.restFreq = pksrec.restFreq(0); 192 } 193 strncpy(mbrec.obsType, (char *)pksrec.obsType.chars(), 16); 218 194 219 195 // Now beam-dependent parameters. 220 mbrec.beamNo = beamNo;221 mbrec.ra = direction(0);222 mbrec.dec = direction(1);223 mbrec.raRate = scanRate(0);224 mbrec.decRate = scanRate(1);196 mbrec.beamNo = pksrec.beamNo; 197 mbrec.ra = pksrec.direction(0); 198 mbrec.dec = pksrec.direction(1); 199 mbrec.raRate = pksrec.scanRate(0); 200 mbrec.decRate = pksrec.scanRate(1); 225 201 226 202 // Now IF-dependent parameters. … … 231 207 232 208 mbrec.fqRefPix[0] = (nChan/2) + 1; 233 mbrec.fqRefVal[0] = refFreq;234 mbrec.fqDelt[0] = freqInc;209 mbrec.fqRefVal[0] = pksrec.refFreq; 210 mbrec.fqDelt[0] = pksrec.freqInc; 235 211 236 212 // Now the data itself. 237 for (uInt i = 0; i < tsys.nelements(); i++) {238 mbrec.tsys[0][i] = tsys(i);213 for (uInt i = 0; i < pksrec.tsys.nelements(); i++) { 214 mbrec.tsys[0][i] = pksrec.tsys(i); 239 215 } 240 216 241 217 for (uInt ipol = 0; ipol < nPol; ipol++) { 242 mbrec.calfctr[0][ipol] = calFctr(ipol);218 mbrec.calfctr[0][ipol] = pksrec.calFctr(ipol); 243 219 } 244 220 245 221 if (cHaveXPol(iIF)) { 246 mbrec.xcalfctr[0][0] = xCalFctr.real();247 mbrec.xcalfctr[0][1] = xCalFctr.imag();222 mbrec.xcalfctr[0][0] = pksrec.xCalFctr.real(); 223 mbrec.xcalfctr[0][1] = pksrec.xCalFctr.imag(); 248 224 } else { 249 225 mbrec.xcalfctr[0][0] = 0.0f; … … 255 231 256 232 for (uInt ipol = 0; ipol < nPol; ipol++) { 257 mbrec.baseLin[0][ipol][0] = baseLin(0,ipol);258 mbrec.baseLin[0][ipol][1] = baseLin(1,ipol);259 260 for (uInt j = 0; j < baseSub.nrow(); j++) {261 mbrec.baseSub[0][ipol][j] = baseSub(j,ipol);233 mbrec.baseLin[0][ipol][0] = pksrec.baseLin(0,ipol); 234 mbrec.baseLin[0][ipol][1] = pksrec.baseLin(1,ipol); 235 236 for (uInt j = 0; j < pksrec.baseSub.nrow(); j++) { 237 mbrec.baseSub[0][ipol][j] = pksrec.baseSub(j,ipol); 262 238 } 263 for (uInt j = baseSub.nrow(); j < 9; j++) {239 for (uInt j = pksrec.baseSub.nrow(); j < 24; j++) { 264 240 mbrec.baseSub[0][ipol][j] = 0.0f; 265 241 } … … 271 247 272 248 Bool delSpectra = False; 273 const Float *specstor = spectra.getStorage(delSpectra);249 const Float *specstor = pksrec.spectra.getStorage(delSpectra); 274 250 mbrec.spectra[0] = (float *)specstor; 275 251 276 252 Bool delFlagged = False; 277 const uChar *flagstor = flagged.getStorage(delFlagged);253 const uChar *flagstor = pksrec.flagged.getStorage(delFlagged); 278 254 mbrec.flagged[0] = (unsigned char *)flagstor; 279 255 … … 281 257 const Complex *xpolstor; 282 258 if (cHaveXPol(iIF)) { 283 xpolstor = xPol.getStorage(delXPol);259 xpolstor = pksrec.xPol.getStorage(delXPol); 284 260 } else { 285 261 xpolstor = 0; … … 289 265 // Finish off with system calibration parameters. 290 266 mbrec.extraSysCal = 1; 291 mbrec.refBeam = refBeam;292 for (uInt i = 0; i < tcal.nelements(); i++) {293 mbrec.tcal[0][i] = tcal(i);294 } 295 strncpy(mbrec.tcalTime, (char *) tcalTime.chars(), 16);296 mbrec.azimuth = azimuth;297 mbrec.elevation = elevation;298 mbrec.parAngle = p arAngle;299 mbrec.focusAxi = focusAxi;300 mbrec.focusTan = focusTan;301 mbrec.focusRot = focusRot;302 mbrec.temp = temperature;303 mbrec.pressure = p ressure;304 mbrec.humidity = humidity;305 mbrec.windSpeed = windSpeed;306 mbrec.windAz = windAz;267 mbrec.refBeam = pksrec.refBeam; 268 for (uInt i = 0; i < pksrec.tcal.nelements(); i++) { 269 mbrec.tcal[0][i] = pksrec.tcal(i); 270 } 271 strncpy(mbrec.tcalTime, (char *)pksrec.tcalTime.chars(), 16); 272 mbrec.azimuth = pksrec.azimuth; 273 mbrec.elevation = pksrec.elevation; 274 mbrec.parAngle = pksrec.parAngle; 275 mbrec.focusAxi = pksrec.focusAxi; 276 mbrec.focusTan = pksrec.focusTan; 277 mbrec.focusRot = pksrec.focusRot; 278 mbrec.temp = pksrec.temperature; 279 mbrec.pressure = pksrec.pressure; 280 mbrec.humidity = pksrec.humidity; 281 mbrec.windSpeed = pksrec.windSpeed; 282 mbrec.windAz = pksrec.windAz; 307 283 308 284 Int status = cSDwriter.write(mbrec); 285 //logMsg(cSDwriter.getMsg()); 286 //cSDwriter.clearMsg(); 309 287 if (status) { 310 cSDwriter.reportError();311 288 status = 1; 312 289 } 313 290 314 spectra.freeStorage(specstor, delSpectra);315 flagged.freeStorage(flagstor, delFlagged);316 xPol.freeStorage(xpolstor, delXPol);291 pksrec.spectra.freeStorage(specstor, delSpectra); 292 pksrec.flagged.freeStorage(flagstor, delFlagged); 293 pksrec.xPol.freeStorage(xpolstor, delXPol); 317 294 318 295 return status; 319 296 } 320 297 298 //------------------------------------------------------- PKSSDwriter::history 299 300 // Write a history record. 301 302 Int PKSSDwriter::history(const String text) 303 { 304 return cSDwriter.history((char *)text.chars()); 305 } 306 307 Int PKSSDwriter::history(const char *text) 308 { 309 return cSDwriter.history((char *)text); 310 } 311 321 312 //--------------------------------------------------------- PKSSDwriter::close 322 313 … … 326 317 { 327 318 cSDwriter.close(); 328 } 319 //logMsg(cSDwriter.getMsg()); 320 //cSDwriter.clearMsg(); 321 }
Note: See TracChangeset
for help on using the changeset viewer.