| 1 | //#---------------------------------------------------------------------------
 | 
|---|
| 2 | //# PKSMS2writer.h: Class to write Parkes Multibeam data to a measurementset.
 | 
|---|
| 3 | //#---------------------------------------------------------------------------
 | 
|---|
| 4 | //# Copyright (C) 2000-2007
 | 
|---|
| 5 | //# Associated Universities, Inc. Washington DC, USA.
 | 
|---|
| 6 | //#
 | 
|---|
| 7 | //# This library is free software; you can redistribute it and/or modify it
 | 
|---|
| 8 | //# under the terms of the GNU Library General Public License as published by
 | 
|---|
| 9 | //# the Free Software Foundation; either version 2 of the License, or (at your
 | 
|---|
| 10 | //# option) any later version.
 | 
|---|
| 11 | //#
 | 
|---|
| 12 | //# This library is distributed in the hope that it will be useful, but WITHOUT
 | 
|---|
| 13 | //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 | 
|---|
| 14 | //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
 | 
|---|
| 15 | //# License for more details.
 | 
|---|
| 16 | //#
 | 
|---|
| 17 | //# You should have received a copy of the GNU Library General Public License
 | 
|---|
| 18 | //# along with this library; if not, write to the Free Software Foundation,
 | 
|---|
| 19 | //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
 | 
|---|
| 20 | //#
 | 
|---|
| 21 | //# Correspondence concerning AIPS++ should be addressed as follows:
 | 
|---|
| 22 | //#        Internet email: aips2-request@nrao.edu.
 | 
|---|
| 23 | //#        Postal address: AIPS++ Project Office
 | 
|---|
| 24 | //#                        National Radio Astronomy Observatory
 | 
|---|
| 25 | //#                        520 Edgemont Road
 | 
|---|
| 26 | //#                        Charlottesville, VA 22903-2475 USA
 | 
|---|
| 27 | //#
 | 
|---|
| 28 | //# $Id: PKSMS2writer.h,v 19.13 2008-11-17 06:40:25 cal103 Exp $
 | 
|---|
| 29 | //#---------------------------------------------------------------------------
 | 
|---|
| 30 | 
 | 
|---|
| 31 | #ifndef ATNF_PKSMS2WRITER_H
 | 
|---|
| 32 | #define ATNF_PKSMS2WRITER_H
 | 
|---|
| 33 | 
 | 
|---|
| 34 | #include <atnf/PKSIO/PKSrecord.h>
 | 
|---|
| 35 | #include <atnf/PKSIO/PKSwriter.h>
 | 
|---|
| 36 | 
 | 
|---|
| 37 | #include <casa/aips.h>
 | 
|---|
| 38 | #include <casa/Arrays/Matrix.h>
 | 
|---|
| 39 | #include <casa/Arrays/Vector.h>
 | 
|---|
| 40 | #include <casa/BasicSL/Complex.h>
 | 
|---|
| 41 | #include <casa/BasicSL/String.h>
 | 
|---|
| 42 | #include <ms/MeasurementSets/MeasurementSet.h>
 | 
|---|
| 43 | #include <ms/MeasurementSets/MSColumns.h>
 | 
|---|
| 44 | 
 | 
|---|
| 45 | #include <casa/namespace.h>
 | 
|---|
| 46 | 
 | 
|---|
| 47 | // <summary>
 | 
|---|
| 48 | // Class to write Parkes Multibeam data to a measurementset.
 | 
|---|
| 49 | // </summary>
 | 
|---|
| 50 | 
 | 
|---|
| 51 | class PKSMS2writer : public PKSwriter
 | 
|---|
| 52 | {
 | 
|---|
| 53 |   public:
 | 
|---|
| 54 |     // Default constructor.
 | 
|---|
| 55 |     PKSMS2writer();
 | 
|---|
| 56 | 
 | 
|---|
| 57 |     // Destructor.
 | 
|---|
| 58 |     virtual ~PKSMS2writer();
 | 
|---|
| 59 | 
 | 
|---|
| 60 |     // Create the output MS and write static data.
 | 
|---|
| 61 |     virtual Int create(
 | 
|---|
| 62 |         const String msName,
 | 
|---|
| 63 |         const String observer,
 | 
|---|
| 64 |         const String project,
 | 
|---|
| 65 |         const String antName,
 | 
|---|
| 66 |         const Vector<Double> antPosition,
 | 
|---|
| 67 |         const String obsMode,
 | 
|---|
| 68 |         const String bunit,
 | 
|---|
| 69 |         const Float  equinox,
 | 
|---|
| 70 |         const String dopplerFrame,
 | 
|---|
| 71 |         const Vector<uInt> nChan,
 | 
|---|
| 72 |         const Vector<uInt> nPol,
 | 
|---|
| 73 |         const Vector<Bool> haveXPol,
 | 
|---|
| 74 |         const Bool   haveBase);
 | 
|---|
| 75 | 
 | 
|---|
| 76 |     // Write the next data record.
 | 
|---|
| 77 |     virtual Int write(
 | 
|---|
| 78 |         const PKSrecord &pksrec);
 | 
|---|
| 79 | 
 | 
|---|
| 80 |     // Close the MS, flushing all associated Tables.
 | 
|---|
| 81 |     virtual void close();
 | 
|---|
| 82 | 
 | 
|---|
| 83 |   private:
 | 
|---|
| 84 |     MFrequency::Types cDopplerFrame;
 | 
|---|
| 85 | 
 | 
|---|
| 86 |     // Measurementset main table and subtables.
 | 
|---|
| 87 |     MeasurementSet *cPKSMS;
 | 
|---|
| 88 |     MSAntenna cAntenna;
 | 
|---|
| 89 |     MSDataDescription cDataDescription;
 | 
|---|
| 90 |     MSDoppler cDoppler;
 | 
|---|
| 91 |     MSFeed cFeed;
 | 
|---|
| 92 |     MSField cField;
 | 
|---|
| 93 |     MSFlagCmd cFlagCmd;
 | 
|---|
| 94 |     MSHistory cHistory;
 | 
|---|
| 95 |     MSObservation cObservation;
 | 
|---|
| 96 |     MSPointing cPointing;
 | 
|---|
| 97 |     MSPolarization cPolarization;
 | 
|---|
| 98 |     MSProcessor cProcessor;
 | 
|---|
| 99 |     MSSource cSource;
 | 
|---|
| 100 |     MSSpectralWindow cSpectralWindow;
 | 
|---|
| 101 |     MSState cState;
 | 
|---|
| 102 |     MSSysCal cSysCal;
 | 
|---|
| 103 |     MSWeather cWeather;
 | 
|---|
| 104 | 
 | 
|---|
| 105 |     // Access to measurementset table columns; we are forced to use pointers
 | 
|---|
| 106 |     // here since none of these classes have default constructors.
 | 
|---|
| 107 |     MSColumns *cMSCols;
 | 
|---|
| 108 |     MSAntennaColumns *cAntennaCols;
 | 
|---|
| 109 |     MSDataDescColumns *cDataDescCols;
 | 
|---|
| 110 |     MSDopplerColumns *cDopplerCols;
 | 
|---|
| 111 |     MSFeedColumns *cFeedCols;
 | 
|---|
| 112 |     MSFieldColumns *cFieldCols;
 | 
|---|
| 113 |     MSFlagCmdColumns *cFlagCmdCols;
 | 
|---|
| 114 |     MSHistoryColumns *cHistoryCols;
 | 
|---|
| 115 |     MSObservationColumns *cObservationCols;
 | 
|---|
| 116 |     MSPointingColumns *cPointingCols;
 | 
|---|
| 117 |     MSPolarizationColumns *cPolarizationCols;
 | 
|---|
| 118 |     MSProcessorColumns *cProcessorCols;
 | 
|---|
| 119 |     MSSourceColumns *cSourceCols;
 | 
|---|
| 120 |     MSSpWindowColumns *cSpWindowCols;
 | 
|---|
| 121 |     MSStateColumns *cStateCols;
 | 
|---|
| 122 |     MSSysCalColumns *cSysCalCols;
 | 
|---|
| 123 |     MSWeatherColumns *cWeatherCols;
 | 
|---|
| 124 | 
 | 
|---|
| 125 |     ArrayColumn<Float> *cCalFctrCol;
 | 
|---|
| 126 |     ArrayColumn<Float> *cBaseLinCol;
 | 
|---|
| 127 |     ArrayColumn<Float> *cBaseSubCol;
 | 
|---|
| 128 |     ScalarColumn<Complex> *cXCalFctrCol;
 | 
|---|
| 129 | 
 | 
|---|
| 130 | 
 | 
|---|
| 131 |     // Add an entry to the ANTENNA subtable.
 | 
|---|
| 132 |     Int addAntennaEntry(
 | 
|---|
| 133 |         const String antName,
 | 
|---|
| 134 |         const Vector<Double> &antPosition);
 | 
|---|
| 135 | 
 | 
|---|
| 136 |     // Add an entry to the DATA_DESCRIPTION subtable.
 | 
|---|
| 137 |     Int addDataDescriptionEntry(
 | 
|---|
| 138 |         const Int iIF);
 | 
|---|
| 139 | 
 | 
|---|
| 140 |     // Add an entry to the DOPPLER subtable.
 | 
|---|
| 141 |     Int addDopplerEntry();
 | 
|---|
| 142 | 
 | 
|---|
| 143 |     // Add an entry to the FEED subtable.
 | 
|---|
| 144 |     Int addFeedEntry();
 | 
|---|
| 145 | 
 | 
|---|
| 146 |     // Add an entry to the FIELD subtable.
 | 
|---|
| 147 |     Int addFieldEntry(
 | 
|---|
| 148 |         const String fieldName,
 | 
|---|
| 149 |         const Double mjd,
 | 
|---|
| 150 |         const Vector<Double> direction,
 | 
|---|
| 151 |         const Vector<Double> scanRate,
 | 
|---|
| 152 |         const Int srcId);
 | 
|---|
| 153 | 
 | 
|---|
| 154 |     // Skip FLAG_CMD subtable.
 | 
|---|
| 155 | 
 | 
|---|
| 156 |     // Skip FREQ_OFFSET subtable.
 | 
|---|
| 157 | 
 | 
|---|
| 158 |     // Skip HISTORY subtable.
 | 
|---|
| 159 | 
 | 
|---|
| 160 |     // Add an entry to the OBSERVATION subtable.
 | 
|---|
| 161 |     Int addObservationEntry(
 | 
|---|
| 162 |         const String observer,
 | 
|---|
| 163 |         const String project);
 | 
|---|
| 164 | 
 | 
|---|
| 165 |     // Add an entry to the POINTING subtable.
 | 
|---|
| 166 |     Int addPointingEntry(
 | 
|---|
| 167 |         const Double mjd,
 | 
|---|
| 168 |         const Double interval,
 | 
|---|
| 169 |         const String fieldName,
 | 
|---|
| 170 |         const Vector<Double> direction,
 | 
|---|
| 171 |         const Vector<Double> scanRate);
 | 
|---|
| 172 | 
 | 
|---|
| 173 |     // Add an entry to the POLARIZATION subtable.
 | 
|---|
| 174 |     Int addPolarizationEntry(
 | 
|---|
| 175 |         const Int iIF,
 | 
|---|
| 176 |         const Int nPol);
 | 
|---|
| 177 | 
 | 
|---|
| 178 |     // Add an entry to the PROCESSOR subtable.
 | 
|---|
| 179 |     Int addProcessorEntry();
 | 
|---|
| 180 | 
 | 
|---|
| 181 |     // Add an entry to the SOURCE subtable.
 | 
|---|
| 182 |     Int addSourceEntry(
 | 
|---|
| 183 |         const String name,
 | 
|---|
| 184 |         const Vector<Double> direction,
 | 
|---|
| 185 |         const Vector<Double> properMotion,
 | 
|---|
| 186 |         const Double restFreq,
 | 
|---|
| 187 |         const Double radialVelocity);
 | 
|---|
| 188 | 
 | 
|---|
| 189 |     // Add an entry to the SPECTRAL_WINDOW subtable.
 | 
|---|
| 190 |     Int addSpectralWindowEntry(
 | 
|---|
| 191 |         const Int iIF,
 | 
|---|
| 192 |         const Int nChan,
 | 
|---|
| 193 |         const Double refFreq,
 | 
|---|
| 194 |         const Double bandwidth,
 | 
|---|
| 195 |         const Double freqInc);
 | 
|---|
| 196 | 
 | 
|---|
| 197 |     // Add an entry to the STATE subtable.
 | 
|---|
| 198 |     Int addStateEntry(
 | 
|---|
| 199 |         const String obsMode);
 | 
|---|
| 200 | 
 | 
|---|
| 201 |     // Add an entry to the SYSCAL subtable.
 | 
|---|
| 202 |     Int addSysCalEntry(
 | 
|---|
| 203 |         const Int beamNo,
 | 
|---|
| 204 |         const Int spWinId,
 | 
|---|
| 205 |         const Double mjd,
 | 
|---|
| 206 |         const Double interval,
 | 
|---|
| 207 |         const Vector<Float> Tcal,
 | 
|---|
| 208 |         const Vector<Float> Tsys);
 | 
|---|
| 209 | 
 | 
|---|
| 210 |     // Add an entry to the WEATHER subtable.
 | 
|---|
| 211 |     Int addWeatherEntry(
 | 
|---|
| 212 |         const Double mjd,
 | 
|---|
| 213 |         const Double interval,
 | 
|---|
| 214 |         const Double pressure,
 | 
|---|
| 215 |         const Double humidity,
 | 
|---|
| 216 |         const Double temperature);
 | 
|---|
| 217 | };
 | 
|---|
| 218 | 
 | 
|---|
| 219 | #endif
 | 
|---|