-
Notifications
You must be signed in to change notification settings - Fork 4
/
NOVAS_solsys1.c
304 lines (250 loc) · 8.72 KB
/
NOVAS_solsys1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
/*
Naval Observatory Vector Astrometry Software (NOVAS)
C Edition, Version 3.1
solsys1.c: Interface to JPL ephemerides for use with eph_manager
U. S. Naval Observatory
Astronomical Applications Dept.
Washington, DC
http://www.usno.navy.mil/USNO/astronomical-applications
*/
#ifndef _NOVAS_
#include "NOVAS_novas.h"
#endif
#ifndef _EPHMAN_
#include "NOVAS_eph_manager.h"
#endif
/********solarsystem */
short int solarsystem (double tjd, short int body, short int origin,
double *position, double *velocity)
/*
------------------------------------------------------------------------
PURPOSE:
Provides an interface between the JPL direct-access solar system
ephemerides and NOVAS-C.
REFERENCES:
JPL. 2007, "JPL Planetary and Lunar Ephemerides: Export Information,"
(Pasadena, CA: JPL) http://ssd.jpl.nasa.gov/?planet_eph_export.
Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
Subroutines"; USNO internal document dated 20 Oct 1988;
revised 15 Mar 1990.
INPUT
ARGUMENTS:
tjd (double)
Julian date of the desired time, on the TDB time scale.
body (short int)
Body identification number for the solar system object of
interest;Mercury = 1, ..., Pluto= 9, Sun= 10, Moon = 11.
origin (short int)
Origin code
= 0 ... solar system barycenter
= 1 ... center of mass of the Sun
= 2 ... center of Earth
OUTPUT
ARGUMENTS:
position[3] (double)
Position vector of 'body' at tjd; equatorial rectangular
coordinates in AU referred to the ICRS.
velocity[3] (double)
Velocity vector of 'body' at tjd; equatorial rectangular
system referred to the ICRS, in AU/day.
RETURNED
VALUE:
None.
GLOBALS
USED:
None.
FUNCTIONS
CALLED:
planet_ephemeris eph_manager.h
VER./DATE/
PROGRAMMER:
V1.0/03-93/WTH (USNO/AA): Convert FORTRAN to C.
V1.1/07-93/WTH (USNO/AA): Update to C standards.
V2.0/07-93/WTH (USNO/AA): Update to C standards.
V2.1/06-99/JAB (USNO/AA): Minor style and documentation mods.
V2.2/11-06/JAB (USNO/AA): Update to handle split-JD input
now supported in 'Planet_Ephemeris'.
V2.3/09-10/WKP (USNO/AA): Initialized local variable 'center'
to silence compiler warning.
V2.4/10-10/WKP (USNO/AA): Changed 'Planet_Ephmeris' function
name to lower case to comply with
C coding standards.
V2.5/02-11/JLB (USNO/AA): Reformatted description of origin for
consistency with other documentation.
V2.6/02-11/WKP (USNO/AA): More minor prolog changes for
consistency among all solsysn.c files.
NOTES:
1. This function and function 'planet_ephemeris' were designed
to work with the 1997 version of the JPL ephemerides, as
noted in the references.
2. The user must create the binary ephemeris files using
software from JPL, and open the file using function
'ephem_open' in eph_manager.h, prior to calling this
function.
3. This function places the entire Julian date in the first
element of the input time to 'planet_ephemeris'. This is
adequate for all but the highest precision applications. For
highest precision, use function 'solarsystem_hp' in file
'solsys1.c'.
4. Function 'planet_ephemeris' is a C rewrite of the JPL Fortran
subroutine 'pleph'.
------------------------------------------------------------------------
*/
{
short int target, center = 0;
double jd[2];
/*
Perform sanity checks on the input body and origin.
*/
if ((body < 1) || (body > 11))
return 1;
else if ((origin < 0) || (origin > 2))
return 2;
/*
Select 'target' according to value of 'body'.
*/
switch (body)
{
case 10:
target = 10;
break;
case 11:
target = 9;
break;
default:
target = body - 1;
}
/*
Select 'center' according to the value of 'origin'.
*/
if (!origin)
center = 11;
else if (origin == 1)
center = 10;
else if (origin == 2)
center = 2;
/*
Obtain position and velocity vectors. The entire Julian date is
contained in the first element of 'jd'. This is adequate for all
but the highest precision applications.
*/
jd[0] = tjd;
jd[1] = 0.0;
planet_ephemeris (jd,target,center, position,velocity);
return 0;
}
/********solarsystem_hp */
short int solarsystem_hp (double tjd[2], short int body,
short int origin,
double *position, double *velocity)
/*
------------------------------------------------------------------------
PURPOSE:
Provides an interface between the JPL direct-access solar system
ephemerides and NOVAS-C for highest precision applications.
REFERENCES:
JPL. 2007, "JPL Planetary and Lunar Ephemerides: Export Information,"
(Pasadena, CA: JPL) http://ssd.jpl.nasa.gov/?planet_eph_export.
Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
Subroutines"; USNO internal document dated 20 Oct 1988;
revised 15 Mar 1990.
INPUT
ARGUMENTS:
tjd[2] (double)
Two-element array containing the Julian date, which may be
split any way (although the first element is usually the
"integer" part, and the second element is the "fractional"
part). Julian date is on the TDB or "T_eph" time scale.
body (short int)
Body identification number for the solar system object of
interest;Mercury = 1, ..., Pluto= 9, Sun= 10, Moon = 11.
origin (short int)
Origin code
= 0 ... solar system barycenter
= 1 ... center of mass of the Sun
= 2 ... center of Earth
OUTPUT
ARGUMENTS:
position[3] (double)
Position vector of 'body' at tjd; equatorial rectangular
coordinates in AU referred to the ICRS.
velocity[3] (double)
Velocity vector of 'body' at tjd; equatorial rectangular
system referred to the ICRS, in AU/day.
RETURNED
VALUE:
None.
GLOBALS
USED:
None.
FUNCTIONS
CALLED:
planet_ephemeris eph_manager.h
VER./DATE/
PROGRAMMER:
V1.0/11-06/JAB (USNO/AA): Update to handle split-JD input
now supported in 'Planet_Ephemeris'.
V1.1/09-10/WKP (USNO/AA): Initialized local variable 'center'
to silence compiler warning.
V1.2/10-10/WKP (USNO/AA): Changed 'Planet_Ephmeris' function
name to lower case to comply with
C coding standards.
V1.3/02-11/JLB (USNO/AA): Reformatted description of origin for
consistency with other documentation.
V1.4/02-11/WKP (USNO/AA): More minor prolog changes for
consistency among all solsysn.c files.
NOTES:
1. This function and function 'planet_ephemeris' were designed
to work with the 1997 version of the JPL ephemerides, as
noted in the references.
2. The user must create the binary ephemeris files using
software from JPL, and open the file using function
'ephem_open' in eph_manager.h, prior to calling this
function.
3. This function supports the "split" Julian date feature of
function 'planet_ephemeris' for highest precision. For
usual applications, use function 'solarsystem' in file
'solsys1.c'.
4. Function 'planet_ephemeris' is a C rewrite of the JPL Fortran
subroutine 'pleph'.
------------------------------------------------------------------------
*/
{
short int target, center = 0;
/*
Perform sanity checks on the input body and origin.
*/
if ((body < 1) || (body > 11))
return 1;
else if ((origin < 0) || (origin > 2))
return 2;
/*
Select 'target' according to value of 'body'.
*/
switch (body)
{
case 10:
target = 10;
break;
case 11:
target = 9;
break;
default:
target = body - 1;
}
/*
Select 'center' according to the value of 'origin'.
*/
if (!origin)
center = 11;
else if (origin == 1)
center = 10;
else if (origin == 2)
center = 2;
/*
Obtain position and velocity vectors. The Julian date is split
between two double-precision elements for highest precision.
*/
planet_ephemeris (tjd,target,center, position,velocity);
return 0;
}