00001 //# DerivedMSCal.h: Virtual column engine to return derived MS values 00002 //# Copyright (C) 2010 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$ 00027 00028 #ifndef DERIVEDMSCAL_DERIVEDMSCAL_H 00029 #define DERIVEDMSCAL_DERIVEDMSCAL_H 00030 00031 //# Includes 00032 #include <casacore/casa/aips.h> 00033 #include <casacore/derivedmscal/DerivedMC/MSCalEngine.h> 00034 #include <casacore/tables/DataMan/VirtColEng.h> 00035 00036 namespace casacore { 00037 00038 // <summary> 00039 // Virtual column engine to return derived MS values 00040 // </summary> 00041 00042 // <use visibility=export> 00043 00044 // <reviewed reviewer="" date="" tests="tDerivedMSCal.cc"> 00045 // </reviewed> 00046 00047 // <prerequisite> 00048 //# Classes you should understand before using this one. 00049 // <li> The Table Data Managers concept as described in module file 00050 // <linkto module="Tables:Data Managers">Tables.h</linkto> 00051 // <li> MeasurementSet 00052 // </prerequisite> 00053 00054 // <synopsis> 00055 // DerivedMSCal makes it possible to have virtual columns for the derived 00056 // MeasurementSet values hourangle, parallactic angle, azimuth/elevation, 00057 // and local sidereal time. In this way such derived values appear to be 00058 // ordinary columns with the exception that no values can be put into them. 00059 // 00060 // The following columns can be defined: 00061 // <ul> 00062 // <li> HA is the hourangle of the array center (observatory position). 00063 // <li> HA1 is the hourangle of ANTENNA1. 00064 // <li> HA2 is the hourangle of ANTENNA2. 00065 // <li> HADEC is the hourangle/DEC of the array center (observatory position). 00066 // <li> HADEC1 is the hourangle/DEC of ANTENNA1. 00067 // <li> HADEC2 is the hourangle/DEC of ANTENNA2. 00068 // <li> LAST is the local sidereal time of the array center. 00069 // <li> LAST1 is the local sidereal time of ANTENNA1. 00070 // <li> LAST2 is the local sidereal time of ANTENNA2. 00071 // <li> PA1 is the parallactic angle of ANTENNA1. 00072 // <li> PA2 is the parallactic angle of ANTENNA2. 00073 // <li> AZEL1 is the azimuth/elevation of ANTENNA1. 00074 // <li> AZEL2 is the azimuth/elevation of ANTENNA2. 00075 // <li> UVW_J2000 is the UVW coordinates in J2000 (in meters) 00076 // </ul> 00077 // All columns have data type double and unit radian (except UVW). The HADEC, 00078 // AZEL, and UVW columns are array columnns while the others are scalar columns. 00079 // 00080 // This engine is meant for a MeasurementSet, but can be used for any table 00081 // containing an ANTENNA and FIELD subtable and the relevant columns in the 00082 // main table (ANTENNA1 and/or ANTENNA2, FIELD_ID, and TIME). 00083 // <br>In principle the array center is the Observatory position, which is 00084 // taken from the Measures Observatory table using the telescope name found 00085 // in the OBSERVATION subtable. However, if the subtable is not defined or 00086 // empty or if the telescope name is unknown, the position of the first antenna 00087 // is used as the array position. 00088 // 00089 // The engine can also be used for a CASA Calibration Table. It understands 00090 // how it references the MeasurementSets. Because calibration tables contain 00091 // no ANTENNA2 columns, columns XX2 are the same as XX1. 00092 // </synopsis> 00093 00094 // <motivation> 00095 // It makes it possible to use generic table software (like querying, 00096 // plotting, tablebrowser) on these values. 00097 // </motivation> 00098 00099 // <example> 00100 // The following example shows how to add such columns to an MS and use 00101 // them thereafter. 00102 // <srcblock> 00103 // // Open the table for update (to be able to add the columns). 00104 // Table tab ("tDerivedMSCal_tmp.tab", Table::Update); 00105 // // Define the columns and add them using DerivedMSCal. 00106 // TableDesc td; 00107 // td.addColumn (ScalarColumnDesc<double>("HA1")); 00108 // td.addColumn (ScalarColumnDesc<double>("HA2")); 00109 // td.addColumn (ScalarColumnDesc<double>("PA1")); 00110 // td.addColumn (ScalarColumnDesc<double>("PA2")); 00111 // DerivedMSCal dataMan; 00112 // tab.addColumn (td, dataMan); 00113 // // Print values of all rows. 00114 // ScalarColumn<double> ha1(tab, "HA1"); 00115 // ScalarColumn<double> ha2(tab, "HA2"); 00116 // ScalarColumn<double> pa1(tab, "PA1"); 00117 // ScalarColumn<double> pa2(tab, "PA2"); 00118 // for (uInt row=0; row<tab.nrow(); ++row) { 00119 // cout << ha1(row)<<' '<<ha2(row)<<' '<<pa1(row)<<' '<<pa2(row)<<endl; 00120 // } 00121 // </srcblock> 00122 // </example> 00123 00124 // <todo asof="$DATE:$"> 00125 // <li> Take care of the feeds and their offsets. 00126 // <li> Have a conversion engine per field/antenna/feed? 00127 // </todo> 00128 00129 00130 class DerivedMSCal : public VirtualColumnEngine 00131 { 00132 public: 00133 // Create the data manager. 00134 DerivedMSCal(); 00135 00136 // Create a Lofar storage manager with the given name. 00137 // The specifications are part of the record (as created by dataManagerSpec). 00138 explicit DerivedMSCal (const Record& spec); 00139 00140 ~DerivedMSCal(); 00141 00142 // Clone this object. 00143 virtual DataManager* clone() const; 00144 00145 // Prepare the object. It sets the Table object in the engine. 00146 virtual void prepare(); 00147 00148 // Get the type name of the data manager (i.e. DerivedMSCal). 00149 virtual String dataManagerType() const; 00150 00151 // Record a record containing data manager specifications. 00152 virtual Record dataManagerSpec() const; 00153 00154 // Columns can be added. 00155 virtual Bool canAddColumn() const; 00156 00157 // Columns can be removed. 00158 virtual Bool canRemoveColumn() const; 00159 00160 // Make the object from the type name string. 00161 // This function gets registered in the DataManager "constructor" map. 00162 // The caller has to delete the object. 00163 // The dataManName is not used. 00164 static DataManager* makeObject (const String& dataManName, 00165 const Record& spec); 00166 00167 // Register the class name and the static makeObject "constructor". 00168 // This will make the engine known to the table system. 00169 static void registerClass(); 00170 00171 private: 00172 // Copy constructor cannot be used. 00173 DerivedMSCal (const DerivedMSCal& that); 00174 00175 // Assignment cannot be used. 00176 DerivedMSCal& operator= (const DerivedMSCal& that); 00177 00178 // Do the final addition of a column. 00179 // It won't do anything. 00180 virtual void addColumn (DataManagerColumn*); 00181 00182 // Remove a column from the data file. 00183 // It won't do anything. 00184 virtual void removeColumn (DataManagerColumn*); 00185 00186 // Create a column in the storage manager on behalf of a table column. 00187 // The caller has to delete the newly created object. 00188 // <group> 00189 // Create a scalar column. 00190 virtual DataManagerColumn* makeScalarColumn (const String& aName, 00191 int aDataType, 00192 const String& aDataTypeID); 00193 // Create an indirect array column. 00194 virtual DataManagerColumn* makeIndArrColumn (const String& aName, 00195 int aDataType, 00196 const String& aDataTypeID); 00197 // </group> 00198 00199 //# Declare member variables. 00200 MSCalEngine itsEngine; 00201 vector<DataManagerColumn*> itsColumns; 00202 }; 00203 00204 00205 } //# end namespace 00206 00207 #endif