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 #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,
186  MeasJPL::Files file,
187  MeasJPL::Types type,
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
casacore::MeasJPL::MeasJPL
MeasJPL()
Default constructor, NOT defined.
casacore::MeasJPL::Files
Files
Types of files.
Definition: MeasJPL.h:158
casacore::MeasJPL::curDate
static vector< Int > curDate[N_Files]
Dates of the data read in buffer.
Definition: MeasJPL.h:244
casacore::MeasJPL::LIBRATION
@ LIBRATION
Librations.
Definition: MeasJPL.h:153
casacore::MeasJPL::fillMeas
static const Double * fillMeas(Double &intv, MeasJPL::Files which, const MVEpoch &utf)
Get a pointer to the data for the given date.
casacore::MeasJPL::VENUS
@ VENUS
Definition: MeasJPL.h:136
casacore::MeasJPL::cn
static Double cn[N_Files][N_Codes]
Definition: MeasJPL.h:251
casacore::MeasJPL::DEFAULT
@ DEFAULT
Default.
Definition: MeasJPL.h:166
casacore::MeasJPL::idx
static Int idx[N_Files][3][13]
Index in record.
Definition: MeasJPL.h:242
casacore::MeasJPL::MARS
@ MARS
Definition: MeasJPL.h:138
casacore::MeasJPL
Interface to JPL DE tables.
Definition: MeasJPL.h:120
casacore::MeasJPL::interMeas
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.
casacore::MeasJPL::MOON
@ MOON
Definition: MeasJPL.h:144
casacore::MeasJPL::GMS
@ GMS
Solar mass (GM0)/c2 in AU.
Definition: MeasJPL.h:173
casacore::MeasJPL::closeMeas
static void closeMeas()
Close the set of JPL tables only.
casacore::MeasJPL::theirMutex
static Mutex theirMutex
Mutex for thread-safety (other than initialization).
Definition: MeasJPL.h:228
casacore::MeasJPL::BARYEARTH
@ BARYEARTH
Earth-Moon system barycentre.
Definition: MeasJPL.h:149
casacore::MeasJPL::SATURN
@ SATURN
Definition: MeasJPL.h:140
casacore::MeasJPL::N_Columns
@ N_Columns
Number of columns.
Definition: MeasJPL.h:133
casacore::MeasJPL::CAU
@ CAU
Light velocity used in AU/d.
Definition: MeasJPL.h:171
casacore::ArrayColumn< Double >
casacore::MeasJPL::JUPITER
@ JUPITER
Definition: MeasJPL.h:139
casacore::MeasJPL::acc
static ArrayColumn< Double > acc[N_Files]
Data column descriptor.
Definition: MeasJPL.h:232
casacore::MeasJPL::mjd0
static Int mjd0[N_Files]
First (-1) MJD in list.
Definition: MeasJPL.h:234
casacore::MeasJPL::X
@ X
Column with data.
Definition: MeasJPL.h:131
casacore::MeasJPL::BARYSOLAR
@ BARYSOLAR
Solar system barycentre.
Definition: MeasJPL.h:147
casacore::MeasJPL::NUTATION
@ NUTATION
Nutations.
Definition: MeasJPL.h:151
casacore::Table
Main interface class to a read/write table.
Definition: Table.h:153
casacore::MeasJPL::MJD
@ MJD
MJD (must be first in list)
Definition: MeasJPL.h:129
casacore::Double
double Double
Definition: aipstype.h:55
casacore::MeasJPL::dmjd
static Int dmjd[N_Files]
Interval in days (i.e., date step between subsequent rows)
Definition: MeasJPL.h:238
casacore::date
TableExprNode date(const TableExprNode &node)
Definition: ExprNode.h:1468
casacore::MeasJPL::Codes
Codes
Codes for special constants.
Definition: MeasJPL.h:169
casacore::MeasJPL::mjdl
static Int mjdl[N_Files]
Last MJD in list.
Definition: MeasJPL.h:236
casacore::MeasJPL::N_Types
@ N_Types
Number of types.
Definition: MeasJPL.h:155
casacore::MeasJPL::getConst
static Bool getConst(Double &res, MeasJPL::Files which, MeasJPL::Codes what)
Get indicated special constant.
casacore::MeasJPL::SUN
@ SUN
Definition: MeasJPL.h:145
casacore::MeasJPL::Types
Types
Types of known data.
Definition: MeasJPL.h:127
casacore::MeasJPL::tp
static const String tp[N_Files]
File names.
Definition: MeasJPL.h:240
casacore::MeasJPL::DE405
@ DE405
DE405.
Definition: MeasJPL.h:162
casacore::MeasJPL::aufac
static Double aufac[N_Files]
Some helper data read from the table keywords.
Definition: MeasJPL.h:249
casacore::MeasJPL::N_Codes
@ N_Codes
Definition: MeasJPL.h:179
casacore::Int
int Int
Definition: aipstype.h:50
casacore
this file contains all the compiler specific defines
Definition: mainpage.dox:28
casacore::MeasJPL::operator=
MeasJPL & operator=(const MeasJPL &other)
Copy assign, NOT defined.
casacore::MVEpoch
A class for high precision time.
Definition: MVEpoch.h:90
casacore::MeasJPL::URANUS
@ URANUS
Definition: MeasJPL.h:141
casacore::MeasJPL::N_Files
@ N_Files
Definition: MeasJPL.h:164
casacore::MeasJPL::NEPTUNE
@ NEPTUNE
Definition: MeasJPL.h:142
casacore::MeasJPL::get
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)).
casacore::MeasJPL::EARTH
@ EARTH
Definition: MeasJPL.h:137
casacore::MeasJPL::dval
static vector< Vector< Double > > dval[N_Files]
Data read in.
Definition: MeasJPL.h:246
casacore::MeasJPL::RADS
@ RADS
Solar radius in AU.
Definition: MeasJPL.h:177
casacore::MeasJPL::theirCallOnce
static CallOnce theirCallOnce[N_Files]
Object to ensure safe multi-threaded lazy single initialization.
Definition: MeasJPL.h:226
casacore::String
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::Mutex
Wrapper around a pthreads mutex.
Definition: Mutex.h:58
casacore::Bool
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::MeasJPL::t
static Table t[N_Files]
Tables present.
Definition: MeasJPL.h:230
casacore::MeasJPL::DE200
@ DE200
DE200.
Definition: MeasJPL.h:160
casacore::Vector< Double >
casacore::MeasJPL::initMeasOnce
static Bool initMeasOnce(MeasJPL::Files which)
Destructor, NOT defined and not declared to stop warning ~MeasJPL();.
casacore::MeasJPL::doInitMeas
static void doInitMeas(MeasJPL::Files which)
casacore::MeasJPL::AU
@ AU
AU in km.
Definition: MeasJPL.h:175
casacore::MeasJPL::emrat
static Double emrat[N_Files]
Definition: MeasJPL.h:250
casacore::CallOnce
CallOnce: func has one arg.
Definition: Mutex.h:251
casacore::MeasJPL::MERCURY
@ MERCURY
Planets.
Definition: MeasJPL.h:135
casacore::MeasJPL::PLUTO
@ PLUTO
Definition: MeasJPL.h:143