Changeset 1452 for trunk/external/atnf/PKSIO/PKSMS2writer.cc
- Timestamp:
- 11/19/08 20:41:16 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/external/atnf/PKSIO/PKSMS2writer.cc
r1399 r1452 2 2 //# PKSMS2writer.cc: Class to write Parkes multibeam data to a measurementset. 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: PKSMS2writer.cc,v 19.1 2 2007/11/12 03:37:56cal103 Exp $28 //# $Id: PKSMS2writer.cc,v 19.14 2008-11-17 06:56:13 cal103 Exp $ 29 29 //#--------------------------------------------------------------------------- 30 30 31 #include <atnf/PKSIO/PKSrecord.h> 31 32 #include <atnf/PKSIO/PKSMS2writer.h> 32 33 … … 54 55 PKSMS2writer::PKSMS2writer() 55 56 { 57 cPKSMS = 0x0; 58 59 // By default, messages are written to stderr. 60 initMsg(); 56 61 } 57 62 … … 84 89 const Bool haveBase) 85 90 { 91 if (cPKSMS) { 92 logMsg("ERROR: Output MS already open, close it first."); 93 return 1; 94 } 95 96 // Clear the message stack. 97 clearMsg(); 98 86 99 // Open a MS table. 87 100 TableDesc pksDesc = MS::requiredTableDesc(); … … 369 382 370 383 Int PKSMS2writer::write( 371 const Int scanNo, 372 const Int cycleNo, 373 const Double mjd, 374 const Double interval, 375 const String fieldName, 376 const String srcName, 377 const Vector<Double> srcDir, 378 const Vector<Double> srcPM, 379 const Double srcVel, 380 const String obsMode, 381 const Int IFno, 382 const Double refFreq, 383 const Double bandwidth, 384 const Double freqInc, 385 const Double restFreq, 386 const Vector<Float> tcal, 387 const String tcalTime, 388 const Float azimuth, 389 const Float elevation, 390 const Float parAngle, 391 const Float focusAxi, 392 const Float focusTan, 393 const Float focusRot, 394 const Float temperature, 395 const Float pressure, 396 const Float humidity, 397 const Float windSpeed, 398 const Float windAz, 399 const Int refBeam, 400 const Int beamNo, 401 const Vector<Double> direction, 402 const Vector<Double> scanRate, 403 const Vector<Float> tsys, 404 const Vector<Float> sigma, 405 const Vector<Float> calFctr, 406 const Matrix<Float> baseLin, 407 const Matrix<Float> baseSub, 408 const Matrix<Float> &spectra, 409 const Matrix<uChar> &flagged, 410 const Complex xCalFctr, 411 const Vector<Complex> &xPol) 384 const PKSrecord &pksrec) 412 385 { 413 386 // Extend the time range in the OBSERVATION subtable. 414 387 Vector<Double> timerange(2); 415 388 cObservationCols->timeRange().get(0, timerange); 416 Double time = mjd*86400.0;389 Double time = pksrec.mjd*86400.0; 417 390 if (timerange(0) == 0.0) { 418 391 timerange(0) = time; … … 421 394 cObservationCols->timeRange().put(0, timerange); 422 395 423 Int iIF = IFno - 1;396 Int iIF = pksrec.IFno - 1; 424 397 Int nChan = cNChan(iIF); 425 398 Int nPol = cNPol(iIF); … … 427 400 // IFno is the 1-relative row number in the DATA_DESCRIPTION, 428 401 // SPECTRAL_WINDOW, and POLARIZATION subtables. 429 if (Int(cDataDescription.nrow()) < IFno) {402 if (Int(cDataDescription.nrow()) < pksrec.IFno) { 430 403 // Add a new entry to each subtable. 431 addDataDescriptionEntry(IFno); 432 addSpectralWindowEntry(IFno, nChan, refFreq, bandwidth, freqInc); 433 addPolarizationEntry(IFno, nPol); 404 addDataDescriptionEntry(pksrec.IFno); 405 addSpectralWindowEntry(pksrec.IFno, nChan, pksrec.refFreq, 406 pksrec.bandwidth, pksrec.freqInc); 407 addPolarizationEntry(pksrec.IFno, nPol); 434 408 } 435 409 436 410 // Find or add the source to the SOURCE subtable. 437 Int srcId = addSourceEntry(srcName, srcDir, srcPM, restFreq, srcVel); 438 439 // Find or add the obsMode to the STATE subtable. 440 Int stateId = addStateEntry(obsMode); 411 Int srcId = addSourceEntry(pksrec.srcName, pksrec.srcDir, pksrec.srcPM, 412 pksrec.restFreq, pksrec.srcVel); 413 414 // Find or add the obsType to the STATE subtable. 415 Int stateId = addStateEntry(pksrec.obsType); 441 416 442 417 // FIELD subtable. 443 Int fieldId = addFieldEntry(fieldName, time, direction, scanRate, srcId); 418 Vector<Double> scanRate(2); 419 scanRate(0) = pksrec.scanRate(0); 420 scanRate(1) = pksrec.scanRate(1); 421 Int fieldId = addFieldEntry(pksrec.fieldName, time, pksrec.direction, 422 scanRate, srcId); 444 423 445 424 // POINTING subtable. 446 addPointingEntry(time, interval, fieldName, direction, scanRate); 425 addPointingEntry(time, pksrec.interval, pksrec.fieldName, pksrec.direction, 426 scanRate); 447 427 448 428 // SYSCAL subtable. 449 addSysCalEntry(beamNo, iIF, time, interval, tcal, tsys); 429 addSysCalEntry(pksrec.beamNo, iIF, time, pksrec.interval, pksrec.tcal, 430 pksrec.tsys); 450 431 451 432 // Handle weather information. … … 453 434 Int nWeather = wTime.nrow(); 454 435 if (nWeather == 0 || time > wTime(nWeather-1)) { 455 addWeatherEntry(time, interval, pressure, humidity, temperature); 436 addWeatherEntry(time, pksrec.interval, pksrec.pressure, pksrec.humidity, 437 pksrec.temperature); 456 438 } 457 439 … … 465 447 cMSCols->antenna1().put(irow, 0); 466 448 cMSCols->antenna2().put(irow, 0); 467 cMSCols->feed1().put(irow, beamNo-1);468 cMSCols->feed2().put(irow, beamNo-1);449 cMSCols->feed1().put(irow, pksrec.beamNo-1); 450 cMSCols->feed2().put(irow, pksrec.beamNo-1); 469 451 cMSCols->dataDescId().put(irow, iIF); 470 452 cMSCols->processorId().put(irow, 0); … … 472 454 473 455 // Non-key attributes. 474 cMSCols->interval().put(irow, interval);475 cMSCols->exposure().put(irow, interval);456 cMSCols->interval().put(irow, pksrec.interval); 457 cMSCols->exposure().put(irow, pksrec.interval); 476 458 cMSCols->timeCentroid().put(irow, time); 477 cMSCols->scanNumber().put(irow, scanNo);459 cMSCols->scanNumber().put(irow, pksrec.scanNo); 478 460 cMSCols->arrayId().put(irow, 0); 479 461 cMSCols->observationId().put(irow, 0); … … 485 467 // Baseline fit parameters. 486 468 if (cHaveBase) { 487 cBaseLinCol->put(irow, baseLin);488 489 if ( baseSub.nrow() == 9) {490 cBaseSubCol->put(irow, baseSub);469 cBaseLinCol->put(irow, pksrec.baseLin); 470 471 if (pksrec.baseSub.nrow() == 9) { 472 cBaseSubCol->put(irow, pksrec.baseSub); 491 473 492 474 } else { 493 475 Matrix<Float> tmp(9, 2, 0.0f); 494 476 for (Int ipol = 0; ipol < nPol; ipol++) { 495 for (uInt j = 0; j < baseSub.nrow(); j++) {496 tmp(j,ipol) = baseSub(j,ipol);477 for (uInt j = 0; j < pksrec.baseSub.nrow(); j++) { 478 tmp(j,ipol) = pksrec.baseSub(j,ipol); 497 479 } 498 480 } … … 506 488 for (Int ipol = 0; ipol < nPol; ipol++) { 507 489 for (Int ichan = 0; ichan < nChan; ichan++) { 508 tmpData(ipol,ichan) = spectra(ichan,ipol);509 tmpFlag(ipol,ichan) = flagged(ichan,ipol);490 tmpData(ipol,ichan) = pksrec.spectra(ichan,ipol); 491 tmpFlag(ipol,ichan) = pksrec.flagged(ichan,ipol); 510 492 } 511 493 } 512 494 513 cCalFctrCol->put(irow, calFctr);495 cCalFctrCol->put(irow, pksrec.calFctr); 514 496 cMSCols->floatData().put(irow, tmpData); 515 497 cMSCols->flag().put(irow, tmpFlag); … … 517 499 // Cross-polarization spectra. 518 500 if (cHaveXPol(iIF)) { 519 cXCalFctrCol->put(irow, xCalFctr);520 cMSCols->data().put(irow, xPol);521 } 522 523 cMSCols->sigma().put(irow, sigma);501 cXCalFctrCol->put(irow, pksrec.xCalFctr); 502 cMSCols->data().put(irow, pksrec.xPol); 503 } 504 505 cMSCols->sigma().put(irow, pksrec.sigma); 524 506 525 507 Vector<Float> weight(1, 1.0f); … … 586 568 cSysCal = MSSysCal(); 587 569 cWeather = MSWeather(); 570 588 571 // Release the main table. 589 delete cPKSMS; cPKSMS=0; 572 delete cPKSMS; 573 cPKSMS = 0x0; 590 574 } 591 575 … … 984 968 985 969 Int PKSMS2writer::addStateEntry( 986 const String obs Mode)970 const String obsType) 987 971 { 988 972 // Look for an entry in the STATE subtable. 989 973 for (uInt n = 0; n < cStateCols->nrow(); n++) { 990 if (cStateCols->obsMode()(n) == obs Mode) {974 if (cStateCols->obsMode()(n) == obsType) { 991 975 return n; 992 976 } … … 998 982 999 983 // Data. 1000 if (obs Mode.contains("RF")) {984 if (obsType.contains("RF")) { 1001 985 cStateCols->sig().put(n, False); 1002 986 cStateCols->ref().put(n, True); 1003 } else if (!obs Mode.contains("PA")) {987 } else if (!obsType.contains("PA")) { 1004 988 // Signal and reference are both false for "paddle" data. 1005 989 cStateCols->sig().put(n, True); … … 1010 994 cStateCols->cal().put(n, 0.0); 1011 995 cStateCols->subScan().put(n, 0); 1012 cStateCols->obsMode().put(n, obs Mode);996 cStateCols->obsMode().put(n, obsType); 1013 997 1014 998 // Flags.
Note: See TracChangeset
for help on using the changeset viewer.