Changeset 1757 for branches/alma/external/atnf/PKSIO/PKSMS2writer.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/PKSMS2writer.cc
r1453 r1757 2 2 //# PKSMS2writer.cc: Class to write Parkes multibeam data to a measurementset. 3 3 //#--------------------------------------------------------------------------- 4 //# Copyright (C) 2000-20065 //# Associated Universities, Inc. Washington DC, USA.4 //# livedata - processing pipeline for single-dish, multibeam spectral data. 5 //# Copyright (C) 2000-2009, Australia Telescope National Facility, CSIRO 6 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. 7 //# This file is part of livedata. 11 8 //# 12 //# This library is distributed in the hope that it will be useful, but13 //# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY14 //# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public15 //# License for more details.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. 16 13 //# 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. 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. 20 18 //# 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 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/>. 27 21 //# 28 //# $Id: PKSMS2writer.cc,v 19.11 2006/11/06 22:25:22 mmarquar Exp $ 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: PKSMS2writer.cc,v 19.16 2009-09-29 07:33:38 cal103 Exp $ 29 32 //#--------------------------------------------------------------------------- 30 33 34 #include <atnf/PKSIO/PKSrecord.h> 31 35 #include <atnf/PKSIO/PKSMS2writer.h> 32 36 … … 49 53 #include <tables/Tables/TiledShapeStMan.h> 50 54 55 // Class name 56 const string className = "PKSMS2writer" ; 57 51 58 //------------------------------------------------- PKSMS2writer::PKSMS2writer 52 59 … … 55 62 PKSMS2writer::PKSMS2writer() 56 63 { 64 cPKSMS = 0x0; 57 65 } 58 66 … … 77 85 const Vector<Double> antPosition, 78 86 const String obsMode, 87 const String bunit, 79 88 const Float equinox, 80 89 const String dopplerFrame, … … 82 91 const Vector<uInt> nPol, 83 92 const Vector<Bool> haveXPol, 84 const Bool haveBase, 85 const String fluxUnit) 86 { 93 const Bool haveBase) 94 { 95 const string methodName = "create()" ; 96 LogIO os( LogOrigin( className, methodName, WHERE ) ) ; 97 98 if (cPKSMS) { 99 os << LogIO::SEVERE << "Output MS already open, close it first." << LogIO::POST ; 100 return 1; 101 } 102 87 103 // Open a MS table. 88 104 TableDesc pksDesc = MS::requiredTableDesc(); … … 93 109 94 110 Int maxNPol = max(cNPol); 95 cGBT = cAPEX = cSMT = cALMA = False; 96 111 cGBT = cAPEX = cSMT = cALMA = cATF = False; 112 113 String telName = antName; 97 114 // check if it is GBT data 98 115 if (antName.contains("GBT")) { … … 108 125 cALMA = True; 109 126 } 127 else if (antName.contains("ATF")) { 128 cATF = True; 129 telName="ATF"; 130 } 110 131 111 112 113 //cGBT = antName.contains("GBT");114 //cAPEX = antName.contains("APEX");115 //cSMT = antName.contains("HHT");116 //cALMA = antName.contains("ALMA");117 118 132 // Add the non-standard CALFCTR column. 119 133 pksDesc.addColumn(ArrayColumnDesc<Float>("CALFCTR", "Calibration factors", … … 125 139 // define("UNIT", String("Jy")); 126 140 pksDesc.rwColumnDesc(MS::columnName(MS::FLOAT_DATA)).rwKeywordSet(). 127 define("UNIT", fluxUnit);141 define("UNIT", bunit); 128 142 pksDesc.rwColumnDesc(MS::columnName(MS::FLOAT_DATA)).rwKeywordSet(). 129 143 define("MEASURE_TYPE", ""); … … 134 148 IPosition(2,2,maxNPol), ColumnDesc::Direct)); 135 149 pksDesc.addColumn(ArrayColumnDesc<Float>("BASESUB", "Baseline subtracted", 136 IPosition(2, 9,maxNPol), ColumnDesc::Direct));150 IPosition(2,24,maxNPol), ColumnDesc::Direct)); 137 151 } 138 152 … … 147 161 // define("UNIT", "Jy"); 148 162 pksDesc.rwColumnDesc(MS::columnName(MS::DATA)).rwKeywordSet(). 149 define("UNIT", fluxUnit);163 define("UNIT", bunit); 150 164 pksDesc.rwColumnDesc(MS::columnName(MS::DATA)).rwKeywordSet(). 151 165 define("MEASURE_TYPE", ""); … … 387 401 addFeedEntry(); 388 402 //addObservationEntry(observer, project); 389 addObservationEntry(observer, project, antName);403 addObservationEntry(observer, project, telName); 390 404 addProcessorEntry(); 391 405 … … 397 411 // Write the next data record. 398 412 413 /** 399 414 Int PKSMS2writer::write( 400 415 const Int scanNo, … … 438 453 const Matrix<Float> &spectra, 439 454 const Matrix<uChar> &flagged, 455 const uInt flagrow, 440 456 const Complex xCalFctr, 441 457 const Vector<Complex> &xPol) 458 **/ 459 Int PKSMS2writer::write( 460 const PKSrecord &pksrec) 442 461 { 443 462 // Extend the time range in the OBSERVATION subtable. 444 463 Vector<Double> timerange(2); 445 464 cObservationCols->timeRange().get(0, timerange); 446 Double time = mjd*86400.0;465 Double time = pksrec.mjd*86400.0; 447 466 if (timerange(0) == 0.0) { 448 467 timerange(0) = time; … … 451 470 cObservationCols->timeRange().put(0, timerange); 452 471 453 Int iIF = IFno - 1;472 Int iIF = pksrec.IFno - 1; 454 473 Int nChan = cNChan(iIF); 455 474 Int nPol = cNPol(iIF); … … 457 476 // IFno is the 1-relative row number in the DATA_DESCRIPTION, 458 477 // SPECTRAL_WINDOW, and POLARIZATION subtables. 459 if (Int(cDataDescription.nrow()) < IFno) {478 if (Int(cDataDescription.nrow()) < pksrec.IFno) { 460 479 // Add a new entry to each subtable. 461 addDataDescriptionEntry(IFno); 462 addSpectralWindowEntry(IFno, nChan, refFreq, bandwidth, freqInc); 463 addPolarizationEntry(IFno, nPol); 480 addDataDescriptionEntry(pksrec.IFno); 481 addSpectralWindowEntry(pksrec.IFno, nChan, pksrec.refFreq, 482 pksrec.bandwidth, pksrec.freqInc); 483 addPolarizationEntry(pksrec.IFno, nPol); 464 484 } 465 485 466 486 // Find or add the source to the SOURCE subtable. 467 Int srcId = addSourceEntry(srcName, srcDir, srcPM, restFreq, srcVel); 487 Int srcId = addSourceEntry(pksrec.srcName, pksrec.srcDir, pksrec.srcPM, 488 pksrec.restFreq, pksrec.srcVel); 468 489 469 490 // Find or add the obsMode to the STATE subtable. 470 Int stateId = addStateEntry( obsMode);491 Int stateId = addStateEntry(pksrec.obsType); 471 492 472 493 // FIELD subtable. 473 Int fieldId = addFieldEntry(fieldName, time, direction, scanRate, srcId); 494 //Vector<Double> scanRate(2); 495 //scanRate(0) = pksrec.scanRate(0); 496 //scanRate(1) = pksrec.scanRate(1); 497 Int fieldId = addFieldEntry(pksrec.fieldName, time, pksrec.direction, 498 pksrec.scanRate, srcId); 474 499 475 500 // POINTING subtable. 476 addPointingEntry(time, interval, fieldName, direction, scanRate); 501 addPointingEntry(time, pksrec.interval, pksrec.fieldName, pksrec.direction, 502 pksrec.scanRate); 477 503 478 504 // SYSCAL subtable. 479 addSysCalEntry( beamNo, iIF, time, interval, tcal, tsys, nPol);480 505 addSysCalEntry(pksrec.beamNo, iIF, time, pksrec.interval, pksrec.tcal, 506 pksrec.tsys, nPol); 481 507 482 508 // Handle weather information. … … 484 510 Int nWeather = wTime.nrow(); 485 511 if (nWeather == 0 || time > wTime(nWeather-1)) { 486 addWeatherEntry(time, interval, pressure, humidity, temperature); 512 addWeatherEntry(time, pksrec.interval, pksrec.pressure, pksrec.humidity, 513 pksrec.temperature); 487 514 } 488 515 … … 496 523 cMSCols->antenna1().put(irow, 0); 497 524 cMSCols->antenna2().put(irow, 0); 498 cMSCols->feed1().put(irow, beamNo-1);499 cMSCols->feed2().put(irow, beamNo-1);525 cMSCols->feed1().put(irow, pksrec.beamNo-1); 526 cMSCols->feed2().put(irow, pksrec.beamNo-1); 500 527 cMSCols->dataDescId().put(irow, iIF); 501 528 cMSCols->processorId().put(irow, 0); … … 503 530 504 531 // Non-key attributes. 505 cMSCols->interval().put(irow, interval);506 cMSCols->exposure().put(irow, interval);532 cMSCols->interval().put(irow, pksrec.interval); 533 cMSCols->exposure().put(irow, pksrec.interval); 507 534 cMSCols->timeCentroid().put(irow, time); 508 cMSCols->scanNumber().put(irow, scanNo);535 cMSCols->scanNumber().put(irow, pksrec.scanNo); 509 536 cMSCols->arrayId().put(irow, 0); 510 537 cMSCols->observationId().put(irow, 0); … … 516 543 // Baseline fit parameters. 517 544 if (cHaveBase) { 518 cBaseLinCol->put(irow, baseLin);519 520 if ( baseSub.nrow() == 9) {521 cBaseSubCol->put(irow, baseSub);545 cBaseLinCol->put(irow, pksrec.baseLin); 546 547 if (pksrec.baseSub.nrow() == 24) { 548 cBaseSubCol->put(irow, pksrec.baseSub); 522 549 523 550 } else { 524 Matrix<Float> tmp( 9, 2, 0.0f);551 Matrix<Float> tmp(24, 2, 0.0f); 525 552 for (Int ipol = 0; ipol < nPol; ipol++) { 526 for (uInt j = 0; j < baseSub.nrow(); j++) {527 tmp(j,ipol) = baseSub(j,ipol);553 for (uInt j = 0; j < pksrec.baseSub.nrow(); j++) { 554 tmp(j,ipol) = pksrec.baseSub(j,ipol); 528 555 } 529 556 } … … 531 558 } 532 559 } 560 533 561 // Transpose spectra. 534 562 Matrix<Float> tmpData(nPol, nChan); … … 536 564 for (Int ipol = 0; ipol < nPol; ipol++) { 537 565 for (Int ichan = 0; ichan < nChan; ichan++) { 538 tmpData(ipol,ichan) = spectra(ichan,ipol);539 tmpFlag(ipol,ichan) = flagged(ichan,ipol);566 tmpData(ipol,ichan) = pksrec.spectra(ichan,ipol); 567 tmpFlag(ipol,ichan) = pksrec.flagged(ichan,ipol); 540 568 } 541 569 } 542 cCalFctrCol->put(irow, calFctr); 570 571 cCalFctrCol->put(irow, pksrec.calFctr); 543 572 cMSCols->floatData().put(irow, tmpData); 544 573 cMSCols->flag().put(irow, tmpFlag); … … 546 575 // Cross-polarization spectra. 547 576 if (cHaveXPol(iIF)) { 548 cXCalFctrCol->put(irow, xCalFctr);549 cMSCols->data().put(irow, xPol);550 } 551 552 cMSCols->sigma().put(irow, sigma);577 cXCalFctrCol->put(irow, pksrec.xCalFctr); 578 cMSCols->data().put(irow, pksrec.xPol); 579 } 580 581 cMSCols->sigma().put(irow, pksrec.sigma); 553 582 554 583 //Vector<Float> weight(1, 1.0f); … … 563 592 //cMSCols->flag().put(irow, flags.xyPlane(0)); 564 593 cMSCols->flagCategory().put(irow, flags); 565 cMSCols->flagRow().put(irow, False); 594 // Row-based flagging info. (True:>0, False:0) 595 cMSCols->flagRow().put(irow, (pksrec.flagrow > 0)); 596 566 597 567 598 return 0; … … 601 632 delete cXCalFctrCol; cXCalFctrCol=0; 602 633 } 603 634 604 635 // Release all subtables. 605 636 cAntenna = MSAntenna(); … … 620 651 cWeather = MSWeather(); 621 652 // Release the main table. 622 delete cPKSMS; cPKSMS=0; 653 delete cPKSMS; 654 cPKSMS=0x0; 623 655 } 624 656 … … 649 681 } 650 682 else if (cALMA) { 683 // this needs to be changed in future... 651 684 cAntennaCols->station().put(n, "CHAJNANTOR"); 685 cAntennaCols->dishDiameter().put(n, 12.0); 686 } 687 else if (cATF) { 688 //pad name for the antenna is static... 689 String stname="unknown"; 690 if (antName.contains("DV")) { 691 stname="PAD001"; 692 } 693 if (antName.contains("DA")) { 694 stname="PAD002"; 695 } 696 cAntennaCols->station().put(n, stname); 652 697 cAntennaCols->dishDiameter().put(n, 12.0); 653 698 } … … 1095 1140 1096 1141 Int PKSMS2writer::addStateEntry( 1097 const String obs Mode)1142 const String obsType) 1098 1143 { 1099 1144 // Look for an entry in the STATE subtable. 1100 1145 for (uInt n = 0; n < cStateCols->nrow(); n++) { 1101 if (cStateCols->obsMode()(n) == obs Mode) {1146 if (cStateCols->obsMode()(n) == obsType) { 1102 1147 return n; 1103 1148 } … … 1109 1154 1110 1155 // Data. 1111 if (obs Mode.contains("RF")) {1156 if (obsType.contains("RF")) { 1112 1157 cStateCols->sig().put(n, False); 1113 1158 cStateCols->ref().put(n, True); 1114 } else if (!obs Mode.contains("PA")) {1159 } else if (!obsType.contains("PA")) { 1115 1160 // Signal and reference are both false for "paddle" data. 1116 1161 cStateCols->sig().put(n, True); … … 1121 1166 cStateCols->cal().put(n, 0.0); 1122 1167 cStateCols->subScan().put(n, 0); 1123 cStateCols->obsMode().put(n, obs Mode);1168 cStateCols->obsMode().put(n, obsType); 1124 1169 1125 1170 // Flags.
Note: See TracChangeset
for help on using the changeset viewer.