casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MeasJPL.h
Go to the documentation of this file.
1 //# MeasJPL.h: Interface to JPL DE tables
2 //# Copyright (C) 1996,1997,1998,1999,2002,2016
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 MEASURES_MEASJPL_H
29 #define MEASURES_MEASJPL_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
38 #include <casacore/casa/OS/Mutex.h>
39 
40 namespace casacore { //# NAMESPACE CASACORE - BEGIN
41 
42 //# Forward Declarations
43 class String;
44 class MVEpoch;
45 
46 // <summary> Interface to JPL DE tables </summary>
47 
48 // <use visibility=local>
49 
50 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMeasJPL" demos="">
51 // </reviewed>
52 
53 // <prerequisite>
54 // <li> <linkto class=MeasTable>MeasTable</linkto>
55 // </prerequisite>
56 //
57 // <etymology>
58 // From Measure and JPL
59 // </etymology>
60 //
61 // <synopsis>
62 // MeasJPL is the interface class to the JPL DE planetary data.
63 // It has only static memebers.<br>
64 // Tables are found using the aipsrc
65 // (using <src>measures.<table>.directory</src>)
66 // mechanism. If not provided they are assumed to reside in standard places
67 // (i.e. in $AIPSROOT/data/ephemerides) Tables are assumed to have the
68 // VS_VERSION, VS_DATE, VS_CREATE and VS_TYPE keywords, and be of type IERS,
69 // else an exception will be thrown.<br>
70 // The <src>get()</src> method will obtain data from the JPL planetary
71 // tables (i.e. the <src>DE200</src> and
72 // the <src>DE405</src> tables). The data obtained will be the barycentric
73 // position (AU) and velocity (AU/d) of planets; the nutation (rad, rad/d)
74 // or the libration (rad, rad/d; DE405 only). All in the J2000 system.<br>
75 // The JPL DE Tables have a large set of constants attach to it. Some
76 // will be available by their own special code, the others their filed name.
77 // (See the <src>get</src> functions.<br>
78 // The enumeration code gives the available data and planets. See
79 // E.M. Standish et al., JPL IOM 314.10 - 127 for further details.
80 // <br>
81 // Note that the normal usage of these tables is through the Measures system.
82 //
83 // <note>
84 // A message is Logged (once) if a table cannot be found.
85 // A message is logged (once) if a date outside the range in
86 // the Tables is asked for.
87 // </note>
88 // <thrown>
89 // <li> AipsError if table opened has wrong format or otherwise corrupted.
90 // </thrown>
91 // </synopsis>
92 //
93 // <example>
94 // <srcblock>
95 // #include <casacore/casa/aips.h>
96 // #include <casacore/casa/Quanta/MVEpoch.h>
97 // #include <casacore/measures/Measures/MeasJPL.h>
98 // #include <casacore/casa/Arrays/Vector.h>
99 // const MVEpoch dat = 51116; // a date (1998/10/30) in TDB
100 // Vector<Double> val(6), valE(6); // results
101 // // Get position and velocity of Venus (barycentric)
102 // if (!MeasJPL::get(val, MeasJPL::DE200, MeasJPL::VENUS, dat)) {
103 // cout << "Some error getting Venus position" << endl;
104 // // Get Earth position and velocity (barycentric)
105 // } else if (!MeasJPL::get(valE, MeasJPL::DE200, MeasJPL::VENUS, dat)) {
106 // cout << "Some error getting Earth position" << endl;
107 // } else {
108 // cout << "Venus (geocentric): " << (val-valE) << endl;
109 // };
110 // </srcblock>
111 // </example>
112 //
113 // <motivation>
114 // To use the JPL data for planetary positions and high precision nutation
115 // </motivation>
116 //
117 // <todo asof="1998/08/24">
118 // </todo>
119 
120 class MeasJPL {
121 
122 public:
123  //# Constants
124 
125  //# Enumerations
126  // Types of known data
127  enum Types {
128  // MJD (must be first in list)
130  // Column with data
131  X,
132  // Number of columns
134  // Planets
135  MERCURY = 1,
136  VENUS = 2,
137  EARTH = 3,
138  MARS = 4,
139  JUPITER = 5,
140  SATURN = 6,
141  URANUS = 7,
142  NEPTUNE = 8,
143  PLUTO = 9,
144  MOON = 10,
145  SUN = 11,
146  // Solar system barycentre
147  BARYSOLAR = 12,
148  // Earth-Moon system barycentre
149  BARYEARTH = 13,
150  // Nutations
151  NUTATION = 14,
152  // Librations
153  LIBRATION = 15,
154  // Number of types
156 
157  // Types of files
158  enum Files {
159  // DE200
161  // DE405
163  // # of known types
165  // Default
167 
168  // Codes for special constants
169  enum Codes {
170  // Light velocity used in AU/d
172  // Solar mass (GM0)/c<sup>2</sup> in AU
174  // AU in km
175  AU,
176  // Solar radius in AU
178  // # of codes
180 
181 
182  //# General Member Functions
183  // Get the values from a DE table, interpolated for date(in MJD(TDB)).
184  // The file can be DE200 or DE405, the type as given in enum.
185  static Bool get(Vector<Double> &returnValue,
188  const MVEpoch &date);
189  // Get indicated special constant
190  static Bool getConst(Double &res, MeasJPL::Files which,
191  MeasJPL::Codes what);
192  // Get filed constant with name nam
193  static Bool getConst(Double &res, MeasJPL::Files which,
194  const String &nam);
195 
196  // Close the set of JPL tables only. Only call it last at end of program.
197  static void closeMeas();
198 
199 private:
200 
201  //# Constructors
202  // Default constructor, NOT defined
203  MeasJPL();
204 
205  // Copy assign, NOT defined
206  MeasJPL &operator=(const MeasJPL &other);
207 
208  //# Destructor
209  // Destructor, NOT defined and not declared to stop warning
210  // ~MeasJPL();
211 
212  //# General member functions
213  // Initialise tables
214  static Bool initMeasOnce(MeasJPL::Files which);
215  static void doInitMeas(MeasJPL::Files which);
216  // Get a pointer to the data for the given date. It reads the data if needed.
217  static const Double* fillMeas(Double &intv, MeasJPL::Files which,
218  const MVEpoch &utf);
219  // Interpolate Chebyshev polymomial to res
220  static void interMeas(Double res[], MeasJPL::Files which, Double intv,
221  Double ivf, Int ncf, Int ncm, Int na,
222  const Double buf[]);
223 
224  //# Data members
225  // Object to ensure safe multi-threaded lazy single initialization
227  // Mutex for thread-safety (other than initialization).
229  // Tables present
230  static Table t[N_Files];
231  // Data column descriptor
233  // First (-1) MJD in list
234  static Int mjd0[N_Files];
235  // Last MJD in list
236  static Int mjdl[N_Files];
237  // Interval in days (i.e., date step between subsequent rows)
238  static Int dmjd[N_Files];
239  // File names
240  static const String tp[N_Files];
241  // Index in record
242  static Int idx[N_Files][3][13];
243  // Dates of the data read in buffer.
244  static vector<Int> curDate[N_Files];
245  // Data read in.
246  static vector<Vector<Double> > dval[N_Files];
247  // Some helper data read from the table keywords
248  // <group>
252  // </group>
253 };
254 
255 //# Inline Implementations
256 
257 
258 } //# NAMESPACE CASACORE - END
259 
260 #endif
int Int
Definition: aipstype.h:50
Codes
Codes for special constants.
Definition: MeasJPL.h:169
static void closeMeas()
Close the set of JPL tables only.
Main interface class to a read/write table.
Definition: Table.h:153
static Mutex theirMutex
Mutex for thread-safety (other than initialization).
Definition: MeasJPL.h:228
static const Double * fillMeas(Double &intv, MeasJPL::Files which, const MVEpoch &utf)
Get a pointer to the data for the given date.
static Int mjdl[N_Files]
Last MJD in list.
Definition: MeasJPL.h:236
static vector< Int > curDate[N_Files]
Dates of the data read in buffer.
Definition: MeasJPL.h:244
static vector< Vector< Double > > dval[N_Files]
Data read in.
Definition: MeasJPL.h:246
virtual casacore::String type() const
Implements RegionShape::type.
Definition: RegionShapes.h:548
static Int mjd0[N_Files]
First (-1) MJD in list.
Definition: MeasJPL.h:234
static void doInitMeas(MeasJPL::Files which)
static Bool initMeasOnce(MeasJPL::Files which)
Destructor, NOT defined and not declared to stop warning ~MeasJPL();.
Solar radius in AU.
Definition: MeasJPL.h:177
static const String tp[N_Files]
File names.
Definition: MeasJPL.h:240
static Double cn[N_Files][N_Codes]
Definition: MeasJPL.h:251
static Double aufac[N_Files]
Some helper data read from the table keywords.
Definition: MeasJPL.h:249
Interface to JPL DE tables.
Definition: MeasJPL.h:120
MeasJPL()
Default constructor, NOT defined.
double Double
Definition: aipstype.h:55
CallOnce: func has one arg.
Definition: Mutex.h:251
static Int dmjd[N_Files]
Interval in days (i.e., date step between subsequent rows)
Definition: MeasJPL.h:238
Files
Types of files.
Definition: MeasJPL.h:158
Solar mass (GM0)/c2 in AU.
Definition: MeasJPL.h:173
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
MeasJPL & operator=(const MeasJPL &other)
Copy assign, NOT defined.
static void interMeas(Double res[], MeasJPL::Files which, Double intv, Double ivf, Int ncf, Int ncm, Int na, const Double buf[])
Interpolate Chebyshev polymomial to res.
static ArrayColumn< Double > acc[N_Files]
Data column descriptor.
Definition: MeasJPL.h:232
static CallOnce theirCallOnce[N_Files]
Object to ensure safe multi-threaded lazy single initialization.
Definition: MeasJPL.h:226
Wrapper around a pthreads mutex.
Definition: Mutex.h:58
Earth-Moon system barycentre.
Definition: MeasJPL.h:149
Solar system barycentre.
Definition: MeasJPL.h:147
A class for high precision time.
Definition: MVEpoch.h:90
Column with data.
Definition: MeasJPL.h:131
Light velocity used in AU/d.
Definition: MeasJPL.h:171
String: the storage and methods of handling collections of characters.
Definition: String.h:223
Number of columns.
Definition: MeasJPL.h:133
static Bool getConst(Double &res, MeasJPL::Files which, MeasJPL::Codes what)
Get indicated special constant.
Types
Types of known data.
Definition: MeasJPL.h:127
static Int idx[N_Files][3][13]
Index in record.
Definition: MeasJPL.h:242
static Table t[N_Files]
Tables present.
Definition: MeasJPL.h:230
Number of types.
Definition: MeasJPL.h:155
of known types
Definition: MeasJPL.h:164
static Double emrat[N_Files]
Definition: MeasJPL.h:250
MJD (must be first in list)
Definition: MeasJPL.h:129
Defines nreal time structures used by the VLA table filler.
Definition: nreal.h:100
TableExprNode date(const TableExprNode &node)
Definition: ExprNode.h:1468
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42