Stellarium  0.90.0
jpl_int.h
1 /* jpl_int.cpp: internal definitions for JPL ephemeris functions
2 
3 Copyright (C) 2011, Project Pluto
4 
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 02110-1301, USA. */
19 
20  /* A JPL binary ephemeris header contains five doubles and */
21  /* (up to) 41 int32_t integers, so: */
22 #define JPL_HEADER_SIZE (5 * sizeof( double) + 41 * sizeof( int32_t))
23  /* ...also known as 5 * 8 + 41 * 4 = 204 bytes. */
24 
25 
26  /* Thus far, no DE ephems use eighteen terms in the Chebyshev */
27  /* expansion. There's an assert to catch it if this changes.. */
28 #define MAX_CHEBY 18
29 
30 #pragma pack(1)
31 
33  {
34  double posn_coeff[MAX_CHEBY], vel_coeff[MAX_CHEBY], twot;
35  unsigned n_posn_avail, n_vel_avail;
36  };
37 
38 struct jpl_eph_data {
39  double ephem_start, ephem_end, ephem_step;
40  uint32_t ncon;
41  double au;
42  double emrat;
43  uint32_t ipt[15][3];
44  uint32_t ephemeris_version;
45  /* This is the end of the file header. Following are */
46  /* items computed within my code. */
47  uint32_t kernel_size, recsize, ncoeff;
48  uint32_t swap_bytes;
49  uint32_t curr_cache_loc;
50  double pvsun[9];
51  double pvsun_t;
52  double *cache;
53  struct interpolation_info iinfo;
54  FILE *ifile;
55  };
56 #pragma pack()
57 
58 /* 2014 Mar 25: notes about the file structure :
59 
60 Bytes 0- 83: first line ("JPL Planetary Ephemeris DExxx/LExxx")
61  84-167: second line ("Start Epoch: JED = ttttttt.t yyyy-MMM-dd 00:00:00")
62  168-251: third line ("Final Epoch: JED = ttttttt.t yyyy-MMM-dd 00:00:00")
63  252-257: first constant name ("DENUM ")
64  252+6n to 257+6n: nth constant name (0 <= n < 399)
65  2646-2651: 400th constant name
66  2652-2659: ephem_start
67  2660-2667: ephem_end
68  2668-2675: ephem_step
69  2676-2679: ncon
70  2680-2687: AU in km: close to 149597870.700000
71  2688-2695: Earth/moon mass ratio: about 81.300569
72  ...followed by 36 32-bit ints for the above 'ipt' array [12][3]...
73  2840-2843: ephemeris version (405, 430, etc.)
74  ...followed by three 32-bit ints for ipt[12][0...2].
75  2844-2855: ipt[12][0], ipt[12][1], ipt[12][2]
76  Note that in the JPL FORTRAN code,
77  ipt[12][0..2] become lpt[0..2] (the lunar libration offsets);
78  ipt[13][0..2] become rpt[0..2] (the lunar euler angle rate offsets);
79  ipt[14][0..2] become tpt[0..2] (the TT-TDB offsets)
80  Further note that ipt[13] and [14] are new to DE-430t. In older
81  versions, they're just zeroes.
82  2856-2861: name of 401th constant
83  2862-2867: name of 402st constant
84  ...and after the last constant, ipt[13][0..2] and ipt[14][0..2].
85  If n_constants <= 400, these will occupy bytes 2856-2879. Otherwise,
86  add (n_constants - 400) * 6 to get the byte offset.
87 
88  Notice that _most_ of the data in the jpl_eph_data struct is stored
89  between bytes 2652 to 2839. That gets us up to ipt[11][2]. In a
90  sensible world, this would be followed by ipt[12][0]. However, it
91  used to be that DE just gave eleven variables; librations and
92  TT-TDB are sort of an afterthought. And furthermore, having more
93  than 400 constants was something of an afterthought, too. So you
94  have ipts[0] to [11] stored contiguously; then four bytes for the
95  ephemeris version are stuck in there; then twelve bytes for ipt[12],
96  which may be zero; then any "extra" (past 400) constant names;
97  and _then_ 24 bytes for ipt[13] and ipt[14].
98 
99  recsize-recsize+8*ncon: actual values of the constants.
100  recsize = 8 * ncoeff; ncoeff, thus far, has been...
101  ncoeff = 773 for DE-102
102  ncoeff = 826 for DE-200 & 202
103  ncoeff = 1018 for DE-403, 405, 406, 410, 414, 421, 422, 423, 424, 430, 431,
104  ncoeff = 728 for DE-406
105  ncoeff = 982 for DE-432, DE-432t
106 */