casacore
Loading...
Searching...
No Matches
PositionEngine.h
Go to the documentation of this file.
1//# PositionEngine.h: Engine for TaQL UDF Position 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_POSITIONENGINE_H
27#define MEAS_POSITIONENGINE_H
28
29//# Includes
30#include <casacore/casa/aips.h>
31#include<casacore/meas/MeasUDF/MeasEngine.h>
32#include <casacore/measures/Measures/MPosition.h>
33#include <casacore/measures/Measures/MCPosition.h>
34#include <casacore/measures/Measures/MeasConvert.h>
35
36namespace casacore {
37
38 // <summary>
39 // Engine for TaQL UDF Position conversions
40 // </summary>
41
42 // <use visibility=export>
43
44 // <reviewed reviewer="" date="" tests="tMeas.cc">
45 // </reviewed>
46
47 // <prerequisite>
48 //# Classes you should understand before using this one.
49 // <li> EngineBase
50 // </prerequisite>
51
52 // <synopsis>
53 // PositionEngine defines Engines (user defined functions) that can be used
54 // in TaQL to convert Measures for positions.
55 // In this way such derived values appear to be ordinary TaQL functions.
56 //
57 // In TaQL these functions can be called like:
58 // <srcblock>
59 // meas.pos (toref, pos)
60 // meas.wgs (pos)
61 // meas.itrfxyz (pos)
62 // For example,
63 // meas.pos ('ITRF', [1e6m,1e6m,1e6m], 'WGS84')
64 // </srcblock>
65 // <ul>
66 // <li> <src>toref</src> is a single constant string defining the
67 // reference frame to convert to. Note it should be omitted for
68 // the functions (e.g., meas.wgs) with an implicit destination
69 // reference frame.
70 // The reference type WGS84 or ITRF can optionally have the suffix
71 // XYZ, LLH, LL (or LONLAT) and H (or HEIGHT) telling how the result
72 // should be returned.
73 // <li> <src>pos</src> specifies the position(s) which can be done in
74 // various ways.
75 // <ul>
76 // <li> An array of positions given as xyz, as lonlat, as lon-lat-height
77 // or as height. The latter is taken towards the pole.
78 // Note that specifying as lon-lat-height precludes use of units
79 // (angle and length units cannot be mixed in a TaQL value).
80 // It can be given as a single list or a multi-dim array.
81 // If given as lonlat it can be followed by an array defining
82 // the height for each lon,lat pair (their sizes should match).
83 // Finally it can be followed by a string defining the source
84 // reference type, which defaults to ITRF for x,y,z and WGS84
85 // for lon,lat.
86 // The source reference type can contain the suffix XYZ, LLH, LL
87 // or H to tell how the values are specified. If no suffix is given,
88 // it is derived from the unit of the first value (angle means LL,
89 // length means XYZ).
90 // <li> If a single constant position is used, it can be given as
91 // 1, 2 or 3 scalar values, optionally followed by the source
92 // reference type. If x,y,z or lon,lat or lon,lat,h or h is given
93 // is derived in the same way as above.
94 // <li> The name of a column in a table or a subset of it such as
95 // <src>POSITION[0,]</src>. Often this is a TableMeasures column
96 // which is recognized as such, also its source reference frame.
97 // If such a column is used in a expression, it will not be
98 // recognized as a TableMeasures column and its reference frame
99 // should be given.
100 // <li> As a list containing (case-insensitive) names of known
101 // observatories such as 'WSRT' or 'VLA'.
102 // </ul>
103 // </ul>
104 //
105 // The result of the function is an array with shape [2|3,pos] if
106 // lon,lat(,h) or x,y,z is returned and shape [pos] if height is returned.
107 // The last element is the shape of the position argument. It is omitted if
108 // it has length 1. In such a case getting the height results in a scalar.
109 // </synopsis>
110
111 // <example>
112 // <srcblock>
113 // // Get the WGS84 lon,lat of WSRT (in degrees).
114 // meas.wgsll ('WSRT') deg
115 // // Get the ITRF x,y,z of WSRT and VLA.
116 // meas.itrfxyz (['WSRT', 'VLA'])
117 // </srcblock>
118 // </example>
119
120 // <motivation>
121 // It makes it possible to handle measures in TaQL.
122 // </motivation>
123
124 class PositionEngine: public MeasEngine<MPosition>
125 {
126 public:
128
130
131 // Get the value type. It also gives the nr of output values per position.
132 // 0=default, 1=height, 2=angles, 3=xyz
134 { return itsValueType; }
135
136 // Get the values.
138 MPosition::Types toRefType,
139 Int toValueType);
140
141 // Get the positions.
143
144 // Handle the argument(s) giving the input positions and reference type.
145 // The position can be a column in a table.
146 void handlePosition (Int toValueType,
147 const std::vector<TENShPtr>& args,
148 uInt& argnr);
149
150 private:
151 virtual String stripMeasType (const String& type);
152 virtual void deriveAttr (const Unit& unit, Int nval);
153 // Let a derived class set its value type.
154 // By default is does nothing.
155 virtual void setValueType (Int valueType);
156
157 // Make an MPosition from xyz or height,angles.
159 const Quantity& q1,
160 const Quantity& q2) const;
161 void handleScalars (const TENShPtr& e1, const TENShPtr& e2,
162 const TENShPtr& e3, Int nval);
163 void handleObservatory (const TENShPtr& operand);
164 void handlePosArray (const TENShPtr& angles, const TENShPtr& height);
165 virtual void handleValues (TableExprNode& operand,
166 const TableExprId& id,
167 Array<MPosition>& positions);
168
169 //# Data members.
170 //# 0=unknown, 1=height, 2=angles, 3=xyz, -3=angles,height
172 };
173
174} //end namespace
175
176#endif
const Unit & unit() const
Get the unit of the function's result.
Definition BaseEngine.h:121
Types
Types of known MPositions Warning: The order defines the order in the translation matrix FromTo in t...
Definition MPosition.h:91
Int valueType() const
Get the value type.
MPosition makePosition(const Quantity &qh, const Quantity &q1, const Quantity &q2) const
Make an MPosition from xyz or height,angles.
virtual void setValueType(Int valueType)
Let a derived class set its value type.
virtual String stripMeasType(const String &type)
Let a derived class strip part of the reference type.
Array< Double > getArrayDouble(const TableExprId &id, MPosition::Types toRefType, Int toValueType)
Get the values.
void handleScalars(const TENShPtr &e1, const TENShPtr &e2, const TENShPtr &e3, Int nval)
void handleObservatory(const TENShPtr &operand)
virtual void deriveAttr(const Unit &unit, Int nval)
Let a derived class derive its attributes.
virtual void handleValues(TableExprNode &operand, const TableExprId &id, Array< MPosition > &positions)
Let a derive class handle the values.
void handlePosArray(const TENShPtr &angles, const TENShPtr &height)
void handlePosition(Int toValueType, const std::vector< TENShPtr > &args, uInt &argnr)
Handle the argument(s) giving the input positions and reference type.
Array< MPosition > getPositions(const TableExprId &id)
Get the positions.
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
unsigned int uInt
Definition aipstype.h:49
std::shared_ptr< TableExprNodeRep > TENShPtr
Definition ExprNodeRep.h:55
int Int
Definition aipstype.h:48