casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MSPointingColumns.h
Go to the documentation of this file.
00001 //# MSPointingColumns.h: provides easy access to MSPointing columns
00002 //# Copyright (C) 1999,2000
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: MSPointingColumns.h 20739 2009-09-29 01:15:15Z Malte.Marquarding $
00027 
00028 #ifndef MS_MSPOINTINGCOLUMNS_H
00029 #define MS_MSPOINTINGCOLUMNS_H
00030 
00031 #include <casa/aips.h>
00032 #include <measures/Measures/MDirection.h>
00033 #include <measures/Measures/MEpoch.h>
00034 #include <measures/Measures/MCDirection.h>
00035 #include <measures/Measures/MCEpoch.h>
00036 #include <measures/TableMeasures/ArrayMeasColumn.h>
00037 #include <measures/TableMeasures/ScalarMeasColumn.h>
00038 #include <measures/TableMeasures/ScalarQuantColumn.h>
00039 #include <tables/Tables/ArrayColumn.h>
00040 #include <tables/Tables/ScalarColumn.h>
00041 
00042 namespace casa { //# NAMESPACE CASA - BEGIN
00043 
00044 class MSPointing;
00045 
00046 // <summary>
00047 // A class to provide easy read-only access to MSPointing columns
00048 // </summary>
00049 
00050 // <use visibility=export>
00051 
00052 // <reviewed reviewer="Bob Garwood" date="1997/02/01" tests="" demos="">
00053 // </reviewed>
00054 
00055 // <prerequisite>
00056 //   <li> MSPointing
00057 //   <li> ArrayColumn
00058 //   <li> ScalarColumn
00059 // </prerequisite>
00060 //
00061 // <etymology>
00062 // ROMSPointingColumns stands for Read-Only MeasurementSet Pointing Table columns.
00063 // </etymology>
00064 //
00065 // <synopsis>
00066 // This class provides read-only access to the columns in the MSPointing
00067 // Table.  It does the declaration of all the Scalar and ArrayColumns with the
00068 // correct types, so the application programmer doesn't have to worry about
00069 // getting those right. There is an access function for every predefined
00070 // column. Access to non-predefined columns will still have to be done with
00071 // explicit declarations.  See <linkto class=ROMSColumns>
00072 // ROMSColumns</linkto> for an example.
00073 // </synopsis>
00074 //
00075 // <motivation>
00076 // See <linkto class=MSColumns> MSColumns</linkto> for the motivation.
00077 // </motivation>
00078 
00079 class ROMSPointingColumns
00080 {
00081 public:
00082   // Create a columns object that accesses the data in the specified Table
00083   ROMSPointingColumns(const MSPointing& msPointing);
00084 
00085   // The destructor does nothing special
00086   ~ROMSPointingColumns();
00087 
00088   // Access to required columns
00089   // <group>
00090   const ROScalarColumn<Int>& antennaId() const {return antennaId_p;}
00091   const ROScalarColumn<Double>& time() const {return time_p;}
00092   const ROScalarQuantColumn<Double>& timeQuant() const {return timeQuant_p;}
00093   const ROScalarMeasColumn<MEpoch>& timeMeas() const {return timeMeas_p;}
00094   const ROScalarColumn<Double>& interval() const {return interval_p;}
00095   const ROScalarQuantColumn<Double>& intervalQuant() const {
00096     return intervalQuant_p;}
00097   const ROScalarColumn<String>& name() const {return name_p;}
00098   const ROScalarColumn<Int>& numPoly() const {return numPoly_p;}
00099   const ROScalarColumn<Double>& timeOrigin() const {return timeOrigin_p;}
00100   const ROScalarQuantColumn<Double>& timeOriginQuant() const {
00101    return timeOriginQuant_p;}
00102   const ROScalarMeasColumn<MEpoch>& timeOriginMeas() const {
00103     return timeOriginMeas_p;}
00104   const ROArrayColumn<Double>& direction() const {return direction_p;}
00105   const ROArrayMeasColumn<MDirection>& directionMeasCol() const {
00106     return directionMeas_p;}
00107   const ROArrayColumn<Double>& target() const {return target_p;}
00108   const ROArrayMeasColumn<MDirection>& targetMeasCol()const {
00109     return targetMeas_p;}
00110   const ROScalarColumn<Bool>& tracking() const {return tracking_p;}
00111   // </group>
00112 
00113   // Access to optional columns
00114   // <group>
00115   const ROArrayColumn<Double>& pointingOffset() const {
00116     return pointingOffset_p;}
00117   const ROArrayMeasColumn<MDirection>& pointingOffsetMeasCol() const {
00118     return pointingOffsetMeas_p;}
00119   const ROArrayColumn<Double>& sourceOffset() const {return sourceOffset_p;}
00120   const ROArrayMeasColumn<MDirection>& sourceOffsetMeasCol() const {
00121     return sourceOffsetMeas_p;}
00122   const ROArrayColumn<Double>& encoder() const {return encoder_p;}
00123   const ROScalarMeasColumn<MDirection>& encoderMeas() const {
00124     return encoderMeas_p;}
00125   const ROScalarColumn<Int>& pointingModelId() const {
00126     return pointingModelId_p;}
00127   const ROScalarColumn<Bool>& onSource() const {return onSource_p;}
00128   const ROScalarColumn<Bool>& overTheTop() const {return overTheTop_p;}
00129   // </group>
00130   
00131   // Access to interpolated directions, the default time of zero will
00132   // return the 0th order element of the polynomial.
00133   // <group>
00134   MDirection directionMeas(Int row, Double time = 0) const;
00135   MDirection targetMeas(Int row, Double time = 0) const;
00136   MDirection pointingOffsetMeas(Int row, Double time = 0) const;
00137   MDirection sourceOffsetMeas(Int row, Double time = 0) const;
00138   // </group>
00139 
00140   // return the first matching row index for this time and antenna, 
00141   // returns -1 if no match was found
00142   // For long tables you may give a guess row...the last return
00143   // is usually a good one.
00144   Int pointingIndex(Int antenna, Double time, Int guessRow=0) const;
00145 
00146   // Convenience function that returns the number of rows in any of the columns
00147   uInt nrow() const {return antennaId_p.nrow();}
00148 
00149 protected:
00150   //# default constructor creates a object that is not usable. Use the attach
00151   //# function correct this.
00152   ROMSPointingColumns();
00153 
00154   //# attach this object to the supplied table.
00155   void attach(const MSPointing& msPointing);
00156 
00157 private:
00158   //# Make the assignment operator and the copy constructor private to prevent
00159   //# any compiler generated one from being used.
00160   ROMSPointingColumns(const ROMSPointingColumns&);
00161   ROMSPointingColumns& operator=(const ROMSPointingColumns&);
00162 
00163   //# Check if any optional columns exist and if so attach them.
00164   void attachOptionalCols(const MSPointing& msPointing);
00165   
00166   //# required columns
00167   ROScalarColumn<Int> antennaId_p;
00168   ROArrayColumn<Double> direction_p;
00169   ROScalarColumn<Double> interval_p;
00170   ROScalarColumn<String> name_p;
00171   ROScalarColumn<Int> numPoly_p;
00172   ROArrayColumn<Double> target_p;
00173   ROScalarColumn<Double> time_p;
00174   ROScalarColumn<Double> timeOrigin_p;
00175   ROScalarColumn<Bool> tracking_p;
00176   //# optional columns
00177   ROArrayColumn<Double> encoder_p;
00178   ROScalarColumn<Bool> onSource_p;
00179   ROScalarColumn<Int> pointingModelId_p;
00180   ROArrayColumn<Double> pointingOffset_p;
00181   ROArrayColumn<Double> sourceOffset_p;
00182   ROScalarColumn<Bool> overTheTop_p;
00183 
00184   //# Access to Measure columns
00185   ROArrayMeasColumn<MDirection> directionMeas_p;
00186   ROArrayMeasColumn<MDirection> targetMeas_p;
00187   ROScalarMeasColumn<MEpoch> timeMeas_p;
00188   ROScalarMeasColumn<MEpoch> timeOriginMeas_p;
00189   //# optional Measure columns
00190   ROScalarMeasColumn<MDirection> encoderMeas_p;
00191   ROArrayMeasColumn<MDirection> pointingOffsetMeas_p;
00192   ROArrayMeasColumn<MDirection> sourceOffsetMeas_p;
00193 
00194   //# Access to Quantum columns
00195   ROScalarQuantColumn<Double> intervalQuant_p;
00196   ROScalarQuantColumn<Double> timeQuant_p;
00197   ROScalarQuantColumn<Double> timeOriginQuant_p;
00198 };
00199 
00200 // <summary>
00201 // A class to provide easy read-write access to MSPointing columns
00202 // </summary>
00203 
00204 // <use visibility=export>
00205 
00206 // <reviewed reviewer="Bob Garwood" date="1997/02/01" tests="" demos="">
00207 // </reviewed>
00208 
00209 // <prerequisite>
00210 //   <li> MSPointing
00211 //   <li> ArrayColumn
00212 //   <li> ScalarColumn
00213 // </prerequisite>
00214 //
00215 // <etymology>
00216 // MSPointingColumns stands for MeasurementSet Pointing Table columns.
00217 // </etymology>
00218 //
00219 // <synopsis>
00220 // This class provides access to the columns in the MSPointing Table,
00221 // it does the declaration of all the Scalar and ArrayColumns with the
00222 // correct types, so the application programmer doesn't have to
00223 // worry about getting those right. There is an access function
00224 // for every predefined column. Access to non-predefined columns will still
00225 // have to be done with explicit declarations.
00226 // See <linkto class=MSColumns> MSColumns</linkto> for an example.
00227 // </synopsis>
00228 //
00229 // <motivation>
00230 // See <linkto class=MSColumns> MSColumns</linkto> for the motivation.
00231 // </motivation>
00232 
00233 class MSPointingColumns: public ROMSPointingColumns
00234 {
00235 public:
00236   // Construct from the supplied Table
00237   MSPointingColumns(MSPointing& msPointing);
00238 
00239   // The destructor does nothing special
00240   ~MSPointingColumns();
00241 
00242   // Read-write access to required columns
00243   //
00244   // Note that the direction measures with a stored polynomial have Col() added
00245   // to their name. They are better accessed via the functions that have the
00246   // same name, without the Col suffix, that will do the interpolation for
00247   // you. These functions are in the ROMSPointingColumns class.
00248   // <group>
00249   ScalarColumn<Int>& antennaId() {return antennaId_p;}
00250   ScalarColumn<Double>& time() {return time_p;}
00251   ScalarMeasColumn<MEpoch>& timeMeas() {return timeMeas_p;}
00252   ScalarQuantColumn<Double>& timeQuant() {return timeQuant_p;}
00253   ScalarColumn<Double>& interval() {return interval_p;}
00254   ScalarQuantColumn<Double>& intervalQuant() {return intervalQuant_p;}
00255   ScalarColumn<String>& name() {return name_p;}
00256   ScalarColumn<Int>& numPoly() {return numPoly_p;}
00257   ScalarColumn<Double>& timeOrigin() {return timeOrigin_p;}
00258   ScalarQuantColumn<Double>& timeOriginQuant() {return timeOriginQuant_p;}
00259   ScalarMeasColumn<MEpoch>& timeOriginMeas() {return timeOriginMeas_p;}
00260   ArrayColumn<Double>& direction() {return direction_p;}
00261   ArrayMeasColumn<MDirection>& directionMeasCol() {return directionMeas_p;}
00262   ArrayColumn<Double>& target() {return target_p;}
00263   ArrayMeasColumn<MDirection>& targetMeasCol() {return targetMeas_p;}
00264   ScalarColumn<Bool>& tracking() {return tracking_p;}
00265   // </group>
00266 
00267   // Read-write access to optional columns
00268   // 
00269   // Note that the direction measures with a stored polynomial have Col() added
00270   // to their name. They are better accessed via the functions that have the
00271   // same name, without the Col suffix, that will do the interpolation for
00272   // you. These functions are in the ROMSPointingColumns class.
00273   // <group>
00274   ArrayColumn<Double>& pointingOffset() {return pointingOffset_p;}
00275   ArrayMeasColumn<MDirection>& pointingOffsetMeasCol() {
00276     return pointingOffsetMeas_p;}
00277   ArrayColumn<Double>& sourceOffset() {return sourceOffset_p;}
00278   ArrayMeasColumn<MDirection>& sourceOffsetMeasCol() {
00279     return sourceOffsetMeas_p;}
00280   ArrayColumn<Double>& encoder() {return encoder_p;}
00281   ScalarMeasColumn<MDirection>& encoderMeas() {return encoderMeas_p;}
00282   ScalarColumn<Int>& pointingModelId() {return pointingModelId_p;}
00283   ScalarColumn<Bool>& onSource() {return onSource_p;}
00284   ScalarColumn<Bool>& overTheTop() {return overTheTop_p;}
00285   // </group>
00286 
00287   // Read-only access to required columns
00288   // <group>
00289   const ROScalarColumn<Int>& antennaId() const {
00290     return ROMSPointingColumns::antennaId();}
00291   const ROScalarColumn<Double>& time() const {
00292     return ROMSPointingColumns::time();}
00293   const ROScalarQuantColumn<Double>& timeQuant() const {
00294     return ROMSPointingColumns::timeQuant();}
00295   const ROScalarMeasColumn<MEpoch>& timeMeas() const {
00296     return ROMSPointingColumns::timeMeas();}
00297   const ROScalarColumn<Double>& interval() const {
00298     return ROMSPointingColumns::interval();}
00299   const ROScalarQuantColumn<Double>& intervalQuant() const {
00300     return ROMSPointingColumns::intervalQuant();}
00301   const ROScalarColumn<String>& name() const {
00302     return ROMSPointingColumns::name();}
00303   const ROScalarColumn<Int>& numPoly() const {
00304     return ROMSPointingColumns::numPoly();}
00305   const ROScalarColumn<Double>& timeOrigin() const {
00306     return ROMSPointingColumns::timeOrigin();}
00307   const ROScalarQuantColumn<Double>& timeOriginQuant() const {
00308     return ROMSPointingColumns::timeOriginQuant();}
00309   const ROScalarMeasColumn<MEpoch>& timeOriginMeas() const {
00310     return ROMSPointingColumns::timeOriginMeas();}
00311   const ROArrayColumn<Double>& direction() const {
00312     return ROMSPointingColumns::direction();}
00313   const ROArrayMeasColumn<MDirection>& directionMeasCol() const {
00314     return ROMSPointingColumns::directionMeasCol();}
00315   const ROArrayColumn<Double>& target() const {
00316     return ROMSPointingColumns::target();}
00317   const ROArrayMeasColumn<MDirection>& targetMeasCol()const {
00318     return ROMSPointingColumns::targetMeasCol();}
00319   const ROScalarColumn<Bool>& tracking() const {
00320     return ROMSPointingColumns::tracking();}
00321   // </group>
00322 
00323   // Access to optional columns
00324   // <group>
00325   const ROArrayColumn<Double>& pointingOffset() const {
00326     return ROMSPointingColumns::pointingOffset();}
00327   const ROArrayMeasColumn<MDirection>& pointingOffsetMeasCol() const {
00328     return ROMSPointingColumns::pointingOffsetMeasCol();}
00329   const ROArrayColumn<Double>& sourceOffset() const {
00330     return ROMSPointingColumns::sourceOffset();}
00331   const ROArrayMeasColumn<MDirection>& sourceOffsetMeasCol() const {
00332     return ROMSPointingColumns::sourceOffsetMeasCol();}
00333   const ROArrayColumn<Double>& encoder() const {
00334     return ROMSPointingColumns::encoder();}
00335   const ROScalarMeasColumn<MDirection>& encoderMeas() const {
00336     return ROMSPointingColumns::encoderMeas();}
00337   const ROScalarColumn<Int>& pointingModelId() const {
00338     return ROMSPointingColumns::pointingModelId();}
00339   const ROScalarColumn<Bool>& onSource() const {
00340     return ROMSPointingColumns::onSource();}
00341   const ROScalarColumn<Bool>& overTheTop() const {
00342     return ROMSPointingColumns::overTheTop();}
00343   // </group>
00344   
00345   // set the epoch reference type for the TIME & TIME_ORIGIN column.
00346   // <note role=tip>
00347   // In principle this function can only be used if the table is empty,
00348   // otherwise already written values may thereafter have an incorrect
00349   // reference, offset, or unit.  However, it is possible that part of the
00350   // table gets written before these values are known.  In that case the
00351   // reference, offset, or units can be set by using a False
00352   // <src>tableMustBeEmpty</src> argument.
00353   // </note>
00354   void setEpochRef(MEpoch::Types ref, Bool tableMustBeEmpty=True);
00355 
00356   // set the direction reference type for the DIRECTION, TARGET & and, if
00357   // defined, the SOURCE_OFFSET & POINTING_OFFSET columns. This can only be
00358   // done when the table has no rows. Trying to do so at other times will throw
00359   // an exception.  Note that the optional ENCODER column must be done
00360   // separately as the MSv2 definition requires this column to use the frame(s)
00361   // of the antenna mounts.
00362   void setDirectionRef(MDirection::Types ref);
00363 
00364   // set the direction reference type for the ENCODER column (if it is defined).
00365   // This can only be done when the table has no rows. Trying to do so at other
00366   // times will throw an exception.
00367   void setEncoderDirectionRef(MDirection::Types ref);
00368 
00369 protected:
00370   //# default constructor creates a object that is not usable. Use the attach
00371   //# function correct this.
00372   MSPointingColumns();
00373 
00374   //# attach this object to the supplied table.
00375   void attach(MSPointing& msPointing);
00376 
00377 private:
00378   //# Make the assignment operator and the copy constructor private to prevent
00379   //# any compiler generated one from being used.
00380   MSPointingColumns(const MSPointingColumns&);
00381   MSPointingColumns& operator=(const MSPointingColumns&);
00382 
00383   //# Check if any optional columns exist and if so attach them.
00384   void attachOptionalCols(MSPointing& msPointing);
00385   
00386   //# required columns
00387   ScalarColumn<Int> antennaId_p;
00388   ArrayColumn<Double> direction_p;
00389   ScalarColumn<Double> interval_p;
00390   ScalarColumn<String> name_p;
00391   ScalarColumn<Int> numPoly_p;
00392   ArrayColumn<Double> target_p;
00393   ScalarColumn<Double> time_p;
00394   ScalarColumn<Double> timeOrigin_p;
00395   ScalarColumn<Bool> tracking_p;
00396   //# optional columns
00397   ArrayColumn<Double> encoder_p;
00398   ScalarColumn<Bool> onSource_p;
00399   ScalarColumn<Int> pointingModelId_p;
00400   ArrayColumn<Double> pointingOffset_p;
00401   ArrayColumn<Double> sourceOffset_p;
00402   ScalarColumn<Bool> overTheTop_p;
00403 
00404   //# Access to Measure columns
00405   ArrayMeasColumn<MDirection> directionMeas_p;
00406   ArrayMeasColumn<MDirection> targetMeas_p;
00407   ScalarMeasColumn<MEpoch> timeMeas_p;
00408   ScalarMeasColumn<MEpoch> timeOriginMeas_p;
00409   //# optional Measure columns
00410   ScalarMeasColumn<MDirection> encoderMeas_p;
00411   ArrayMeasColumn<MDirection> pointingOffsetMeas_p;
00412   ArrayMeasColumn<MDirection> sourceOffsetMeas_p;
00413 
00414   //# Access to Quantum columns
00415   ScalarQuantColumn<Double> intervalQuant_p;
00416   ScalarQuantColumn<Double> timeQuant_p;
00417   ScalarQuantColumn<Double> timeOriginQuant_p;
00418 };
00419 
00420 } //# NAMESPACE CASA - END
00421 
00422 #endif