OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
gmha.c
Go to the documentation of this file.
1 /*
2  *----------------------------------------------------------------------
3  * @(#) gmha.c 1.1 20 Mar 93 <shc>
4  * Copyright (c) 1993, CSIRO Division of Oceanography
5  *----------------------------------------------------------------------
6  *
7  * gmha --
8  *
9  * Greenwich Mean Hour angle.
10  *
11  * Results:
12  *
13  * gmha() returns the Greenwich mean hour angle at a given time,
14  * which must be in modified Julian date format (number of days since
15  * noon on the 31st Dec 4714 minus 2,400,000). It does not exhibit
16  * the slight day-to-day discontinuity of algorithms based on day and
17  * fraction. Lifted and adapted from Chris Rizos's code which was
18  * derived from a U.S. Naval Observatory circular. dgmha() returns
19  * the derivative of mean hour angle in radians/sec.
20  *
21  * Side effects:
22  * None.
23  *
24  * History:
25  * 1.0 28 Nov 90 <shc>
26  * Initial FORTRAN version.
27  *
28  * 1.1 14 May 92 <shc>
29  * Changed gha() to gmha().
30  *
31  * 1.1 20 Mar 93 <shc>
32  * Converted from FORTRAN to C.
33  *
34  * 1.2 27 Jun 95 <shc>
35  * Added dgmha().
36  *
37  *----------------------------------------------------------------------
38  */
39 
40 #include <math.h>
41 #include "orbit.h"
42 
43 
44 /*
45  * Polynomial coefficients for GMST from USNO circular #163, P.A3,
46  * converted to radians and divided by 36525.0**N (N=0..3)
47  */
48 
49 static double gmstc[] = {
50  0.4894961212823058751375704430e+01,
51  0.6300388098984893552276513720e+01,
52  0.5075209994113591478053805523e-14,
53  -0.9253097568194335640067190688e-23
54 };
55 
56 /*
57  * Greenwich mean hour angle (radians)
58  */
59 
60 double
61 gmha(tjd)
62 double tjd; /* Time in Julian days mod 2400000 */
63 {
64  double t, sid, gmha;
65 
66  t = tjd - J2000;
67  sid = gmstc[0] + t * (gmstc[1] + t * (gmstc[2] + t * gmstc[3]));
68  gmha = fmod(fmod(sid, D2PI) + D2PI, D2PI);
69 
70  return (gmha);
71 }
72 
73 /*
74  * Greenwich mean hour angle derivative (radians/day)
75  */
76 
77 double
78 gmhadot(tjd)
79 double tjd; /* Time in Julian days mod 2400000 */
80 {
81  double t, dsid;
82 
83  t = tjd - J2000;
84  dsid = gmstc[1] + t * (2.0 * gmstc[2] + t * 3.0 * gmstc[3]);
85 
86  return (dsid);
87 }
data_t t[NROOTS+1]
Definition: decode_rs.h:77
double gmhadot(double tjd)
Definition: gmha.c:78
double gmha(double tjd)
Definition: gmha.c:61
#define D2PI
Definition: orbit.h:45
#define J2000
Definition: orbit.h:72