casa
$Rev:20696$
|
00001 //# MSAntennaColumns.h: provides easy access to MSAntenna 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: MSAntennaColumns.h 19944 2007-02-27 11:14:34Z Malte.Marquarding $ 00027 00028 #ifndef MS_MSANTENNACOLUMNS_H 00029 #define MS_MSANTENNACOLUMNS_H 00030 00031 #include <casa/aips.h> 00032 #include <measures/Measures/MPosition.h> 00033 #include <measures/Measures/MCPosition.h> 00034 #include <measures/TableMeasures/ArrayQuantColumn.h> 00035 #include <measures/TableMeasures/ScalarMeasColumn.h> 00036 #include <measures/TableMeasures/ScalarQuantColumn.h> 00037 #include <tables/Tables/ArrayColumn.h> 00038 #include <tables/Tables/ScalarColumn.h> 00039 #include <casa/BasicSL/String.h> 00040 00041 namespace casa { //# NAMESPACE CASA - BEGIN 00042 00043 class MSAntenna; 00044 00045 // <summary> 00046 // A class to provide easy read-only access to MSAntenna columns 00047 // </summary> 00048 00049 // <use visibility=export> 00050 00051 // <reviewed reviewer="Bob Garwood" date="1997/02/01" tests="" demos=""> 00052 // </reviewed> 00053 00054 // <prerequisite> 00055 // <li> MSAntenna 00056 // <li> ArrayColumn 00057 // <li> ScalarColumn 00058 // </prerequisite> 00059 // 00060 // <etymology> 00061 // ROMSAntennaColumns stands for Read-Only MeasurementSet Antenna Table columns. 00062 // </etymology> 00063 // 00064 // <synopsis> 00065 // This class provides read-only access to the columns in the MSAntenna 00066 // Table. It does the declaration of all the Scalar and ArrayColumns with the 00067 // correct types, so the application programmer doesn't have to worry about 00068 // getting those right. There is an access function for every predefined 00069 // column. Access to non-predefined columns will still have to be done with 00070 // explicit declarations. 00071 // See <linkto class=ROMSColumns> ROMSColumns</linkto> for an example. 00072 // </synopsis> 00073 // 00074 // <motivation> 00075 // See <linkto class=MSColumns> MSColumns</linkto> for the motivation. 00076 // </motivation> 00077 00078 class ROMSAntennaColumns 00079 { 00080 public: 00081 00082 // Create a columns object that accesses the data in the specified Table 00083 ROMSAntennaColumns(const MSAntenna& msAntenna); 00084 00085 // The destructor does nothing special 00086 ~ROMSAntennaColumns(); 00087 00088 // Access to columns 00089 // <group> 00090 const ROScalarColumn<Double>& dishDiameter() const {return dishDiameter_p;} 00091 const ROScalarQuantColumn<Double>& dishDiameterQuant() const 00092 {return dishDiameterQuant_p;} 00093 const ROScalarColumn<Bool>& flagRow() const {return flagRow_p;} 00094 const ROScalarColumn<String>& mount() const {return mount_p;} 00095 const ROScalarColumn<String>& name() const {return name_p;} 00096 const ROArrayColumn<Double>& offset() const {return offset_p;} 00097 const ROArrayQuantColumn<Double>& offsetQuant() const {return offsetQuant_p;} 00098 const ROScalarMeasColumn<MPosition>& offsetMeas() const { 00099 return offsetMeas_p;} 00100 const ROArrayColumn<Double>& position() const {return position_p;} 00101 const ROArrayQuantColumn<Double>& positionQuant() const { 00102 return positionQuant_p;} 00103 const ROScalarMeasColumn<MPosition>& positionMeas() const 00104 { return positionMeas_p;} 00105 const ROScalarColumn<String>& station() const {return station_p;} 00106 const ROScalarColumn<String>& type() const {return type_p;} 00107 // </group> 00108 00109 // Access to optional columns 00110 // <group> 00111 const ROArrayColumn<Double>& meanOrbit() const {return meanOrbit_p;} 00112 const ROScalarColumn<Int>& orbitId() const {return orbitId_p;} 00113 const ROScalarColumn<Int>& phasedArrayId() const {return phasedArrayId_p;} 00114 // </group> 00115 00116 // Convenience function that returns the number of rows in any of the columns 00117 uInt nrow() const {return dishDiameter_p.nrow();} 00118 00119 // returns the last row that contains an antenna at the specified position, 00120 // to within the specified tolerance. The reference frame of the supplied 00121 // position must be the same as the one for the POSITION columns. If not an 00122 // AipsError is thrown as such an argument will never match any row of the 00123 // Table. The tolerance is the maximum allowed distance between the two 00124 // positions and the supplied Quantum must have dimensions of length. This is 00125 // checked when compiled in debug mode and an AipsError exception is thrown 00126 // if the dimensions are wrong. Returns -1 if no match could be found. Flaged 00127 // rows can never match. If tryRow is non-negative, then that row is tested 00128 // to see if it matches before any others are tested. Setting tryRow to a 00129 // positive value greater than the table length will throw an exception 00130 // (AipsError), when compiled in debug mode. 00131 Int matchAntenna(const MPosition& antennaPos, 00132 const Quantum<Double>& tolerance, Int tryRow=-1); 00133 00134 // Same as the previous function except that the antenna name must also 00135 // match. 00136 Int matchAntenna(const String& antName, const MPosition& antennaPos, 00137 const Quantum<Double>& tolerance, Int tryRow=-1); 00138 00139 // Same as the previous function except that the station name must also 00140 // match. 00141 Int matchAntennaAndStation(const String& antName, 00142 const String& stationName, // ignored when empty 00143 const MPosition& antennaPos, 00144 const Quantum<Double>& tolerance, Int tryRow=-1); 00145 protected: 00146 //# default constructor creates a object that is not usable. Use the attach 00147 //# function correct this. 00148 ROMSAntennaColumns(); 00149 00150 //# attach this object to the supplied table. 00151 void attach(const MSAntenna& msAntenna); 00152 00153 private: 00154 //# Make the assignment operator and the copy constructor private to prevent 00155 //# any compiler generated one from being used. 00156 ROMSAntennaColumns(const ROMSAntennaColumns&); 00157 ROMSAntennaColumns& operator=(const ROMSAntennaColumns&); 00158 00159 //# Check if any optional columns exist and if so attach them. 00160 void attachOptionalCols(const MSAntenna& msAntenna); 00161 00162 //# Functions which check the supplied values against the relevant column and 00163 //# the specified row. 00164 Bool matchName(uInt row, const String& antName) const; 00165 Bool matchStation(uInt row, const String& stationName) const; 00166 Bool matchPosition(uInt row, const Vector<Double>& antPosInM, 00167 const Double tolInM) const; 00168 00169 00170 //# required columns 00171 ROScalarColumn<Double> dishDiameter_p; 00172 ROScalarColumn<Bool> flagRow_p; 00173 ROScalarColumn<String> mount_p; 00174 ROScalarColumn<String> name_p; 00175 ROArrayColumn<Double> offset_p; 00176 ROArrayColumn<Double> position_p; 00177 ROScalarColumn<String> station_p; 00178 ROScalarColumn<String> type_p; 00179 //# optional columns 00180 ROArrayColumn<Double> meanOrbit_p; 00181 ROScalarColumn<Int> orbitId_p; 00182 ROScalarColumn<Int> phasedArrayId_p; 00183 00184 //# Access to Measure columns 00185 ROScalarMeasColumn<MPosition> offsetMeas_p; 00186 ROScalarMeasColumn<MPosition> positionMeas_p; 00187 00188 //# Access to Quantum columns 00189 ROScalarQuantColumn<Double> dishDiameterQuant_p; 00190 ROArrayQuantColumn<Double> offsetQuant_p; 00191 ROArrayQuantColumn<Double> positionQuant_p; 00192 }; 00193 00194 // <summary> 00195 // A class to provide easy read-write access to MSAntenna columns 00196 // </summary> 00197 00198 // <use visibility=export> 00199 00200 // <reviewed reviewer="Bob Garwood" date="1997/02/01" tests="" demos=""> 00201 // </reviewed> 00202 00203 // <prerequisite> 00204 // <li> MSAntenna 00205 // <li> ArrayColumn 00206 // <li> ScalarColumn 00207 // </prerequisite> 00208 // 00209 // <etymology> 00210 // MSAntennaColumns stands for MeasurementSet Antenna Table columns. 00211 // </etymology> 00212 // 00213 // <synopsis> 00214 // This class provides access to the columns in the MSAntenna Table, 00215 // it does the declaration of all the Scalar and ArrayColumns with the 00216 // correct types, so the application programmer doesn't have to 00217 // worry about getting those right. There is an access function 00218 // for every predefined column. Access to non-predefined columns will still 00219 // have to be done with explicit declarations. 00220 // See <linkto class=MSColumns> MSColumns</linkto> for an example. 00221 // </synopsis> 00222 // 00223 // <motivation> 00224 // See <linkto class=MSColumns> MSColumns</linkto> for the motivation. 00225 // </motivation> 00226 00227 class MSAntennaColumns: public ROMSAntennaColumns 00228 { 00229 public: 00230 00231 // Create a columns object that accesses the data in the specified Table 00232 MSAntennaColumns(MSAntenna& msAntenna); 00233 00234 // The destructor does nothing special 00235 ~MSAntennaColumns(); 00236 00237 // Read-write access to required columns 00238 // <group> 00239 ScalarColumn<Double>& dishDiameter() {return dishDiameter_p;} 00240 ScalarQuantColumn<Double>& dishDiameterQuant() {return dishDiameterQuant_p;} 00241 ScalarColumn<Bool>& flagRow() {return flagRow_p;} 00242 ScalarColumn<String>& mount() {return mount_p;} 00243 ScalarColumn<String>& name() {return name_p;} 00244 ArrayColumn<Double>& offset() {return offset_p;} 00245 ArrayQuantColumn<Double>& offsetQuant() {return offsetQuant_p;} 00246 ScalarMeasColumn<MPosition>& offsetMeas() { return offsetMeas_p;} 00247 ArrayColumn<Double>& position() {return position_p;} 00248 ArrayQuantColumn<Double>& positionQuant() {return positionQuant_p;} 00249 ScalarMeasColumn<MPosition>& positionMeas() { return positionMeas_p;} 00250 ScalarColumn<String>& station() {return station_p;} 00251 ScalarColumn<String>& type() {return type_p;} 00252 // </group> 00253 00254 // Read-write access to optional columns 00255 // <group> 00256 ArrayColumn<Double>& meanOrbit() {return meanOrbit_p;} 00257 ScalarColumn<Int>& orbitId() {return orbitId_p;} 00258 ScalarColumn<Int>& phasedArrayId() {return phasedArrayId_p;} 00259 // </group> 00260 00261 // Read-only access to required columns 00262 // <group> 00263 const ROScalarColumn<Double>& dishDiameter() const { 00264 return ROMSAntennaColumns::dishDiameter();} 00265 const ROScalarQuantColumn<Double>& dishDiameterQuant() const { 00266 return ROMSAntennaColumns::dishDiameterQuant();} 00267 const ROScalarColumn<Bool>& flagRow() const { 00268 return ROMSAntennaColumns::flagRow();} 00269 const ROScalarColumn<String>& mount() const { 00270 return ROMSAntennaColumns::mount();} 00271 const ROScalarColumn<String>& name() const { 00272 return ROMSAntennaColumns::name();} 00273 const ROArrayColumn<Double>& offset() const { 00274 return ROMSAntennaColumns::offset();} 00275 const ROArrayQuantColumn<Double>& offsetQuant() const { 00276 return ROMSAntennaColumns::offsetQuant();} 00277 const ROScalarMeasColumn<MPosition>& offsetMeas() const { 00278 return ROMSAntennaColumns::offsetMeas();} 00279 const ROArrayColumn<Double>& position() const { 00280 return ROMSAntennaColumns::position();} 00281 const ROArrayQuantColumn<Double>& positionQuant() const { 00282 return ROMSAntennaColumns::positionQuant();} 00283 const ROScalarMeasColumn<MPosition>& positionMeas() const { 00284 return ROMSAntennaColumns::positionMeas();} 00285 const ROScalarColumn<String>& station() const { 00286 return ROMSAntennaColumns::station();} 00287 const ROScalarColumn<String>& type() const { 00288 return ROMSAntennaColumns::type();} 00289 // </group> 00290 00291 // Read-only access to optional columns 00292 // <group> 00293 const ROArrayColumn<Double>& meanOrbit() const { 00294 return ROMSAntennaColumns::meanOrbit();} 00295 const ROScalarColumn<Int>& orbitId() const { 00296 return ROMSAntennaColumns::orbitId();} 00297 const ROScalarColumn<Int>& phasedArrayId() const { 00298 return ROMSAntennaColumns::phasedArrayId();} 00299 // </group> 00300 00301 // set the position type for the POSITION column. This can only be done when 00302 // the table has no rows. Trying to do so at other times will throw an 00303 // exception. 00304 void setPositionRef(MPosition::Types ref); 00305 00306 // set the position type for the OFFSET column. This can only be done when 00307 // the table has no rows. Trying to do so at other times will throw an 00308 // exception. 00309 void setOffsetRef(MPosition::Types ref); 00310 00311 protected: 00312 //# default constructor creates a object that is not usable. Use the attach 00313 //# function correct this. 00314 MSAntennaColumns(); 00315 00316 //# attach this object to the supplied table. 00317 void attach(MSAntenna& msAntenna); 00318 00319 private: 00320 //# Make the assignment operator and the copy constructor private to prevent 00321 //# any compiler generated one from being used. 00322 MSAntennaColumns(const MSAntennaColumns&); 00323 MSAntennaColumns& operator=(const MSAntennaColumns&); 00324 00325 //# Check if any optional columns exist and if so attach them. 00326 void attachOptionalCols(MSAntenna& msAntenna); 00327 00328 //# required columns 00329 ScalarColumn<Double> dishDiameter_p; 00330 ScalarColumn<Bool> flagRow_p; 00331 ScalarColumn<String> mount_p; 00332 ScalarColumn<String> name_p; 00333 ArrayColumn<Double> offset_p; 00334 ArrayColumn<Double> position_p; 00335 ScalarColumn<String> station_p; 00336 ScalarColumn<String> type_p; 00337 //# optional columns 00338 ArrayColumn<Double> meanOrbit_p; 00339 ScalarColumn<Int> orbitId_p; 00340 ScalarColumn<Int> phasedArrayId_p; 00341 00342 //# Access to Measure columns 00343 ScalarMeasColumn<MPosition> offsetMeas_p; 00344 ScalarMeasColumn<MPosition> positionMeas_p; 00345 00346 //# Access to Quantum columns 00347 ScalarQuantColumn<Double> dishDiameterQuant_p; 00348 ArrayQuantColumn<Double> offsetQuant_p; 00349 ArrayQuantColumn<Double> positionQuant_p; 00350 00351 }; 00352 00353 } //# NAMESPACE CASA - END 00354 00355 #endif