Ignore:
Timestamp:
07/04/08 13:23:49 (16 years ago)
Author:
Malte Marquarding
Message:

sync with livedata/implement/atnf

Location:
trunk/external/atnf/PKSIO
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/external/atnf/PKSIO/MBFITSreader.cc

    r1399 r1427  
    22//# MBFITSreader.cc: ATNF single-dish RPFITS reader.
    33//#---------------------------------------------------------------------------
    4 //# Copyright (C) 2000-2007
     4//# Copyright (C) 2000-2008
    55//# Mark Calabretta, ATNF
    66//#
     
    2727//#                        AUSTRALIA
    2828//#
    29 //# $Id: MBFITSreader.cc,v 19.36 2007/11/12 03:37:56 cal103 Exp $
     29//# $Id: MBFITSreader.cc,v 19.38 2008-06-26 02:24:22 cal103 Exp $
    3030//#---------------------------------------------------------------------------
    3131//# The MBFITSreader class reads single dish RPFITS files (such as Parkes
     
    5252const double PI = 3.141592653589793238462643;
    5353const double TWOPI = 2.0 * PI;
     54const double R2D = 180.0 / PI;
    5455
    5556//------------------------------------------------- MBFITSreader::MBFITSreader
     
    501502
    502503#ifdef PKSIO_DEBUG
    503         printf("End-of-file detected, flushing last scan.\n");
     504        printf("\nEnd-of-file detected, flushing last scan.\n");
    504505#endif
    505506
     
    609610          cCycleNo = 0;
    610611          cPrevUTC = 0.0;
    611           cStaleness = new int[cNBeamSel];
    612           for (int iBeamSel = 0; iBeamSel < cNBeamSel; iBeamSel++) {
    613             cStaleness[iBeamSel] = 0;
    614           }
    615612        }
    616613
     
    670667
    671668#ifdef PKSIO_DEBUG
    672         printf(" In:%4d%4d%3d%3d\n", cScanNo, cCycleNo, beamNo, cIFno);
     669        printf("\n In:%4d%4d%3d%3d\n", cScanNo, cCycleNo, beamNo, cIFno);
    673670        if (cEOS) printf("Start of new scan, flushing previous scan.\n");
    674671#endif
     
    730727
    731728    if (cFlushing && cFlushBin == 0 && cFlushIF == 0 && cInterp) {
    732       // Interpolate the beam position at the start of the flush cycle.
    733 #ifdef PKSIO_DEBUG
    734       printf("Doing position interpolation for beam %d.\n", iMBuff->beamNo);
    735 #endif
    736 
    737       double prevRA  = iMBuff->ra;
    738       double prevDec = iMBuff->dec;
    739       double prevUTC = cPosUTC[iBeamSel];
    740 
    741       if (!cEOF && !cEOS) {
    742         // The position is measured by the control system at a time returned
    743         // by RPFITSIN as the 'w' visibility coordinate.  The ra and dec,
    744         // returned as the 'u' and 'v' visibility coordinates, must be
    745         // interpolated to the integration time which RPFITSIN returns as
    746         // 'cUTC', this usually being a second or two later.
    747         //
     729      // Start of flush cycle, interpolate the beam position.
     730      //
     731      // The position is measured by the control system at a time returned by
     732      // RPFITSIN as the 'w' visibility coordinate.  The ra and dec, returned
     733      // as the 'u' and 'v' visibility coordinates, must be interpolated to
     734      // the integration time which RPFITSIN returns as 'cUTC', this usually
     735      // being a second or two later.
     736      //
     737      // "This" RA, Dec, and UTC refers to the position currently stored in
     738      // the buffer marked for output (iMBuff).  This position will be
     739      // interpolated to the midpoint of that integration using the position
     740      // recorded in the "next" integration which is currently sitting in the
     741      // RPFITS commons.  The interpolation method used here is based on the
     742      // scan rate.  At the end of a scan, or if the next position has not
     743      // been updated, the most recent determination of the scan rate will be
     744      // used for extrapolation.
     745      //
     746      // The rate "age" is the offset from "this" integration (in iMBuff) of
     747      // the earliest integration in the pair used to compute the rate.  A
     748      // rate "age" of 0 thus refers to the normal situation where the rate
     749      // is determined from "this" integration and the "next" one.  An age
     750      // of 1 cycle means that it is determined from "this" integration and
     751      // the one preceding it, which should be equally reliable.  An age
     752      // of 2 cycles means that the rate is determined from the previous
     753      // integration and the one before that, so the extrapolation spans one
     754      // integration cycle.  Thus it has a "staleness" of 1.
     755
     756      double thisRA  = iMBuff->ra;
     757      double thisDec = iMBuff->dec;
     758      double thisUTC = cPosUTC[iBeamSel];
     759
     760      if (cEOF || cEOS) {
     761        iMBuff->rateAge++;
     762        iMBuff->rateson = 0;
     763       
     764      } else {
    748765        // Note that the time recorded as the 'w' visibility coordinate
    749766        // cycles through 86400 back to 0 at midnight, whereas that in 'cUTC'
    750767        // continues to increase past 86400.
    751768
    752         double thisRA  = cU;
    753         double thisDec = cV;
    754         double thisUTC = cW;
    755 
    756         if (thisUTC < prevUTC) {
     769        double nextRA  = cU;
     770        double nextDec = cV;
     771        double nextUTC = cW;
     772
     773        if (nextUTC < thisUTC) {
    757774          // Must have cycled through midnight.
    758           thisUTC += 86400.0;
     775          nextUTC += 86400.0;
    759776        }
    760777
    761778        // Guard against RA cycling through 24h in either direction.
    762         if (fabs(thisRA - prevRA) > PI) {
    763           if (thisRA < prevRA) {
    764             thisRA += TWOPI;
     779        if (fabs(nextRA - thisRA) > PI) {
     780          if (nextRA < thisRA) {
     781            nextRA += TWOPI;
    765782          } else {
    766             thisRA -= TWOPI;
     783            nextRA -= TWOPI;
    767784          }
    768785        }
     786
     787#ifdef PKSIO_DEBUG
     788        printf("Previous ra, dec, UTC:  %8.4f  %8.4f  %7.1f\n", thisRA*R2D,
     789          thisDec*R2D, thisUTC);
     790        printf("Current  ra, dec, UTC:  %8.4f  %8.4f  %7.1f\n", nextRA*R2D,
     791          nextDec*R2D, nextUTC);
     792#endif
    769793
    770794        // The control system at Mopra typically does not update the
     
    774798        // likely to be a better guess than anything else.
    775799
    776         double dUTC = thisUTC - prevUTC;
     800        double dUTC = nextUTC - thisUTC;
    777801
    778802        // Scan rate for this beam.
    779803        if (dUTC > 0.0) {
    780           iMBuff->raRate  = (thisRA  - prevRA)  / dUTC;
    781           iMBuff->decRate = (thisDec - prevDec) / dUTC;
     804          iMBuff->raRate  = (nextRA  - thisRA)  / dUTC;
     805          iMBuff->decRate = (nextDec - thisDec) / dUTC;
     806          iMBuff->rateAge = 0;
     807          iMBuff->rateson = 0;
    782808
    783809          if (cInterp == 2) {
    784810            // Use the same interpolation scheme as the original pksmbfits
    785             // client.  This incorrectly assumed that (thisUTC - prevUTC) is
     811            // client.  This incorrectly assumed that (nextUTC - thisUTC) is
    786812            // equal to the integration time and interpolated by computing a
    787813            // weighted sum of the positions before and after the required
     
    789815
    790816            double utc = iMBuff->utc;
    791             if (utc - prevUTC > 100.0) {
     817            if (utc - thisUTC > 100.0) {
    792818              // Must have cycled through midnight.
    793819              utc -= 86400.0;
    794820            }
    795821
    796             double tw1 = 1.0 - (utc - prevUTC) / iMBuff->exposure;
    797             double tw2 = 1.0 - (thisUTC - utc) / iMBuff->exposure;
    798             double gamma = (tw2 / (tw1 + tw2)) * dUTC / (utc - prevUTC);
     822            double tw1 = 1.0 - (utc - thisUTC) / iMBuff->exposure;
     823            double tw2 = 1.0 - (nextUTC - utc) / iMBuff->exposure;
     824            double gamma = (tw2 / (tw1 + tw2)) * dUTC / (utc - thisUTC);
    799825
    800826            iMBuff->raRate  *= gamma;
     
    802828          }
    803829
    804           cStaleness[iBeamSel] = 0;
    805 
    806830        } else {
    807           // Issue warnings.
    808           int nch = 0;
    809           fprintf(stderr, "WARNING, scan %d,%n cycle %d: Position ",
    810             iMBuff->scanNo, &nch, iMBuff->cycleNo);
    811 
     831          iMBuff->rateAge++;
     832
     833          // Staleness codes.
    812834          if (dUTC < 0.0) {
    813             fprintf(stderr, "timestamp went backwards!\n");
     835            iMBuff->rateson = 3;
    814836          } else {
    815             if (thisRA != prevRA || thisDec != prevDec) {
    816               fprintf(stderr, "changed but timestamp unchanged!\n");
     837            if (nextRA != thisRA || nextDec != thisDec) {
     838              iMBuff->rateson = 2;
    817839            } else {
    818               fprintf(stderr, "and timestamp unchanged!\n");
     840              iMBuff->rateson = 1;
    819841            }
    820842          }
    821 
    822           cStaleness[iBeamSel]++;
    823           fprintf(stderr, "%-*s Using stale scan rate, staleness = %d "
    824             "cycle%s.\n", nch, "WARNING,", cStaleness[iBeamSel],
    825             (cStaleness[iBeamSel] == 1) ? "" : "s");
    826 
    827           if (thisRA != prevRA || thisDec != prevDec) {
    828             if (iMBuff->raRate == 0.0 && iMBuff->decRate == 0.0) {
    829               fprintf(stderr, "%-*s But the previous rate was zero!  "
    830                 "Position will be inaccurate.\n", nch, "WARNING,");
    831             }
    832           }
    833         }
    834       }
     843        }
     844      }
     845
     846#ifdef PKSIO_DEBUG
     847      printf("Doing position interpolation for beam %d.\n", iMBuff->beamNo);
     848      printf("RA and Dec rates and age: %7.4f  %7.4f  %d\n",
     849        iMBuff->raRate*R2D, iMBuff->decRate*R2D, iMBuff->rateAge);
     850#endif
    835851
    836852      // Compute the position of this beam for all bins.
     
    841857        cBuffer[jbuff].decRate = iMBuff->decRate;
    842858
    843         double dutc = cBuffer[jbuff].utc - prevUTC;
     859        double dutc = cBuffer[jbuff].utc - thisUTC;
    844860        if (dutc > 100.0) {
    845861          // Must have cycled through midnight.
     
    847863        }
    848864
    849         cBuffer[jbuff].ra  = prevRA  + cBuffer[jbuff].raRate  * dutc;
    850         cBuffer[jbuff].dec = prevDec + cBuffer[jbuff].decRate * dutc;
     865        cBuffer[jbuff].ra  = thisRA  + cBuffer[jbuff].raRate  * dutc;
     866        cBuffer[jbuff].dec = thisDec + cBuffer[jbuff].decRate * dutc;
    851867        if (cBuffer[jbuff].ra < 0.0) {
    852868          cBuffer[jbuff].ra += TWOPI;
  • trunk/external/atnf/PKSIO/MBFITSreader.h

    r1399 r1427  
    2727//#                        AUSTRALIA
    2828//#
    29 //# $Id: MBFITSreader.h,v 19.14 2007/11/12 03:37:56 cal103 Exp $
     29//# $Id: MBFITSreader.h,v 19.15 2008-06-26 02:14:36 cal103 Exp $
    3030//#---------------------------------------------------------------------------
    3131//# The MBFITSreader class reads single dish RPFITS files (such as Parkes
     
    114114    char   cDateObs[10];
    115115    int    *cBeamSel, *cChanOff, cFirst, *cIFSel, cInterp, cIntTime, cMBopen,
    116            cMopra, cNBeamSel, cNBin, cRetry, *cStaleness, cSUpos, *cXpolOff;
     116           cMopra, cNBeamSel, cNBin, cRetry, cSUpos, *cXpolOff;
    117117
    118118    // The data has to be bufferred to allow positions to be interpolated.
  • trunk/external/atnf/PKSIO/PKSFITSreader.cc

    r1399 r1427  
    11//# PKSFITSreader.cc: Class to read Parkes multibeam data from a FITS file.
    22//#---------------------------------------------------------------------------
    3 //# Copyright (C) 2000-2007
     3//# Copyright (C) 2000-2008
    44//# Associated Universities, Inc. Washington DC, USA.
    55//#
     
    2525//#                        Charlottesville, VA 22903-2475 USA
    2626//#
    27 //# $Id: PKSFITSreader.cc,v 19.13 2007/11/12 03:37:56 cal103 Exp $
     27//# $Id: PKSFITSreader.cc,v 19.14 2008-06-26 02:07:21 cal103 Exp $
    2828//#---------------------------------------------------------------------------
    2929//# Original: 2000/08/02, Mark Calabretta, ATNF
     
    5050        const Bool   interpolate)
    5151{
    52   cMBrec.setNIFs(1);
     52  cFITSMBrec.setNIFs(1);
    5353
    5454  if (fitsType == "SDFITS") {
     
    321321// Read the next data record.
    322322
    323 Int PKSFITSreader::read(
    324         Int             &scanNo,
    325         Int             &cycleNo,
    326         Double          &mjd,
    327         Double          &interval,
    328         String          &fieldName,
    329         String          &srcName,
    330         Vector<Double>  &srcDir,
    331         Vector<Double>  &srcPM,
    332         Double          &srcVel,
    333         String          &obsType,
    334         Int             &IFno,
    335         Double          &refFreq,
    336         Double          &bandwidth,
    337         Double          &freqInc,
    338         Double          &restFreq,
    339         Vector<Float>   &tcal,
    340         String          &tcalTime,
    341         Float           &azimuth,
    342         Float           &elevation,
    343         Float           &parAngle,
    344         Float           &focusAxi,
    345         Float           &focusTan,
    346         Float           &focusRot,
    347         Float           &temperature,
    348         Float           &pressure,
    349         Float           &humidity,
    350         Float           &windSpeed,
    351         Float           &windAz,
    352         Int             &refBeam,
    353         Int             &beamNo,
    354         Vector<Double>  &direction,
    355         Vector<Double>  &scanRate,
    356         Vector<Float>   &tsys,
    357         Vector<Float>   &sigma,
    358         Vector<Float>   &calFctr,
    359         Matrix<Float>   &baseLin,
    360         Matrix<Float>   &baseSub,
    361         Matrix<Float>   &spectra,
    362         Matrix<uChar>   &flagged,
    363         Complex         &xCalFctr,
    364         Vector<Complex> &xPol)
     323Int PKSFITSreader::read(MBrecord &MBrec)
    365324{
    366325  Int status;
    367326
    368   if ((status = cReader->read(cMBrec))) {
     327  if ((status = cReader->read(cFITSMBrec))) {
    369328    if (status != -1) {
    370329      status = 1;
     
    375334
    376335
    377   uInt nChan = cMBrec.nChan[0];
    378   uInt nPol  = cMBrec.nPol[0];
    379 
    380   scanNo  = cMBrec.scanNo;
    381   cycleNo = cMBrec.cycleNo;
     336  uInt nChan = cFITSMBrec.nChan[0];
     337  uInt nPol  = cFITSMBrec.nPol[0];
     338
     339  MBrec.scanNo  = cFITSMBrec.scanNo;
     340  MBrec.cycleNo = cFITSMBrec.cycleNo;
    382341
    383342  // Extract MJD.
    384343  Int day, month, year;
    385   sscanf(cMBrec.datobs, "%4d-%2d-%2d", &year, &month, &day);
    386   mjd = MVTime(year, month, Double(day)).day() + cMBrec.utc/86400.0;
    387 
    388   interval  = cMBrec.exposure;
    389 
    390   fieldName = trim(cMBrec.srcName);
    391   srcName   = fieldName;
    392   srcDir(0) = cMBrec.srcRA;
    393   srcDir(1) = cMBrec.srcDec;
    394   srcPM(0)  = 0.0;
    395   srcPM(1)  = 0.0;
    396   srcVel    = 0.0;
    397   obsType   = trim(cMBrec.obsType);
    398 
    399   IFno = cMBrec.IFno[0];
    400   Double chanWidth = fabs(cMBrec.fqDelt[0]);
    401   refFreq   = cMBrec.fqRefVal[0];
    402   bandwidth = chanWidth * nChan;
    403   freqInc   = cMBrec.fqDelt[0];
    404   restFreq  = cMBrec.restFreq;
    405 
    406   tcal.resize(nPol);
     344  sscanf(cFITSMBrec.datobs, "%4d-%2d-%2d", &year, &month, &day);
     345  MBrec.mjd = MVTime(year, month, Double(day)).day() + cFITSMBrec.utc/86400.0;
     346
     347  MBrec.interval  = cFITSMBrec.exposure;
     348
     349  MBrec.fieldName = trim(cFITSMBrec.srcName);
     350  MBrec.srcName   = MBrec.fieldName;
     351
     352  MBrec.srcDir.resize(2);
     353  MBrec.srcDir(0) = cFITSMBrec.srcRA;
     354  MBrec.srcDir(1) = cFITSMBrec.srcDec;
     355
     356  MBrec.srcPM.resize(2);
     357  MBrec.srcPM(0)  = 0.0;
     358  MBrec.srcPM(1)  = 0.0;
     359  MBrec.srcVel    = 0.0;
     360  MBrec.obsType   = trim(cFITSMBrec.obsType);
     361
     362  MBrec.IFno = cFITSMBrec.IFno[0];
     363  Double chanWidth = fabs(cFITSMBrec.fqDelt[0]);
     364  MBrec.refFreq   = cFITSMBrec.fqRefVal[0];
     365  MBrec.bandwidth = chanWidth * nChan;
     366  MBrec.freqInc   = cFITSMBrec.fqDelt[0];
     367  MBrec.restFreq  = cFITSMBrec.restFreq;
     368
     369  MBrec.tcal.resize(nPol);
    407370  for (uInt ipol = 0; ipol < nPol; ipol++) {
    408     tcal(ipol) = cMBrec.tcal[0][ipol];
    409   }
    410   tcalTime  = trim(cMBrec.tcalTime);
    411   azimuth   = cMBrec.azimuth;
    412   elevation = cMBrec.elevation;
    413   parAngle  = cMBrec.parAngle;
    414   focusAxi  = cMBrec.focusAxi;
    415   focusTan  = cMBrec.focusTan;
    416   focusRot  = cMBrec.focusRot;
    417 
    418   temperature = cMBrec.temp;
    419   pressure    = cMBrec.pressure;
    420   humidity    = cMBrec.humidity;
    421   windSpeed   = cMBrec.windSpeed;
    422   windAz      = cMBrec.windAz;
    423 
    424   refBeam = cMBrec.refBeam;
    425   beamNo  = cMBrec.beamNo;
    426 
    427   direction(0) = cMBrec.ra;
    428   direction(1) = cMBrec.dec;
    429   scanRate(0)  = cMBrec.raRate;
    430   scanRate(1)  = cMBrec.decRate;
    431 
    432   tsys.resize(nPol);
    433   sigma.resize(nPol);
    434   calFctr.resize(nPol);
     371    MBrec.tcal(ipol) = cFITSMBrec.tcal[0][ipol];
     372  }
     373  MBrec.tcalTime  = trim(cFITSMBrec.tcalTime);
     374  MBrec.azimuth   = cFITSMBrec.azimuth;
     375  MBrec.elevation = cFITSMBrec.elevation;
     376  MBrec.parAngle  = cFITSMBrec.parAngle;
     377  MBrec.focusAxi  = cFITSMBrec.focusAxi;
     378  MBrec.focusTan  = cFITSMBrec.focusTan;
     379  MBrec.focusRot  = cFITSMBrec.focusRot;
     380
     381  MBrec.temperature = cFITSMBrec.temp;
     382  MBrec.pressure    = cFITSMBrec.pressure;
     383  MBrec.humidity    = cFITSMBrec.humidity;
     384  MBrec.windSpeed   = cFITSMBrec.windSpeed;
     385  MBrec.windAz      = cFITSMBrec.windAz;
     386
     387  MBrec.refBeam = cFITSMBrec.refBeam;
     388  MBrec.beamNo  = cFITSMBrec.beamNo;
     389
     390  MBrec.direction.resize(2);
     391  MBrec.direction(0) = cFITSMBrec.ra;
     392  MBrec.direction(1) = cFITSMBrec.dec;
     393
     394  MBrec.scanRate.resize(2);
     395  MBrec.scanRate(0)  = cFITSMBrec.raRate;
     396  MBrec.scanRate(1)  = cFITSMBrec.decRate;
     397  MBrec.rateAge      = cFITSMBrec.rateAge;
     398  MBrec.rateson      = cFITSMBrec.rateson;
     399
     400  MBrec.tsys.resize(nPol);
     401  MBrec.sigma.resize(nPol);
     402  MBrec.calFctr.resize(nPol);
    435403  for (uInt ipol = 0; ipol < nPol; ipol++) {
    436     tsys(ipol)  = cMBrec.tsys[0][ipol];
    437     sigma(ipol) = tsys(ipol) / 0.81 / sqrt(interval * chanWidth);
    438     calFctr(ipol) = cMBrec.calfctr[0][ipol];
    439   }
    440 
    441   if (cMBrec.haveBase) {
    442     baseLin.resize(2,nPol);
    443     baseSub.resize(9,nPol);
     404    MBrec.tsys(ipol)  = cFITSMBrec.tsys[0][ipol];
     405    MBrec.sigma(ipol) = (MBrec.tsys(ipol) / 0.81) /
     406                         sqrt(MBrec.interval * chanWidth);
     407    MBrec.calFctr(ipol) = cFITSMBrec.calfctr[0][ipol];
     408  }
     409
     410  if (cFITSMBrec.haveBase) {
     411    MBrec.baseLin.resize(2,nPol);
     412    MBrec.baseSub.resize(9,nPol);
    444413
    445414    for (uInt ipol = 0; ipol < nPol; ipol++) {
    446       baseLin(0,ipol) = cMBrec.baseLin[0][ipol][0];
    447       baseLin(1,ipol) = cMBrec.baseLin[0][ipol][1];
     415      MBrec.baseLin(0,ipol) = cFITSMBrec.baseLin[0][ipol][0];
     416      MBrec.baseLin(1,ipol) = cFITSMBrec.baseLin[0][ipol][1];
    448417
    449418      for (uInt j = 0; j < 9; j++) {
    450         baseSub(j,ipol) = cMBrec.baseSub[0][ipol][j];
     419        MBrec.baseSub(j,ipol) = cFITSMBrec.baseSub[0][ipol][j];
    451420      }
    452421    }
    453422
    454423  } else {
    455     baseLin.resize(0,0);
    456     baseSub.resize(0,0);
    457   }
    458 
    459   if (cGetSpectra && cMBrec.haveSpectra) {
    460     spectra.resize(nChan,nPol);
    461     spectra.takeStorage(IPosition(2,nChan,nPol), cMBrec.spectra[0], SHARE);
    462 
    463     flagged.resize(nChan,nPol);
    464     flagged.takeStorage(IPosition(2,nChan,nPol), cMBrec.flagged[0], SHARE);
     424    MBrec.baseLin.resize(0,0);
     425    MBrec.baseSub.resize(0,0);
     426  }
     427
     428  if (cGetSpectra && cFITSMBrec.haveSpectra) {
     429    MBrec.spectra.resize(nChan,nPol);
     430    MBrec.spectra.takeStorage(IPosition(2,nChan,nPol), cFITSMBrec.spectra[0],
     431      SHARE);
     432
     433    MBrec.flagged.resize(nChan,nPol);
     434    MBrec.flagged.takeStorage(IPosition(2,nChan,nPol), cFITSMBrec.flagged[0],
     435      SHARE);
    465436
    466437  } else {
    467     spectra.resize(0,0);
    468     flagged.resize(0,0);
     438    MBrec.spectra.resize(0,0);
     439    MBrec.flagged.resize(0,0);
    469440  }
    470441
    471442  if (cGetXPol) {
    472     xCalFctr = Complex(cMBrec.xcalfctr[0][0], cMBrec.xcalfctr[0][1]);
    473     xPol.resize(nChan);
    474     xPol.takeStorage(IPosition(1,nChan), (Complex *)cMBrec.xpol[0], SHARE);
     443    MBrec.xCalFctr = Complex(cFITSMBrec.xcalfctr[0][0],
     444                             cFITSMBrec.xcalfctr[0][1]);
     445    MBrec.xPol.resize(nChan);
     446    MBrec.xPol.takeStorage(IPosition(1,nChan), (Complex *)cFITSMBrec.xpol[0],
     447      SHARE);
    475448  }
    476449
     
    493466  Int status;
    494467
    495   if ((status = cReader->read(cMBrec))) {
     468  if ((status = cReader->read(cFITSMBrec))) {
    496469    if (status != -1) {
    497470      status = 1;
     
    501474  }
    502475
    503   IFno = cMBrec.IFno[0];
    504 
    505   uInt nChan = cMBrec.nChan[0];
    506   uInt nPol  = cMBrec.nPol[0];
     476  IFno = cFITSMBrec.IFno[0];
     477
     478  uInt nChan = cFITSMBrec.nChan[0];
     479  uInt nPol  = cFITSMBrec.nPol[0];
    507480
    508481  tsys.resize(nPol);
    509482  calFctr.resize(nPol);
    510483  for (uInt ipol = 0; ipol < nPol; ipol++) {
    511     tsys(ipol) = cMBrec.tsys[0][ipol];
    512     calFctr(ipol) = cMBrec.calfctr[0][ipol];
    513   }
    514 
    515   if (cMBrec.haveBase) {
     484    tsys(ipol) = cFITSMBrec.tsys[0][ipol];
     485    calFctr(ipol) = cFITSMBrec.calfctr[0][ipol];
     486  }
     487
     488  if (cFITSMBrec.haveBase) {
    516489    baseLin.resize(2,nPol);
    517490    baseSub.resize(9,nPol);
    518491
    519492    for (uInt ipol = 0; ipol < nPol; ipol++) {
    520       baseLin(0,ipol) = cMBrec.baseLin[0][ipol][0];
    521       baseLin(1,ipol) = cMBrec.baseLin[0][ipol][1];
     493      baseLin(0,ipol) = cFITSMBrec.baseLin[0][ipol][0];
     494      baseLin(1,ipol) = cFITSMBrec.baseLin[0][ipol][1];
    522495
    523496      for (uInt j = 0; j < 9; j++) {
    524         baseSub(j,ipol) = cMBrec.baseSub[0][ipol][j];
     497        baseSub(j,ipol) = cFITSMBrec.baseSub[0][ipol][j];
    525498      }
    526499    }
     
    531504  }
    532505
    533   if (cGetSpectra && cMBrec.haveSpectra) {
     506  if (cGetSpectra && cFITSMBrec.haveSpectra) {
    534507    spectra.resize(nChan,nPol);
    535     spectra.takeStorage(IPosition(2,nChan,nPol), cMBrec.spectra[0], SHARE);
     508    spectra.takeStorage(IPosition(2,nChan,nPol), cFITSMBrec.spectra[0],
     509      SHARE);
    536510
    537511    flagged.resize(nChan,nPol);
    538     flagged.takeStorage(IPosition(2,nChan,nPol), cMBrec.flagged[0], SHARE);
     512    flagged.takeStorage(IPosition(2,nChan,nPol), cFITSMBrec.flagged[0],
     513      SHARE);
    539514
    540515  } else {
  • trunk/external/atnf/PKSIO/PKSFITSreader.h

    r1399 r1427  
    22//# PKSFITSreader.h: Class to read Parkes Multibeam data from a FITS file.
    33//#---------------------------------------------------------------------------
    4 //# Copyright (C) 2000-2007
     4//# Copyright (C) 2000-2008
    55//# Associated Universities, Inc. Washington DC, USA.
    66//#
     
    2626//#                        Charlottesville, VA 22903-2475 USA
    2727//#
    28 //# $Id: PKSFITSreader.h,v 19.12 2007/11/12 03:37:56 cal103 Exp $
     28//# $Id: PKSFITSreader.h,v 19.13 2008-06-26 02:02:43 cal103 Exp $
    2929//#---------------------------------------------------------------------------
    3030//# This class is basically a wrapper class for reading data from either an
     
    114114
    115115    // Read the next data record.
    116     virtual Int read(
    117         Int             &scanNo,
    118         Int             &cycleNo,
    119         Double          &mjd,
    120         Double          &interval,
    121         String          &fieldName,
    122         String          &srcName,
    123         Vector<Double>  &srcDir,
    124         Vector<Double>  &srcPM,
    125         Double          &srcVel,
    126         String          &obsType,
    127         Int             &IFno,
    128         Double          &refFreq,
    129         Double          &bandwidth,
    130         Double          &freqInc,
    131         Double          &restFreq,
    132         Vector<Float>   &tcal,
    133         String          &tcalTime,
    134         Float           &azimuth,
    135         Float           &elevation,
    136         Float           &parAngle,
    137         Float           &focusAxi,
    138         Float           &focusTan,
    139         Float           &focusRot,
    140         Float           &temperature,
    141         Float           &pressure,
    142         Float           &humidity,
    143         Float           &windSpeed,
    144         Float           &windAz,
    145         Int             &refBeam,
    146         Int             &beamNo,
    147         Vector<Double>  &direction,
    148         Vector<Double>  &scanRate,
    149         Vector<Float>   &tsys,
    150         Vector<Float>   &sigma,
    151         Vector<Float>   &calFctr,
    152         Matrix<Float>   &baseLin,
    153         Matrix<Float>   &baseSub,
    154         Matrix<Float>   &spectra,
    155         Matrix<uChar>   &flagged,
    156         Complex         &xCalFctr,
    157         Vector<Complex> &xPol);
     116    virtual Int read(MBrecord &mbrec);
    158117
    159118    // Read the next data record, just the basics.
     
    173132    Int    *cBeams, *cIFs;
    174133    uInt   cNBeam, cNIF;
    175     PKSMBrecord cMBrec;
     134    PKSMBrecord cFITSMBrec;
    176135    FITSreader  *cReader;
    177136
  • trunk/external/atnf/PKSIO/PKSMBrecord.cc

    r1325 r1427  
    22//# PKSMBrecord.cc: Class to store an MBFITS single-dish data record.
    33//#---------------------------------------------------------------------------
    4 //# Copyright (C) 2000-2006
     4//# Copyright (C) 2000-2008
    55//# Mark Calabretta, ATNF
    66//#
     
    2727//#                        AUSTRALIA
    2828//#
    29 //# $Id: PKSMBrecord.cc,v 19.6 2006/07/05 04:52:07 mcalabre Exp $
     29//# $Id: PKSMBrecord.cc,v 19.7 2008-06-26 02:10:21 cal103 Exp $
    3030//#---------------------------------------------------------------------------
    3131//# The PKSMBrecord class stores an MBFITS single-dish data record.
     
    5353  raRate  = 0.0f;
    5454  decRate = 0.0f;
     55  rateAge = 0;
    5556  nIF     = 0;
    5657}
     
    226227  // Beam-dependent parameters.
    227228  beamNo  = other.beamNo;
    228   ra       = other.ra;
    229   dec      = other.dec;
    230   raRate   = other.raRate;
    231   decRate  = other.decRate;
     229  ra      = other.ra;
     230  dec     = other.dec;
     231  raRate  = other.raRate;
     232  decRate = other.decRate;
     233  rateAge = other.rateAge;
     234  rateson = other.rateson;
    232235
    233236  // IF-dependent parameters.
     
    343346  // Beam-dependent parameters.
    344347  beamNo  = other.beamNo;
    345   ra       = other.ra;
    346   dec      = other.dec;
    347   raRate   = other.raRate;
    348   decRate  = other.decRate;
     348  ra      = other.ra;
     349  dec     = other.dec;
     350  raRate  = other.raRate;
     351  decRate = other.decRate;
     352  rateAge = other.rateAge;
     353  rateson = other.rateson;
    349354
    350355  // IF-dependent parameters.
  • trunk/external/atnf/PKSIO/PKSMBrecord.h

    r1325 r1427  
    22//# PKSMBrecord.h: Class to store an MBFITS single-dish data record.
    33//#---------------------------------------------------------------------------
    4 //# Copyright (C) 2000-2006
     4//# Copyright (C) 2000-2008
    55//# Mark Calabretta, ATNF
    66//#
     
    2727//#                        AUSTRALIA
    2828//#
    29 //# $Id: PKSMBrecord.h,v 19.8 2006/07/05 04:52:07 mcalabre Exp $
     29//# $Id: PKSMBrecord.h,v 19.9 2008-06-26 02:10:21 cal103 Exp $
    3030//#---------------------------------------------------------------------------
    3131//# The PKSMBrecord class stores an MBFITS single-dish data record.
     
    109109    float  raRate;              // Scan rate in right ascension, radian/s.
    110110    float  decRate;             // Scan rate in declination, radian/s.
     111    short  rateAge;             // Scan rate age (staleness), cycles.
     112    short  rateson;             // Staleness reason code:
     113                                //   1: position and timestamp unchanged,
     114                                //   2: position changed but not timestamp,
     115                                //   3: position timestamp went backwards.
    111116
    112117    // IF-dependent parameters.
  • trunk/external/atnf/PKSIO/PKSMS2reader.cc

    r1399 r1427  
    22//# PKSMS2reader.cc: Class to read Parkes Multibeam data from a v2 MS.
    33//#---------------------------------------------------------------------------
    4 //# Copyright (C) 2000-2007
     4//# Copyright (C) 2000-2008
    55//# Associated Universities, Inc. Washington DC, USA.
    66//#
     
    2626//#                        Charlottesville, VA 22903-2475 USA
    2727//#
    28 //# $Id: PKSMS2reader.cc,v 19.12 2007/11/12 03:37:56 cal103 Exp $
     28//# $Id: PKSMS2reader.cc,v 19.13 2008-06-26 02:08:02 cal103 Exp $
    2929//#---------------------------------------------------------------------------
    3030//# Original: 2000/08/03, Mark Calabretta, ATNF
     
    248248        String &antName,
    249249        Vector<Double> &antPosition,
    250         String &obsMode,
     250        String &obsType,
    251251        String &bunit,
    252252        Float  &equinox,
     
    272272  // Observation type.
    273273  if (cObsModeCol.nrow()) {
    274     obsMode = cObsModeCol(0);
    275     if (obsMode == "\0") obsMode = "RF";
    276   } else {
    277     obsMode = "RF";
     274    obsType = cObsModeCol(0);
     275    if (obsType == "\0") obsType = "RF";
     276  } else {
     277    obsType = "RF";
    278278  }
    279279
     
    486486// Read the next data record.
    487487
    488 Int PKSMS2reader::read(
    489         Int             &scanNo,
    490         Int             &cycleNo,
    491         Double          &mjd,
    492         Double          &interval,
    493         String          &fieldName,
    494         String          &srcName,
    495         Vector<Double>  &srcDir,
    496         Vector<Double>  &srcPM,
    497         Double          &srcVel,
    498         String          &obsMode,
    499         Int             &IFno,
    500         Double          &refFreq,
    501         Double          &bandwidth,
    502         Double          &freqInc,
    503         Double          &restFreq,
    504         Vector<Float>   &tcal,
    505         String          &tcalTime,
    506         Float           &azimuth,
    507         Float           &elevation,
    508         Float           &parAngle,
    509         Float           &focusAxi,
    510         Float           &focusTan,
    511         Float           &focusRot,
    512         Float           &temperature,
    513         Float           &pressure,
    514         Float           &humidity,
    515         Float           &windSpeed,
    516         Float           &windAz,
    517         Int             &refBeam,
    518         Int             &beamNo,
    519         Vector<Double>  &direction,
    520         Vector<Double>  &scanRate,
    521         Vector<Float>   &tsys,
    522         Vector<Float>   &sigma,
    523         Vector<Float>   &calFctr,
    524         Matrix<Float>   &baseLin,
    525         Matrix<Float>   &baseSub,
    526         Matrix<Float>   &spectra,
    527         Matrix<uChar>   &flagged,
    528         Complex         &xCalFctr,
    529         Vector<Complex> &xPol)
     488Int PKSMS2reader::read(MBrecord &MBrec)
    530489{
    531490  if (!cMSopen) {
     
    555514
    556515  // Renumerate scan no. Here still is 1-based
    557   scanNo = cScanNoCol(cIdx) - cScanNoCol(0) + 1;
    558 
    559   if (scanNo != cScanNo) {
     516  MBrec.scanNo = cScanNoCol(cIdx) - cScanNoCol(0) + 1;
     517
     518  if (MBrec.scanNo != cScanNo) {
    560519    // Start of new scan.
    561     cScanNo  = scanNo;
     520    cScanNo  = MBrec.scanNo;
    562521    cCycleNo = 1;
    563522    cTime    = cTimeCol(cIdx);
     
    565524
    566525  Double time = cTimeCol(cIdx);
    567   mjd      = time/86400.0;
    568   interval = cIntervalCol(cIdx);
     526  MBrec.mjd      = time/86400.0;
     527  MBrec.interval = cIntervalCol(cIdx);
    569528
    570529  // Reconstruct the integration cycle number; due to small latencies the
    571530  // integration time is usually slightly less than the time between cycles,
    572531  // resetting cTime will prevent the difference from accumulating.
    573   cCycleNo += nint((time - cTime)/interval);
    574   cycleNo = cCycleNo;
     532  cCycleNo += nint((time - cTime)/MBrec.interval);
     533  MBrec.cycleNo = cCycleNo;
    575534  cTime   = time;
    576535
    577536  Int fieldId = cFieldIdCol(cIdx);
    578   fieldName = cFieldNameCol(fieldId);
     537  MBrec.fieldName = cFieldNameCol(fieldId);
    579538
    580539  Int srcId = cSrcIdCol(fieldId);
    581   srcName = cSrcNameCol(srcId);
    582   srcDir  = cSrcDirCol(srcId);
    583   srcPM   = cSrcPMCol(srcId);
     540  MBrec.srcName = cSrcNameCol(srcId);
     541  MBrec.srcDir  = cSrcDirCol(srcId);
     542  MBrec.srcPM   = cSrcPMCol(srcId);
    584543
    585544  // Systemic velocity.
    586545  if (!cHaveSrcVel) {
    587     srcVel = 0.0f;
    588   } else {
    589     srcVel  = cSrcVelCol(srcId)(IPosition(1,0));
     546    MBrec.srcVel = 0.0f;
     547  } else {
     548    MBrec.srcVel  = cSrcVelCol(srcId)(IPosition(1,0));
    590549  }
    591550
    592551  // Observation type.
    593552  Int stateId = cStateIdCol(cIdx);
    594   obsMode = cObsModeCol(stateId);
    595 
    596   IFno = iIF + 1;
     553  MBrec.obsType = cObsModeCol(stateId);
     554
     555  MBrec.IFno = iIF + 1;
    597556  Int nChan = abs(cEndChan(iIF) - cStartChan(iIF)) + 1;
    598557
     
    601560  if (nChan == 1) {
    602561    cout << "The input is continuum data. "<< endl;
    603     freqInc  = chanFreq(0);
    604     refFreq  = chanFreq(0);
    605     restFreq = 0.0f;
     562    MBrec.freqInc  = chanFreq(0);
     563    MBrec.refFreq  = chanFreq(0);
     564    MBrec.restFreq = 0.0f;
    606565  } else {
    607566    if (cStartChan(iIF) <= cEndChan(iIF)) {
    608       freqInc = chanFreq(1) - chanFreq(0);
     567      MBrec.freqInc = chanFreq(1) - chanFreq(0);
    609568    } else {
    610       freqInc = chanFreq(0) - chanFreq(1);
    611     }
    612 
    613     refFreq  = chanFreq(cRefChan(iIF)-1);
    614     restFreq = cSrcRestFrqCol(srcId)(IPosition(1,0));
    615   }
    616   bandwidth = abs(freqInc * nChan);
    617 
    618   tcal.resize(cNPol(iIF));
    619   tcal      = 0.0f;
    620   tcalTime  = "";
    621   azimuth   = 0.0f;
    622   elevation = 0.0f;
    623   parAngle  = 0.0f;
    624   focusAxi  = 0.0f;
    625   focusTan  = 0.0f;
    626   focusRot  = 0.0f;
     569      MBrec.freqInc = chanFreq(0) - chanFreq(1);
     570    }
     571
     572    MBrec.refFreq  = chanFreq(cRefChan(iIF)-1);
     573    MBrec.restFreq = cSrcRestFrqCol(srcId)(IPosition(1,0));
     574  }
     575  MBrec.bandwidth = abs(MBrec.freqInc * nChan);
     576
     577  MBrec.tcal.resize(cNPol(iIF));
     578  MBrec.tcal      = 0.0f;
     579  MBrec.tcalTime  = "";
     580  MBrec.azimuth   = 0.0f;
     581  MBrec.elevation = 0.0f;
     582  MBrec.parAngle  = 0.0f;
     583  MBrec.focusAxi  = 0.0f;
     584  MBrec.focusTan  = 0.0f;
     585  MBrec.focusRot  = 0.0f;
    627586
    628587  // Find the appropriate entry in the WEATHER subtable.
     
    637596  if (weatherIdx < 0) {
    638597    // No appropriate WEATHER entry.
    639     pressure    = 0.0f;
    640     humidity    = 0.0f;
    641     temperature = 0.0f;
    642   } else {
    643     pressure    = cPressureCol(weatherIdx);
    644     humidity    = cHumidityCol(weatherIdx);
    645     temperature = cTemperatureCol(weatherIdx);
    646   }
    647 
    648   windSpeed = 0.0f;
    649   windAz    = 0.0f;
    650 
    651   refBeam = 0;
    652   beamNo  = ibeam + 1;
     598    MBrec.temperature = 0.0f;
     599    MBrec.pressure    = 0.0f;
     600    MBrec.humidity    = 0.0f;
     601  } else {
     602    MBrec.temperature = cTemperatureCol(weatherIdx);
     603    MBrec.pressure    = cPressureCol(weatherIdx);
     604    MBrec.humidity    = cHumidityCol(weatherIdx);
     605  }
     606
     607  MBrec.windSpeed = 0.0f;
     608  MBrec.windAz    = 0.0f;
     609
     610  MBrec.refBeam = 0;
     611  MBrec.beamNo  = ibeam + 1;
    653612
    654613  Matrix<Double> pointingDir = cPointingCol(fieldId);
    655   direction = pointingDir.column(0);
     614  MBrec.direction = pointingDir.column(0);
    656615  uInt ncols = pointingDir.ncolumn();
    657616  if (ncols == 1) {
    658     scanRate = 0.0f;
    659   } else {
    660     scanRate  = pointingDir.column(1);
    661   }
     617    MBrec.scanRate = 0.0f;
     618  } else {
     619    MBrec.scanRate  = pointingDir.column(1);
     620  }
     621  MBrec.rateAge = 0;
     622  MBrec.rateson = 0;
    662623
    663624  // Get Tsys assuming that entries in the SYSCAL table match the main table.
     
    669630  }
    670631  if (cHaveTsys) {
    671     cTsysCol.get(cIdx, tsys, True);
     632    cTsysCol.get(cIdx, MBrec.tsys, True);
    672633  } else {
    673634    Int numReceptor;
    674635    cNumReceptorCol.get(0, numReceptor);
    675     tsys.resize(numReceptor);
    676     tsys = 1.0f;
    677   }
    678   cSigmaCol.get(cIdx, sigma, True);
     636    MBrec.tsys.resize(numReceptor);
     637    MBrec.tsys = 1.0f;
     638  }
     639  cSigmaCol.get(cIdx, MBrec.sigma, True);
    679640
    680641  // Calibration factors (if available).
    681   calFctr.resize(cNPol(iIF));
     642  MBrec.calFctr.resize(cNPol(iIF));
    682643  if (cHaveCalFctr) {
    683     cCalFctrCol.get(cIdx, calFctr);
    684   } else {
    685     calFctr = 0.0f;
     644    cCalFctrCol.get(cIdx, MBrec.calFctr);
     645  } else {
     646    MBrec.calFctr = 0.0f;
    686647  }
    687648
    688649  // Baseline parameters (if available).
    689650  if (cHaveBaseLin) {
    690     baseLin.resize(2,cNPol(iIF));
    691     cBaseLinCol.get(cIdx, baseLin);
    692 
    693     baseSub.resize(9,cNPol(iIF));
    694     cBaseSubCol.get(cIdx, baseSub);
    695 
    696   } else {
    697     baseLin.resize(0,0);
    698     baseSub.resize(0,0);
     651    MBrec.baseLin.resize(2,cNPol(iIF));
     652    cBaseLinCol.get(cIdx, MBrec.baseLin);
     653
     654    MBrec.baseSub.resize(9,cNPol(iIF));
     655    cBaseSubCol.get(cIdx, MBrec.baseSub);
     656
     657  } else {
     658    MBrec.baseLin.resize(0,0);
     659    MBrec.baseSub.resize(0,0);
    699660  }
    700661
     
    709670    // Transpose spectra.
    710671    Int nPol = tmpData.nrow();
    711     spectra.resize(nChan, nPol);
    712     flagged.resize(nChan, nPol);
     672    MBrec.spectra.resize(nChan, nPol);
     673    MBrec.flagged.resize(nChan, nPol);
    713674    if (cEndChan(iIF) >= cStartChan(iIF)) {
    714675      // Simple transposition.
    715676      for (Int ipol = 0; ipol < nPol; ipol++) {
    716677        for (Int ichan = 0; ichan < nChan; ichan++) {
    717           spectra(ichan,ipol) = tmpData(ipol,ichan);
    718           flagged(ichan,ipol) = tmpFlag(ipol,ichan);
     678          MBrec.spectra(ichan,ipol) = tmpData(ipol,ichan);
     679          MBrec.flagged(ichan,ipol) = tmpFlag(ipol,ichan);
    719680        }
    720681      }
     
    725686      for (Int ipol = 0; ipol < nPol; ipol++) {
    726687        for (Int ichan = 0; ichan < nChan; ichan++, jchan--) {
    727           spectra(ichan,ipol) = tmpData(ipol,jchan);
    728           flagged(ichan,ipol) = tmpFlag(ipol,jchan);
     688          MBrec.spectra(ichan,ipol) = tmpData(ipol,jchan);
     689          MBrec.flagged(ichan,ipol) = tmpFlag(ipol,jchan);
    729690        }
    730691      }
     
    735696  if (cGetXPol) {
    736697    if (cHaveXCalFctr) {
    737       cXCalFctrCol.get(cIdx, xCalFctr);
     698      cXCalFctrCol.get(cIdx, MBrec.xCalFctr);
    738699    } else {
    739       xCalFctr = Complex(0.0f, 0.0f);
    740     }
    741 
    742     cDataCol.get(cIdx, xPol, True);
     700      MBrec.xCalFctr = Complex(0.0f, 0.0f);
     701    }
     702
     703    cDataCol.get(cIdx, MBrec.xPol, True);
    743704
    744705    if (cEndChan(iIF) < cStartChan(iIF)) {
     
    746707      Int jchan = nChan - 1;
    747708      for (Int ichan = 0; ichan < nChan/2; ichan++, jchan--) {
    748         ctmp = xPol(ichan);
    749         xPol(ichan) = xPol(jchan);
    750         xPol(jchan) = ctmp;
     709        ctmp = MBrec.xPol(ichan);
     710        MBrec.xPol(ichan) = MBrec.xPol(jchan);
     711        MBrec.xPol(jchan) = ctmp;
    751712      }
    752713    }
  • trunk/external/atnf/PKSIO/PKSMS2reader.h

    r1399 r1427  
    22//# PKSMS2reader.h: Class to read Parkes Multibeam data from a v2 MS.
    33//#---------------------------------------------------------------------------
    4 //# Copyright (C) 2000-2007
     4//# Copyright (C) 2000-2008
    55//# Associated Universities, Inc. Washington DC, USA.
    66//#
     
    2626//#                        Charlottesville, VA 22903-2475 USA
    2727//#
    28 //# $Id: PKSMS2reader.h,v 19.13 2007/11/12 03:37:56 cal103 Exp $
     28//# $Id: PKSMS2reader.h,v 19.14 2008-06-26 02:03:51 cal103 Exp $
    2929//#---------------------------------------------------------------------------
    3030//# Original: 2000/08/03, Mark Calabretta, ATNF
     
    111111
    112112    // Read the next data record.
    113     virtual Int read(
    114         Int             &scanNo,
    115         Int             &cycleNo,
    116         Double          &mjd,
    117         Double          &interval,
    118         String          &fieldName,
    119         String          &srcName,
    120         Vector<Double>  &srcDir,
    121         Vector<Double>  &srcPM,
    122         Double          &srcVel,
    123         String          &obsMode,
    124         Int             &IFno,
    125         Double          &refFreq,
    126         Double          &bandwidth,
    127         Double          &freqInc,
    128         Double          &restFreq,
    129         Vector<Float>   &tcal,
    130         String          &tcalTime,
    131         Float           &azimuth,
    132         Float           &elevation,
    133         Float           &parAngle,
    134         Float           &focusAxi,
    135         Float           &focusTan,
    136         Float           &focusRot,
    137         Float           &temperature,
    138         Float           &pressure,
    139         Float           &humidity,
    140         Float           &windSpeed,
    141         Float           &windAz,
    142         Int             &refBeam,
    143         Int             &beamNo,
    144         Vector<Double>  &direction,
    145         Vector<Double>  &scanRate,
    146         Vector<Float>   &tsys,
    147         Vector<Float>   &sigma,
    148         Vector<Float>   &calFctr,
    149         Matrix<Float>   &baseLin,
    150         Matrix<Float>   &baseSub,
    151         Matrix<Float>   &spectra,
    152         Matrix<uChar>   &flagged,
    153         Complex         &xCalFctr,
    154         Vector<Complex> &xPol);
     113    virtual Int read(MBrecord &mbrec);
    155114
    156115    // Read the next data record, just the basics.
  • trunk/external/atnf/PKSIO/PKSreader.cc

    r1325 r1427  
    22//# PKSreader.cc: Class to read Parkes multibeam data.
    33//#---------------------------------------------------------------------------
    4 //# Copyright (C) 2000-2006
     4//# Copyright (C) 2000-2008
    55//# Associated Universities, Inc. Washington DC, USA.
    66//#
     
    2626//#                        Charlottesville, VA 22903-2475 USA
    2727//#
    28 //# $Id: PKSreader.cc,v 19.4 2006/05/19 02:14:50 mcalabre Exp $
     28//# $Id: PKSreader.cc,v 19.6 2008-06-26 01:54:08 cal103 Exp $
    2929//#---------------------------------------------------------------------------
    3030//# Original: 2000/08/23, Mark Calabretta, ATNF
     
    7575  if (inFile.isRegular()) {
    7676    // Is it MBFITS or SDFITS?
    77     RegularFileIO file(name);
    78     char buf[32];
    79     file.read(30, buf, False);
    80     buf[30] = '\0';
    81     if (String(buf) == "SIMPLE  =                    T") {
    82       // Looks like SDFITS.
     77    if (strstr(name.chars(), ".sdfits")) {
     78      // Looks like SDFITS, possibly gzip'd.
    8379      format = "SDFITS";
    8480      reader = new PKSFITSreader("SDFITS");
    8581
    8682    } else {
    87       // Assume it's MBFITS.
    88       format = "MBFITS";
    89       reader = new PKSFITSreader("MBFITS", retry, interpolate);
     83      RegularFileIO file(name);
     84      char buf[32];
     85      file.read(30, buf, False);
     86      buf[30] = '\0';
     87      if (String(buf) == "SIMPLE  =                    T") {
     88        // Looks like SDFITS.
     89        format = "SDFITS";
     90        reader = new PKSFITSreader("SDFITS");
     91
     92      } else {
     93        // Assume it's MBFITS.
     94        format = "MBFITS";
     95        reader = new PKSFITSreader("MBFITS", retry, interpolate);
     96      }
    9097    }
    9198
     
    155162  return 0;
    156163}
     164
     165
     166//-------------------------------------------------------- PKSFITSreader::read
     167
     168// Read the next data record.
     169
     170Int PKSreader::read(
     171        Int             &scanNo,
     172        Int             &cycleNo,
     173        Double          &mjd,
     174        Double          &interval,
     175        String          &fieldName,
     176        String          &srcName,
     177        Vector<Double>  &srcDir,
     178        Vector<Double>  &srcPM,
     179        Double          &srcVel,
     180        String          &obsType,
     181        Int             &IFno,
     182        Double          &refFreq,
     183        Double          &bandwidth,
     184        Double          &freqInc,
     185        Double          &restFreq,
     186        Vector<Float>   &tcal,
     187        String          &tcalTime,
     188        Float           &azimuth,
     189        Float           &elevation,
     190        Float           &parAngle,
     191        Float           &focusAxi,
     192        Float           &focusTan,
     193        Float           &focusRot,
     194        Float           &temperature,
     195        Float           &pressure,
     196        Float           &humidity,
     197        Float           &windSpeed,
     198        Float           &windAz,
     199        Int             &refBeam,
     200        Int             &beamNo,
     201        Vector<Double>  &direction,
     202        Vector<Double>  &scanRate,
     203        Vector<Float>   &tsys,
     204        Vector<Float>   &sigma,
     205        Vector<Float>   &calFctr,
     206        Matrix<Float>   &baseLin,
     207        Matrix<Float>   &baseSub,
     208        Matrix<Float>   &spectra,
     209        Matrix<uChar>   &flagged,
     210        Complex         &xCalFctr,
     211        Vector<Complex> &xPol)
     212{
     213  Int status;
     214  MBrecord MBrec;
     215
     216  if ((status = read(MBrec))) {
     217    if (status != -1) {
     218      status = 1;
     219    }
     220
     221    return status;
     222  }
     223
     224  scanNo      = MBrec.scanNo;
     225  cycleNo     = MBrec.cycleNo;
     226  mjd         = MBrec.mjd;
     227  interval    = MBrec.interval;
     228  fieldName   = MBrec.fieldName;
     229  srcName     = MBrec.srcName;
     230  srcDir      = MBrec.srcDir;
     231  srcPM       = MBrec.srcPM;
     232  srcVel      = MBrec.srcVel;
     233  obsType     = MBrec.obsType;
     234  IFno        = MBrec.IFno;
     235  refFreq     = MBrec.refFreq;
     236  bandwidth   = MBrec.bandwidth;
     237  freqInc     = MBrec.freqInc;
     238  restFreq    = MBrec.restFreq;
     239  tcal        = MBrec.tcal;
     240  tcalTime    = MBrec.tcalTime;
     241  azimuth     = MBrec.azimuth;
     242  elevation   = MBrec.elevation;
     243  parAngle    = MBrec.parAngle;
     244  focusAxi    = MBrec.focusAxi;
     245  focusTan    = MBrec.focusTan;
     246  focusRot    = MBrec.focusRot;
     247  temperature = MBrec.temperature;
     248  pressure    = MBrec.pressure;
     249  humidity    = MBrec.humidity;
     250  windSpeed   = MBrec.windSpeed;
     251  windAz      = MBrec.windAz;
     252  refBeam     = MBrec.refBeam;
     253  beamNo      = MBrec.beamNo;
     254  direction   = MBrec.direction;
     255  scanRate    = MBrec.scanRate;
     256  tsys        = MBrec.tsys;
     257  sigma       = MBrec.sigma;
     258  calFctr     = MBrec.calFctr;
     259  baseLin     = MBrec.baseLin;
     260  baseSub     = MBrec.baseSub;
     261  spectra     = MBrec.spectra;
     262  flagged     = MBrec.flagged;
     263  xCalFctr    = MBrec.xCalFctr;
     264  xPol        = MBrec.xPol;
     265
     266  return 0;
     267}
  • trunk/external/atnf/PKSIO/PKSreader.h

    r1399 r1427  
    22//# PKSreader.h: Class to read Parkes multibeam data.
    33//#---------------------------------------------------------------------------
    4 //# Copyright (C) 2000-2007
     4//# Copyright (C) 2000-2008
    55//# Associated Universities, Inc. Washington DC, USA.
    66//#
     
    2626//#                        Charlottesville, VA 22903-2475 USA
    2727//#
    28 //# $Id: PKSreader.h,v 19.12 2007/11/12 03:37:56 cal103 Exp $
     28//# $Id: PKSreader.h,v 19.13 2008-06-26 01:50:24 cal103 Exp $
    2929//#---------------------------------------------------------------------------
    3030//# Original: 2000/08/02, Mark Calabretta, ATNF
     
    4040#include <casa/BasicSL/String.h>
    4141
     42#include <casa/namespace.h>
     43
    4244// <summary>
    4345// Class to read Parkes multibeam data.
    4446// </summary>
    45 
    46 #include <casa/namespace.h>
    4747
    4848// Open an appropriate PKSreader for a Parkes Multibeam dataset.
     
    7676        Bool   &haveSpectra);
    7777
     78class MBrecord;
    7879
    7980class PKSreader
     
    132133        Matrix<Double> &positions) = 0;
    133134
    134     // Read the next data record.
     135    // Read the next data record (MBrecord is defined below).
     136    virtual Int read(MBrecord &mbrec) = 0;
     137
     138    // Read the next data record (for backwards compatibility, do not use).
    135139    virtual Int read(
    136140        Int             &scanNo,
     
    174178        Matrix<uChar>   &flagged,
    175179        Complex         &xCalFctr,
    176         Vector<Complex> &xPol) = 0;
     180        Vector<Complex> &xPol);
    177181
    178182    // Read the next data record, just the basics.
     
    196200};
    197201
     202
     203// Essentially just a struct used as a function argument.
     204class MBrecord
     205{
     206  public:
     207    Int             scanNo;
     208    Int             cycleNo;
     209    Double          mjd;
     210    Double          interval;
     211    String          fieldName;
     212    String          srcName;
     213    Vector<Double>  srcDir;
     214    Vector<Double>  srcPM;
     215    Double          srcVel;
     216    String          obsType;
     217    Int             IFno;
     218    Double          refFreq;
     219    Double          bandwidth;
     220    Double          freqInc;
     221    Double          restFreq;
     222    Vector<Float>   tcal;
     223    String          tcalTime;
     224    Float           azimuth;
     225    Float           elevation;
     226    Float           parAngle;
     227    Float           focusAxi;
     228    Float           focusTan;
     229    Float           focusRot;
     230    Float           temperature;
     231    Float           pressure;
     232    Float           humidity;
     233    Float           windSpeed;
     234    Float           windAz;
     235    Int             refBeam;
     236    Int             beamNo;
     237    Vector<Double>  direction;
     238    Vector<Double>  scanRate;
     239    Int             rateAge;
     240    Int             rateson;
     241    Vector<Float>   tsys;
     242    Vector<Float>   sigma;
     243    Vector<Float>   calFctr;
     244    Matrix<Float>   baseLin;
     245    Matrix<Float>   baseSub;
     246    Matrix<Float>   spectra;
     247    Matrix<uChar>   flagged;
     248    Complex         xCalFctr;
     249    Vector<Complex> xPol;
     250};
     251
    198252#endif
  • trunk/external/atnf/PKSIO/SDFITSreader.cc

    r1399 r1427  
    22//# SDFITSreader.cc: ATNF CFITSIO interface class for SDFITS input.
    33//#---------------------------------------------------------------------------
    4 //# Copyright (C) 2000-2007
     4//# Copyright (C) 2000-2008
    55//# Associated Universities, Inc. Washington DC, USA.
    66//#
     
    2626//#                        Charlottesville, VA 22903-2475 USA
    2727//#
    28 //# $Id: SDFITSreader.cc,v 19.23 2007/11/12 03:37:56 cal103 Exp $
     28//# $Id: SDFITSreader.cc,v 19.24 2008-06-26 02:13:11 cal103 Exp $
    2929//#---------------------------------------------------------------------------
    3030//# The SDFITSreader class reads single dish FITS files such as those written
     
    12891289    mbrec.decRate = scanrate[1] * D2R;
    12901290  }
     1291  mbrec.rateAge = 0;
     1292  mbrec.rateson = 0;
    12911293
    12921294  // IF-dependent parameters.
Note: See TracChangeset for help on using the changeset viewer.