casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MSFeedColumns.h
Go to the documentation of this file.
00001 //# MSFeedColumns.h: provides easy access to MSFeed columns
00002 //# Copyright (C) 1996,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: MSFeedColumns.h 19944 2007-02-27 11:14:34Z Malte.Marquarding $
00027 
00028 #ifndef MS_MSFEEDCOLUMNS_H
00029 #define MS_MSFEEDCOLUMNS_H
00030 
00031 #include <casa/aips.h>
00032 #include <casa/BasicSL/Complex.h>
00033 #include <measures/Measures/MDirection.h>
00034 #include <measures/Measures/MEpoch.h>
00035 #include <measures/Measures/MPosition.h>
00036 #include <measures/Measures/MCDirection.h>
00037 #include <measures/Measures/MCEpoch.h>
00038 #include <measures/Measures/MCPosition.h>
00039 #include <measures/TableMeasures/ArrayMeasColumn.h>
00040 #include <measures/TableMeasures/ArrayQuantColumn.h>
00041 #include <measures/TableMeasures/ScalarMeasColumn.h>
00042 #include <measures/TableMeasures/ScalarQuantColumn.h>
00043 #include <tables/Tables/ArrayColumn.h>
00044 #include <tables/Tables/ScalarColumn.h>
00045 #include <casa/BasicSL/String.h>
00046 
00047 namespace casa { //# NAMESPACE CASA - BEGIN
00048 
00049 class MSFeed;
00050 
00051 // <summary>
00052 // A class to provide easy read-only access to MSFeed columns
00053 // </summary>
00054 
00055 // <use visibility=export>
00056 
00057 // <reviewed reviewer="Bob Garwood" date="1997/02/01" tests="" demos="">
00058 // </reviewed>
00059 
00060 // <prerequisite>
00061 //   <li> MSFeed
00062 //   <li> ArrayColumn
00063 //   <li> ScalarColumn
00064 // </prerequisite>
00065 //
00066 // <etymology>
00067 // ROMSFeedColumns stands for Read-Only MeasurementSet Feed Table columns.
00068 // </etymology>
00069 //
00070 // <synopsis>
00071 // This class provides read-only access to the columns in the MSFeed Table.
00072 // It does the declaration of all the Scalar and ArrayColumns with the
00073 // correct types, so the application programmer doesn't have to
00074 // worry about getting those right. There is an access function
00075 // for every predefined column. Access to non-predefined columns will still
00076 // have to be done with explicit declarations.
00077 // See <linkto class=ROMSColumns> ROMSColumns</linkto> for an example.
00078 // </synopsis>
00079 //
00080 // <motivation>
00081 // See <linkto class=MSColumns> MSColumns</linkto> for the motivation.
00082 // </motivation>
00083 
00084 class ROMSFeedColumns
00085 {
00086 public:
00087   // Create a columns object that accesses the data in the specified Table
00088   ROMSFeedColumns(const MSFeed& msFeed);
00089 
00090   // The destructor does nothing special
00091   ~ROMSFeedColumns();
00092 
00093   // Access to required columns
00094   // <group>
00095   const ROScalarColumn<Int>& antennaId() const {return antennaId_p;}
00096   const ROScalarColumn<Int>& beamId() const {return beamId_p;}
00097   const ROArrayColumn<Double>& beamOffset() const {return beamOffset_p;}
00098   const ROArrayQuantColumn<Double>& beamOffsetQuant() const {
00099     return beamOffsetQuant_p;}
00100   const ROArrayMeasColumn<MDirection>& beamOffsetMeas() const 
00101     {return beamOffsetMeas_p;}
00102   const ROScalarColumn<Int>& feedId() const {return feedId_p;}
00103   const ROScalarColumn<Double>& interval() const {return interval_p;}
00104   const ROScalarQuantColumn<Double>& intervalQuant() const {
00105     return intervalQuant_p;}
00106   const ROScalarColumn<Int>& numReceptors() const {return numReceptors_p;}
00107   const ROArrayColumn<Complex>& polResponse() const {return polResponse_p;}
00108   const ROArrayColumn<String>& polarizationType() const {
00109     return polarizationType_p;}
00110   const ROArrayColumn<Double>& position() const {return position_p;}
00111   const ROArrayQuantColumn<Double>& positionQuant() const {
00112     return positionQuant_p;}
00113   const ROScalarMeasColumn<MPosition>& positionMeas() const 
00114     { return positionMeas_p;}
00115   const ROArrayColumn<Double>& receptorAngle() const {return receptorAngle_p;}
00116   const ROArrayQuantColumn<Double>& receptorAngleQuant() const {
00117     return receptorAngleQuant_p;}
00118   const ROScalarColumn<Int>& spectralWindowId() const {
00119     return spectralWindowId_p;}
00120   const ROScalarColumn<Double>& time() const {return time_p;}
00121   const ROScalarQuantColumn<Double>& timeQuant() const {
00122     return timeQuant_p;}
00123   const ROScalarMeasColumn<MEpoch>& timeMeas() const {return timeMeas_p;}
00124   // </group>
00125 
00126   // Access to optional columns
00127   // <group>
00128   const ROScalarColumn<Double>& focusLength() const {return focusLength_p;}
00129   const ROScalarQuantColumn<Double>& focusLengthQuant() const {
00130     return focusLengthQuant_p;}
00131   const ROScalarColumn<Int>& phasedFeedId() const {return phasedFeedId_p;}
00132   // </group>
00133 
00134   // Convenience function that returns the number of rows in any of the columns
00135   uInt nrow() const {return antennaId_p.nrow();}
00136 
00137   // Returns the last row that contains a feed with the specified values.
00138   // If no matching row can be found, but a match is possible if the validity
00139   // time interval is widened, return that row and the suggestion for the
00140   // new time information.
00141   // If no change to time is necessary, newTimeQ and newIntervalQ are zero.
00142   // Returns -1 if no match could be found.
00143   // Ignore the Feed table rows contained in vector ignoreRows. 
00144   // focusLengthQ is only compared if this optional column is present and
00145   // if the value of focusLengthQ is not dimensionless.
00146   Int matchFeed(Quantum<Double>& newTimeQ,
00147                 Quantum<Double>& newIntervalQ,
00148                 const Int& antId,
00149                 const Int& fId, // feedId
00150                 const Int& spwId, 
00151                 const Quantum<Double>& timeQ,
00152                 const Quantum<Double>& intervalQ,
00153                 const Int& numRec,
00154                 const Array<Quantum<Double> >& beamOffsetQ,
00155                 const Array<String>& polType,
00156                 const Array<Complex>& polResp,
00157                 const Array<Quantum<Double> >& positionQ,
00158                 const Array<Quantum<Double> >& receptorAngleQ,
00159                 const Vector<uInt>& ignoreRows,
00160                 const Quantum<Double>& focusLengthQ=Quantum<Double>() 
00161                 );
00162 
00163 protected:
00164   //# default constructor creates a object that is not usable. Use the attach
00165   //# function correct this.
00166   ROMSFeedColumns();
00167 
00168   //# attach this object to the supplied table.
00169   void attach(const MSFeed& msFeed);
00170 
00171 private:
00172   //# Make the assignment operator and the copy constructor private to prevent
00173   //# any compiler generated one from being used.
00174   ROMSFeedColumns(const ROMSFeedColumns&);
00175   ROMSFeedColumns& operator=(const ROMSFeedColumns&);
00176 
00177   //# Check if any optional columns exist and if so attach them.
00178   void attachOptionalCols(const MSFeed& msFeed);
00179   
00180   //# required columns
00181   ROScalarColumn<Int> antennaId_p;
00182   ROScalarColumn<Int> beamId_p;
00183   ROArrayColumn<Double> beamOffset_p;
00184   ROScalarColumn<Int> feedId_p;
00185   ROScalarColumn<Double> interval_p;
00186   ROScalarColumn<Int> numReceptors_p;
00187   ROArrayColumn<Complex> polResponse_p;
00188   ROArrayColumn<String> polarizationType_p;
00189   ROArrayColumn<Double> position_p;
00190   ROArrayColumn<Double> receptorAngle_p;
00191   ROScalarColumn<Int> spectralWindowId_p;
00192   ROScalarColumn<Double> time_p;
00193   //# optional columns
00194   ROScalarColumn<Double> focusLength_p;
00195   ROScalarColumn<Int> phasedFeedId_p;
00196 
00197   // Access to Measure columns
00198   ROArrayMeasColumn<MDirection> beamOffsetMeas_p;
00199   ROScalarMeasColumn<MPosition> positionMeas_p;
00200   ROScalarMeasColumn<MEpoch> timeMeas_p;
00201 
00202   // Access to Quantum columns
00203   ROArrayQuantColumn<Double> beamOffsetQuant_p;
00204   ROScalarQuantColumn<Double> intervalQuant_p;
00205   ROArrayQuantColumn<Double> positionQuant_p;
00206   ROArrayQuantColumn<Double> receptorAngleQuant_p;
00207   ROScalarQuantColumn<Double> timeQuant_p;
00208   //# optional Quantum columns
00209   ROScalarQuantColumn<Double> focusLengthQuant_p;
00210 };
00211 
00212 // <summary>
00213 // A class to provide easy read-write access to MSFeed columns
00214 // </summary>
00215 
00216 // <use visibility=export>
00217 
00218 // <reviewed reviewer="Bob Garwood" date="1997/02/01" tests="" demos="">
00219 // </reviewed>
00220 
00221 // <prerequisite>
00222 //   <li> MSFeed
00223 //   <li> ArrayColumn
00224 //   <li> ScalarColumn
00225 // </prerequisite>
00226 //
00227 // <etymology>
00228 // MSFeedColumns stands for MeasurementSet Feed Table columns.
00229 // </etymology>
00230 //
00231 // <synopsis>
00232 // This class provides access to the columns in the MSFeed Table,
00233 // it does the declaration of all the Scalar and ArrayColumns with the
00234 // correct types, so the application programmer doesn't have to
00235 // worry about getting those right. There is an access function
00236 // for every predefined column. Access to non-predefined columns will still
00237 // have to be done with explicit declarations.
00238 // See <linkto class=MSColumns> MSColumns</linkto> for an example.
00239 // </synopsis>
00240 //
00241 // <motivation>
00242 // See <linkto class=MSColumns> MSColumns</linkto> for the motivation.
00243 // </motivation>
00244 
00245 class MSFeedColumns: public ROMSFeedColumns
00246 {
00247 public:
00248   // Create a columns object that accesses the data in the specified Table
00249   MSFeedColumns(MSFeed& msFeed);
00250 
00251   // The desctructor does nothing special
00252   ~MSFeedColumns();
00253 
00254   // Read-write access to required columns
00255   // <group>
00256   ScalarColumn<Int>& antennaId() {return antennaId_p;}
00257   ScalarColumn<Int>& beamId() {return beamId_p;}
00258   ArrayColumn<Double>& beamOffset() {return beamOffset_p;}
00259   ArrayQuantColumn<Double>& beamOffsetQuant() { return beamOffsetQuant_p;}
00260   ArrayMeasColumn<MDirection>& beamOffsetMeas() 
00261     {return beamOffsetMeas_p;}
00262   ScalarColumn<Int>& feedId() {return feedId_p;}
00263   ScalarColumn<Double>& interval() {return interval_p;}
00264   ScalarQuantColumn<Double>& intervalQuant() { return intervalQuant_p;}
00265   ScalarColumn<Int>& numReceptors() {return numReceptors_p;}
00266   ArrayColumn<Complex>& polResponse() {return polResponse_p;}
00267   ArrayColumn<String>& polarizationType() {return polarizationType_p;}
00268   ArrayColumn<Double>& position() {return position_p;}
00269   ArrayQuantColumn<Double>& positionQuant() {return positionQuant_p;}
00270   ScalarMeasColumn<MPosition>& positionMeas() 
00271     { return positionMeas_p;}
00272   ArrayColumn<Double>& receptorAngle() {return receptorAngle_p;}
00273   ArrayQuantColumn<Double>& receptorAngleQuant() {
00274     return receptorAngleQuant_p;}
00275   ScalarColumn<Int>& spectralWindowId() {return spectralWindowId_p;}
00276   ScalarColumn<Double>& time() {return time_p;}
00277   ScalarQuantColumn<Double>& timeQuant() { return timeQuant_p;}
00278   ScalarMeasColumn<MEpoch>& timeMeas() { return timeMeas_p;}
00279   // </group>
00280 
00281   // Read-write access to optional columns
00282   // <group>
00283   ScalarColumn<Double>& focusLength() {return focusLength_p;}
00284   ScalarQuantColumn<Double>& focusLengthQuant() { return focusLengthQuant_p;}
00285   ScalarColumn<Int>& phasedFeedId() {return phasedFeedId_p;}
00286   // </group>
00287 
00288   // Read-only access to required columns
00289   // <group>
00290   const ROScalarColumn<Int>& antennaId() const {
00291     return ROMSFeedColumns::antennaId();}
00292   const ROScalarColumn<Int>& beamId() const {
00293     return ROMSFeedColumns::beamId();}
00294   const ROArrayColumn<Double>& beamOffset() const {
00295     return ROMSFeedColumns::beamOffset();}
00296   const ROArrayQuantColumn<Double>& beamOffsetQuant() const {
00297     return ROMSFeedColumns::beamOffsetQuant();}
00298   const ROArrayMeasColumn<MDirection>& beamOffsetMeas() const {
00299     return ROMSFeedColumns::beamOffsetMeas();}
00300   const ROScalarColumn<Int>& feedId() const {
00301     return ROMSFeedColumns::feedId();}
00302   const ROScalarColumn<Double>& interval() const {
00303     return ROMSFeedColumns::interval();}
00304   const ROScalarQuantColumn<Double>& intervalQuant() const {
00305     return ROMSFeedColumns::intervalQuant();}
00306   const ROScalarColumn<Int>& numReceptors() const {
00307     return ROMSFeedColumns::numReceptors();}
00308   const ROArrayColumn<Complex>& polResponse() const {
00309     return ROMSFeedColumns::polResponse();}
00310   const ROArrayColumn<String>& polarizationType() const {
00311     return ROMSFeedColumns::polarizationType();}
00312   const ROArrayColumn<Double>& position() const {
00313     return ROMSFeedColumns::position();}
00314   const ROArrayQuantColumn<Double>& positionQuant() const {
00315     return ROMSFeedColumns::positionQuant();}
00316   const ROScalarMeasColumn<MPosition>& positionMeas() const {
00317     return ROMSFeedColumns::positionMeas();}
00318   const ROArrayColumn<Double>& receptorAngle() const {
00319     return ROMSFeedColumns::receptorAngle();}
00320   const ROArrayQuantColumn<Double>& receptorAngleQuant() const {
00321     return ROMSFeedColumns::receptorAngleQuant();}
00322   const ROScalarColumn<Int>& spectralWindowId() const {
00323     return ROMSFeedColumns::spectralWindowId();}
00324   const ROScalarColumn<Double>& time() const {
00325     return ROMSFeedColumns::time();}
00326   const ROScalarQuantColumn<Double>& timeQuant() const {
00327     return ROMSFeedColumns::timeQuant();}
00328   const ROScalarMeasColumn<MEpoch>& timeMeas() const {
00329     return ROMSFeedColumns::timeMeas();}
00330   // </group>
00331 
00332   // Read-only access to optional columns
00333   // <group>
00334   const ROScalarColumn<Double>& focusLength() const {
00335     return ROMSFeedColumns::focusLength();}
00336   const ROScalarQuantColumn<Double>& focusLengthQuant() const {
00337     return ROMSFeedColumns::focusLengthQuant();}
00338   const ROScalarColumn<Int>& phasedFeedId() const {
00339     return ROMSFeedColumns::phasedFeedId();}
00340   // </group>
00341 
00342   // set the epoch type for the TIME column.
00343   // <note role=tip>
00344   // In principle this function can only be used if the table is empty,
00345   // otherwise already written values may thereafter have an incorrect
00346   // reference, offset, or unit.  However, it is possible that part of the
00347   // table gets written before these values are known.  In that case the
00348   // reference, offset, or units can be set by using a False
00349   // <src>tableMustBeEmpty</src> argument.
00350   // </note>
00351   void setEpochRef(MEpoch::Types ref, Bool tableMustBeEmpty=True);
00352 
00353   // set the direction type for the BEAM_OFFSET column. This can only be done
00354   // when the table has no rows. Trying to do so at other times will throw an
00355   // exception.
00356   void setDirectionRef(MDirection::Types ref);
00357 
00358   // set the position type for the POSITION column. This can only be done when
00359   // the table has no rows. Trying to do so at other times will throw an
00360   // exception.
00361   void setPositionRef(MPosition::Types ref);
00362 
00363 protected:
00364   //# default constructor creates a object that is not usable. Use the attach
00365   //# function correct this.
00366   MSFeedColumns();
00367 
00368   //# attach this object to the supplied table.
00369   void attach(MSFeed& msFeed);
00370 
00371 private:
00372   //# Make the assignment operator and the copy constructor private to prevent
00373   //# any compiler generated one from being used.
00374   MSFeedColumns(const MSFeedColumns&);
00375   MSFeedColumns& operator=(const MSFeedColumns&);
00376 
00377   //# Check if any optional columns exist and if so attach them.
00378   void attachOptionalCols(MSFeed& msFeed);
00379   
00380   //# required columns
00381   ScalarColumn<Int> antennaId_p;
00382   ScalarColumn<Int> beamId_p;
00383   ArrayColumn<Double> beamOffset_p;
00384   ScalarColumn<Int> feedId_p;
00385   ScalarColumn<Double> interval_p;
00386   ScalarColumn<Int> numReceptors_p;
00387   ArrayColumn<Complex> polResponse_p;
00388   ArrayColumn<String> polarizationType_p;
00389   ArrayColumn<Double> position_p;
00390   ArrayColumn<Double> receptorAngle_p;
00391   ScalarColumn<Int> spectralWindowId_p;
00392   ScalarColumn<Double> time_p;
00393   //# optional columns
00394   ScalarColumn<Double> focusLength_p;
00395   ScalarColumn<Int> phasedFeedId_p;
00396 
00397   //# Access to Measure columns
00398   ArrayMeasColumn<MDirection> beamOffsetMeas_p;
00399   ScalarMeasColumn<MPosition> positionMeas_p;
00400   ScalarMeasColumn<MEpoch> timeMeas_p;
00401 
00402   //# Access to Quantum columns
00403   ArrayQuantColumn<Double> beamOffsetQuant_p;
00404   ScalarQuantColumn<Double> intervalQuant_p;
00405   ArrayQuantColumn<Double> positionQuant_p;
00406   ArrayQuantColumn<Double> receptorAngleQuant_p;
00407   ScalarQuantColumn<Double> timeQuant_p;
00408   //# optional Quantum columns
00409   ScalarQuantColumn<Double> focusLengthQuant_p;
00410 };
00411 
00412 } //# NAMESPACE CASA - END
00413 
00414 #endif