ocssw  1.0
/disk01/web/ocssw/build/src/libosmi/gmha.c (r8102/r3)
Go to the documentation of this file.
00001 /*
00002  *----------------------------------------------------------------------
00003  * @(#) gmha.c      1.1 20 Mar 93   <shc>
00004  * Copyright (c) 1993, CSIRO Division of Oceanography
00005  *----------------------------------------------------------------------
00006  *
00007  * gmha --
00008  *
00009  *  Greenwich Mean Hour angle.
00010  *
00011  * Results:
00012  *
00013  *  gmha() returns the Greenwich mean hour angle at a given time,
00014  *  which must be in modified Julian date format (number of days since
00015  *  noon on the 31st Dec 4714 minus 2,400,000).  It does not exhibit
00016  *  the slight day-to-day discontinuity of algorithms based on day and
00017  *  fraction.  Lifted and adapted from Chris Rizos's code which was
00018  *  derived from a U.S. Naval Observatory circular.  dgmha() returns
00019  *  the derivative of mean hour angle in radians/sec.
00020  *
00021  * Side effects:
00022  *  None.
00023  *
00024  * History:
00025  *  1.0 28 Nov 90   <shc>
00026  *     Initial FORTRAN version.
00027  *
00028  *  1.1 14 May 92   <shc>
00029  *     Changed gha() to gmha().
00030  *
00031  *  1.1 20 Mar 93   <shc>
00032  *     Converted from FORTRAN to C.
00033  *
00034  *  1.2 27 Jun 95   <shc>
00035  *     Added dgmha().
00036  *
00037  *----------------------------------------------------------------------
00038  */
00039 
00040 #include <math.h>
00041 #include "orbit.h"
00042 
00043 
00044 /*
00045  * Polynomial coefficients for GMST from USNO circular #163, P.A3,
00046  * converted to radians and divided by 36525.0**N (N=0..3)
00047  */
00048 
00049 static double gmstc[] = {
00050     0.4894961212823058751375704430e+01,
00051     0.6300388098984893552276513720e+01,
00052     0.5075209994113591478053805523e-14,
00053     -0.9253097568194335640067190688e-23
00054 };
00055 
00056 
00057 /*
00058  * Greenwich mean hour angle (radians)
00059  */
00060 
00061 double
00062 gmha(tjd)
00063 double tjd; /* Time in Julian days mod 2400000 */
00064 {
00065     double t, sid, gmha;
00066 
00067     t = tjd - J2000;
00068     sid = gmstc[0] + t*(gmstc[1] + t*(gmstc[2] + t*gmstc[3]));
00069     gmha = fmod(fmod(sid, D2PI) + D2PI, D2PI);
00070 
00071     return(gmha);
00072 }
00073 
00074 
00075 /*
00076  * Greenwich mean hour angle derivative (radians/day)
00077  */
00078 
00079 double
00080 gmhadot(tjd)
00081 double tjd; /* Time in Julian days mod 2400000 */
00082 {
00083     double t, dsid;
00084 
00085     t = tjd - J2000;
00086     dsid = gmstc[1] + t*(2.0*gmstc[2] + t*3.0*gmstc[3]);
00087 
00088     return(dsid);
00089 }