casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MeasEngine.h
Go to the documentation of this file.
1 //# MeasEngine.h: Templated base class for the TaQL UDF conversion engines
2 //# Copyright (C) 2018
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 MEAS_MEASENGINE_H
29 #define MEAS_MEASENGINE_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
37 
38 namespace casacore {
39 
40  // <summary>
41  // Templated base class for the TaQL UDF conversion engines
42  // </summary>
43 
44  // <use visibility=export>
45 
46  // <reviewed reviewer="" date="" tests="tMeas.cc">
47  // </reviewed>
48 
49  // <prerequisite>
50  //# Classes you should understand before using this one.
51  // <li> BaseEngine
52  // </prerequisite>
53 
54  // <synopsis>
55  // DopplerEngine defines Engines (user defined functions) that can be used
56  // in TaQL to convert Measures for dopplers.
57  // In this way such derived values appear to be ordinary TaQL functions.
58  //
59  // Doppler conversions require a MeasFrame containing sky direction,
60  // epoch and position on earth.
61  // In TaQL these functions can be called like:
62  // <srcblock>
63  // meas.rv ('TOPO', 1 'm/s', 'LSRK', 'CasA', date(),
64  // [1e6m,1e6m,1e6m], 'WGS84')
65  // </srcblock>
66  // which converts the dopplers from LSRK to TOPO.
67  // <ul>
68  // <li>
69  // <src>toref</src> is a single constant string.
70  // <li>
71  // <src>pos</src> can have various value types. A single numeric array is
72  // a series of RA,DEC in J2000. If given as a set, the last argument of the
73  // set can be the reference types of the values in the set. The values can
74  // be strings (indicating planetary objects) or value pairs giving lon,lat.
75  // The default reference type is J2000.
76  // </ul>
77  // All such functions return data with type double and unit Hz.
78  //
79  // Dopplers can be given like:
80  // [v1,v2,...], fromRef
81  // where fromRef is the reference type.
82  //
83  // A doppler can also be a table column which usually knows its type.
84  // It can also be an expression (e.g. DOPPLER[0,]) which also knows the type.
85  // </synopsis>
86 
87  // <motivation>
88  // It makes it possible to handle measures in TaQL.
89  // </motivation>
90 
91  template <typename M>
92  class MeasEngine: public BaseEngine
93  {
94  public:
96  : itsRefType (M::N_Types)
97  {}
98 
99  virtual ~MeasEngine();
100 
101  // Get the reference type.
102  typename M::Types refType() const
103  { return itsRefType; }
104 
105  // Handle a doppler reference type.
106  // If the reference type is invalid, an exception is only thrown
107  // if <src>doThrow=True</src>. In this way a string argument can
108  // be a source name for a direction.
109  Bool handleMeasType (const TENShPtr& operand, Bool doThrow);
110 
111  // Make the expression result attributes.
112  Record makeAttributes (typename M::Types refType,
113  Int valueType = 1) const;
114 
115  protected:
116  // Handle the operand representing an array of Meas values.
117  void handleMeasArray (const TENShPtr& operand);
118 
119  // Handle a constant Meas value.
120  void handleConstant (const TENShPtr& operand);
121 
122  // Let a derive class handle the values.
123  virtual void handleValues (TableExprNode& operand,
124  const TableExprId& id,
125  Array<M>& positions) = 0;
126 
127  //# Data members.
129  typename M::Types itsRefType;
132  };
133 
134 } //end namespace
135 
136 
137 #ifndef CASACORE_NO_AUTO_TEMPLATES
138 #include <casacore/meas/MeasUDF/MeasEngine.tcc>
139 #endif //# CASACORE_NO_AUTO_TEMPLATES
140 #endif
int Int
Definition: aipstype.h:50
ArrayMeasColumn< M > itsMeasArrCol
Definition: MeasEngine.h:131
M::Types refType() const
Get the reference type.
Definition: MeasEngine.h:102
Templated base class for the TaQL UDF conversion engines.
Definition: MeasEngine.h:92
Handle class for a table column expression tree.
Definition: ExprNode.h:156
Bool handleMeasType(const TENShPtr &operand, Bool doThrow)
Handle a doppler reference type.
Array< M > itsConstants
Definition: MeasEngine.h:128
void handleConstant(const TENShPtr &operand)
Handle a constant Meas value.
ScalarMeasColumn< M > itsMeasScaCol
Definition: MeasEngine.h:130
Access table array Measure columns.
Definition: MBaseline.h:45
Record makeAttributes(typename M::Types refType, Int valueType=1) const
Make the expression result attributes.
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual void handleValues(TableExprNode &operand, const TableExprId &id, Array< M > &positions)=0
Let a derive class handle the values.
void handleMeasArray(const TENShPtr &operand)
Handle the operand representing an array of Meas values.
Abstract base class for the TaQL UDF conversion engines.
Definition: BaseEngine.h:91
The identification of a TaQL selection subject.
Definition: TableExprId.h:97
Read only access to table scalar Measure columns.
Definition: MBaseline.h:46