casacore
EpochEngine.h
Go to the documentation of this file.
1 //# EpochEngine.h: Engine for TaQL UDF Epoch 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: 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_EPOCHENGINE_H
29 #define MEAS_EPOCHENGINE_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 #include<casacore/meas/MeasUDF/PositionEngine.h>
34 #include <casacore/tables/TaQL/ExprNode.h>
35 #include <casacore/measures/Measures/MEpoch.h>
36 #include <casacore/measures/Measures/MCEpoch.h>
37 #include <casacore/measures/Measures/MeasConvert.h>
38 #include <casacore/measures/TableMeasures/ArrayMeasColumn.h>
39 
40 namespace casacore {
41 
42 // <summary>
43 // Engine for TaQL UDF Epoch conversions
44 // </summary>
45 
46 // <use visibility=export>
47 
48 // <reviewed reviewer="" date="" tests="tMeas.cc">
49 // </reviewed>
50 
51 // <prerequisite>
52 //# Classes you should understand before using this one.
53 // <li> EngineBase
54 // </prerequisite>
55 
56 // <synopsis>
57 // EpochEngine defines Engines (user defined functions) that can be used in TaQL
58 // to convert Measures for epochs.
59 // In this way such derived values appear to be ordinary TaQL functions.
60 //
61 // In TaQL these functions can be called like:
62 // <srcblock>
63 // meas.epoch (toref, time, fromref)
64 // meas.last (time, fromref, pos, posref)
65 // For example,
66 // meas.epoch ('UTC', 1e9 s, 'WGS84')
67 // </srcblock>
68 // <ul>
69 // <li>
70 // <src>toref</src> is a single constant string.
71 // <li>
72 // <src>pos</src> can have various value types. A single numeric array is
73 // a series of RA,DEC in J2000. If given as a set, the last argument of the
74 // set can be the reference types of the values in the set. The values can
75 // be strings (indicating planetary objects) or value pairs giving lon,lat.
76 // The default reference type is J2000.
77 // </ul>
78 // All functions have data type double and unit radian.
79 
80 // A epoch can also be a table column which usually knows its type.
81 // It can also be an expression (e.g. EPOCH[0,]) which also knows the type.
82 // </synopsis>
83 
84 // <motivation>
85 // It makes it possible to handle measures in TaQL.
86 // </motivation>
87 
89  {
90  public:
91  EpochEngine();
92 
93  // Get the reference type.
95  { return itsRefType; }
96 
97  // Get the shape.
98  const IPosition& shape() const
99  { return itsShape; }
100 
101  // Get the dimensionality.
102  Int ndim() const
103  { return itsNDim; }
104 
105  // Tell if the expression is constant.
106  Bool isConstant() const;
107 
108  // Get the unit.
109  const Unit& unit() const
110  { return itsUnit; }
111 
112  // Get the values.
114 
115  // Get the epochs.
116  Array<MEpoch> getEpochs (const TableExprId& id);
117 
118  // Handle the argument(s) giving the input epochs and reference type.
119  // The epoch can be a column in a table.
121  uInt& argnr);
122 
123  // Handle a epoch reference type.
124  // If the reference type is invalid, an exception is only thrown
125  // if <src>doThrow=True</src>. In this way a string argument can
126  // be an observatory name for a position.
127  Bool handleEpochType (TableExprNodeRep* operand, Bool doThrow);
128 
129  // Set the MeasConvert object.
130  void setConverter (MEpoch::Types toType);
131 
132  // Set the possible position engine.
133  // It can be done only once.
134  void setPositionEngine (PositionEngine& engine);
135 
136  private:
137  void handleEpochArray (TableExprNodeRep* operand);
138  void handleConstant (TableExprNodeRep* operand);
139 
140  //# Data members.
144  MeasFrame itsFrame; //# frame used by converter
151  };
152 
153 } //end namespace
154 
155 #endif
TableExprNode itsExprNode
Definition: EpochEngine.h:148
A Vector of integers, for indexing into Array<T> objects.
Definition: IPosition.h:119
A 1-D Specialization of the Array class.
Definition: ArrayIO.h:45
int Int
Definition: aipstype.h:47
MEpoch::Types itsRefType
Definition: EpochEngine.h:147
Handle class for a table column expression tree.
Definition: ExprNode.h:578
void handleConstant(TableExprNodeRep *operand)
Container for Measure frame.
Definition: MeasFrame.h:137
Engine for TaQL UDF Position conversions.
Abstract base class for a node in a table column expression tree.
Definition: ExprNodeRep.h:150
Read only access to table array Measure columns.
Definition: MBaseline.h:45
Bool isConstant() const
Tell if the expression is constant.
void handleEpoch(PtrBlock< TableExprNodeRep * > &args, uInt &argnr)
Handle the argument(s) giving the input epochs and reference type.
Array< MEpoch > getEpochs(const TableExprId &id)
Get the epochs.
MEpoch::Convert itsConverter
Definition: EpochEngine.h:145
defines physical units
Definition: Unit.h:189
void setConverter(MEpoch::Types toType)
Set the MeasConvert object.
const IPosition & shape() const
Get the shape.
Definition: EpochEngine.h:98
Bool handleEpochType(TableExprNodeRep *operand, Bool doThrow)
Handle a epoch reference type.
Engine for TaQL UDF Epoch conversions.
Definition: EpochEngine.h:88
PositionEngine * itsPositionEngine
Definition: EpochEngine.h:150
Vector< MEpoch > itsConstants
Definition: EpochEngine.h:146
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:39
Array< Double > getArrayDouble(const TableExprId &id)
Get the values.
const Unit & unit() const
Get the unit.
Definition: EpochEngine.h:109
A drop-in replacement for Block<T*>.
Definition: Block.h:861
void handleEpochArray(TableExprNodeRep *operand)
The identification of a TaQL selection subject.
Definition: TableExprId.h:98
Int ndim() const
Get the dimensionality.
Definition: EpochEngine.h:102
Types
Types of known MEpochs Caution: The order defines the order in the translation matrix in the MCEpoch...
Definition: MEpoch.h:117
MEpoch::Types refType() const
Get the reference type.
Definition: EpochEngine.h:94
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:48
void setPositionEngine(PositionEngine &engine)
Set the possible position engine.
ArrayMeasColumn< MEpoch > itsMeasCol
Definition: EpochEngine.h:149