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 public:
118 // Default constructor.
120
121 // Destructor.
123
124 // Get the table used.
125 Table getTable() const { return itsTable; }
126
127 // Use the given table (MS or CalTable) in the engine.
128 void setTable(const Table&);
129
130 // Set the direction to be used instead of a direction from the FIELD table.
132
133 // Set the direction column name to use in the FIELD table.
134 void setDirColName(const String& colName);
135
136 // Get the hourangle for the given row.
137 double getHA(Int antnr, rownr_t rownr);
138
139 // Get the hourangle/DEC for the given row.
140 void getHaDec(Int antnr, rownr_t rownr, Array<Double>&);
141
142 // Get the parallatic angle for the given row.
143 double getPA(Int antnr, rownr_t rownr);
144
145 // Get the local sidereal time for the given row.
146 double getLAST(Int antnr, rownr_t rownr);
147
148 // Get the azimuth/elevation for the given row.
149 void getAzEl(Int antnr, rownr_t rownr, Array<Double>&);
150
151 // Get the ITRF coordinates for the given row.
152 void getItrf(Int antnr, rownr_t rownr, Array<Double>&);
153
154 // Get the UVW in J2000 or APP for the given row.
155 void getNewUVW(Bool asApp, rownr_t rownr, Array<Double>&);
156
157 // Get the delay for the given row.
158 double getDelay(Int antnr, rownr_t rownr);
159
160 private:
161 // Copy constructor cannot be used.
163
164 // Assignment cannot be used.
166
167 // Set the data in the measure converter machines.
168 // The antenna positions are only filled in antnr>=0 or if fillAnt is set.
169 // It returns the mount of the antenna.
170 Int setData(Int antnr, rownr_t rownr, Bool fillAnt = False);
171
172 // Initialize the column objects, etc.
173 void init();
174
175 // Fill the CalDesc info for calibration tables.
177
178 // Fill or update the antenna positions from the ANTENNA subtable at
179 // row calDescId. It is stored in the calInx-th entry of itsAntPos/itsMount.
180 void fillAntPos(Int calDescId, Int calInx);
181
182 // Fill or update the field directions from the FIELD subtable at
183 // row calDescId. It is stored in the calInx-th entry of itsFieldDir.
184 void fillFieldDir(Int calDescId, Int calInx);
185
186 // Get a calibration MS subtable for the given id.
187 Table getSubTable(Int calDescId, const String& subTabName, Bool mustExist = True);
188
189 // # Declare member variables.
190 Table itsTable; // # MS or CalTable to use
191 Int itsLastCalInx; // # id of CAL_DESC last used
192 Int itsLastFieldId; // # id of the field last used
193 Int itsLastAntId; // # -1 is array position used
195 ScalarColumn<Int> itsAntCol[2]; // # ANTENNA1 and ANTENNA2
196 ScalarColumn<Int> itsFeedCol[2]; // # FEED1 and FEED2
200 ScalarColumn<Int> itsCalCol; // # CAL_DESC_ID
201 map<std::string, int> itsCalMap; // # map of MS name to index
202 vector<Int> itsCalIdMap; // # map of calId to index
204 Vector<double> itsArrayItrf; // # ITRF array position
205 vector<vector<MPosition>> itsAntPos; // # ITRF antenna positions
206 vector<vector<Int>> itsMount; // # 1=alt-az 0=else
207 vector<vector<MDirection>> itsFieldDir; // # J2000 field directions
208 Bool itsReadFieldDir; // # False: explicit directions
209 String itsDirColName; // # FIELD DIR column to read
210 vector<vector<MBaseline>> itsAntMB; // # J2000 MBaseline per antenna
211 vector<vector<Vector<double>>> itsAntUvw; // # J2000 UVW per antenna
212 vector<Block<bool>> itsUvwFilled; // # is UVW filled for antenna i?
213 MDirection::Convert itsRADecToAzEl; // # converter ra/dec to az/el
214 MDirection::Convert itsPoleToAzEl; // # converter pole to az/el
215 MDirection::Convert itsRADecToHADec; // # converter ra/dec to ha/dec
216 MDirection::Convert itsRADecToItrf; // # converter ra/dec to itrf
217 MDirection::Convert itsDirToJ2000; // # converter direction to J2000
218 MEpoch::Convert itsUTCToLAST; // # converter UTC to LAST
219 MBaseline::Convert itsBLToJ2000; // # convert ITRF to J2000
220 MeasFrame itsFrame; // # frame used by the converters
221 MDirection itsLastDirJ2000; // # itsLastFieldId dir in J2000
222};
223
224} // namespace casacore
225
226#endif
MeasConvert< MBaseline > Convert
Measure Convert (i.e.
Definition MBaseline.h:138
MeasConvert< MDirection > Convert
Measure Convert (i.e.
Definition MDirection.h:244
MeasConvert< MEpoch > Convert
Measure Convert (i.e.
Definition MEpoch.h:157
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
map< std::string, int > itsCalMap
~MSCalEngine()
Destructor.
MDirection::Convert itsDirToJ2000
MSCalEngine()
Default constructor.
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:355
For temporary backward namespace compatibility, use casa as alias for casacore.
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