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/ScalarMeasColumn.h>
39 #include <casacore/measures/TableMeasures/ArrayMeasColumn.h>
40 
41 namespace casacore {
42 
43 // <summary>
44 // Engine for TaQL UDF Epoch 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 // EpochEngine defines Engines (user defined functions) that can be used in TaQL
59 // to convert Measures for epochs.
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.epoch (toref, time, fromref)
65 // meas.last (time, fromref, pos, posref)
66 // For example,
67 // meas.epoch ('UTC', 1e9 s, 'WGS84')
68 // </srcblock>
69 // <ul>
70 // <li>
71 // <src>toref</src> is a single constant string.
72 // <li>
73 // <src>pos</src> can have various value types. A single numeric array is
74 // a series of RA,DEC in J2000. If given as a set, the last argument of the
75 // set can be the reference types of the values in the set. The values can
76 // be strings (indicating planetary objects) or value pairs giving lon,lat.
77 // The default reference type is J2000.
78 // </ul>
79 // All functions have data type double and unit radian.
80 
81 // A epoch can also be a table column which usually knows its type.
82 // It can also be an expression (e.g. EPOCH[0,]) which also knows the type.
83 // </synopsis>
84 
85 // <motivation>
86 // It makes it possible to handle measures in TaQL.
87 // </motivation>
88 
90  {
91  public:
92  EpochEngine();
93 
94  // Get the reference type.
96  { return itsRefType; }
97 
98  // Tell if the fraction has to be used for sidereal times.
99  Bool sidFrac() const
100  { return itsSidFrac; }
101 
102  // Get the shape.
103  const IPosition& shape() const
104  { return itsShape; }
105 
106  // Get the dimensionality.
107  Int ndim() const
108  { return itsNDim; }
109 
110  // Tell if the expression is constant.
111  Bool isConstant() const;
112 
113  // Get the unit.
114  const Unit& unit() const
115  { return itsUnit; }
116 
117  // Get the values.
119 
120  // Get the epochs.
121  Array<MEpoch> getEpochs (const TableExprId& id);
122 
123  // Handle the argument(s) giving the input epochs and reference type.
124  // The epoch can be a column in a table.
126  uInt& argnr);
127 
128  // Handle a epoch reference type.
129  // If the reference type is invalid, an exception is only thrown
130  // if <src>doThrow=True</src>. In this way a string argument can
131  // be an observatory name for a position.
132  Bool handleEpochType (TableExprNodeRep* operand, Bool doThrow);
133 
134  // Set the MeasConvert object.
135  void setConverter (MEpoch::Types toType, Bool sidFrac);
136 
137  // Set the possible position engine.
138  // It can be done only once.
139  void setPositionEngine (PositionEngine& engine);
140 
141  private:
142  void handleEpochArray (TableExprNodeRep* operand);
143  void handleConstant (TableExprNodeRep* operand);
144 
145  //# Data members.
149  Bool itsSidFrac; //# T = fraction for sidereal
150  MeasFrame itsFrame; //# frame used by converter
158  };
159 
160 } //end namespace
161 
162 #endif
TableExprNode itsExprNode
Definition: EpochEngine.h:154
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:50
MEpoch::Types itsRefType
Definition: EpochEngine.h:153
Handle class for a table column expression tree.
Definition: ExprNode.h:614
void handleConstant(TableExprNodeRep *operand)
Container for Measure frame.
Definition: MeasFrame.h:137
Engine for TaQL UDF Position conversions.
void setConverter(MEpoch::Types toType, Bool sidFrac)
Set the MeasConvert object.
Abstract base class for a node in a table column expression tree.
Definition: ExprNodeRep.h:151
const IPosition & shape() const
Get the shape.
Definition: EpochEngine.h:103
Int ndim() const
Get the dimensionality.
Definition: EpochEngine.h:107
Read only access to table array Measure columns.
Definition: MBaseline.h:45
Array< MEpoch > getEpochs(const TableExprId &id)
Get the epochs.
MEpoch::Convert itsConverter
Definition: EpochEngine.h:151
MEpoch::Types refType() const
Get the reference type.
Definition: EpochEngine.h:95
defines physical units
Definition: Unit.h:189
ScalarMeasColumn< MEpoch > itsMeasScaCol
Definition: EpochEngine.h:155
Bool handleEpochType(TableExprNodeRep *operand, Bool doThrow)
Handle a epoch reference type.
Bool sidFrac() const
Tell if the fraction has to be used for sidereal times.
Definition: EpochEngine.h:99
Engine for TaQL UDF Epoch conversions.
Definition: EpochEngine.h:89
PositionEngine * itsPositionEngine
Definition: EpochEngine.h:157
Vector< MEpoch > itsConstants
Definition: EpochEngine.h:152
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Array< Double > getArrayDouble(const TableExprId &id)
Get the values.
A drop-in replacement for Block<T*>.
Definition: Block.h:861
void handleEpochArray(TableExprNodeRep *operand)
const Unit & unit() const
Get the unit.
Definition: EpochEngine.h:114
void handleEpoch(PtrBlock< TableExprNodeRep *> &args, uInt &argnr)
Handle the argument(s) giving the input epochs and reference type.
The identification of a TaQL selection subject.
Definition: TableExprId.h:98
Bool isConstant() const
Tell if the expression is constant.
Read only access to table scalar Measure columns.
Definition: MBaseline.h:46
Types
Types of known MEpochs Caution: The order defines the order in the translation matrix in the MCEpoch...
Definition: MEpoch.h:117
this file contains all the compiler specific defines
Definition: mainpage.dox:28
ArrayMeasColumn< MEpoch > itsMeasArrCol
Definition: EpochEngine.h:156
unsigned int uInt
Definition: aipstype.h:51
void setPositionEngine(PositionEngine &engine)
Set the possible position engine.