casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DerivedMSCal.h
Go to the documentation of this file.
1 //# DerivedMSCal.h: Virtual column engine to return derived MS values
2 //# Copyright (C) 2010
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef DERIVEDMSCAL_DERIVEDMSCAL_H
29 #define DERIVEDMSCAL_DERIVEDMSCAL_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
35 
36 namespace casacore {
37 
38 // <summary>
39 // Virtual column engine to return derived MS values
40 // </summary>
41 
42 // <use visibility=export>
43 
44 // <reviewed reviewer="" date="" tests="tDerivedMSCal.cc">
45 // </reviewed>
46 
47 // <prerequisite>
48 //# Classes you should understand before using this one.
49 // <li> The Table Data Managers concept as described in module file
50 // <linkto module="Tables:Data Managers">Tables.h</linkto>
51 // <li> MeasurementSet
52 // </prerequisite>
53 
54 // <synopsis>
55 // DerivedMSCal makes it possible to have virtual columns for the derived
56 // MeasurementSet values hourangle, parallactic angle, azimuth/elevation,
57 // and local sidereal time. In this way such derived values appear to be
58 // ordinary columns with the exception that no values can be put into them.
59 //
60 // The following columns can be defined:
61 // <ul>
62 // <li> HA is the hourangle of the pointing from the array center (observatory position).
63 // <li> HA1 is the hourangle of the pointing from ANTENNA1.
64 // <li> HA2 is the hourangle of the pointing from ANTENNA2.
65 // <li> HADEC is the hourangle/DEC of the pointing from the array center (observatory position).
66 // <li> HADEC1 is the hourangle/DEC of the pointing from ANTENNA1.
67 // <li> HADEC2 is the hourangle/DEC of the pointing from ANTENNA2.
68 // <li> LAST is the local sidereal time of the pointing from the array center.
69 // <li> LAST1 is the local sidereal time of the pointing from ANTENNA1.
70 // <li> LAST2 is the local sidereal time of the pointing from ANTENNA2.
71 // <li> PA1 is the parallactic angle of the pointing from ANTENNA1.
72 // <li> PA2 is the parallactic angle of the pointing from ANTENNA2.
73 // <li> AZEL is the azimuth/elevation of the pointing from the array center.
74 // <li> AZEL1 is the azimuth/elevation of the pointing from ANTENNA1.
75 // <li> AZEL2 is the azimuth/elevation of the pointing from ANTENNA2.
76 // <li> ITRF is the pointing in (time-dependent) ITRF coordinates.
77 // <li> UVW_J2000 is the UVW coordinates in J2000 (in meters).
78 // </ul>
79 // All columns have data type double and unit radian (except UVW). The HADEC,
80 // AZEL, ITRF and UVW columns are array columnns while the others are
81 // scalar columns.
82 //
83 // This engine is meant for a MeasurementSet, but can be used for any table
84 // containing an ANTENNA and FIELD subtable and the relevant columns in the
85 // main table (ANTENNA1 and/or ANTENNA2, FIELD_ID, and TIME).
86 // <br>In principle the array center is the Observatory position, which is
87 // taken from the Measures Observatory table using the telescope name found
88 // in the OBSERVATION subtable. However, if the subtable is not defined or
89 // empty or if the telescope name is unknown, the position of the first antenna
90 // is used as the array position.
91 //
92 // The engine can also be used for a CASA Calibration Table. It understands
93 // how it references the MeasurementSets. Because calibration tables contain
94 // no ANTENNA2 columns, columns XX2 are the same as XX1.
95 // </synopsis>
96 
97 // <motivation>
98 // It makes it possible to use generic table software (like querying,
99 // plotting, tablebrowser) on these values.
100 // </motivation>
101 
102 // <example>
103 // The following example shows how to add such columns to an MS and use
104 // them thereafter.
105 // <srcblock>
106 // // Open the table for update (to be able to add the columns).
107 // Table tab ("tDerivedMSCal_tmp.tab", Table::Update);
108 // // Define the columns and add them using DerivedMSCal.
109 // TableDesc td;
110 // td.addColumn (ScalarColumnDesc<double>("HA1"));
111 // td.addColumn (ScalarColumnDesc<double>("HA2"));
112 // td.addColumn (ScalarColumnDesc<double>("PA1"));
113 // td.addColumn (ScalarColumnDesc<double>("PA2"));
114 // DerivedMSCal dataMan;
115 // tab.addColumn (td, dataMan);
116 // // Print values of all rows.
117 // ScalarColumn<double> ha1(tab, "HA1");
118 // ScalarColumn<double> ha2(tab, "HA2");
119 // ScalarColumn<double> pa1(tab, "PA1");
120 // ScalarColumn<double> pa2(tab, "PA2");
121 // for (rownr_t row=0; row<tab.nrow(); ++row) {
122 // cout << ha1(row)<<' '<<ha2(row)<<' '<<pa1(row)<<' '<<pa2(row)<<endl;
123 // }
124 // </srcblock>
125 // </example>
126 
127 // <todo asof="$DATE:$">
128 // <li> Take care of the feeds and their offsets.
129 // <li> Have a conversion engine per field/antenna/feed?
130 // </todo>
131 
132 
134 {
135 public:
136  // Create the data manager.
137  DerivedMSCal();
138 
139  // Create a Lofar storage manager with the given name.
140  // The specifications are part of the record (as created by dataManagerSpec).
141  explicit DerivedMSCal (const Record& spec);
142 
143  ~DerivedMSCal();
144 
145  // Clone this object.
146  virtual DataManager* clone() const;
147 
148  // Prepare the object. It sets the Table object in the engine.
149  virtual void prepare();
150 
151  // Get the type name of the data manager (i.e. DerivedMSCal).
152  virtual String dataManagerType() const;
153 
154  // Record a record containing data manager specifications.
155  virtual Record dataManagerSpec() const;
156 
157  // Columns can be added.
158  virtual Bool canAddColumn() const;
159 
160  // Columns can be removed.
161  virtual Bool canRemoveColumn() const;
162 
163  // Make the object from the type name string.
164  // This function gets registered in the DataManager "constructor" map.
165  // The caller has to delete the object.
166  // The dataManName is not used.
167  static DataManager* makeObject (const String& dataManName,
168  const Record& spec);
169 
170  // Register the class name and the static makeObject "constructor".
171  // This will make the engine known to the table system.
172  static void registerClass();
173 
174 private:
175  // Copy constructor cannot be used.
176  DerivedMSCal (const DerivedMSCal& that);
177 
178  // Assignment cannot be used.
179  DerivedMSCal& operator= (const DerivedMSCal& that);
180 
181  // Do the final addition of a column.
182  // It won't do anything.
183  virtual void addColumn (DataManagerColumn*);
184 
185  // Remove a column from the data file.
186  // It won't do anything.
187  virtual void removeColumn (DataManagerColumn*);
188 
189  // Create a column in the storage manager on behalf of a table column.
190  // The caller has to delete the newly created object.
191  // <group>
192  // Create a scalar column.
193  virtual DataManagerColumn* makeScalarColumn (const String& aName,
194  int aDataType,
195  const String& aDataTypeID);
196  // Create an indirect array column.
197  virtual DataManagerColumn* makeIndArrColumn (const String& aName,
198  int aDataType,
199  const String& aDataTypeID);
200  // </group>
201 
202  //# Declare member variables.
204  vector<DataManagerColumn*> itsColumns;
205 };
206 
207 
208 } //# end namespace
209 
210 #endif
Abstract base class for virtual column handling.
Definition: VirtColEng.h:111
virtual String dataManagerType() const
Get the type name of the data manager (i.e.
Abstract base class for a column in a data manager.
virtual void removeColumn(DataManagerColumn *)
Remove a column from the data file.
virtual DataManagerColumn * makeIndArrColumn(const String &aName, int aDataType, const String &aDataTypeID)
Create an indirect array column.
virtual void addColumn(DataManagerColumn *)
Do the final addition of a column.
vector< DataManagerColumn * > itsColumns
Definition: DerivedMSCal.h:204
static DataManager * makeObject(const String &dataManName, const Record &spec)
Make the object from the type name string.
virtual void prepare()
Prepare the object.
static void registerClass()
Register the class name and the static makeObject &quot;constructor&quot;.
DerivedMSCal & operator=(const DerivedMSCal &that)
Assignment cannot be used.
DerivedMSCal()
Create the data manager.
virtual DataManager * clone() const
Clone this object.
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual Bool canAddColumn() const
Columns can be added.
virtual Record dataManagerSpec() const
Record a record containing data manager specifications.
Abstract base class for a data manager.
Definition: DataManager.h:220
Virtual column engine to return derived MS values.
Definition: DerivedMSCal.h:133
String: the storage and methods of handling collections of characters.
Definition: String.h:225
virtual DataManagerColumn * makeScalarColumn(const String &aName, int aDataType, const String &aDataTypeID)
Create a column in the storage manager on behalf of a table column.
virtual Bool canRemoveColumn() const
Columns can be removed.
Engine to calculate derived MS values.
Definition: MSCalEngine.h:118