FACT++  1.0
nut80.c
Go to the documentation of this file.
1 #include "erfa.h"
2 
3 void eraNut80(double date1, double date2, double *dpsi, double *deps)
4 /*
5 ** - - - - - - - - -
6 ** e r a N u t 8 0
7 ** - - - - - - - - -
8 **
9 ** Nutation, IAU 1980 model.
10 **
11 ** Given:
12 ** date1,date2 double TT as a 2-part Julian Date (Note 1)
13 **
14 ** Returned:
15 ** dpsi double nutation in longitude (radians)
16 ** deps double nutation in obliquity (radians)
17 **
18 ** Notes:
19 **
20 ** 1) The TT date date1+date2 is a Julian Date, apportioned in any
21 ** convenient way between the two arguments. For example,
22 ** JD(TT)=2450123.7 could be expressed in any of these ways,
23 ** among others:
24 **
25 ** date1 date2
26 **
27 ** 2450123.7 0.0 (JD method)
28 ** 2451545.0 -1421.3 (J2000 method)
29 ** 2400000.5 50123.2 (MJD method)
30 ** 2450123.5 0.2 (date & time method)
31 **
32 ** The JD method is the most natural and convenient to use in
33 ** cases where the loss of several decimal digits of resolution
34 ** is acceptable. The J2000 method is best matched to the way
35 ** the argument is handled internally and will deliver the
36 ** optimum resolution. The MJD method and the date & time methods
37 ** are both good compromises between resolution and convenience.
38 **
39 ** 2) The nutation components are with respect to the ecliptic of
40 ** date.
41 **
42 ** Called:
43 ** eraAnpm normalize angle into range +/- pi
44 **
45 ** Reference:
46 **
47 ** Explanatory Supplement to the Astronomical Almanac,
48 ** P. Kenneth Seidelmann (ed), University Science Books (1992),
49 ** Section 3.222 (p111).
50 **
51 ** Copyright (C) 2013-2015, NumFOCUS Foundation.
52 ** Derived, with permission, from the SOFA library. See notes at end of file.
53 */
54 {
55  double t, el, elp, f, d, om, dp, de, arg, s, c;
56  int j;
57 
58 /* Units of 0.1 milliarcsecond to radians */
59  const double U2R = ERFA_DAS2R / 1e4;
60 
61 /* ------------------------------------------------ */
62 /* Table of multiples of arguments and coefficients */
63 /* ------------------------------------------------ */
64 
65 /* The units for the sine and cosine coefficients are 0.1 mas and */
66 /* the same per Julian century */
67 
68  static const struct {
69  int nl,nlp,nf,nd,nom; /* coefficients of l,l',F,D,Om */
70  double sp,spt; /* longitude sine, 1 and t coefficients */
71  double ce,cet; /* obliquity cosine, 1 and t coefficients */
72  } x[] = {
73 
74  /* 1-10 */
75  { 0, 0, 0, 0, 1, -171996.0, -174.2, 92025.0, 8.9 },
76  { 0, 0, 0, 0, 2, 2062.0, 0.2, -895.0, 0.5 },
77  { -2, 0, 2, 0, 1, 46.0, 0.0, -24.0, 0.0 },
78  { 2, 0, -2, 0, 0, 11.0, 0.0, 0.0, 0.0 },
79  { -2, 0, 2, 0, 2, -3.0, 0.0, 1.0, 0.0 },
80  { 1, -1, 0, -1, 0, -3.0, 0.0, 0.0, 0.0 },
81  { 0, -2, 2, -2, 1, -2.0, 0.0, 1.0, 0.0 },
82  { 2, 0, -2, 0, 1, 1.0, 0.0, 0.0, 0.0 },
83  { 0, 0, 2, -2, 2, -13187.0, -1.6, 5736.0, -3.1 },
84  { 0, 1, 0, 0, 0, 1426.0, -3.4, 54.0, -0.1 },
85 
86  /* 11-20 */
87  { 0, 1, 2, -2, 2, -517.0, 1.2, 224.0, -0.6 },
88  { 0, -1, 2, -2, 2, 217.0, -0.5, -95.0, 0.3 },
89  { 0, 0, 2, -2, 1, 129.0, 0.1, -70.0, 0.0 },
90  { 2, 0, 0, -2, 0, 48.0, 0.0, 1.0, 0.0 },
91  { 0, 0, 2, -2, 0, -22.0, 0.0, 0.0, 0.0 },
92  { 0, 2, 0, 0, 0, 17.0, -0.1, 0.0, 0.0 },
93  { 0, 1, 0, 0, 1, -15.0, 0.0, 9.0, 0.0 },
94  { 0, 2, 2, -2, 2, -16.0, 0.1, 7.0, 0.0 },
95  { 0, -1, 0, 0, 1, -12.0, 0.0, 6.0, 0.0 },
96  { -2, 0, 0, 2, 1, -6.0, 0.0, 3.0, 0.0 },
97 
98  /* 21-30 */
99  { 0, -1, 2, -2, 1, -5.0, 0.0, 3.0, 0.0 },
100  { 2, 0, 0, -2, 1, 4.0, 0.0, -2.0, 0.0 },
101  { 0, 1, 2, -2, 1, 4.0, 0.0, -2.0, 0.0 },
102  { 1, 0, 0, -1, 0, -4.0, 0.0, 0.0, 0.0 },
103  { 2, 1, 0, -2, 0, 1.0, 0.0, 0.0, 0.0 },
104  { 0, 0, -2, 2, 1, 1.0, 0.0, 0.0, 0.0 },
105  { 0, 1, -2, 2, 0, -1.0, 0.0, 0.0, 0.0 },
106  { 0, 1, 0, 0, 2, 1.0, 0.0, 0.0, 0.0 },
107  { -1, 0, 0, 1, 1, 1.0, 0.0, 0.0, 0.0 },
108  { 0, 1, 2, -2, 0, -1.0, 0.0, 0.0, 0.0 },
109 
110  /* 31-40 */
111  { 0, 0, 2, 0, 2, -2274.0, -0.2, 977.0, -0.5 },
112  { 1, 0, 0, 0, 0, 712.0, 0.1, -7.0, 0.0 },
113  { 0, 0, 2, 0, 1, -386.0, -0.4, 200.0, 0.0 },
114  { 1, 0, 2, 0, 2, -301.0, 0.0, 129.0, -0.1 },
115  { 1, 0, 0, -2, 0, -158.0, 0.0, -1.0, 0.0 },
116  { -1, 0, 2, 0, 2, 123.0, 0.0, -53.0, 0.0 },
117  { 0, 0, 0, 2, 0, 63.0, 0.0, -2.0, 0.0 },
118  { 1, 0, 0, 0, 1, 63.0, 0.1, -33.0, 0.0 },
119  { -1, 0, 0, 0, 1, -58.0, -0.1, 32.0, 0.0 },
120  { -1, 0, 2, 2, 2, -59.0, 0.0, 26.0, 0.0 },
121 
122  /* 41-50 */
123  { 1, 0, 2, 0, 1, -51.0, 0.0, 27.0, 0.0 },
124  { 0, 0, 2, 2, 2, -38.0, 0.0, 16.0, 0.0 },
125  { 2, 0, 0, 0, 0, 29.0, 0.0, -1.0, 0.0 },
126  { 1, 0, 2, -2, 2, 29.0, 0.0, -12.0, 0.0 },
127  { 2, 0, 2, 0, 2, -31.0, 0.0, 13.0, 0.0 },
128  { 0, 0, 2, 0, 0, 26.0, 0.0, -1.0, 0.0 },
129  { -1, 0, 2, 0, 1, 21.0, 0.0, -10.0, 0.0 },
130  { -1, 0, 0, 2, 1, 16.0, 0.0, -8.0, 0.0 },
131  { 1, 0, 0, -2, 1, -13.0, 0.0, 7.0, 0.0 },
132  { -1, 0, 2, 2, 1, -10.0, 0.0, 5.0, 0.0 },
133 
134  /* 51-60 */
135  { 1, 1, 0, -2, 0, -7.0, 0.0, 0.0, 0.0 },
136  { 0, 1, 2, 0, 2, 7.0, 0.0, -3.0, 0.0 },
137  { 0, -1, 2, 0, 2, -7.0, 0.0, 3.0, 0.0 },
138  { 1, 0, 2, 2, 2, -8.0, 0.0, 3.0, 0.0 },
139  { 1, 0, 0, 2, 0, 6.0, 0.0, 0.0, 0.0 },
140  { 2, 0, 2, -2, 2, 6.0, 0.0, -3.0, 0.0 },
141  { 0, 0, 0, 2, 1, -6.0, 0.0, 3.0, 0.0 },
142  { 0, 0, 2, 2, 1, -7.0, 0.0, 3.0, 0.0 },
143  { 1, 0, 2, -2, 1, 6.0, 0.0, -3.0, 0.0 },
144  { 0, 0, 0, -2, 1, -5.0, 0.0, 3.0, 0.0 },
145 
146  /* 61-70 */
147  { 1, -1, 0, 0, 0, 5.0, 0.0, 0.0, 0.0 },
148  { 2, 0, 2, 0, 1, -5.0, 0.0, 3.0, 0.0 },
149  { 0, 1, 0, -2, 0, -4.0, 0.0, 0.0, 0.0 },
150  { 1, 0, -2, 0, 0, 4.0, 0.0, 0.0, 0.0 },
151  { 0, 0, 0, 1, 0, -4.0, 0.0, 0.0, 0.0 },
152  { 1, 1, 0, 0, 0, -3.0, 0.0, 0.0, 0.0 },
153  { 1, 0, 2, 0, 0, 3.0, 0.0, 0.0, 0.0 },
154  { 1, -1, 2, 0, 2, -3.0, 0.0, 1.0, 0.0 },
155  { -1, -1, 2, 2, 2, -3.0, 0.0, 1.0, 0.0 },
156  { -2, 0, 0, 0, 1, -2.0, 0.0, 1.0, 0.0 },
157 
158  /* 71-80 */
159  { 3, 0, 2, 0, 2, -3.0, 0.0, 1.0, 0.0 },
160  { 0, -1, 2, 2, 2, -3.0, 0.0, 1.0, 0.0 },
161  { 1, 1, 2, 0, 2, 2.0, 0.0, -1.0, 0.0 },
162  { -1, 0, 2, -2, 1, -2.0, 0.0, 1.0, 0.0 },
163  { 2, 0, 0, 0, 1, 2.0, 0.0, -1.0, 0.0 },
164  { 1, 0, 0, 0, 2, -2.0, 0.0, 1.0, 0.0 },
165  { 3, 0, 0, 0, 0, 2.0, 0.0, 0.0, 0.0 },
166  { 0, 0, 2, 1, 2, 2.0, 0.0, -1.0, 0.0 },
167  { -1, 0, 0, 0, 2, 1.0, 0.0, -1.0, 0.0 },
168  { 1, 0, 0, -4, 0, -1.0, 0.0, 0.0, 0.0 },
169 
170  /* 81-90 */
171  { -2, 0, 2, 2, 2, 1.0, 0.0, -1.0, 0.0 },
172  { -1, 0, 2, 4, 2, -2.0, 0.0, 1.0, 0.0 },
173  { 2, 0, 0, -4, 0, -1.0, 0.0, 0.0, 0.0 },
174  { 1, 1, 2, -2, 2, 1.0, 0.0, -1.0, 0.0 },
175  { 1, 0, 2, 2, 1, -1.0, 0.0, 1.0, 0.0 },
176  { -2, 0, 2, 4, 2, -1.0, 0.0, 1.0, 0.0 },
177  { -1, 0, 4, 0, 2, 1.0, 0.0, 0.0, 0.0 },
178  { 1, -1, 0, -2, 0, 1.0, 0.0, 0.0, 0.0 },
179  { 2, 0, 2, -2, 1, 1.0, 0.0, -1.0, 0.0 },
180  { 2, 0, 2, 2, 2, -1.0, 0.0, 0.0, 0.0 },
181 
182  /* 91-100 */
183  { 1, 0, 0, 2, 1, -1.0, 0.0, 0.0, 0.0 },
184  { 0, 0, 4, -2, 2, 1.0, 0.0, 0.0, 0.0 },
185  { 3, 0, 2, -2, 2, 1.0, 0.0, 0.0, 0.0 },
186  { 1, 0, 2, -2, 0, -1.0, 0.0, 0.0, 0.0 },
187  { 0, 1, 2, 0, 1, 1.0, 0.0, 0.0, 0.0 },
188  { -1, -1, 0, 2, 1, 1.0, 0.0, 0.0, 0.0 },
189  { 0, 0, -2, 0, 1, -1.0, 0.0, 0.0, 0.0 },
190  { 0, 0, 2, -1, 2, -1.0, 0.0, 0.0, 0.0 },
191  { 0, 1, 0, 2, 0, -1.0, 0.0, 0.0, 0.0 },
192  { 1, 0, -2, -2, 0, -1.0, 0.0, 0.0, 0.0 },
193 
194  /* 101-106 */
195  { 0, -1, 2, 0, 1, -1.0, 0.0, 0.0, 0.0 },
196  { 1, 1, 0, -2, 1, -1.0, 0.0, 0.0, 0.0 },
197  { 1, 0, -2, 2, 0, -1.0, 0.0, 0.0, 0.0 },
198  { 2, 0, 0, 2, 0, 1.0, 0.0, 0.0, 0.0 },
199  { 0, 0, 2, 4, 2, -1.0, 0.0, 0.0, 0.0 },
200  { 0, 1, 0, 1, 0, 1.0, 0.0, 0.0, 0.0 }
201  };
202 
203 /* Number of terms in the series */
204  const int NT = (int) (sizeof x / sizeof x[0]);
205 
206 /*--------------------------------------------------------------------*/
207 
208 /* Interval between fundamental epoch J2000.0 and given date (JC). */
209  t = ((date1 - ERFA_DJ00) + date2) / ERFA_DJC;
210 
211 /* --------------------- */
212 /* Fundamental arguments */
213 /* --------------------- */
214 
215 /* Mean longitude of Moon minus mean longitude of Moon's perigee. */
216  el = eraAnpm(
217  (485866.733 + (715922.633 + (31.310 + 0.064 * t) * t) * t)
218  * ERFA_DAS2R + fmod(1325.0 * t, 1.0) * ERFA_D2PI);
219 
220 /* Mean longitude of Sun minus mean longitude of Sun's perigee. */
221  elp = eraAnpm(
222  (1287099.804 + (1292581.224 + (-0.577 - 0.012 * t) * t) * t)
223  * ERFA_DAS2R + fmod(99.0 * t, 1.0) * ERFA_D2PI);
224 
225 /* Mean longitude of Moon minus mean longitude of Moon's node. */
226  f = eraAnpm(
227  (335778.877 + (295263.137 + (-13.257 + 0.011 * t) * t) * t)
228  * ERFA_DAS2R + fmod(1342.0 * t, 1.0) * ERFA_D2PI);
229 
230 /* Mean elongation of Moon from Sun. */
231  d = eraAnpm(
232  (1072261.307 + (1105601.328 + (-6.891 + 0.019 * t) * t) * t)
233  * ERFA_DAS2R + fmod(1236.0 * t, 1.0) * ERFA_D2PI);
234 
235 /* Longitude of the mean ascending node of the lunar orbit on the */
236 /* ecliptic, measured from the mean equinox of date. */
237  om = eraAnpm(
238  (450160.280 + (-482890.539 + (7.455 + 0.008 * t) * t) * t)
239  * ERFA_DAS2R + fmod(-5.0 * t, 1.0) * ERFA_D2PI);
240 
241 /* --------------- */
242 /* Nutation series */
243 /* --------------- */
244 
245 /* Initialize nutation components. */
246  dp = 0.0;
247  de = 0.0;
248 
249 /* Sum the nutation terms, ending with the biggest. */
250  for (j = NT-1; j >= 0; j--) {
251 
252  /* Form argument for current term. */
253  arg = (double)x[j].nl * el
254  + (double)x[j].nlp * elp
255  + (double)x[j].nf * f
256  + (double)x[j].nd * d
257  + (double)x[j].nom * om;
258 
259  /* Accumulate current nutation term. */
260  s = x[j].sp + x[j].spt * t;
261  c = x[j].ce + x[j].cet * t;
262  if (s != 0.0) dp += s * sin(arg);
263  if (c != 0.0) de += c * cos(arg);
264  }
265 
266 /* Convert results from 0.1 mas units to radians. */
267  *dpsi = dp * U2R;
268  *deps = de * U2R;
269 
270  return;
271 
272 }
273 /*----------------------------------------------------------------------
274 **
275 **
276 ** Copyright (C) 2013-2015, NumFOCUS Foundation.
277 ** All rights reserved.
278 **
279 ** This library is derived, with permission, from the International
280 ** Astronomical Union's "Standards of Fundamental Astronomy" library,
281 ** available from http://www.iausofa.org.
282 **
283 ** The ERFA version is intended to retain identical functionality to
284 ** the SOFA library, but made distinct through different function and
285 ** file names, as set out in the SOFA license conditions. The SOFA
286 ** original has a role as a reference standard for the IAU and IERS,
287 ** and consequently redistribution is permitted only in its unaltered
288 ** state. The ERFA version is not subject to this restriction and
289 ** therefore can be included in distributions which do not support the
290 ** concept of "read only" software.
291 **
292 ** Although the intent is to replicate the SOFA API (other than
293 ** replacement of prefix names) and results (with the exception of
294 ** bugs; any that are discovered will be fixed), SOFA is not
295 ** responsible for any errors found in this version of the library.
296 **
297 ** If you wish to acknowledge the SOFA heritage, please acknowledge
298 ** that you are using a library derived from SOFA, rather than SOFA
299 ** itself.
300 **
301 **
302 ** TERMS AND CONDITIONS
303 **
304 ** Redistribution and use in source and binary forms, with or without
305 ** modification, are permitted provided that the following conditions
306 ** are met:
307 **
308 ** 1 Redistributions of source code must retain the above copyright
309 ** notice, this list of conditions and the following disclaimer.
310 **
311 ** 2 Redistributions in binary form must reproduce the above copyright
312 ** notice, this list of conditions and the following disclaimer in
313 ** the documentation and/or other materials provided with the
314 ** distribution.
315 **
316 ** 3 Neither the name of the Standards Of Fundamental Astronomy Board,
317 ** the International Astronomical Union nor the names of its
318 ** contributors may be used to endorse or promote products derived
319 ** from this software without specific prior written permission.
320 **
321 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
322 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
323 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
324 ** FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
325 ** COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
326 ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
327 ** BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
328 ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
329 ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
330 ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
331 ** ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
332 ** POSSIBILITY OF SUCH DAMAGE.
333 **
334 */
#define ERFA_DJ00
Definition: erfam.h:87
#define ERFA_DAS2R
Definition: erfam.h:60
#define ERFA_D2PI
Definition: erfam.h:48
#define ERFA_DJC
Definition: erfam.h:81
double eraAnpm(double a)
Definition: anpm.c:3
TT t
Definition: test_client.c:26
void eraNut80(double date1, double date2, double *dpsi, double *deps)
Definition: nut80.c:3