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 public:
121 // # Constants
122
123 // # Enumerations
124 // Types of known data
125 enum Types {
126 // MJD (must be first in list)
128 // Column with data
130 // Number of columns
132 // Planets
134 VENUS = 2,
135 EARTH = 3,
136 MARS = 4,
141 PLUTO = 9,
142 MOON = 10,
143 SUN = 11,
144 // Solar system barycentre
146 // Earth-Moon system barycentre
148 // Nutations
150 // Librations
152 // Number of types
154 };
155
156 // Types of files
157 enum Files {
158 // DE200
160 // DE405
162 // # of known types
164 // Default
166 };
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
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.
186 const MVEpoch &date);
187 // Get indicated special constant
189 // Get filed constant with name nam
190 static Bool getConst(Double &res, MeasJPL::Files which, const String &nam);
191
192 // Close the set of JPL tables only. Only call it last at end of program.
193 static void closeMeas();
194
195 private:
196 // # Constructors
197 // Default constructor, NOT defined
199
200 // Copy assign, NOT defined
201 MeasJPL &operator=(const MeasJPL &other);
202
203 // # Destructor
204 // Destructor, NOT defined and not declared to stop warning
205 // ~MeasJPL();
206
207 // # General member functions
208 // Initialise tables
210 static void doInitMeas(MeasJPL::Files which);
211 // Get a pointer to the data for the given date. It reads the data if needed.
212 static const Double *fillMeas(Double &intv, MeasJPL::Files which, const MVEpoch &utf);
213 // Interpolate Chebyshev polymomial to res
214 static void interMeas(Double res[], MeasJPL::Files which, Double intv, Double ivf, Int ncf,
215 Int ncm, Int na, const Double buf[]);
216
217 // # Data members
218 // Object to ensure safe multi-threaded lazy single initialization
219 static std::once_flag theirCallOnceFlags[N_Files];
220 // Mutex for thread-safety (other than initialization).
221 static std::mutex theirMutex;
222 // Tables present
223 static Table t[N_Files];
224 // Data column descriptor
226 // First (-1) MJD in list
227 static Int mjd0[N_Files];
228 // Last MJD in list
229 static Int mjdl[N_Files];
230 // Interval in days (i.e., date step between subsequent rows)
231 static Int dmjd[N_Files];
232 // File names
233 static const String tp[N_Files];
234 // Index in record
235 static Int idx[N_Files][3][13];
236 // Dates of the data read in buffer.
237 static vector<Int> curDate[N_Files];
238 // Data read in.
239 static vector<Vector<Double>> dval[N_Files];
240 // Some helper data read from the table keywords
241 // <group>
245 // </group>
246};
247
248// # Inline Implementations
249
250} // namespace casacore
251
252#endif
static Int dmjd[N_Files]
Interval in days (i.e., date step between subsequent rows).
Definition MeasJPL.h:231
static ArrayColumn< Double > acc[N_Files]
Data column descriptor.
Definition MeasJPL.h:225
Types
Types of known data.
Definition MeasJPL.h:125
@ BARYEARTH
Earth-Moon system barycentre.
Definition MeasJPL.h:147
@ MERCURY
Planets.
Definition MeasJPL.h:133
@ N_Columns
Number of columns.
Definition MeasJPL.h:131
@ LIBRATION
Librations.
Definition MeasJPL.h:151
@ NUTATION
Nutations.
Definition MeasJPL.h:149
@ MJD
MJD (must be first in list).
Definition MeasJPL.h:127
@ N_Types
Number of types.
Definition MeasJPL.h:153
@ BARYSOLAR
Solar system barycentre.
Definition MeasJPL.h:145
@ X
Column with data.
Definition MeasJPL.h:129
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:239
MeasJPL & operator=(const MeasJPL &other)
Copy assign, NOT defined.
static const String tp[N_Files]
File names.
Definition MeasJPL.h:233
static std::mutex theirMutex
Mutex for thread-safety (other than initialization).
Definition MeasJPL.h:221
static Int mjdl[N_Files]
Last MJD in list.
Definition MeasJPL.h:229
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:237
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:235
static Double cn[N_Files][N_Codes]
Definition MeasJPL.h:244
static Double aufac[N_Files]
Some helper data read from the table keywords.
Definition MeasJPL.h:242
Codes
Codes for special constants.
Definition MeasJPL.h:169
@ CAU
Light velocity used in AU/d.
Definition MeasJPL.h:171
@ GMS
Solar mass (GM0)/c2 in AU.
Definition MeasJPL.h:173
@ RADS
Solar radius in AU.
Definition MeasJPL.h:177
@ AU
AU in km.
Definition MeasJPL.h:175
static Int mjd0[N_Files]
First (-1) MJD in list.
Definition MeasJPL.h:227
static Bool initMeasOnce(MeasJPL::Files which)
Destructor, NOT defined and not declared to stop warning ~MeasJPL();.
static Double emrat[N_Files]
Definition MeasJPL.h:243
static void closeMeas()
Close the set of JPL tables only.
static Table t[N_Files]
Tables present.
Definition MeasJPL.h:223
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:219
MeasJPL()
Default constructor, NOT defined.
String: the storage and methods of handling collections of characters.
Definition String.h:355
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
TableExprNode date(const TableExprNode &node)
Definition ExprNode.h:1320
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