casacore
DirectionUDF.h
Go to the documentation of this file.
1 //# DirectionUDF.h: TaQL UDFs for 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: 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_DIRECTIONUDF_H
29 #define MEAS_DIRECTIONUDF_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 #include <casacore/meas/MeasUDF/DirectionEngine.h>
34 #include <casacore/tables/TaQL/UDFBase.h>
35 #include <casacore/tables/TaQL/ExprNode.h>
36 #include <casacore/measures/Measures/MDirection.h>
37 #include <casacore/measures/Measures/MPosition.h>
38 #include <casacore/measures/Measures/MEpoch.h>
39 #include <casacore/measures/Measures/MCDirection.h>
40 #include <casacore/measures/Measures/MeasConvert.h>
41 
42 namespace casacore {
43 
44 // <summary>
45 // TaQL UDFs for Direction conversions.
46 // </summary>
47 
48 // <use visibility=export>
49 
50 // <reviewed reviewer="" date="" tests="tMeas.cc">
51 // </reviewed>
52 
53 // <prerequisite>
54 //# Classes you should understand before using this one.
55 // <li> UDFBase
56 // </prerequisite>
57 
58 // <synopsis>
59 // DirectionUDF defines UDFs (user defined functions) that can be used in TaQL
60 // to convert Measures for directions.
61 // Special functions exist to convert to hourangle and azimuth/elevation.
62 // In this way such derived values appear to be ordinary TaQL functions.
63 //
64 // A function is called like:
65 // <srcblock>
66 // meas.dir (toref, dir, time, pos)
67 // meas.dir (toref, dir, time, pos)
68 // For example,
69 // meas.dir ('B1950', [2rad,1rad])
70 // meas.dir ('B1950', [[2rad,1rad], 'J2000'])
71 // meas.dir ('APP', 'MOON', TIME, [[5d12m, 52deg, 11m], 'WGS84'])
72 // meas.dir ('APP', 'MOON', TIME, POSITION)
73 // Or
74 // meas.dir (toref, fromref, dir, pos, time)
75 // </srcblock>
76 // <ul>
77 // <li>
78 // <src>toref</src> is a single constant string.
79 // <li>
80 // <src>dir</src> can have various value types. A single numeric array is
81 // a series of RA,DEC in J2000. If given as a set, the last argument of the
82 // set can be the reference types of the values in the set. The values can
83 // be strings (indicating planetary objects) or value pairs giving lon,lat.
84 // The default reference type is J2000.
85 // </ul>
86 // All functions have data type double and unit radian.
87 // </synopsis>
88 
89 // <motivation>
90 // It makes it possible to handle measures in TaQL.
91 // </motivation>
92 
93  class DirectionUDF: public UDFBase
94  {
95  public:
96  // Define the possible function types.
99 
100  // Create for the given function type.
101  // The Bools tell if rise/set times have to be calculated.
102  explicit DirectionUDF (FuncType, Bool riseSet=False);
103 
104  // Function to create an object.
105  static UDFBase* makeDIR (const String&);
106  static UDFBase* makeHADEC (const String&);
107  static UDFBase* makeAZEL (const String&);
108  static UDFBase* makeAPP (const String&);
109  static UDFBase* makeJ2000 (const String&);
110  static UDFBase* makeB1950 (const String&);
111  static UDFBase* makeECL (const String&);
112  static UDFBase* makeGAL (const String&);
113  static UDFBase* makeSGAL (const String&);
114  static UDFBase* makeRISESET (const String&);
115 
116  // Setup the object.
117  virtual void setup (const Table&, const TaQLStyle&);
118 
119  // Get the value.
120  virtual Double getDouble (const TableExprId& id);
121  virtual Array<Double> getArrayDouble (const TableExprId& id);
122  virtual Array<MVTime> getArrayDate (const TableExprId& id);
123 
124  private:
125  //# Data members.
131  Bool itsRiseSet; //# True = calculate rise/set time
132  };
133 
134 } //end namespace
135 
136 #endif
virtual void setup(const Table &, const TaQLStyle &)
Setup the object.
static UDFBase * makeRISESET(const String &)
Main interface class to a read/write table.
Definition: Table.h:149
MDirection::Types itsRefType
Definition: DirectionUDF.h:130
virtual Array< Double > getArrayDouble(const TableExprId &id)
virtual Array< MVTime > getArrayDate(const TableExprId &id)
static UDFBase * makeSGAL(const String &)
Engine for TaQL UDF Position conversions.
Abstract base class for a user-defined TaQL function.
Definition: UDFBase.h:233
virtual Double getDouble(const TableExprId &id)
Get the value.
static UDFBase * makeGAL(const String &)
EpochEngine itsEpochEngine
Definition: DirectionUDF.h:127
DirectionEngine itsEngine
Definition: DirectionUDF.h:126
Types
Types of known MDirections Warning: The order defines the order in the translation matrix FromTo in ...
Definition: MDirection.h:188
TaQL UDFs for Direction conversions.
Definition: DirectionUDF.h:93
double Double
Definition: aipstype.h:52
Class with static members defining the TaQL style.
Definition: TaQLStyle.h:64
Engine for TaQL UDF Epoch conversions.
Definition: EpochEngine.h:88
Engine for TaQL UDF Direction conversions.
PositionEngine itsPositionEngine
Definition: DirectionUDF.h:128
static UDFBase * makeAPP(const String &)
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:39
const Bool False
Definition: aipstype.h:41
FuncType
Define the possible function types.
Definition: DirectionUDF.h:97
The identification of a TaQL selection subject.
Definition: TableExprId.h:98
static UDFBase * makeB1950(const String &)
static UDFBase * makeHADEC(const String &)
static UDFBase * makeAZEL(const String &)
String: the storage and methods of handling collections of characters.
Definition: String.h:223
static UDFBase * makeDIR(const String &)
Function to create an object.
static UDFBase * makeJ2000(const String &)
static UDFBase * makeECL(const String &)
this file contains all the compiler specific defines
Definition: mainpage.dox:28
DirectionUDF(FuncType, Bool riseSet=False)
Create for the given function type.