casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
PKSMS2writer.h
Go to the documentation of this file.
00001 //#---------------------------------------------------------------------------
00002 //# PKSMS2writer.h: Class to write Parkes Multibeam data to a measurementset.
00003 //#---------------------------------------------------------------------------
00004 //# livedata - processing pipeline for single-dish, multibeam spectral data.
00005 //# Copyright (C) 2000-2009, Australia Telescope National Facility, CSIRO
00006 //#
00007 //# This file is part of livedata.
00008 //#
00009 //# livedata is free software: you can redistribute it and/or modify it under
00010 //# the terms of the GNU General Public License as published by the Free
00011 //# Software Foundation, either version 3 of the License, or (at your option)
00012 //# any later version.
00013 //#
00014 //# livedata is distributed in the hope that it will be useful, but WITHOUT
00015 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00016 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
00017 //# more details.
00018 //#
00019 //# You should have received a copy of the GNU General Public License along
00020 //# with livedata.  If not, see <http://www.gnu.org/licenses/>.
00021 //#
00022 //# Correspondence concerning livedata may be directed to:
00023 //#        Internet email: mcalabre@atnf.csiro.au
00024 //#        Postal address: Dr. Mark Calabretta
00025 //#                        Australia Telescope National Facility, CSIRO
00026 //#                        PO Box 76
00027 //#                        Epping NSW 1710
00028 //#                        AUSTRALIA
00029 //#
00030 //# http://www.atnf.csiro.au/computing/software/livedata.html
00031 //# $Id: PKSMS2writer.h,v 19.14 2009-09-29 07:33:38 cal103 Exp $
00032 //#---------------------------------------------------------------------------
00033 
00034 #ifndef ATNF_PKSMS2WRITER_H
00035 #define ATNF_PKSMS2WRITER_H
00036 
00037 #include <atnf/PKSIO/PKSrecord.h>
00038 #include <atnf/PKSIO/PKSwriter.h>
00039 
00040 #include <casa/aips.h>
00041 #include <casa/Arrays/Matrix.h>
00042 #include <casa/Arrays/Vector.h>
00043 #include <casa/BasicSL/Complex.h>
00044 #include <casa/BasicSL/String.h>
00045 #include <ms/MeasurementSets/MeasurementSet.h>
00046 #include <ms/MeasurementSets/MSColumns.h>
00047 
00048 #include <casa/namespace.h>
00049 
00050 // <summary>
00051 // Class to write Parkes Multibeam data to a measurementset.
00052 // </summary>
00053 
00054 class PKSMS2writer : public PKSwriter
00055 {
00056   public:
00057     // Default constructor.
00058     PKSMS2writer();
00059 
00060     // Destructor.
00061     virtual ~PKSMS2writer();
00062 
00063     // Create the output MS and write static data.
00064     virtual Int create(
00065         const String msName,
00066         const String observer,
00067         const String project,
00068         const String antName,
00069         const Vector<Double> antPosition,
00070         const String obsMode,
00071         const String bunit,
00072         const Float  equinox,
00073         const String dopplerFrame,
00074         const Vector<uInt> nChan,
00075         const Vector<uInt> nPol,
00076         const Vector<Bool> haveXPol,
00077         const Bool   haveBase);
00078 
00079     // Write the next data record.
00126     virtual Int write(
00127         const PKSrecord &pksrec);
00128 
00129     // Close the MS, flushing all associated Tables.
00130     virtual void close();
00131 
00132   private:
00133     MFrequency::Types cDopplerFrame;
00134 
00135     // Measurementset main table and subtables.
00136     MeasurementSet *cPKSMS;
00137     MSAntenna cAntenna;
00138     MSDataDescription cDataDescription;
00139     MSDoppler cDoppler;
00140     MSFeed cFeed;
00141     MSField cField;
00142     MSFlagCmd cFlagCmd;
00143     MSHistory cHistory;
00144     MSObservation cObservation;
00145     MSPointing cPointing;
00146     MSPolarization cPolarization;
00147     MSProcessor cProcessor;
00148     MSSource cSource;
00149     MSSpectralWindow cSpectralWindow;
00150     MSState cState;
00151     MSSysCal cSysCal;
00152     MSWeather cWeather;
00153 
00154     // Access to measurementset table columns; we are forced to use pointers
00155     // here since none of these classes have default constructors.
00156     MSColumns *cMSCols;
00157     MSAntennaColumns *cAntennaCols;
00158     MSDataDescColumns *cDataDescCols;
00159     MSDopplerColumns *cDopplerCols;
00160     MSFeedColumns *cFeedCols;
00161     MSFieldColumns *cFieldCols;
00162     MSFlagCmdColumns *cFlagCmdCols;
00163     MSHistoryColumns *cHistoryCols;
00164     MSObservationColumns *cObservationCols;
00165     MSPointingColumns *cPointingCols;
00166     MSPolarizationColumns *cPolarizationCols;
00167     MSProcessorColumns *cProcessorCols;
00168     MSSourceColumns *cSourceCols;
00169     MSSpWindowColumns *cSpWindowCols;
00170     MSStateColumns *cStateCols;
00171     MSSysCalColumns *cSysCalCols;
00172     MSWeatherColumns *cWeatherCols;
00173 
00174     ArrayColumn<Float> *cCalFctrCol;
00175     ArrayColumn<Float> *cBaseLinCol;
00176     ArrayColumn<Float> *cBaseSubCol;
00177     ScalarColumn<Complex> *cXCalFctrCol;
00178 
00179     // for handling parameters specific to GBT and other telescopes
00180     Bool cGBT, cSMT, cAPEX, cALMA, cATF;
00181 
00182     // Add an entry to the ANTENNA subtable.
00183     Int addAntennaEntry(
00184         const String antName,
00185         const Vector<Double> &antPosition);
00186 
00187     // Add an entry to the DATA_DESCRIPTION subtable.
00188     Int addDataDescriptionEntry(
00189         const Int iIF);
00190 
00191     // Add an entry to the DOPPLER subtable.
00192     Int addDopplerEntry();
00193 
00194     // Add an entry to the FEED subtable.
00195     Int addFeedEntry();
00196 
00197     // Add an entry to the FIELD subtable.
00198     Int addFieldEntry(
00199         const String fieldName,
00200         const Double mjd,
00201         const Vector<Double> direction,
00202         const Vector<Double> scanRate,
00203         const Int srcId);
00204 
00205     // Skip FLAG_CMD subtable.
00206 
00207     // Skip FREQ_OFFSET subtable.
00208 
00209     // Skip HISTORY subtable.
00210 
00211     // Add an entry to the OBSERVATION subtable.
00212     Int addObservationEntry(
00213         const String observer,
00214         const String project,
00215         const String antName);
00216 
00217     // Add an entry to the POINTING subtable.
00218     Int addPointingEntry(
00219         const Double mjd,
00220         const Double interval,
00221         const String fieldName,
00222         const Vector<Double> direction,
00223         const Vector<Double> scanRate);
00224 
00225     // Add an entry to the POLARIZATION subtable.
00226     Int addPolarizationEntry(
00227         const Int iIF,
00228         const Int nPol);
00229 
00230     // Add an entry to the PROCESSOR subtable.
00231     Int addProcessorEntry();
00232 
00233     // Add an entry to the SOURCE subtable.
00234     Int addSourceEntry(
00235         const String name,
00236         const Vector<Double> direction,
00237         const Vector<Double> properMotion,
00238         //const Double restFreq,
00239         const Vector<Double> restFreq,
00240         const Double radialVelocity);
00241 
00242     // Add an entry to the SPECTRAL_WINDOW subtable.
00243     Int addSpectralWindowEntry(
00244         const Int iIF,
00245         const Int nChan,
00246         const Double refFreq,
00247         const Double bandwidth,
00248         const Double freqInc);
00249 
00250     // Add an entry to the STATE subtable.
00251     Int addStateEntry(
00252         const String obsMode);
00253 
00254     // Add an entry to the SYSCAL subtable.
00255     Int addSysCalEntry(
00256         const Int beamNo,
00257         const Int spWinId,
00258         const Double mjd,
00259         const Double interval,
00260         const Vector<Float> Tcal,
00261         const Vector<Float> Tsys,
00262         const Int nPol);
00263 
00264     // Add an entry to the WEATHER subtable.
00265     Int addWeatherEntry(
00266         const Double mjd,
00267         const Double interval,
00268         const Double pressure,
00269         const Double humidity,
00270         const Double temperature);
00271 };
00272 
00273 #endif