//#---------------------------------------------------------------------------
//# PKSMS2reader.h: Class to read Parkes Multibeam data from a v2 MS.
//#---------------------------------------------------------------------------
//# livedata - processing pipeline for single-dish, multibeam spectral data.
//# Copyright (C) 2000-2009, Australia Telescope National Facility, CSIRO
//#
//# This file is part of livedata.
//#
//# livedata is free software: you can redistribute it and/or modify it under
//# the terms of the GNU General Public License as published by the Free
//# Software Foundation, either version 3 of the License, or (at your option)
//# any later version.
//#
//# livedata is distributed in the hope that it will be useful, but WITHOUT
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
//# more details.
//#
//# You should have received a copy of the GNU General Public License along
//# with livedata.  If not, see .
//#
//# Correspondence concerning livedata may be directed to:
//#        Internet email: mcalabre@atnf.csiro.au
//#        Postal address: Dr. Mark Calabretta
//#                        Australia Telescope National Facility, CSIRO
//#                        PO Box 76
//#                        Epping NSW 1710
//#                        AUSTRALIA
//#
//# http://www.atnf.csiro.au/computing/software/livedata.html
//# $Id: PKSMS2reader.h,v 19.18 2009-09-29 07:33:38 cal103 Exp $
//#---------------------------------------------------------------------------
//# Original: 2000/08/03, Mark Calabretta, ATNF
//#---------------------------------------------------------------------------
#ifndef ATNF_PKSMS2READER_H
#define ATNF_PKSMS2READER_H
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
// 
// Class to read Parkes Multibeam data from a v2 MS.
// 
class PKSMS2reader : public PKSreader
{
  public:
    // Default constructor.
    PKSMS2reader();
    // Destructor.
    virtual ~PKSMS2reader();
    //  Open the MS for reading.
    virtual Int open(
        const String msName,
        Vector &beams,
        Vector &IFs,
        Vector &nChan,
        Vector &nPol,
        Vector &haveXPol,
        Bool   &haveBase,
        Bool   &haveSpectra);
    // Get parameters describing the data.
    virtual Int getHeader(
        String &observer,
        String &project,
        String &antName,
        Vector &antPosition,
        String &obsMode,
        String &bunit,
        Float  &equinox,
        String &dopplerFrame,
        Double &mjd,
        Double &refFreq,
        Double &bandwidth);
    // Get frequency parameters for each IF.
    virtual Int getFreqInfo(
        Vector &startFreq,
        Vector &endFreq);
    // Set data selection criteria.  Channel numbering is 1-relative, zero or
    // negative channel numbers are taken to be offsets from the last channel.
    virtual uInt select(
        const Vector beamSel,
        const Vector IFsel,
        const Vector  startChan,
        const Vector  endChan,
        const Vector  refChan,
        const Bool getSpectra = True,
        const Bool getXPol    = False,
        const Int  coordSys   = 0);
    // Find the range of the data selected in time and position.
    virtual Int findRange(
        Int    &nRow,
        Int    &nSel,
        Vector &timeSpan,
        Matrix &positions);
    // Read the next data record.
    virtual Int read(PKSrecord &pksrec);
    // Close the MS.
    virtual void close(void);
  private:
    Bool   cHaveBaseLin, cHaveCalFctr, cHaveSrcVel, cHaveTsys, cHaveXCalFctr,
           cMSopen;
    Int    cCycleNo, cIdx, cNRow, cScanNo;
    Double cTime;
    Vector    cEndChan, cRefChan, cStartChan;
    Vector   cBeams, cIFs;
    Vector cDataSel;
    MeasurementSet cPKSMS;
    ROScalarColumn     cScanNoCol;
    ROScalarColumn  cTimeCol;
    ROScalarColumn  cIntervalCol;
    ROScalarColumn     cFieldIdCol;
    ROScalarColumn  cFieldNameCol;
    ROScalarColumn     cSrcIdCol;
    ROScalarColumn  cSrcNameCol;
    ROArrayColumn   cSrcDirCol;
    ROArrayColumn   cSrcPMCol;
    ROArrayColumn   cSrcVelCol;
    ROScalarColumn     cStateIdCol;
    ROScalarColumn  cObsModeCol;
    ROArrayColumn   cSrcRestFrqCol;
    ROScalarColumn     cDataDescIdCol;
    ROArrayColumn   cChanFreqCol;
    ROScalarColumn  cWeatherTimeCol;
    ROScalarColumn   cTemperatureCol;
    ROScalarColumn   cPressureCol;
    ROScalarColumn   cHumidityCol;
    ROScalarColumn     cBeamNoCol;
    ROArrayColumn   cPointingCol;
    ROArrayColumn    cTsysCol;
    ROArrayColumn    cSigmaCol;
    ROArrayColumn    cCalFctrCol;
    ROArrayColumn    cBaseLinCol;
    ROArrayColumn    cBaseSubCol;
    ROArrayColumn    cFloatDataCol;
    ROArrayColumn     cFlagCol;
    ROScalarColumn cXCalFctrCol;
    ROArrayColumn  cDataCol;
    ROScalarColumn     cNumReceptorCol;
};
#endif