| 1 | //#--------------------------------------------------------------------------- | 
|---|
| 2 | //# PKSMS2writer.h: Class to write Parkes Multibeam data to a measurementset. | 
|---|
| 3 | //#--------------------------------------------------------------------------- | 
|---|
| 4 | //# Copyright (C) 2000-2006 | 
|---|
| 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.11 2006/07/05 05:35:31 mcalabre Exp $ | 
|---|
| 29 | //#--------------------------------------------------------------------------- | 
|---|
| 30 |  | 
|---|
| 31 | #ifndef ATNF_PKSMS2WRITER_H | 
|---|
| 32 | #define ATNF_PKSMS2WRITER_H | 
|---|
| 33 |  | 
|---|
| 34 | #include <atnf/PKSIO/PKSwriter.h> | 
|---|
| 35 |  | 
|---|
| 36 | #include <casa/aips.h> | 
|---|
| 37 | #include <casa/Arrays/Matrix.h> | 
|---|
| 38 | #include <casa/Arrays/Vector.h> | 
|---|
| 39 | #include <casa/BasicSL/Complex.h> | 
|---|
| 40 | #include <ms/MeasurementSets/MeasurementSet.h> | 
|---|
| 41 | #include <ms/MeasurementSets/MSColumns.h> | 
|---|
| 42 | #include <casa/BasicSL/String.h> | 
|---|
| 43 |  | 
|---|
| 44 | // <summary> | 
|---|
| 45 | // Class to write Parkes Multibeam data to a measurementset. | 
|---|
| 46 | // </summary> | 
|---|
| 47 |  | 
|---|
| 48 | #include <casa/namespace.h> | 
|---|
| 49 | class PKSMS2writer : public PKSwriter | 
|---|
| 50 | { | 
|---|
| 51 | public: | 
|---|
| 52 | // Default constructor. | 
|---|
| 53 | PKSMS2writer(); | 
|---|
| 54 |  | 
|---|
| 55 | // Destructor. | 
|---|
| 56 | virtual ~PKSMS2writer(); | 
|---|
| 57 |  | 
|---|
| 58 | // Create the output MS and write static data. | 
|---|
| 59 | virtual Int create( | 
|---|
| 60 | const String msName, | 
|---|
| 61 | const String observer, | 
|---|
| 62 | const String project, | 
|---|
| 63 | const String antName, | 
|---|
| 64 | const Vector<Double> antPosition, | 
|---|
| 65 | const String obsMode, | 
|---|
| 66 | const Float  equinox, | 
|---|
| 67 | const String dopplerFrame, | 
|---|
| 68 | const Vector<uInt> nChan, | 
|---|
| 69 | const Vector<uInt> nPol, | 
|---|
| 70 | const Vector<Bool> haveXPol, | 
|---|
| 71 | const Bool   haveBase); | 
|---|
| 72 |  | 
|---|
| 73 | // Write the next data record. | 
|---|
| 74 | virtual Int write( | 
|---|
| 75 | const Int             scanNo, | 
|---|
| 76 | const Int             cycleNo, | 
|---|
| 77 | const Double          mjd, | 
|---|
| 78 | const Double          interval, | 
|---|
| 79 | const String          fieldName, | 
|---|
| 80 | const String          srcName, | 
|---|
| 81 | const Vector<Double>  srcDir, | 
|---|
| 82 | const Vector<Double>  srcPM, | 
|---|
| 83 | const Double          srcVel, | 
|---|
| 84 | const String          obsMode, | 
|---|
| 85 | const Int             IFno, | 
|---|
| 86 | const Double          refFreq, | 
|---|
| 87 | const Double          bandwidth, | 
|---|
| 88 | const Double          freqInc, | 
|---|
| 89 | const Double          restFreq, | 
|---|
| 90 | const Vector<Float>   tcal, | 
|---|
| 91 | const String          tcalTime, | 
|---|
| 92 | const Float           azimuth, | 
|---|
| 93 | const Float           elevation, | 
|---|
| 94 | const Float           parAngle, | 
|---|
| 95 | const Float           focusAxi, | 
|---|
| 96 | const Float           focusTan, | 
|---|
| 97 | const Float           focusRot, | 
|---|
| 98 | const Float           temperature, | 
|---|
| 99 | const Float           pressure, | 
|---|
| 100 | const Float           humidity, | 
|---|
| 101 | const Float           windSpeed, | 
|---|
| 102 | const Float           windAz, | 
|---|
| 103 | const Int             refBeam, | 
|---|
| 104 | const Int             beamNo, | 
|---|
| 105 | const Vector<Double>  direction, | 
|---|
| 106 | const Vector<Double>  scanRate, | 
|---|
| 107 | const Vector<Float>   tsys, | 
|---|
| 108 | const Vector<Float>   sigma, | 
|---|
| 109 | const Vector<Float>   calFctr, | 
|---|
| 110 | const Matrix<Float>   baseLin, | 
|---|
| 111 | const Matrix<Float>   baseSub, | 
|---|
| 112 | const Matrix<Float>   &spectra, | 
|---|
| 113 | const Matrix<uChar>   &flagged, | 
|---|
| 114 | const Complex         xCalFctr, | 
|---|
| 115 | const Vector<Complex> &xPol); | 
|---|
| 116 |  | 
|---|
| 117 | // Close the MS, flushing all associated Tables. | 
|---|
| 118 | virtual void close(); | 
|---|
| 119 |  | 
|---|
| 120 | private: | 
|---|
| 121 | MFrequency::Types cDopplerFrame; | 
|---|
| 122 |  | 
|---|
| 123 | // Measurementset main table and subtables. | 
|---|
| 124 | MeasurementSet *cPKSMS; | 
|---|
| 125 | MSAntenna cAntenna; | 
|---|
| 126 | MSDataDescription cDataDescription; | 
|---|
| 127 | MSDoppler cDoppler; | 
|---|
| 128 | MSFeed cFeed; | 
|---|
| 129 | MSField cField; | 
|---|
| 130 | MSFlagCmd cFlagCmd; | 
|---|
| 131 | MSHistory cHistory; | 
|---|
| 132 | MSObservation cObservation; | 
|---|
| 133 | MSPointing cPointing; | 
|---|
| 134 | MSPolarization cPolarization; | 
|---|
| 135 | MSProcessor cProcessor; | 
|---|
| 136 | MSSource cSource; | 
|---|
| 137 | MSSpectralWindow cSpectralWindow; | 
|---|
| 138 | MSState cState; | 
|---|
| 139 | MSSysCal cSysCal; | 
|---|
| 140 | MSWeather cWeather; | 
|---|
| 141 |  | 
|---|
| 142 | // Access to measurementset table columns; we are forced to use pointers | 
|---|
| 143 | // here since none of these classes have default constructors. | 
|---|
| 144 | MSColumns *cMSCols; | 
|---|
| 145 | MSAntennaColumns *cAntennaCols; | 
|---|
| 146 | MSDataDescColumns *cDataDescCols; | 
|---|
| 147 | MSDopplerColumns *cDopplerCols; | 
|---|
| 148 | MSFeedColumns *cFeedCols; | 
|---|
| 149 | MSFieldColumns *cFieldCols; | 
|---|
| 150 | MSFlagCmdColumns *cFlagCmdCols; | 
|---|
| 151 | MSHistoryColumns *cHistoryCols; | 
|---|
| 152 | MSObservationColumns *cObservationCols; | 
|---|
| 153 | MSPointingColumns *cPointingCols; | 
|---|
| 154 | MSPolarizationColumns *cPolarizationCols; | 
|---|
| 155 | MSProcessorColumns *cProcessorCols; | 
|---|
| 156 | MSSourceColumns *cSourceCols; | 
|---|
| 157 | MSSpWindowColumns *cSpWindowCols; | 
|---|
| 158 | MSStateColumns *cStateCols; | 
|---|
| 159 | MSSysCalColumns *cSysCalCols; | 
|---|
| 160 | MSWeatherColumns *cWeatherCols; | 
|---|
| 161 |  | 
|---|
| 162 | ArrayColumn<Float> *cCalFctrCol; | 
|---|
| 163 | ArrayColumn<Float> *cBaseLinCol; | 
|---|
| 164 | ArrayColumn<Float> *cBaseSubCol; | 
|---|
| 165 | ScalarColumn<Complex> *cXCalFctrCol; | 
|---|
| 166 |  | 
|---|
| 167 |  | 
|---|
| 168 | // Add an entry to the ANTENNA subtable. | 
|---|
| 169 | Int addAntennaEntry( | 
|---|
| 170 | const String antName, | 
|---|
| 171 | const Vector<Double> &antPosition); | 
|---|
| 172 |  | 
|---|
| 173 | // Add an entry to the DATA_DESCRIPTION subtable. | 
|---|
| 174 | Int addDataDescriptionEntry( | 
|---|
| 175 | const Int iIF); | 
|---|
| 176 |  | 
|---|
| 177 | // Add an entry to the DOPPLER subtable. | 
|---|
| 178 | Int addDopplerEntry(); | 
|---|
| 179 |  | 
|---|
| 180 | // Add an entry to the FEED subtable. | 
|---|
| 181 | Int addFeedEntry(); | 
|---|
| 182 |  | 
|---|
| 183 | // Add an entry to the FIELD subtable. | 
|---|
| 184 | Int addFieldEntry( | 
|---|
| 185 | const String fieldName, | 
|---|
| 186 | const Double mjd, | 
|---|
| 187 | const Vector<Double> direction, | 
|---|
| 188 | const Vector<Double> scanRate, | 
|---|
| 189 | const Int srcId); | 
|---|
| 190 |  | 
|---|
| 191 | // Skip FLAG_CMD subtable. | 
|---|
| 192 |  | 
|---|
| 193 | // Skip FREQ_OFFSET subtable. | 
|---|
| 194 |  | 
|---|
| 195 | // Skip HISTORY subtable. | 
|---|
| 196 |  | 
|---|
| 197 | // Add an entry to the OBSERVATION subtable. | 
|---|
| 198 | Int addObservationEntry( | 
|---|
| 199 | const String observer, | 
|---|
| 200 | const String project); | 
|---|
| 201 |  | 
|---|
| 202 | // Add an entry to the POINTING subtable. | 
|---|
| 203 | Int addPointingEntry( | 
|---|
| 204 | const Double mjd, | 
|---|
| 205 | const Double interval, | 
|---|
| 206 | const String fieldName, | 
|---|
| 207 | const Vector<Double> direction, | 
|---|
| 208 | const Vector<Double> scanRate); | 
|---|
| 209 |  | 
|---|
| 210 | // Add an entry to the POLARIZATION subtable. | 
|---|
| 211 | Int addPolarizationEntry( | 
|---|
| 212 | const Int iIF, | 
|---|
| 213 | const Int nPol); | 
|---|
| 214 |  | 
|---|
| 215 | // Add an entry to the PROCESSOR subtable. | 
|---|
| 216 | Int addProcessorEntry(); | 
|---|
| 217 |  | 
|---|
| 218 | // Add an entry to the SOURCE subtable. | 
|---|
| 219 | Int addSourceEntry( | 
|---|
| 220 | const String name, | 
|---|
| 221 | const Vector<Double> direction, | 
|---|
| 222 | const Vector<Double> properMotion, | 
|---|
| 223 | const Double restFreq, | 
|---|
| 224 | const Double radialVelocity); | 
|---|
| 225 |  | 
|---|
| 226 | // Add an entry to the SPECTRAL_WINDOW subtable. | 
|---|
| 227 | Int addSpectralWindowEntry( | 
|---|
| 228 | const Int iIF, | 
|---|
| 229 | const Int nChan, | 
|---|
| 230 | const Double refFreq, | 
|---|
| 231 | const Double bandwidth, | 
|---|
| 232 | const Double freqInc); | 
|---|
| 233 |  | 
|---|
| 234 | // Add an entry to the STATE subtable. | 
|---|
| 235 | Int addStateEntry( | 
|---|
| 236 | const String obsMode); | 
|---|
| 237 |  | 
|---|
| 238 | // Add an entry to the SYSCAL subtable. | 
|---|
| 239 | Int addSysCalEntry( | 
|---|
| 240 | const Int beamNo, | 
|---|
| 241 | const Int spWinId, | 
|---|
| 242 | const Double mjd, | 
|---|
| 243 | const Double interval, | 
|---|
| 244 | const Vector<Float> Tcal, | 
|---|
| 245 | const Vector<Float> Tsys); | 
|---|
| 246 |  | 
|---|
| 247 | // Add an entry to the WEATHER subtable. | 
|---|
| 248 | Int addWeatherEntry( | 
|---|
| 249 | const Double mjd, | 
|---|
| 250 | const Double interval, | 
|---|
| 251 | const Double pressure, | 
|---|
| 252 | const Double humidity, | 
|---|
| 253 | const Double temperature); | 
|---|
| 254 | }; | 
|---|
| 255 |  | 
|---|
| 256 | #endif | 
|---|