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