Changeset 1453 for branches/alma


Ignore:
Timestamp:
11/27/08 12:47:15 (15 years ago)
Author:
TakTsutsumi
Message:

New Development: No

JIRA Issue: No

Ready to Release: Yes

Interface Changes: Yes

What Interface Changed: many

Test Programs: sd.scantable(), sd.scantable.save()

Put in Release Notes: N/A

Description: copied from current casapy code tree


Location:
branches/alma/external/atnf/PKSIO
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • branches/alma/external/atnf/PKSIO/FITSreader.cc

    r1325 r1453  
    2727//#                        AUSTRALIA
    2828//#
    29 //# $Id: FITSreader.cc,v 19.2 2006/05/19 02:14:50 mcalabre Exp $
     29//# $Id$
    3030//#---------------------------------------------------------------------------
    3131//# The FITSreader class is an abstract base class for the Parkes Multibeam
  • branches/alma/external/atnf/PKSIO/FITSreader.h

    r1325 r1453  
    2727//#                        AUSTRALIA
    2828//#
    29 //# $Id: FITSreader.h,v 19.5 2006/05/19 02:18:02 mcalabre Exp $
     29//# $Id$
    3030//#---------------------------------------------------------------------------
    3131//# The FITSreader class is an abstract base class for the Parkes Multibeam
  • branches/alma/external/atnf/PKSIO/MBFITSreader.cc

    r1372 r1453  
    22//# MBFITSreader.cc: ATNF single-dish RPFITS reader.
    33//#---------------------------------------------------------------------------
    4 //# Copyright (C) 2000-2007
     4//# Copyright (C) 2000-2006
    55//# Mark Calabretta, ATNF
    66//#
     
    2727//#                        AUSTRALIA
    2828//#
    29 //# $Id: MBFITSreader.cc,v 19.34 2007/07/02 06:12:18 cal103 Exp $
     29//# $Id$
    3030//#---------------------------------------------------------------------------
    3131//# The MBFITSreader class reads single dish RPFITS files (such as Parkes
     
    8181  cRefChan   = 0x0;
    8282
    83   cVis = 0x0;
    84   cWgt = 0x0;
     83  cVis = new float[2*4*8163];
    8584
    8685  cBeamSel   = 0x0;
     
    9291
    9392  cMBopen = 0;
     93  jstat = -3;
    9494}
    9595
     
    127127
    128128  // Open the RPFITS file.
    129   int jstat = -3;
    130   rpfitsin_(&jstat, cVis, cWgt, &cBaseline, &cUTC, &cU, &cV, &cW, &cFlag,
    131             &cBin, &cIFno, &cSrcNo);
     129  rpfitsin_(&jstat, cVis, weight, &baseline, &ut, &u, &v, &w, &flag, &bin,
     130            &if_no, &sourceno);
    132131
    133132  if (jstat) {
    134     fprintf(stderr, "ERROR, failed to open MBFITS file: %s\n", rpname);
     133    fprintf(stderr, "Failed to open MBFITS file: %s\n", rpname);
    135134    return 1;
    136135  }
     
    148147  // Read the first header.
    149148  jstat = -1;
    150   rpfitsin_(&jstat, cVis, cWgt, &cBaseline, &cUTC, &cU, &cV, &cW, &cFlag,
    151             &cBin, &cIFno, &cSrcNo);
     149  rpfitsin_(&jstat, cVis, weight, &baseline, &ut, &u, &v, &w, &flag, &bin,
     150            &if_no, &sourceno);
    152151
    153152  if (jstat) {
    154     fprintf(stderr, "ERROR, failed to read MBFITS header: %s\n", rpname);
     153    fprintf(stderr, "Failed to read MBFITS header: %s\n", rpname);
    155154    close();
    156155    return 1;
     
    160159  cMopra = strncmp(names_.instrument, "ATMOPRA", 7) == 0;
    161160
    162   // Non-ATNF data may not store the position in (u,v,w).
    163   if (strncmp(names_.sta, "tid", 3) == 0) {
    164     fprintf(stderr, "WARNING, found Tidbinbilla data");
    165     cSUpos = 1;
    166   } else if (strncmp(names_.sta, "HOB", 3) == 0) {
    167     fprintf(stderr, "WARNING, found Hobart data");
    168     cSUpos = 1;
    169   } else if (strncmp(names_.sta, "CED", 3) == 0) {
    170     fprintf(stderr, "WARNING, found Ceduna data");
    171     cSUpos = 1;
    172   } else {
    173     cSUpos = 0;
    174   }
    175 
    176   if (cSUpos) {
    177     fprintf(stderr, ", using telescope position from SU table.\n");
     161  // Tidbinbilla data has some more.
     162  cTid = strncmp(names_.sta, "tid", 3) == 0;
     163  if (cTid) {
     164    // Telescope position is stored in the source table.
    178165    cInterp = 0;
    179166  }
     
    189176
    190177  if (cNBeam <= 0) {
    191     fprintf(stderr, "ERROR, couldn't determine number of beams.\n");
     178    fprintf(stderr, "Couldn't determine number of beams.\n");
    192179    close();
    193180    return 1;
     
    250237  }
    251238
    252   // Allocate memory for RPFITSIN subroutine arguments.
    253   if (cVis) delete [] cVis;
    254   if (cWgt) delete [] cWgt;
    255   cVis = new float[2*maxProd];
    256   cWgt = new float[maxProd];
     239  // Is the vis array declared by RPFITS.h large enough?
     240  if (8*8193 < maxProd) {
     241    // Need to allocate more memory for RPFITSIN.
     242    cVis = new float[2*maxProd];
     243  }
    257244
    258245  nChan    = cNChan;
     
    291278  // Read the first syscal record.
    292279  if (rpget(1, cEOS)) {
    293     fprintf(stderr, "ERROR, failed to read first syscal record.\n");
     280    fprintf(stderr, "Error: Failed to read first syscal record.\n");
    294281    close();
    295282    return 1;
     
    326313{
    327314  if (!cMBopen) {
    328     fprintf(stderr, "ERROR, an MBFITS file has not been opened.\n");
     315    fprintf(stderr, "An MBFITS file has not been opened.\n");
    329316    return 1;
    330317  }
     
    399386  // Time at start of observation.
    400387  sprintf(datobs, "%-10.10s", names_.datobs);
    401   utc = cUTC;
     388  utc = ut;
    402389
    403390  // Spectral parameters.
     
    448435
    449436  if (!cMBopen) {
    450     fprintf(stderr, "ERROR, an MBFITS file has not been opened.\n");
     437    fprintf(stderr, "An MBFITS file has not been opened.\n");
    451438    return 1;
    452439  }
     
    576563
    577564          if (cNBin > 1 && cNBeamSel > 1) {
    578             fprintf(stderr, "ERROR, cannot handle binning mode for multiple "
     565            fprintf(stderr, "Cannot handle binning mode for multiple "
    579566                            "beams.\n");
    580567            close();
     
    582569          }
    583570
    584           // Allocate buffer data storage; the PKSMBrecord constructor zeroes
    585           // class members such as cycleNo that are tested in the first pass
    586           // below.
     571          // Allocate buffer data storage.
    587572          int nBuff = cNBeamSel * cNBin;
    588573          cBuffer = new PKSMBrecord[nBuff];
     
    599584          cScanNo  = 1;
    600585          cCycleNo = 0;
    601           cPrevUTC = 0.0;
     586          cUTC = 0.0;
    602587          cStaleness = new int[cNBeamSel];
    603588          for (int iBeamSel = 0; iBeamSel < cNBeamSel; iBeamSel++) {
     
    610595          cScanNo++;
    611596          cCycleNo = 0;
    612           cPrevUTC = 0.0;
     597          cUTC = 0.0;
    613598        }
    614599
    615600        // Apply beam selection.
    616         beamNo = int(cBaseline / 256.0);
     601        beamNo = int(baseline / 256.0);
    617602        iBeamSel = cBeamSel[beamNo-1];
    618603        if (iBeamSel < 0) continue;
    619604
    620605        // Sanity check (mainly for MOPS).
    621         if (cIFno > cNIF) continue;
     606        if (if_no > cNIF) continue;
    622607
    623608        // Apply IF selection.
    624         iIFSel = cIFSel[cIFno - 1];
     609        iIFSel = cIFSel[if_no - 1];
    625610        if (iIFSel < 0) continue;
    626611
    627612        sprintf(cDateObs, "%-10.10s", names_.datobs);
    628613
    629         // Check for change-of-day.
    630         if (cUTC < cPrevUTC - 85800.0) {
    631           cUTC += 86400.0;
     614        // Change-of-day; note that the ut variable from RPFITS.h is global
     615        // and will be preserved between calls to this function.
     616        if (ut < cUTC - 85800.0) {
     617          ut += 86400.0;
     618        }
     619
     620        // New integration cycle?
     621        if (ut > cUTC) {
     622          cCycleNo++;
     623          cUTC = ut + 0.0001;
    632624        }
    633625
    634626        if (cNBin > 1) {
    635627          // Binning mode: correct the time.
    636           cUTC += param_.intbase * (cBin - (cNBin + 1)/2.0);
    637         }
    638 
    639         // New integration cycle?
    640         if (cUTC > cPrevUTC) {
    641           cCycleNo++;
    642           cPrevUTC = cUTC + 0.0001;
     628          ut += param_.intbase * (bin - (cNBin + 1)/2.0);
    643629        }
    644630
    645631        // Compute buffer number.
    646632        iMBuff = cBuffer + iBeamSel;
    647         if (cNBin > 1) iMBuff += cNBeamSel*(cBin-1);
     633        if (cNBin > 1) iMBuff += cNBeamSel*(bin-1);
    648634
    649635        if (cCycleNo < iMBuff->cycleNo) {
     
    654640
    655641        // Begin flush cycle?
    656         if (cEOS || (iMBuff->nIF && cUTC > iMBuff->utc + 0.0001)) {
     642        if (cEOS || (iMBuff->nIF && ut > iMBuff->utc + 0.0001)) {
    657643          cFlushing = 1;
    658644          cFlushBin = 0;
     
    661647
    662648#ifdef PKSIO_DEBUG
    663         printf(" In:%4d%4d%3d%3d\n", cScanNo, cCycleNo, beamNo, cIFno);
     649        printf(" In:%4d%4d%3d%3d\n", cScanNo, cCycleNo, beamNo, if_no);
    664650        if (cEOS) printf("Start of new scan, flushing previous scan.\n");
    665651#endif
     
    710696
    711697        // The last record read must have been the first of a new cycle.
    712         beamNo = int(cBaseline / 256.0);
     698        beamNo = int(baseline / 256.0);
    713699        iBeamSel = cBeamSel[beamNo-1];
    714700
    715701        // Compute buffer number.
    716702        iMBuff = cBuffer + iBeamSel;
    717         if (cNBin > 1) iMBuff += cNBeamSel*(cBin-1);
     703        if (cNBin > 1) iMBuff += cNBeamSel*(bin-1);
    718704      }
    719705    }
     
    735721        // returned as the 'u' and 'v' visibility coordinates, must be
    736722        // interpolated to the integration time which RPFITSIN returns as
    737         // 'cUTC', this usually being a second or two later.
     723        // 'ut', this usually being a second or two later.
    738724        //
    739725        // Note that the time recorded as the 'w' visibility coordinate
    740         // cycles through 86400 back to 0 at midnight, whereas that in 'cUTC'
     726        // cycles through 86400 back to 0 at midnight, whereas that in 'ut'
    741727        // continues to increase past 86400.
    742728
    743         double thisRA  = cU;
    744         double thisDec = cV;
    745         double thisUTC = cW;
     729        double thisRA  = u;
     730        double thisDec = v;
     731        double thisUTC = w;
    746732
    747733        if (thisUTC < prevUTC) {
     
    865851        // Signal that all IFs in this buffer location have been flushed.
    866852        iMBuff->nIF = 0;
    867 
    868         // Stop cEOS being set when the next integration is read.
    869         iMBuff->cycleNo = 0;
    870 
    871853      } else {
    872854        // Carry on flushing the other IFs.
     
    877859      if (cFlushBin == cNBin - 1) {
    878860        if (cEOS || cEOF) {
     861          // Stop cEOS being set when the next integration is read.
     862          iMBuff->cycleNo = 0;
     863
    879864          // Carry on flushing other buffers.
    880865          cFlushIF = 0;
     
    884869        cFlushing = 0;
    885870
    886         beamNo = int(cBaseline / 256.0);
     871        beamNo = int(baseline / 256.0);
    887872        iBeamSel = cBeamSel[beamNo-1];
    888873
    889874        // Compute buffer number.
    890875        iMBuff = cBuffer + iBeamSel;
    891         if (cNBin > 1) iMBuff += cNBeamSel*(cBin-1);
     876        if (cNBin > 1) iMBuff += cNBeamSel*(bin-1);
    892877      }
    893878    }
     
    903888      }
    904889
    905       // Sanity check on incomplete integrations within a scan.
    906       if (iMBuff->nIF && (iMBuff->cycleNo != cCycleNo)) {
    907         // Force the incomplete integration to be flushed before proceeding.
    908         cFlushing = 1;
    909         continue;
    910       }
    911 
    912890      iMBuff->scanNo  = cScanNo;
    913891      iMBuff->cycleNo = cCycleNo;
     
    915893      // Times.
    916894      strncpy(iMBuff->datobs, cDateObs, 10);
    917       iMBuff->utc = cUTC;
     895      iMBuff->utc = ut;
    918896      iMBuff->exposure = param_.intbase;
    919897
    920898      // Source identification.
    921899      sprintf(iMBuff->srcName, "%-16.16s",
    922               names_.su_name + (cSrcNo-1)*16);
    923       iMBuff->srcRA  = doubles_.su_ra[cSrcNo-1];
    924       iMBuff->srcDec = doubles_.su_dec[cSrcNo-1];
     900              names_.su_name + (sourceno-1)*16);
     901      iMBuff->srcRA  = doubles_.su_ra[sourceno-1];
     902      iMBuff->srcDec = doubles_.su_dec[sourceno-1];
    925903
    926904      // Rest frequency of the line of interest.
     
    948926
    949927      // Beam position at the specified time.
    950       if (cSUpos) {
    951         // Non-ATNF data that does not store the position in (u,v,w).
    952         iMBuff->ra  = doubles_.su_ra[cSrcNo-1];
    953         iMBuff->dec = doubles_.su_dec[cSrcNo-1];
     928      if (cTid) {
     929        // Tidbinbilla data.
     930        iMBuff->ra  = doubles_.su_ra[sourceno-1];
     931        iMBuff->dec = doubles_.su_dec[sourceno-1];
    954932      } else {
    955         iMBuff->ra  = cU;
    956         iMBuff->dec = cV;
    957       }
    958       cPosUTC[iBeamSel] = cW;
     933        iMBuff->ra  = u;
     934        iMBuff->dec = v;
     935      }
     936      cPosUTC[iBeamSel] = w;
    959937
    960938      // IF-dependent parameters.
    961       int iIF = cIFno - 1;
     939      int iIF = if_no - 1;
    962940      int startChan = cStartChan[iIF];
    963941      int endChan   = cEndChan[iIF];
     
    968946      iIFSel = cIFSel[iIF];
    969947      iMBuff->nIF++;
    970       iMBuff->IFno[iIFSel]  = cIFno;
     948      iMBuff->IFno[iIFSel]  = if_no;
    971949      iMBuff->nChan[iIFSel] = nChan;
    972950      iMBuff->nPol[iIFSel]  = cNPol[iIF];
     
    10271005
    10281006      // The baseline flag may be set independently.
    1029       if (rpflag == 0) rpflag = cFlag;
     1007      if (rpflag == 0) rpflag = flag;
    10301008
    10311009      // Copy and scale data.
     
    11571135  int numErr = 0;
    11581136
    1159   int jstat = 0;
     1137  jstat = 0;
    11601138  while (numErr < 10) {
    11611139    int lastjstat = jstat;
    1162     rpfitsin_(&jstat, cVis, cWgt, &cBaseline, &cUTC, &cU, &cV, &cW, &cFlag,
    1163               &cBin, &cIFno, &cSrcNo);
     1140    rpfitsin_(&jstat, cVis, weight, &baseline, &ut, &u, &v, &w, &flag, &bin,
     1141              &if_no, &sourceno);
    11641142
    11651143    switch(jstat) {
     
    11741152      // Successful read.
    11751153      if (lastjstat == 0) {
    1176         if (cBaseline == -1) {
     1154        if (baseline == -1) {
    11771155          // Syscal data.
    11781156          if (syscalonly) {
     
    12301208  }
    12311209
    1232   fprintf(stderr, "ERROR, RPFITS read failed too many times.\n");
     1210  fprintf(stderr, "RPFITS read failed too many times.\n");
    12331211  return 2;
    12341212}
     
    12411219{
    12421220  if (cMBopen) {
    1243     int jstat = 1;
    1244     rpfitsin_(&jstat, cVis, cWgt, &cBaseline, &cUTC, &cU, &cV, &cW, &cFlag,
    1245               &cBin, &cIFno, &cSrcNo);
     1221    jstat = 1;
     1222    rpfitsin_(&jstat, cVis, weight, &baseline, &ut, &u, &v, &w, &flag, &bin,
     1223              &if_no, &sourceno);
    12461224
    12471225    if (cBeams)     delete [] cBeams;
     
    12541232    if (cRefChan)   delete [] cRefChan;
    12551233
    1256     if (cVis) delete [] cVis;
    1257     if (cWgt) delete [] cWgt;
     1234    if (cVis)       delete [] cVis;
    12581235
    12591236    if (cBeamSel)   delete [] cBeamSel;
  • branches/alma/external/atnf/PKSIO/MBFITSreader.h

    r1372 r1453  
    22//# MBFITSreader.h: ATNF single-dish RPFITS reader.
    33//#---------------------------------------------------------------------------
    4 //# Copyright (C) 2000-2007
     4//# Copyright (C) 2000-2006
    55//# Mark Calabretta, ATNF
    66//#
     
    2727//#                        AUSTRALIA
    2828//#
    29 //# $Id: MBFITSreader.h,v 19.13 2007/07/02 06:11:22 cal103 Exp $
     29//# $Id$
    3030//#---------------------------------------------------------------------------
    3131//# The MBFITSreader class reads single dish RPFITS files (such as Parkes
     
    107107
    108108  private:
    109     // RPFITSIN subroutine arguments.
    110     int   cBaseline, cFlag, cBin, cIFno, cSrcNo;
    111     float cUTC, cU, cV, cW, *cVis, *cWgt;
    112 
    113109    char   cDateObs[10];
    114110    int    *cBeamSel, *cChanOff, cFirst, *cIFSel, cInterp, cIntTime, cMBopen,
    115            cMopra, cNBeamSel, cNBin, cRetry, *cStaleness, cSUpos, *cXpolOff;
     111           cMopra, cNBeamSel, cNBin, cRetry, *cStaleness, cTid, *cXpolOff;
     112    float  *cVis;
    116113
    117114    // The data has to be bufferred to allow positions to be interpolated.
     
    121118
    122119    int    cCycleNo, cScanNo;
    123     double cPrevUTC;
     120    double cUTC;
    124121
    125122    // Read the next data record from the RPFITS file.
    126123    int rpget(int syscalonly, int &EOS);
     124    // These are no longer define in the RPFITS.h file so moved here
     125    int jstat;
     126    float *weight;
     127    int baseline;
     128    int flag;
     129    int bin;
     130    int if_no;
     131    int sourceno;
     132    float *vis;
     133    float u;
     134    float v;
     135    float w;
     136    float ut;
     137           
    127138};
    128139
  • branches/alma/external/atnf/PKSIO/PKSFITSreader.cc

    r1393 r1453  
    337337        Double          &bandwidth,
    338338        Double          &freqInc,
    339         Double          &restFreq,
     339        Vector<Double>  &restFreq,
    340340        Vector<Float>   &tcal,
    341341        String          &tcalTime,
     
    403403  bandwidth = chanWidth * nChan;
    404404  freqInc   = cMBrec.fqDelt[0];
    405   restFreq  = cMBrec.restFreq;
     405  //restFreq  = cMBrec.restFreq;
     406  restFreq.resize(1);
     407  restFreq(0)  = cMBrec.restFreq;
    406408
    407409  tcal.resize(nPol);
  • branches/alma/external/atnf/PKSIO/PKSFITSreader.h

    r1393 r1453  
    129129        Double          &bandwidth,
    130130        Double          &freqInc,
    131         Double          &restFreq,
     131        Vector<Double>  &restFreq,
    132132        Vector<Float>   &tcal,
    133133        String          &tcalTime,
  • branches/alma/external/atnf/PKSIO/PKSMBrecord.cc

    r1325 r1453  
    2727//#                        AUSTRALIA
    2828//#
    29 //# $Id: PKSMBrecord.cc,v 19.6 2006/07/05 04:52:07 mcalabre Exp $
     29//# $Id$
    3030//#---------------------------------------------------------------------------
    3131//# The PKSMBrecord class stores an MBFITS single-dish data record.
  • branches/alma/external/atnf/PKSIO/PKSMBrecord.h

    r1325 r1453  
    2727//#                        AUSTRALIA
    2828//#
    29 //# $Id: PKSMBrecord.h,v 19.8 2006/07/05 04:52:07 mcalabre Exp $
     29//# $Id$
    3030//#---------------------------------------------------------------------------
    3131//# The PKSMBrecord class stores an MBFITS single-dish data record.
  • branches/alma/external/atnf/PKSIO/PKSMS2reader.cc

    r1393 r1453  
    9292  cPKSMS  = MeasurementSet(msName);
    9393  // taql access to the syscal table
    94   String tmpcalName = msName;
    95   tmpcalName.append("/SYSCAL");
    96   cSysCalTab = Table(tmpcalName);
     94  cHaveSysCal = False;
     95  if (cHaveSysCal=Table::isReadable(cPKSMS.sysCalTableName())) {
     96    cSysCalTab = Table(cPKSMS.sysCalTableName());
     97  }
    9798
    9899  cIdx    = 0;
     
    116117  ROMSSysCalColumns       sysCalCols(cPKSMS.sysCal());
    117118  ROMSWeatherColumns      weatherCols(cPKSMS.weather());
     119  ROMSAntennaColumns      antennaCols(cPKSMS.antenna());
    118120
    119121  // Column accessors for required columns.
     
    153155
    154156  // Optional columns.
     157  cHaveTsys = False;
     158  cHaveTcal = False;
    155159  if ((cHaveSrcVel = cPKSMS.source().tableDesc().isColumn("SYSVEL"))) {
    156160    cSrcVelCol.attach(cPKSMS.source(), "SYSVEL");
    157161  }
    158162
    159   if ((cHaveTsys = cPKSMS.sysCal().tableDesc().isColumn("TSYS"))) {
     163  if (cHaveSysCal && (cHaveTsys = cPKSMS.sysCal().tableDesc().isColumn("TSYS"))) {
    160164    cTsysCol.attach(cPKSMS.sysCal(), "TSYS");
    161165  }
    162166 
    163   if ((cHaveTcal = cPKSMS.sysCal().tableDesc().isColumn("TCAL"))) {
     167  if (cHaveSysCal && (cHaveTcal = cPKSMS.sysCal().tableDesc().isColumn("TCAL"))) {
    164168    cTcalCol.attach(cPKSMS.sysCal(), "TCAL");
    165169  }
     
    176180  // Spectral data should always be present.
    177181  haveSpectra = True;
    178   cFloatDataCol.reference(msCols.floatData());
     182  cHaveDataCol = False;
     183  cHaveCorrectedDataCol = False;
     184  //String telName = antennaCols.name()(0);
     185  ROMSObservationColumns observationCols(cPKSMS.observation());
     186  String telName = observationCols.telescopeName()(0);
     187  //cATF = (telName.contains("DA41") || telName.contains("DV01"));
     188  cATF = telName.contains("ATF");
     189
     190  if (cHaveDataCol = cPKSMS.isColumn(MSMainEnums::DATA)) {
     191    if (cATF) {
     192      //try to read a single baseline interferometeric data
     193      //and treat it as single dish data
     194      //maybe extended for ALMA commissioning later
     195      cDataCol.reference(msCols.data());
     196      if (cHaveCorrectedDataCol = cPKSMS.isColumn(MSMainEnums::CORRECTED_DATA)) {
     197        //cerr<<"Do have CORRECTED_DATA column"<<endl;
     198        cCorrectedDataCol.reference(msCols.correctedData());
     199      }
     200    }
     201  }
     202  else {
     203    cFloatDataCol.reference(msCols.floatData());
     204  }
    179205  cFlagCol.reference(msCols.flag());
    180206
    181207
    182   if ((cGetXPol = cPKSMS.isColumn(MSMainEnums::DATA))) {
     208  if (cGetXPol = (cPKSMS.isColumn(MSMainEnums::DATA) && (!cATF))) {
    183209    if ((cHaveXCalFctr = cPKSMS.tableDesc().isColumn("XCALFCTR"))) {
    184210      cXCalFctrCol.attach(cPKSMS, "XCALFCTR");
     
    223249  haveXPol = False;
    224250
    225   if (cGetXPol) {
     251  if (cGetXPol && !(cATF)) {
    226252    for (Int irow = 0; irow < cNRow; irow++) {
    227253      if (cDataCol.isDefined(irow)) {
     
    303329
    304330  fluxunit = "";
    305   const TableRecord& keywordSet
    306      = cFloatDataCol.columnDesc().keywordSet();
     331  if (cHaveDataCol) {
     332    const TableRecord& keywordSet2
     333       = cDataCol.columnDesc().keywordSet();
     334    if(keywordSet2.isDefined("UNIT")) {
     335      fluxunit = keywordSet2.asString("UNIT");
     336    }
     337  } else {
     338    const TableRecord& keywordSet
     339       = cFloatDataCol.columnDesc().keywordSet();
     340    if(keywordSet.isDefined("UNIT")) {
     341      fluxunit = keywordSet.asString("UNIT");
     342    }
     343  }
     344
     345/***
     346  const TableRecord& keywordSet
     347       = cFloatDataCol.columnDesc().keywordSet();
    307348  if(keywordSet.isDefined("UNIT")) {
    308349    fluxunit = keywordSet.asString("UNIT");
    309350  }
    310 
     351***/
    311352  // Coordinate equinox.
    312353  ROMSPointingColumns pointingCols(cPKSMS.pointing());
     
    529570        Double          &bandwidth,
    530571        Double          &freqInc,
    531         Double          &restFreq,
     572        Vector<Double>  &restFreq,
    532573        Vector<Float>   &tcal,
    533574        String          &tcalTime,
     
    584625    }
    585626  }
    586 
    587627  // Renumerate scan no. Here still is 1-based
    588628  //scanNo = cScanNoCol(cIdx) - cScanNoCol(0) + 1;
     
    624664
    625665  // Systemic velocity.
    626   if (!cHaveSrcVel) {
     666  if (!cHaveSrcVel || cATF) {
    627667    srcVel = 0.0f;
    628668  } else {
     
    634674  Bool cGBT = telescope.contains("GBT");
    635675  // Observation type.
    636   Int stateId = cStateIdCol(cIdx);
    637   if (stateId == -1) {
    638     //obsMode = " ";
    639   } else {
    640     obsMode = cObsModeCol(stateId);
    641     Bool sigState =cSigStateCol(stateId);
    642     Bool refState =cRefStateCol(stateId);
    643     //DEBUG
    644     //cerr <<"stateid="<<stateId<<" obsmode="<<obsMode<<endl;
    645     if (cGBT) {
    646       // split the obsMode string and append a proper label
    647       // (these are GBT specific)
    648       int epos = obsMode.find_first_of(':');
    649       int nextpos = obsMode.find_first_of(':',epos+1);
    650       string obsMode1 = obsMode.substr(0,epos);
    651       string obsMode2 = obsMode.substr(epos+1,nextpos-epos-1);
     676  // check if State Table exist
     677  //Bool cHaveStateTab=Table::isReadable(cPKSMS.stateTableName());
     678  Int stateId = 0;
     679  Int StateNRow = 0;
     680  StateNRow=cObsModeCol.nrow();
     681  if (Table::isReadable(cPKSMS.stateTableName())) {
     682        obsMode = " ";
     683    if (StateNRow > 0) {
     684      stateId = cStateIdCol(cIdx);
     685      if (stateId == -1) {
     686        //obsMode = " ";
     687      } else {
     688        obsMode = cObsModeCol(stateId);
     689        Bool sigState =cSigStateCol(stateId);
     690        Bool refState =cRefStateCol(stateId);
     691        //DEBUG
     692        //cerr <<"stateid="<<stateId<<" obsmode="<<obsMode<<endl;
     693        if (cGBT) {
     694          // split the obsMode string and append a proper label
     695          // (these are GBT specific)
     696          int epos = obsMode.find_first_of(':');
     697          int nextpos = obsMode.find_first_of(':',epos+1);
     698          string obsMode1 = obsMode.substr(0,epos);
     699          string obsMode2 = obsMode.substr(epos+1,nextpos-epos-1);
    652700     
    653       //cerr <<"obsMode2= "<<obsMode2<<endl;
    654       if (!srcName.contains("_ps")
    655           &&!srcName.contains("_psr")
    656           &&!srcName.contains("_nod")
    657           &&!srcName.contains("_fs")
    658           &&!srcName.contains("_fsr")) {
    659         // if Nod mode observation , append '_nod'
    660         if (obsMode1 == "Nod") {
    661           srcName.append("_nod");
    662         } else if (obsMode1 == "OffOn") {
    663         // for GBT position switch observations (OffOn or OnOff)
    664           if (obsMode2 == "PSWITCHON") srcName.append("_ps");
    665           if (obsMode2 == "PSWITCHOFF") srcName.append("_psr");
    666         } else {
    667           if (obsMode2 == "FSWITCH") {
    668           // for GBT frequency switch mode
    669             if (sigState) srcName.append("_fs");
    670             if (refState) srcName.append("_fsr");
     701          //cerr <<"obsMode2= "<<obsMode2<<endl;
     702          if (!srcName.contains("_ps")
     703              &&!srcName.contains("_psr")
     704              &&!srcName.contains("_nod")
     705              &&!srcName.contains("_fs")
     706              &&!srcName.contains("_fsr")) {
     707            // if Nod mode observation , append '_nod'
     708            if (obsMode1 == "Nod") {
     709              srcName.append("_nod");
     710            } else if (obsMode1 == "OffOn") {
     711            // for GBT position switch observations (OffOn or OnOff)
     712              if (obsMode2 == "PSWITCHON") srcName.append("_ps");
     713              if (obsMode2 == "PSWITCHOFF") srcName.append("_psr");
     714            } else {
     715              if (obsMode2 == "FSWITCH") {
     716              // for GBT frequency switch mode
     717                if (sigState) srcName.append("_fs");
     718                if (refState) srcName.append("_fsr");
     719              }
     720            }
    671721          }
    672         } 
    673       }
    674     }
    675   } 
     722        }
     723      } 
     724    }
     725  }
    676726  // CAL state
    677727  // this should be apply just for GBT data?
    678728  Double Cal;
    679   if (stateId==-1) {
     729  if (stateId==-1 || StateNRow==0) {
    680730    Cal = 0;
    681731  } else {
     
    694744  Vector<Double> chanFreq = cChanFreqCol(iIF);
    695745  if (nChan == 1) {
    696     cout << "The input is continuum data. "<< endl;
    697746    freqInc  = chanFreq(0);
    698747    refFreq  = chanFreq(0);
    699748    restFreq = 0.0f;
    700749  } else {
     750 
    701751    if (cStartChan(iIF) <= cEndChan(iIF)) {
    702752      freqInc = chanFreq(1) - chanFreq(0);
     
    705755    }
    706756    refFreq  = chanFreq(cRefChan(iIF)-1);
    707     restFreq = cSrcRestFrqCol(srcId)(IPosition(1,0));
     757    Bool HaveSrcRestFreq= cSrcRestFrqCol.isDefined(srcId);
     758    if (HaveSrcRestFreq) {
     759      //restFreq = cSrcRestFrqCol(srcId)(IPosition(1,0));
     760      restFreq = cSrcRestFrqCol(srcId);
     761    } else {
     762      restFreq = 0.0f;
     763    }
    708764  }
    709765  bandwidth = abs(freqInc * nChan);
     
    720776
    721777  // Find the appropriate entry in the WEATHER subtable.
    722   Vector<Double> wTimes = cWeatherTimeCol.getColumn();
    723   Int weatherIdx;
    724   for (weatherIdx = wTimes.nelements()-1; weatherIdx >= 0; weatherIdx--) {
    725     if (cWeatherTimeCol(weatherIdx) <= time) {
    726       break;
    727     }
    728   }
    729 
    730   if (weatherIdx < 0) {
     778  //Bool cHaveStateTab=Table::isReadable(cPKSMS.stateTableName());
     779  Bool cHaveWeatherTab = Table::isReadable(cPKSMS.weatherTableName());
     780  Int weatherIdx=-1;
     781  if (cHaveWeatherTab) {
     782    Vector<Double> wTimes = cWeatherTimeCol.getColumn();
     783    for (weatherIdx = wTimes.nelements()-1; weatherIdx >= 0; weatherIdx--) {
     784      if (cWeatherTimeCol(weatherIdx) <= time) {
     785        break;
     786      }
     787    }
     788  }
     789  if (weatherIdx < 0 || !cHaveWeatherTab) {
    731790    // No appropriate WEATHER entry.
    732791    pressure    = 0.0f;
     
    874933    baseSub.resize(0,0);
    875934  }
    876 
    877935  // Get spectral data.
    878936  if (cGetSpectra) {
    879937    Matrix<Float> tmpData;
    880938    Matrix<Bool>  tmpFlag;
    881     cFloatDataCol.getSlice(cIdx, cDataSel(iIF), tmpData, True);
     939    if (cHaveDataCol) {
     940      Matrix<Complex> tmpCmplxData;
     941      Matrix<Float> tmpReData;
     942      Matrix<Float> tmpImData;
     943      //cerr<<"reading spectra..."<<endl;
     944      //# TODO - should have a flag to user to select DATA or CORRECTED_DATA
     945      //# currently just automatically determined, --- read CORRECTED one
     946      //# if the column exist.
     947      if (cHaveCorrectedDataCol) {
     948        cCorrectedDataCol.getSlice(cIdx, cDataSel(iIF), tmpCmplxData, True);
     949      } else {
     950        cDataCol.getSlice(cIdx, cDataSel(iIF), tmpCmplxData, True);
     951      }
     952      tmpReData = real(tmpCmplxData);
     953      tmpImData = imag(tmpCmplxData);
     954      tmpData = sqrt(tmpReData*tmpReData + tmpImData*tmpImData);
     955    } else {
     956      cFloatDataCol.getSlice(cIdx, cDataSel(iIF), tmpData, True);
     957    }
    882958    cFlagCol.getSlice(cIdx, cDataSel(iIF), tmpFlag, True);
    883959
     
    909985  // Get cross-polarization data.
    910986  if (cGetXPol) {
     987    //cerr<<"cGetXPol="<<cGetXPol<<endl;
     988    //cerr<<"cHaveXCalFctr="<<cHaveXCalFctr<<endl;
     989
    911990    if (cHaveXCalFctr) {
    912991      cXCalFctrCol.get(cIdx, xCalFctr);
     
    915994    }
    916995
    917     cDataCol.get(cIdx, xPol, True);
    918 
    919     if (cEndChan(iIF) < cStartChan(iIF)) {
    920       Complex ctmp;
    921       Int jchan = nChan - 1;
    922       for (Int ichan = 0; ichan < nChan/2; ichan++, jchan--) {
    923         ctmp = xPol(ichan);
    924         xPol(ichan) = xPol(jchan);
    925         xPol(jchan) = ctmp;
    926       }
    927     }
    928   }
    929 
     996    if(!cATF) {
     997      cDataCol.get(cIdx, xPol, True);
     998
     999      if (cEndChan(iIF) < cStartChan(iIF)) {
     1000        Complex ctmp;
     1001        Int jchan = nChan - 1;
     1002        for (Int ichan = 0; ichan < nChan/2; ichan++, jchan--) {
     1003          ctmp = xPol(ichan);
     1004          xPol(ichan) = xPol(jchan);
     1005          xPol(jchan) = ctmp;
     1006        }
     1007      }
     1008    }
     1009  }
     1010  /**
     1011  cerr<<"scanNo="<<scanNo<<endl;
     1012  cerr<<"cycleNo="<<cycleNo<<endl;
     1013  cerr<<"mjd="<<mjd<<endl;
     1014  cerr<<"interval="<<interval<<endl;
     1015  cerr<<"fieldName="<<fieldName<<endl;
     1016  cerr<<"srcNmae="<<srcName<<endl;
     1017  cerr<<"srcDir="<<srcDir<<endl;
     1018  cerr<<"srcPM="<<srcPM<<endl;
     1019  cerr<<"srcVel="<<srcVel<<endl;
     1020  cerr<<"obsMode="<<obsMode<<endl;
     1021  cerr<<"IFno="<<IFno<<endl;
     1022  cerr<<"refFreq="<<refFreq<<endl;
     1023  cerr<<"tcal="<<tcal<<endl;
     1024  cerr<<"direction="<<direction<<endl;
     1025  cerr<<"scanRate="<<scanRate<<endl;
     1026  cerr<<"tsys="<<tsys<<endl;
     1027  cerr<<"sigma="<<sigma<<endl;
     1028  cerr<<"calFctr="<<calFctr<<endl;
     1029  cerr<<"baseLin="<<baseLin<<endl;
     1030  cerr<<"baseSub="<<baseSub<<endl;
     1031  cerr<<"spectra="<<spectra.shape()<<endl;
     1032  cerr<<"flagged="<<flagged.shape()<<endl;
     1033  cerr<<"xCalFctr="<<xCalFctr<<endl;
     1034  cerr<<"xPol="<<xPol<<endl;
     1035  **/
    9301036  cIdx++;
    9311037
     
    10031109    Matrix<Float> tmpData;
    10041110    Matrix<Bool>  tmpFlag;
    1005     cFloatDataCol.getSlice(cIdx, cDataSel(iIF), tmpData, True);
     1111    if (cHaveDataCol) {
     1112      Matrix<Complex> tmpCmplxData;
     1113      cDataCol.getSlice(cIdx, cDataSel(iIF), tmpCmplxData, True);
     1114      tmpData = real(tmpCmplxData);
     1115    } else {
     1116      cFloatDataCol.getSlice(cIdx, cDataSel(iIF), tmpData, True);
     1117    }
    10061118    cFlagCol.getSlice(cIdx, cDataSel(iIF), tmpFlag, True);
    10071119
  • branches/alma/external/atnf/PKSIO/PKSMS2reader.h

    r1393 r1453  
    126126        Double          &bandwidth,
    127127        Double          &freqInc,
    128         Double          &restFreq,
     128        Vector<Double>  &restFreq,
    129129        Vector<Float>   &tcal,
    130130        String          &tcalTime,
     
    169169  private:
    170170    Bool   cHaveBaseLin, cHaveCalFctr, cHaveSrcVel, cHaveTsys, cHaveXCalFctr,
    171            cMSopen, cHaveTcal;
     171           cMSopen, cHaveTcal, cHaveDataCol, cATF, cHaveSysCal, cHaveCorrectedDataCol;
    172172    Int    cCycleNo, cIdx, cNRow, cScanNo;
    173173    Double cTime, lastmjd;
     
    213213    ROScalarColumn<Complex> cXCalFctrCol;
    214214    ROArrayColumn<Complex>  cDataCol;
     215    ROArrayColumn<Complex>  cCorrectedDataCol;
    215216    ROScalarColumn<Int>     cNumReceptorCol;
    216217    ROScalarColumn<Bool>    cSigStateCol;
  • branches/alma/external/atnf/PKSIO/PKSMS2writer.cc

    r1393 r1453  
    9393
    9494  Int maxNPol = max(cNPol);
     95  cGBT = cAPEX = cSMT = cALMA = False;
    9596
    9697  // check if it is GBT data
    97   cGBT = antName.contains("GBT");
     98  if (antName.contains("GBT")) {
     99    cGBT = True;
     100  }
     101  else if (antName.contains("APEX")) {
     102    cAPEX = True;
     103  }
     104  else if (antName.contains("HHT") || antName.contains("SMT")) {
     105    cSMT = True;
     106  }
     107  else if (antName.contains("ALMA")) {
     108    cALMA = True;
     109  }
     110 
     111
     112   
     113  //cGBT = antName.contains("GBT");
     114  //cAPEX = antName.contains("APEX");
     115  //cSMT = antName.contains("HHT");
     116  //cALMA = antName.contains("ALMA");
    98117
    99118  // Add the non-standard CALFCTR column.
     
    125144
    126145    MS::addColumnToDesc(pksDesc, MS::DATA, 2);
     146    //pksDesc.rwColumnDesc(MS::columnName(MS::DATA)).rwKeywordSet().
     147    //            define("UNIT", "Jy");
    127148    pksDesc.rwColumnDesc(MS::columnName(MS::DATA)).rwKeywordSet().
    128                 define("UNIT", "Jy");
     149                define("UNIT", fluxUnit);
    129150    pksDesc.rwColumnDesc(MS::columnName(MS::DATA)).rwKeywordSet().
    130151                define("MEASURE_TYPE", "");
     
    391412        const Double          bandwidth,
    392413        const Double          freqInc,
    393         const Double          restFreq,
     414        //const Double          restFreq,
     415        const Vector<Double>  restFreq,
    394416        const Vector<Float>   tcal,
    395417        const String          tcalTime,
     
    533555  Vector<Float> weight(nPol, 1.0f);
    534556  cMSCols->weight().put(irow, weight);
     557  //imaging weight
     558  //Vector<Float> imagingWeight(nChan);
     559  //cMSCols->imagingWeight().put(irow, imagingWeight);
    535560
    536561  // Flag information.
     
    612637  // do specific things for GBT
    613638  // Data.
     639  // plus some more telescopes
    614640  cAntennaCols->name().put(n, antName);
    615641  //cAntennaCols->station().put(n, "ATNF_PARKES");
    616642  if (cGBT) {
    617643    cAntennaCols->station().put(n, "GREENBANK");
     644    cAntennaCols->dishDiameter().put(n, 110.0);
     645  }
     646  else if (cAPEX) {
     647    cAntennaCols->station().put(n, "CHAJNANTOR");
     648    cAntennaCols->dishDiameter().put(n, 12.0);
     649  }
     650  else if (cALMA) {
     651    cAntennaCols->station().put(n, "CHAJNANTOR");
     652    cAntennaCols->dishDiameter().put(n, 12.0);
     653  }
     654  else if (cSMT) {
     655    cAntennaCols->station().put(n, "MT_GRAHAM");
     656    cAntennaCols->dishDiameter().put(n, 10.0);
    618657  }
    619658  else {
    620659    cAntennaCols->station().put(n, "ATNF_PARKES");
     660    cAntennaCols->dishDiameter().put(n, 64.0);
    621661  }
    622662  cAntennaCols->type().put(n, "GROUND-BASED");
     
    626666  cAntennaCols->offset().put(n, antOffset);
    627667  //cAntennaCols->dishDiameter().put(n, 64.0);
    628   if (cGBT) {
    629     cAntennaCols->dishDiameter().put(n, 110.0);
    630   }
    631   else {
    632     cAntennaCols->dishDiameter().put(n, 64.0);
    633   }
     668  //if (cGBT) {
     669  //  cAntennaCols->dishDiameter().put(n, 110.0);
     670  //}
     671  //else {
     672  //  cAntennaCols->dishDiameter().put(n, 64.0);
     673  //}
    634674  // Flags.
    635675  cAntennaCols->flagRow().put(n, False);
     
    950990        const Vector<Double> direction,
    951991        const Vector<Double> properMotion,
    952         const Double restFreq,
     992        //const Double restFreq,
     993        const Vector<Double> restFreq,
    953994        const Double radialVelocity)
    954995{
     
    9841025//  cSourceCols->position().put(n, position);
    9851026    cSourceCols->properMotion().put(n, properMotion);
    986     Vector<Double> restFrequency(1, restFreq);
    987     cSourceCols->restFrequency().put(n, restFrequency);
     1027//  Vector<Double> restFrequency(1, restFreq);
     1028//  cSourceCols->restFrequency().put(n, restFrequency);
     1029    cSourceCols->restFrequency().put(n, restFreq);
    9881030    Vector<Double> sysvel(1, radialVelocity);
    9891031    cSourceCols->sysvel().put(n, sysvel);
  • branches/alma/external/atnf/PKSIO/PKSMS2writer.h

    r1393 r1453  
    8888        const Double          bandwidth,
    8989        const Double          freqInc,
    90         const Double          restFreq,
     90        //const Double          restFreq,
     91        const Vector<Double>  restFreq,
    9192        const Vector<Float>   tcal,
    9293        const String          tcalTime,
     
    166167    ScalarColumn<Complex> *cXCalFctrCol;
    167168
    168     // for GBT specific data handling
     169    // for handling parameters specific to GBT and other telescopes
    169170    Bool cGBT;
     171    Bool cSMT;
     172    Bool cAPEX;
     173    Bool cALMA;
    170174
    171175    // Add an entry to the ANTENNA subtable.
     
    225229        const Vector<Double> direction,
    226230        const Vector<Double> properMotion,
    227         const Double restFreq,
     231        //const Double restFreq,
     232        const Vector<Double> restFreq,
    228233        const Double radialVelocity);
    229234
  • branches/alma/external/atnf/PKSIO/PKSSDwriter.cc

    r1393 r1453  
    135135        const Double          bandwidth,
    136136        const Double          freqInc,
    137         const Double          restFreq,
     137        //const Double          restFreq,
     138        const Vector<Double>  restFreq,
    138139        const Vector<Float>   tcal,
    139140        const String          tcalTime,
     
    211212  mbrec.srcDec   = srcDir(1);
    212213
    213   mbrec.restFreq = restFreq;
     214  //mbrec.restFreq = restFreq;
     215  mbrec.restFreq = restFreq(0);
    214216
    215217  strncpy(mbrec.obsType, (char *)obsMode.chars(), 16);
  • branches/alma/external/atnf/PKSIO/PKSSDwriter.h

    r1393 r1453  
    8888        const Double          bandwidth,
    8989        const Double          freqInc,
    90         const Double          restFreq,
     90        //const Double          restFreq,
     91        const Vector<Double>  restFreq,
    9192        const Vector<Float>   tcal,
    9293        const String          tcalTime,
  • branches/alma/external/atnf/PKSIO/PKSreader.cc

    r1325 r1453  
    2626//#                        Charlottesville, VA 22903-2475 USA
    2727//#
    28 //# $Id: PKSreader.cc,v 19.4 2006/05/19 02:14:50 mcalabre Exp $
     28//# $Id$
    2929//#---------------------------------------------------------------------------
    3030//# Original: 2000/08/23, Mark Calabretta, ATNF
  • branches/alma/external/atnf/PKSIO/PKSreader.h

    r1393 r1453  
    148148        Double          &bandwidth,
    149149        Double          &freqInc,
    150         Double          &restFreq,
     150        Vector<Double>  &restFreq,
    151151        Vector<Float>   &tcal,
    152152        String          &tcalTime,
  • branches/alma/external/atnf/PKSIO/PKSwriter.h

    r1393 r1453  
    8181        const Double          bandwidth,
    8282        const Double          freqInc,
    83         const Double          restFreq,
     83        //const Double          restFreq,
     84        const Vector<Double>  restFreq,
    8485        const Vector<Float>   tcal,
    8586        const String          tcalTime,
  • branches/alma/external/atnf/PKSIO/SDFITSreader.cc

    r1325 r1453  
    2626//#                        Charlottesville, VA 22903-2475 USA
    2727//#
    28 //# $Id: SDFITSreader.cc,v 19.22 2006/07/12 00:14:26 mcalabre Exp $
     28//# $Id$
    2929//#---------------------------------------------------------------------------
    3030//# The SDFITSreader class reads single dish FITS files such as those written
  • branches/alma/external/atnf/PKSIO/SDFITSreader.h

    r1325 r1453  
    2626//#                        Charlottesville, VA 22903-2475 USA
    2727//#
    28 //# $Id: SDFITSreader.h,v 19.12 2006/07/05 05:24:35 mcalabre Exp $
     28//# $Id$
    2929//#---------------------------------------------------------------------------
    3030//# The SDFITSreader class reads single dish FITS files such as those written
  • branches/alma/external/atnf/PKSIO/SDFITSwriter.cc

    r1325 r1453  
    2727//#                        AUSTRALIA
    2828//#
    29 //# $Id: SDFITSwriter.cc,v 19.10 2006/07/05 05:44:52 mcalabre Exp $
     29//# $Id$
    3030//#---------------------------------------------------------------------------
    3131//# Original: 2000/07/24, Mark Calabretta, ATNF
  • branches/alma/external/atnf/PKSIO/SDFITSwriter.h

    r1325 r1453  
    2727//#                        AUSTRALIA
    2828//#
    29 //# $Id: SDFITSwriter.h,v 19.5 2006/05/19 02:19:58 mcalabre Exp $
     29//# $Id$
    3030//#---------------------------------------------------------------------------
    3131//# Original: 2000/07/24, Mark Calabretta, ATNF
Note: See TracChangeset for help on using the changeset viewer.