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