Ignore:
Timestamp:
06/09/10 19:03:06 (14 years ago)
Author:
Kana Sugimoto
Message:

New Development: Yes

JIRA Issue: Yes (CAS-2211)

Ready for Test: Yes

Interface Changes: Yes

What Interface Changed: ASAP 3.0.0 interface changes

Test Programs:

Put in Release Notes: Yes

Module(s): all the CASA sd tools and tasks are affected.

Description: Merged ATNF-ASAP 3.0.0 developments to CASA (alma) branch.

Note you also need to update casa/code/atnf.


Location:
branches/alma
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/alma

  • branches/alma/external/atnf/PKSIO/PKSMS2writer.cc

    r1453 r1757  
    22//# PKSMS2writer.cc: Class to write Parkes multibeam data to a measurementset.
    33//#---------------------------------------------------------------------------
    4 //# Copyright (C) 2000-2006
    5 //# 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
    66//#
    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.
    118//#
    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.
     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.
    1613//#
    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.
    2018//#
    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/>.
    2721//#
    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 $
    2932//#---------------------------------------------------------------------------
    3033
     34#include <atnf/PKSIO/PKSrecord.h>
    3135#include <atnf/PKSIO/PKSMS2writer.h>
    3236
     
    4953#include <tables/Tables/TiledShapeStMan.h>
    5054
     55// Class name
     56const string className = "PKSMS2writer" ;
     57
    5158//------------------------------------------------- PKSMS2writer::PKSMS2writer
    5259
     
    5562PKSMS2writer::PKSMS2writer()
    5663{
     64  cPKSMS = 0x0;
    5765}
    5866
     
    7785        const Vector<Double> antPosition,
    7886        const String obsMode,
     87        const String bunit,
    7988        const Float  equinox,
    8089        const String dopplerFrame,
     
    8291        const Vector<uInt> nPol,
    8392        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
    87103  // Open a MS table.
    88104  TableDesc pksDesc = MS::requiredTableDesc();
     
    93109
    94110  Int maxNPol = max(cNPol);
    95   cGBT = cAPEX = cSMT = cALMA = False;
    96 
     111  cGBT = cAPEX = cSMT = cALMA = cATF = False;
     112
     113  String telName = antName;
    97114  // check if it is GBT data
    98115  if (antName.contains("GBT")) {
     
    108125    cALMA = True;
    109126  }
     127  else if (antName.contains("ATF")) {
     128    cATF = True;
     129    telName="ATF";
     130  }
    110131 
    111 
    112    
    113   //cGBT = antName.contains("GBT");
    114   //cAPEX = antName.contains("APEX");
    115   //cSMT = antName.contains("HHT");
    116   //cALMA = antName.contains("ALMA");
    117 
    118132  // Add the non-standard CALFCTR column.
    119133  pksDesc.addColumn(ArrayColumnDesc<Float>("CALFCTR", "Calibration factors",
     
    125139  //              define("UNIT", String("Jy"));
    126140  pksDesc.rwColumnDesc(MS::columnName(MS::FLOAT_DATA)).rwKeywordSet().
    127                 define("UNIT", fluxUnit);
     141                define("UNIT", bunit);
    128142  pksDesc.rwColumnDesc(MS::columnName(MS::FLOAT_DATA)).rwKeywordSet().
    129143                define("MEASURE_TYPE", "");
     
    134148                IPosition(2,2,maxNPol), ColumnDesc::Direct));
    135149    pksDesc.addColumn(ArrayColumnDesc<Float>("BASESUB", "Baseline subtracted",
    136                 IPosition(2,9,maxNPol), ColumnDesc::Direct));
     150                IPosition(2,24,maxNPol), ColumnDesc::Direct));
    137151  }
    138152
     
    147161    //            define("UNIT", "Jy");
    148162    pksDesc.rwColumnDesc(MS::columnName(MS::DATA)).rwKeywordSet().
    149                 define("UNIT", fluxUnit);
     163                define("UNIT", bunit);
    150164    pksDesc.rwColumnDesc(MS::columnName(MS::DATA)).rwKeywordSet().
    151165                define("MEASURE_TYPE", "");
     
    387401  addFeedEntry();
    388402  //addObservationEntry(observer, project);
    389   addObservationEntry(observer, project, antName);
     403  addObservationEntry(observer, project, telName);
    390404  addProcessorEntry();
    391405
     
    397411// Write the next data record.
    398412
     413/**
    399414Int PKSMS2writer::write(
    400415        const Int             scanNo,
     
    438453        const Matrix<Float>   &spectra,
    439454        const Matrix<uChar>   &flagged,
     455        const uInt            flagrow,
    440456        const Complex         xCalFctr,
    441457        const Vector<Complex> &xPol)
     458**/
     459Int PKSMS2writer::write(
     460        const PKSrecord &pksrec)
    442461{
    443462  // Extend the time range in the OBSERVATION subtable.
    444463  Vector<Double> timerange(2);
    445464  cObservationCols->timeRange().get(0, timerange);
    446   Double time = mjd*86400.0;
     465  Double time = pksrec.mjd*86400.0;
    447466  if (timerange(0) == 0.0) {
    448467    timerange(0) = time;
     
    451470  cObservationCols->timeRange().put(0, timerange);
    452471
    453   Int iIF = IFno - 1;
     472  Int iIF = pksrec.IFno - 1;
    454473  Int nChan = cNChan(iIF);
    455474  Int nPol  = cNPol(iIF);
     
    457476  // IFno is the 1-relative row number in the DATA_DESCRIPTION,
    458477  // SPECTRAL_WINDOW, and POLARIZATION subtables.
    459   if (Int(cDataDescription.nrow()) < IFno) {
     478  if (Int(cDataDescription.nrow()) < pksrec.IFno) {
    460479    // 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);
    464484  }
    465485
    466486  // 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);
    468489
    469490  // Find or add the obsMode to the STATE subtable.
    470   Int stateId = addStateEntry(obsMode);
     491  Int stateId = addStateEntry(pksrec.obsType);
    471492
    472493  // 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);
    474499
    475500  // POINTING subtable.
    476   addPointingEntry(time, interval, fieldName, direction, scanRate);
     501  addPointingEntry(time, pksrec.interval, pksrec.fieldName, pksrec.direction,
     502    pksrec.scanRate);
    477503
    478504  // 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);
    481507
    482508  // Handle weather information.
     
    484510  Int nWeather = wTime.nrow();
    485511  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);
    487514  }
    488515
     
    496523  cMSCols->antenna1().put(irow, 0);
    497524  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);
    500527  cMSCols->dataDescId().put(irow, iIF);
    501528  cMSCols->processorId().put(irow, 0);
     
    503530
    504531  // 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);
    507534  cMSCols->timeCentroid().put(irow, time);
    508   cMSCols->scanNumber().put(irow, scanNo);
     535  cMSCols->scanNumber().put(irow, pksrec.scanNo);
    509536  cMSCols->arrayId().put(irow, 0);
    510537  cMSCols->observationId().put(irow, 0);
     
    516543  // Baseline fit parameters.
    517544  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);
    522549
    523550    } else {
    524       Matrix<Float> tmp(9, 2, 0.0f);
     551      Matrix<Float> tmp(24, 2, 0.0f);
    525552      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);
    528555        }
    529556      }
     
    531558    }
    532559  }
     560
    533561  // Transpose spectra.
    534562  Matrix<Float> tmpData(nPol, nChan);
     
    536564  for (Int ipol = 0; ipol < nPol; ipol++) {
    537565    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);
    540568    }
    541569  }
    542   cCalFctrCol->put(irow, calFctr);
     570
     571  cCalFctrCol->put(irow, pksrec.calFctr);
    543572  cMSCols->floatData().put(irow, tmpData);
    544573  cMSCols->flag().put(irow, tmpFlag);
     
    546575  // Cross-polarization spectra.
    547576  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);
    553582
    554583  //Vector<Float> weight(1, 1.0f);
     
    563592  //cMSCols->flag().put(irow, flags.xyPlane(0));
    564593  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
    566597
    567598  return 0;
     
    601632    delete cXCalFctrCol; cXCalFctrCol=0;
    602633  }
    603  
     634
    604635  // Release all subtables.
    605636  cAntenna         = MSAntenna();
     
    620651  cWeather         = MSWeather();
    621652  // Release the main table.
    622   delete cPKSMS; cPKSMS=0;
     653  delete cPKSMS;
     654  cPKSMS=0x0;
    623655}
    624656
     
    649681  }
    650682  else if (cALMA) {
     683    // this needs to be changed in future...
    651684    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);
    652697    cAntennaCols->dishDiameter().put(n, 12.0);
    653698  }
     
    10951140
    10961141Int PKSMS2writer::addStateEntry(
    1097         const String obsMode)
     1142        const String obsType)
    10981143{
    10991144  // Look for an entry in the STATE subtable.
    11001145  for (uInt n = 0; n < cStateCols->nrow(); n++) {
    1101     if (cStateCols->obsMode()(n) == obsMode) {
     1146    if (cStateCols->obsMode()(n) == obsType) {
    11021147      return n;
    11031148    }
     
    11091154
    11101155  // Data.
    1111   if (obsMode.contains("RF")) {
     1156  if (obsType.contains("RF")) {
    11121157    cStateCols->sig().put(n, False);
    11131158    cStateCols->ref().put(n, True);
    1114   } else if (!obsMode.contains("PA")) {
     1159  } else if (!obsType.contains("PA")) {
    11151160    // Signal and reference are both false for "paddle" data.
    11161161    cStateCols->sig().put(n, True);
     
    11211166  cStateCols->cal().put(n, 0.0);
    11221167  cStateCols->subScan().put(n, 0);
    1123   cStateCols->obsMode().put(n, obsMode);
     1168  cStateCols->obsMode().put(n, obsType);
    11241169
    11251170  // Flags.
Note: See TracChangeset for help on using the changeset viewer.