casacore
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>
33 #include <casacore/derivedmscal/DerivedMC/MSCalEngine.h>
34 #include <casacore/tables/DataMan/VirtColEng.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 array center (observatory position).
63 // <li> HA1 is the hourangle of ANTENNA1.
64 // <li> HA2 is the hourangle of ANTENNA2.
65 // <li> HADEC is the hourangle/DEC of the array center (observatory position).
66 // <li> HADEC1 is the hourangle/DEC of ANTENNA1.
67 // <li> HADEC2 is the hourangle/DEC of ANTENNA2.
68 // <li> LAST is the local sidereal time of the array center.
69 // <li> LAST1 is the local sidereal time of ANTENNA1.
70 // <li> LAST2 is the local sidereal time of ANTENNA2.
71 // <li> PA1 is the parallactic angle of ANTENNA1.
72 // <li> PA2 is the parallactic angle of ANTENNA2.
73 // <li> AZEL1 is the azimuth/elevation of ANTENNA1.
74 // <li> AZEL2 is the azimuth/elevation of ANTENNA2.
75 // <li> UVW_J2000 is the UVW coordinates in J2000 (in meters)
76 // </ul>
77 // All columns have data type double and unit radian (except UVW). The HADEC,
78 // AZEL, and UVW columns are array columnns while the others are scalar columns.
79 //
80 // This engine is meant for a MeasurementSet, but can be used for any table
81 // containing an ANTENNA and FIELD subtable and the relevant columns in the
82 // main table (ANTENNA1 and/or ANTENNA2, FIELD_ID, and TIME).
83 // <br>In principle the array center is the Observatory position, which is
84 // taken from the Measures Observatory table using the telescope name found
85 // in the OBSERVATION subtable. However, if the subtable is not defined or
86 // empty or if the telescope name is unknown, the position of the first antenna
87 // is used as the array position.
88 //
89 // The engine can also be used for a CASA Calibration Table. It understands
90 // how it references the MeasurementSets. Because calibration tables contain
91 // no ANTENNA2 columns, columns XX2 are the same as XX1.
92 // </synopsis>
93 
94 // <motivation>
95 // It makes it possible to use generic table software (like querying,
96 // plotting, tablebrowser) on these values.
97 // </motivation>
98 
99 // <example>
100 // The following example shows how to add such columns to an MS and use
101 // them thereafter.
102 // <srcblock>
103 // // Open the table for update (to be able to add the columns).
104 // Table tab ("tDerivedMSCal_tmp.tab", Table::Update);
105 // // Define the columns and add them using DerivedMSCal.
106 // TableDesc td;
107 // td.addColumn (ScalarColumnDesc<double>("HA1"));
108 // td.addColumn (ScalarColumnDesc<double>("HA2"));
109 // td.addColumn (ScalarColumnDesc<double>("PA1"));
110 // td.addColumn (ScalarColumnDesc<double>("PA2"));
111 // DerivedMSCal dataMan;
112 // tab.addColumn (td, dataMan);
113 // // Print values of all rows.
114 // ScalarColumn<double> ha1(tab, "HA1");
115 // ScalarColumn<double> ha2(tab, "HA2");
116 // ScalarColumn<double> pa1(tab, "PA1");
117 // ScalarColumn<double> pa2(tab, "PA2");
118 // for (uInt row=0; row<tab.nrow(); ++row) {
119 // cout << ha1(row)<<' '<<ha2(row)<<' '<<pa1(row)<<' '<<pa2(row)<<endl;
120 // }
121 // </srcblock>
122 // </example>
123 
124 // <todo asof="$DATE:$">
125 // <li> Take care of the feeds and their offsets.
126 // <li> Have a conversion engine per field/antenna/feed?
127 // </todo>
128 
129 
131 {
132 public:
133  // Create the data manager.
134  DerivedMSCal();
135 
136  // Create a Lofar storage manager with the given name.
137  // The specifications are part of the record (as created by dataManagerSpec).
138  explicit DerivedMSCal (const Record& spec);
139 
140  ~DerivedMSCal();
141 
142  // Clone this object.
143  virtual DataManager* clone() const;
144 
145  // Prepare the object. It sets the Table object in the engine.
146  virtual void prepare();
147 
148  // Get the type name of the data manager (i.e. DerivedMSCal).
149  virtual String dataManagerType() const;
150 
151  // Record a record containing data manager specifications.
152  virtual Record dataManagerSpec() const;
153 
154  // Columns can be added.
155  virtual Bool canAddColumn() const;
156 
157  // Columns can be removed.
158  virtual Bool canRemoveColumn() const;
159 
160  // Make the object from the type name string.
161  // This function gets registered in the DataManager "constructor" map.
162  // The caller has to delete the object.
163  // The dataManName is not used.
164  static DataManager* makeObject (const String& dataManName,
165  const Record& spec);
166 
167  // Register the class name and the static makeObject "constructor".
168  // This will make the engine known to the table system.
169  static void registerClass();
170 
171 private:
172  // Copy constructor cannot be used.
173  DerivedMSCal (const DerivedMSCal& that);
174 
175  // Assignment cannot be used.
176  DerivedMSCal& operator= (const DerivedMSCal& that);
177 
178  // Do the final addition of a column.
179  // It won't do anything.
180  virtual void addColumn (DataManagerColumn*);
181 
182  // Remove a column from the data file.
183  // It won't do anything.
184  virtual void removeColumn (DataManagerColumn*);
185 
186  // Create a column in the storage manager on behalf of a table column.
187  // The caller has to delete the newly created object.
188  // <group>
189  // Create a scalar column.
190  virtual DataManagerColumn* makeScalarColumn (const String& aName,
191  int aDataType,
192  const String& aDataTypeID);
193  // Create an indirect array column.
194  virtual DataManagerColumn* makeIndArrColumn (const String& aName,
195  int aDataType,
196  const String& aDataTypeID);
197  // </group>
198 
199  //# Declare member variables.
201  vector<DataManagerColumn*> itsColumns;
202 };
203 
204 
205 } //# end namespace
206 
207 #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.
Definition: DataManager.h:616
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:201
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 "constructor".
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:181
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:39
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:222
Virtual column engine to return derived MS values.
Definition: DerivedMSCal.h:130
String: the storage and methods of handling collections of characters.
Definition: String.h:223
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.
this file contains all the compiler specific defines
Definition: mainpage.dox:28
Engine to calculate derived MS values.
Definition: MSCalEngine.h:116