casacore
Loading...
Searching...
No Matches
DirectionEngine.h
Go to the documentation of this file.
1//# DirectionEngine.h: Engine for TaQL UDF Direction conversions
2//# Copyright (C) 2011
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 MEAS_DIRECTIONENGINE_H
27#define MEAS_DIRECTIONENGINE_H
28
29//# Includes
30#include <casacore/casa/aips.h>
31#include<casacore/meas/MeasUDF/MeasEngine.h>
32#include <casacore/measures/Measures/MDirection.h>
33#include <casacore/measures/Measures/MCDirection.h>
34#include <casacore/measures/Measures/MeasConvert.h>
35
36namespace casacore {
37
38 //# Forward declarations
39 class EpochEngine;
40 class PositionEngine;
41
42
43 // <summary>
44 // Engine for TaQL UDF Direction conversions
45 // </summary>
46
47 // <use visibility=export>
48
49 // <reviewed reviewer="" date="" tests="tMeas.cc">
50 // </reviewed>
51
52 // <prerequisite>
53 //# Classes you should understand before using this one.
54 // <li> EngineBase
55 // </prerequisite>
56
57 // <synopsis>
58 // DirectionEngine defines Engines (user defined functions) that can be
59 // used in TaQL to convert Measures for directions.
60 // In this way such derived values appear to be ordinary TaQL functions.
61 //
62 // In TaQL these functions can be called like:
63 // <srcblock>
64 // meas.dir (toref, directions, epochs, positions)
65 // meas.j2000 (directions, epochs, positions)
66 // meas.dircos (toref, directions, epochs, positions)
67 // meas.riset (directions, epochs, positions)
68 // </srcblock>
69 // The first two result in angles, the third in direction cosines, while
70 // the fourth returns the rise/set time of sources as datetimes.
71 // Note that the second form is a shorthand for
72 // <src>meas.dir('j2000', ...)</src>. There are more such functions.
73 // The exact number of arguments depends on how they are specified.
74 // <ul>
75 // <li> <src>toref</src> is a single constant string defining the
76 // reference frame to convert to. Note it should be omitted for
77 // the functions (e.g., meas.j2000) with an implicit destination
78 // reference frame.
79 // <li> <src>directions</src> is one or more directions which can be
80 // given in several ways.
81 // <ul>
82 // <li> An array of directions, each 2 angles or 3 directions cosines.
83 // It can be given as a single list or a multi-dim array. The choice
84 // between angles and direction cosines is based on the size of the
85 // first dimension. If divisible by 2, it is angles, by 3 is
86 // direction cosines, otherwise an error. Thus a list of 6 elements
87 // defines 3 directions with 2 angles each (default in radians).
88 // <br>It can be followed by a string defining the source
89 // reference frame. It defaults to 'J2000'.
90 // <li> If a single constant direction is used, it can be given as
91 // 2 (for angles) or 3 (for direction cosines) scalar values,
92 // followed by the optional source reference frame.
93 // <li> The name of a column in a table or a subset of it such as
94 // <src>DELAY_DIR[0,]</src>. Often this is a TableMeasures column
95 // which is recognized as such, also its source reference frame.
96 // If such a column is given as part of an expression, it will not
97 // be recognized as a TableMeasures column and its reference frame
98 // should be given.
99 // <li> As a list of (case-insensitive) names of known sources
100 // such as 'CasA' or 'SUN'.
101 // </ul>
102 // <li> <src>epochs</src> can be given as shown in class EpochEngine.
103 // <li> <src>positions</src> can be given as shown in class PositionEngine.
104 // </ul>
105 // Note that epochs and positions are only needed if required by the
106 // conversion from source reference frame to destination reference frame.
107 // For example, J2000 to/from APP needs them, but not J2000 to/from B1950.
108 //
109 // The result of the function is an array with shape [2|3,dir,epoch,pos]
110 // where the last 3 elements are the shapes of these arguments. They are
111 // omitted if all of them have length 1.
112 //
113 // Futhermore, it is possible to get the rise/set date/time of a source
114 // given the source direction, date and position on earth. These functions
115 // return data with type double and unit d (day).
116 // If the source is visible all day, the rise time is 0 and set time 1.
117 // If the source is not visible at all, the rise time is 1 and set time 0.
118 // For the sun and the moon it is possible to add a suffix to the name
119 // telling if and which edge and twilight should be used. For the sun and
120 // moon the default is -UR (the upper edge with refraction correction).
121 // </synopsis>
122
123 // <example>
124 // <srcblock>
125 // // Get rise/set time of the upper edge of the sun in the coming month
126 // // at the WSRT site.
127 // meas.riseset ('SUN', date()+[0:31], 'WSRT')
128 // // Get the apparent coordinates of CasA for the given date and position.
129 // meas.dircos ('APP', 'CasA', 12mar2015, [52deg,5deg])
130 // // Get the J2000 coordinates (in degrees) of CygA.
131 // meas.j2000 ('cyga') deg
132 // </srcblock>
133 // </example>
134
135 // <motivation>
136 // It makes it possible to easily handle measures in TaQL.
137 // </motivation>
138
139 class DirectionEngine: public MeasEngine<MDirection>
140 {
141 public:
143
145
146 // Get the values.
147 // The first Bool tells if rise/set times have to be calculated.
148 // The second Bool tells if direction cosines have to be calculated.
150 Bool asDirCos);
151
152 // Get the directions.
154
155 // Handle the argument(s) giving the input directions and reference type.
156 // The direction can be a column in a table.
157 void handleDirection (const std::vector<TENShPtr>& args,
158 uInt& argnr, Bool riseSet, Bool asDirCos);
159
160 // Set the MeasConvert object.
162
163 // Set the possible epoch engine.
164 // It can be done only once.
166
167 // Set the possible position engine.
168 // It can be done only once.
170
171 private:
172 void handleScalars (const TENShPtr& e1, const TENShPtr& e2,
173 const TENShPtr& e3);
174 void handleNames (const TENShPtr& operand);
175 virtual void handleValues (TableExprNode& operand,
176 const TableExprId& id,
177 Array<MDirection>& directions);
178
179 // Calucate the rise and set time of a source for a given position and
180 // epoch. Argument <src>h</src> defines the possible edge of sun/moon.
181 void calcRiseSet (const MDirection& dir,
182 const MPosition& pos,
183 const MEpoch& epoch,
184 double h,
185 double& rise, double& set);
186 int fillRiseSet (double epoch,
187 const MDirection& dir,
188 double lat,
189 double h,
190 const MEpoch& off,
191 double* rise, double* set);
192
193 //# Data members.
194 MeasFrame itsFrame; //# frame used by converter
196 Vector<Double> itsH; //# diff for sun or moon
199 };
200
201} //end namespace
202
203#endif
Array< Double > getArrayDouble(const TableExprId &id, Bool riseSet, Bool asDirCos)
Get the values.
void calcRiseSet(const MDirection &dir, const MPosition &pos, const MEpoch &epoch, double h, double &rise, double &set)
Calucate the rise and set time of a source for a given position and epoch.
void setEpochEngine(EpochEngine &engine)
Set the possible epoch engine.
void handleDirection(const std::vector< TENShPtr > &args, uInt &argnr, Bool riseSet, Bool asDirCos)
Handle the argument(s) giving the input directions and reference type.
MDirection::Convert itsConverter
PositionEngine * itsPositionEngine
void handleScalars(const TENShPtr &e1, const TENShPtr &e2, const TENShPtr &e3)
Array< MDirection > getDirections(const TableExprId &id)
Get the directions.
void setConverter(MDirection::Types toType)
Set the MeasConvert object.
int fillRiseSet(double epoch, const MDirection &dir, double lat, double h, const MEpoch &off, double *rise, double *set)
void handleNames(const TENShPtr &operand)
void setPositionEngine(PositionEngine &engine)
Set the possible position engine.
virtual void handleValues(TableExprNode &operand, const TableExprId &id, Array< MDirection > &directions)
Let a derive class handle the values.
Types
Types of known MDirections Warning: The order defines the order in the translation matrix FromTo in ...
Definition MDirection.h:185
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
std::shared_ptr< TableExprNodeRep > TENShPtr
Definition ExprNodeRep.h:55
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40