casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSCalEngine.h
Go to the documentation of this file.
1 //# MSCalEngine.h: Engine to calculate 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_MSCALENGINE_H
29 #define DERIVEDMSCAL_MSCALENGINE_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
41 #include <casacore/casa/vector.h>
42 #include <casacore/casa/stdmap.h>
43 
44 namespace casacore {
45 
46 // <summary>
47 // Engine to calculate derived MS values
48 // </summary>
49 
50 // <use visibility=export>
51 
52 // <reviewed reviewer="" date="" tests="tDerivedMSCal.cc">
53 // </reviewed>
54 
55 // <prerequisite>
56 //# Classes you should understand before using this one.
57 // <li> MeasurementSet
58 // </prerequisite>
59 
60 // <synopsis>
61 // MSCalEngine is a class used to calculate derived MeasurementSet
62 // values hourangle, parallactic angle, azimuth/elevation,
63 // local sidereal time, and UVW coordinates.
64 // It is used by the DerivedMSCal virtual columns and UDFs, but can
65 // be used by other software as well.
66 //
67 // The following values can be obtained:
68 // <ul>
69 // <li> HA is the hourangle of the array center (observatory position).
70 // <li> HA1 is the hourangle of ANTENNA1.
71 // <li> HA2 is the hourangle of ANTENNA2.
72 // <li> HADEC is the hourangle/DEC of the array center (observatory position).
73 // <li> HADEC1 is the hourangle/DEC of ANTENNA1.
74 // <li> HADEC2 is the hourangle/DEC of ANTENNA2.
75 // <li> LAST is the local sidereal time of the array center.
76 // <li> LAST1 is the local sidereal time of ANTENNA1.
77 // <li> LAST2 is the local sidereal time of ANTENNA2.
78 // <li> PA1 is the parallactic angle of ANTENNA1.
79 // <li> PA2 is the parallactic angle of ANTENNA2.
80 // <li> AZEL is the azimuth/elevation of the array center.
81 // <li> AZEL1 is the azimuth/elevation of ANTENNA1.
82 // <li> AZEL2 is the azimuth/elevation of ANTENNA2.
83 // <li> ITRF is the direction in (time-dependent) ITRF coordinates.
84 // <li> UVW_J2000 is the UVW coordinates in J2000 (in meters).
85 // </ul>
86 // All values have data type double and unit radian (except UVW). The HADEC,
87 // AZEL, ITRF and UVW cvalues are arrays while the others are scalars.
88 //
89 // This engine is meant for a MeasurementSet, but can be used for any table
90 // containing an ANTENNA and FIELD subtable and the relevant columns in the
91 // main table (ANTENNA1 and/or ANTENNA2, FIELD_ID, and TIME).
92 // It also looks if columns FEED1 and/or FEED2 exist. They are not used yet,
93 // but might be in the future for support of multi-feed arrays.
94 // <br>In principle the array center is the Observatory position, which is
95 // taken from the Measures Observatory table using the telescope name found
96 // in the OBSERVATION subtable or in the table keyword TELESCOPE_NAME.
97 // However, if the telescope name cannot be found or is unknown, the position
98 // of the middle antenna is used as the array position.
99 //
100 // The new CASA Calibration Table format obeys the rules mentioned above,
101 // so these tables are fully supported. Note they do not contain an
102 // OBSERVATION subtable, but use keyword TELESCOPE_NAME.
103 //
104 // The engine can also be used for old CASA Calibration Tables. It understands
105 // how they reference the MeasurementSets. Because these calibration tables
106 // contain no ANTENNA2 columns, columns XX2 are the same as XX1.
107 // </synopsis>
108 
109 // <motivation>
110 // Factor out common code.
111 // </motivation>
112 
113 // <todo asof="$DATE:$">
114 // <li> Take care of the feeds and their offsets.
115 // <li> Have a conversion engine per field/antenna/feed?
116 // </todo>
117 
119 {
120 public:
121  // Default constructor.
122  MSCalEngine();
123 
124  // Destructor.
125  ~MSCalEngine();
126 
127  // Get the table used.
128  Table getTable() const
129  { return itsTable; }
130 
131  // Use the given table (MS or CalTable) in the engine.
132  void setTable (const Table&);
133 
134  // Set the direction to be used instead of a direction from the FIELD table.
135  void setDirection (const MDirection&);
136 
137  // Set the direction column name to use in the FIELD table.
138  void setDirColName (const String& colName);
139 
140  // Get the hourangle for the given row.
141  double getHA (Int antnr, uInt rownr);
142 
143  // Get the hourangle/DEC for the given row.
144  void getHaDec (Int antnr, uInt rownr, Array<Double>&);
145 
146  // Get the parallatic angle for the given row.
147  double getPA (Int antnr, uInt rownr);
148 
149  // Get the local sidereal time for the given row.
150  double getLAST (Int antnr, uInt rownr);
151 
152  // Get the azimuth/elevation for the given row.
153  void getAzEl (Int antnr, uInt rownr, Array<Double>&);
154 
155  // Get the ITRF coordinates for the given row.
156  void getItrf (Int antnr, uInt rownr, Array<Double>&);
157 
158  // Get the UVW in J2000 or APP for the given row.
159  void getNewUVW (Bool asApp, uInt rownr, Array<Double>&);
160 
161  // Get the delay for the given row.
162  double getDelay (Int antnr, uInt rownr);
163 
164 private:
165  // Copy constructor cannot be used.
166  MSCalEngine (const MSCalEngine& that);
167 
168  // Assignment cannot be used.
169  MSCalEngine& operator= (const MSCalEngine& that);
170 
171  // Set the data in the measure converter machines.
172  // The antenna positions are only filled in antnr>=0 or if fillAnt is set.
173  // It returns the mount of the antenna.
174  Int setData (Int antnr, uInt rownr, Bool fillAnt=False);
175 
176  // Initialize the column objects, etc.
177  void init();
178 
179  // Fill the CalDesc info for calibration tables.
180  void fillCalDesc();
181 
182  // Fill or update the antenna positions from the ANTENNA subtable at
183  // row calDescId. It is stored in the calInx-th entry of itsAntPos/itsMount.
184  void fillAntPos (Int calDescId, Int calInx);
185 
186  // Fill or update the field directions from the FIELD subtable at
187  // row calDescId. It is stored in the calInx-th entry of itsFieldDir.
188  void fillFieldDir (Int calDescId, Int calInx);
189 
190  // Get a calibration MS subtable for the given id.
191  Table getSubTable (Int calDescId, const String& subTabName,
192  Bool mustExist=True);
193 
194  //# Declare member variables.
195  Table itsTable; //# MS or CalTable to use
196  Int itsLastCalInx; //# id of CAL_DESC last used
197  Int itsLastFieldId; //# id of the field last used
198  Int itsLastAntId; //# -1 is array position used
200  ScalarColumn<Int> itsAntCol[2]; //# ANTENNA1 and ANTENNA2
201  ScalarColumn<Int> itsFeedCol[2]; //# FEED1 and FEED2
205  ScalarColumn<Int> itsCalCol; //# CAL_DESC_ID
206  map<string,int> itsCalMap; //# map of MS name to index
207  vector<Int> itsCalIdMap; //# map of calId to index
209  Vector<double> itsArrayItrf; //# ITRF array position
210  vector<vector<MPosition> > itsAntPos; //# ITRF antenna positions
211  vector<vector<Int> > itsMount; //# 1=alt-az 0=else
212  vector<vector<MDirection> > itsFieldDir; //# J2000 field directions
213  Bool itsReadFieldDir; //# False: explicit directions
214  String itsDirColName; //# FIELD DIR column to read
215  vector<vector<MBaseline> > itsAntMB; //# J2000 MBaseline per antenna
216  vector<vector<Vector<double> > > itsAntUvw; //# J2000 UVW per antenna
217  vector<Block<bool> > itsUvwFilled; //# is UVW filled for antenna i?
218  MDirection::Convert itsRADecToAzEl; //# converter ra/dec to az/el
219  MDirection::Convert itsPoleToAzEl; //# converter pole to az/el
220  MDirection::Convert itsRADecToHADec; //# converter ra/dec to ha/dec
221  MDirection::Convert itsRADecToItrf; //# converter ra/dec to itrf
222  MDirection::Convert itsDirToJ2000; //# converter direction to J2000
223  MEpoch::Convert itsUTCToLAST; //# converter UTC to LAST
224  MBaseline::Convert itsBLToJ2000; //# convert ITRF to J2000
225  MeasFrame itsFrame; //# frame used by the converters
226  MDirection itsLastDirJ2000; //# itsLastFieldId dir in J2000
227 };
228 
229 
230 } //# end namespace
231 
232 #endif
~MSCalEngine()
Destructor.
A Measure: astronomical direction.
Definition: MDirection.h:174
MSCalEngine & operator=(const MSCalEngine &that)
Assignment cannot be used.
A Measure: position on Earth.
Definition: MPosition.h:79
int Int
Definition: aipstype.h:50
vector< vector< MBaseline > > itsAntMB
Definition: MSCalEngine.h:215
vector< vector< MPosition > > itsAntPos
Definition: MSCalEngine.h:210
Main interface class to a read/write table.
Definition: Table.h:153
void setDirColName(const String &colName)
Set the direction column name to use in the FIELD table.
void fillCalDesc()
Fill the CalDesc info for calibration tables.
vector< vector< Vector< double > > > itsAntUvw
Definition: MSCalEngine.h:216
void setDirection(const MDirection &)
Set the direction to be used instead of a direction from the FIELD table.
void getItrf(Int antnr, uInt rownr, Array< Double > &)
Get the ITRF coordinates for the given row.
Container for Measure frame.
Definition: MeasFrame.h:137
vector< Block< bool > > itsUvwFilled
Definition: MSCalEngine.h:217
map< string, int > itsCalMap
Definition: MSCalEngine.h:206
double getHA(Int antnr, uInt rownr)
Get the hourangle for the given row.
ScalarColumn< Int > itsAntCol[2]
Definition: MSCalEngine.h:200
ScalarColumn< Int > itsFeedCol[2]
Definition: MSCalEngine.h:201
vector< vector< MDirection > > itsFieldDir
Definition: MSCalEngine.h:212
ScalarMeasColumn< MEpoch > itsTimeMeasCol
Definition: MSCalEngine.h:204
MDirection::Convert itsRADecToHADec
Definition: MSCalEngine.h:220
void getHaDec(Int antnr, uInt rownr, Array< Double > &)
Get the hourangle/DEC for the given row.
double Double
Definition: aipstype.h:55
double getDelay(Int antnr, uInt rownr)
Get the delay for the given row.
ScalarColumn< Int > itsFieldCol
Definition: MSCalEngine.h:202
Table getSubTable(Int calDescId, const String &subTabName, Bool mustExist=True)
Get a calibration MS subtable for the given id.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
ScalarColumn< Int > itsCalCol
Definition: MSCalEngine.h:205
void fillFieldDir(Int calDescId, Int calInx)
Fill or update the field directions from the FIELD subtable at row calDescId.
void setTable(const Table &)
Use the given table (MS or CalTable) in the engine.
Vector< double > itsArrayItrf
Definition: MSCalEngine.h:209
MEpoch::Convert itsUTCToLAST
Definition: MSCalEngine.h:223
MDirection::Convert itsPoleToAzEl
Definition: MSCalEngine.h:219
const Bool False
Definition: aipstype.h:44
vector< Int > itsCalIdMap
Definition: MSCalEngine.h:207
MDirection::Convert itsRADecToAzEl
Definition: MSCalEngine.h:218
Table getTable() const
Get the table used.
Definition: MSCalEngine.h:128
double getPA(Int antnr, uInt rownr)
Get the parallatic angle for the given row.
MDirection::Convert itsRADecToItrf
Definition: MSCalEngine.h:221
void init()
Initialize the column objects, etc.
void getAzEl(Int antnr, uInt rownr, Array< Double > &)
Get the azimuth/elevation for the given row.
void getNewUVW(Bool asApp, uInt rownr, Array< Double > &)
Get the UVW in J2000 or APP for the given row.
MBaseline::Convert itsBLToJ2000
Definition: MSCalEngine.h:224
Int setData(Int antnr, uInt rownr, Bool fillAnt=False)
Set the data in the measure converter machines.
MDirection::Convert itsDirToJ2000
Definition: MSCalEngine.h:222
String: the storage and methods of handling collections of characters.
Definition: String.h:223
MSCalEngine()
Default constructor.
double getLAST(Int antnr, uInt rownr)
Get the local sidereal time for the given row.
const Bool True
Definition: aipstype.h:43
ScalarColumn< Double > itsTimeCol
Definition: MSCalEngine.h:203
void fillAntPos(Int calDescId, Int calInx)
Fill or update the antenna positions from the ANTENNA subtable at row calDescId.
unsigned int uInt
Definition: aipstype.h:51
MDirection itsLastDirJ2000
Definition: MSCalEngine.h:226
vector< vector< Int > > itsMount
Definition: MSCalEngine.h:211
Engine to calculate derived MS values.
Definition: MSCalEngine.h:118
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42