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