Changeset 2551 in Sophya for trunk/SophyaExt/XephemAstroLib/utc_gst.c
- Timestamp:
- Jun 15, 2004, 6:54:12 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/XephemAstroLib/utc_gst.c
r1719 r2551 1 #include "P_.h"2 1 #include "astro.h" 3 2 4 static double gmst0 P_((double mjd));3 static double gmst0 (double mj); 5 4 6 /* given a modified julian date, mj d, and a universally coordinated time, utc,5 /* given a modified julian date, mj, and a universally coordinated time, utc, 7 6 * return greenwich mean siderial time, *gst. 8 * N.B. mj dmust be at the beginning of the day.7 * N.B. mj must be at the beginning of the day. 9 8 */ 10 9 void 11 utc_gst (mjd, utc, gst) 12 double mjd; 13 double utc; 14 double *gst; 10 utc_gst (double mj, double utc, double *gst) 15 11 { 16 static double lastmj d= -18981;12 static double lastmj = -18981; 17 13 static double t0; 18 14 19 if (mj d != lastmjd) {20 t0 = gmst0(mj d);21 lastmj d = mjd;15 if (mj != lastmj) { 16 t0 = gmst0(mj); 17 lastmj = mj; 22 18 } 23 19 *gst = (1.0/SIDRATE)*utc + t0; … … 25 21 } 26 22 27 /* given a modified julian date, mj d, and a greenwich mean siderial time, gst,23 /* given a modified julian date, mj, and a greenwich mean siderial time, gst, 28 24 * return universally coordinated time, *utc. 29 * N.B. mj dmust be at the beginning of the day.25 * N.B. mj must be at the beginning of the day. 30 26 */ 31 27 void 32 gst_utc (mjd, gst, utc) 33 double mjd; 34 double gst; 35 double *utc; 28 gst_utc (double mj, double gst, double *utc) 36 29 { 37 static double lastmj d= -10000;30 static double lastmj = -10000; 38 31 static double t0; 39 32 40 if (mj d != lastmjd) {41 t0 = gmst0 (mj d);42 lastmj d = mjd;33 if (mj != lastmj) { 34 t0 = gmst0 (mj); 35 lastmj = mj; 43 36 } 44 37 *utc = gst - t0; … … 50 43 */ 51 44 static double 52 gmst0 ( mjd)53 double mj d;/* date at 0h UT in julian days since MJD0 */45 gmst0 ( 46 double mj) /* date at 0h UT in julian days since MJD0 */ 54 47 { 55 48 double T, x; 56 49 57 T = ((int)(mj d- 0.5) + 0.5 - J2000)/36525.0;50 T = ((int)(mj - 0.5) + 0.5 - J2000)/36525.0; 58 51 x = 24110.54841 + 59 52 (8640184.812866 + (0.093104 - 6.2e-6 * T) * T) * T; … … 67 60 /* original routine by elwood; has a secular drift of 0.08s/cty */ 68 61 static double 69 tnaught (mj d)70 double mj d; /* julian days since 1900 jan 0.5 */62 tnaught (mj) 63 double mj; /* julian days since 1900 jan 0.5 */ 71 64 { 72 double dmj d;65 double dmj; 73 66 int m, y; 74 67 double d; 75 68 double t, t0; 76 69 77 mjd_cal (mj d, &m, &d, &y);78 cal_mjd (1, 0., y, &dmj d);79 t = dmj d/36525;80 t0 = 6.57098e-2 * (mj d - dmjd) -70 mjd_cal (mj, &m, &d, &y); 71 cal_mjd (1, 0., y, &dmj); 72 t = dmj/36525; 73 t0 = 6.57098e-2 * (mj - dmj) - 81 74 (24 - (6.6460656 + (5.1262e-2 + (t * 2.581e-5))*t) - 82 75 (2400 * (t - (((double)y - 1900)/100)))); … … 90 83 char *argv[]; 91 84 { 92 double mj d, gst;93 while (scanf("%lf", &mj d) == 1) {94 mj d-= MJD0;95 gst = tnaught(mj d);96 printf("%17.9f %10.7f %10.7f\n", mj d + MJD0, gst, gmst0(mjd));85 double mj, gst; 86 while (scanf("%lf", &mj) == 1) { 87 mj -= MJD0; 88 gst = tnaught(mj); 89 printf("%17.9f %10.7f %10.7f\n", mj + MJD0, gst, gmst0(mj)); 97 90 } 98 91 } … … 100 93 101 94 /* For RCS Only -- Do Not Edit */ 102 static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: utc_gst.c,v $ $Date: 200 1-10-22 12:08:28 $ $Revision: 1.2$ $Name: not supported by cvs2svn $"};95 static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: utc_gst.c,v $ $Date: 2004-06-15 16:52:41 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Note:
See TracChangeset
for help on using the changeset viewer.