home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume28 / ephem / part09 < prev    next >
Text File  |  1992-03-15  |  28KB  |  1,026 lines

  1. Newsgroups: comp.sources.misc
  2. From: e_downey@hwking.cca.cr.rockwell.com (Elwood C. Downey)
  3. Subject:  v28i092:  ephem - an interactive astronomical ephemeris, v4.28, Part09/09
  4. Message-ID: <1992Mar10.220013.16464@sparky.imd.sterling.com>
  5. X-Md4-Signature: 94d4c1c83e3a49ba4ac9b39e91110545
  6. Date: Tue, 10 Mar 1992 22:00:13 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: e_downey@hwking.cca.cr.rockwell.com (Elwood C. Downey)
  10. Posting-number: Volume 28, Issue 92
  11. Archive-name: ephem/part09
  12. Environment: UNIX, VMS, DOS, MAC
  13. Supersedes: ephem-4.21: Volume 14, Issue 76-81
  14.  
  15. #! /bin/sh
  16. # into a shell via "sh file" or similar.  To overwrite existing files,
  17. # type "sh file -c".
  18. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  19. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  20. # Contents:  Makefile aa_hadec.c anomaly.c astro.h eq_ecl.c man.a.hdr
  21. #   man.b.hdr moonnf.c obliq.c parallax.c popup.c reduce.c sex_dec.c
  22. #   sun.c utc_gst.c
  23. # Wrapped by kent@sparky on Tue Mar 10 14:34:10 1992
  24. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  25. echo If this archive is complete, you will see the following message:
  26. echo '          "shar: End of archive 9 (of 9)."'
  27. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  28.   echo shar: Will not clobber existing file \"'Makefile'\"
  29. else
  30.   echo shar: Extracting \"'Makefile'\" \(1380 characters\)
  31.   sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  32. X# Makefile for ephem, v 4.28
  33. X
  34. XCFLAGS = -O
  35. X
  36. XEPHEM=    aa_hadec.o altj.o altmenus.o anomaly.o cal_mjd.o circum.o comet.o \
  37. X    compiler.o constel.o eq_ecl.o flog.o formats.o io.o listing.o main.o \
  38. X    mainmenu.o moon.o moonnf.o nutation.o objx.o obliq.o parallax.o \
  39. X    pelement.o plans.o plot.o popup.o precess.o reduce.o refract.o \
  40. X    riset.o riset_c.o sel_fld.o sex_dec.o srch.o sun.o time.o utc_gst.o \
  41. X    version.o watch.o
  42. X
  43. Xephem:    $(EPHEM)
  44. X    cc -o $@ $(EPHEM) -ltermcap -lm
  45. X
  46. Xaa_hadec.o:    astro.h
  47. X
  48. Xaltj.o:        astro.h circum.h screen.h
  49. X
  50. Xaltmenus.o:    astro.h circum.h screen.h
  51. X
  52. Xanomaly.o:    astro.h
  53. X
  54. Xcal_mjd.o:    astro.h
  55. X
  56. Xcircum.o:    astro.h circum.h screen.h
  57. X
  58. Xcomet.o:    astro.h
  59. X
  60. Xcompiler.o:    screen.h
  61. X
  62. Xconstel.o:    astro.h circum.h screen.h
  63. X
  64. Xeq_ecl.o:    astro.h
  65. X
  66. Xflog.o:        screen.h
  67. X
  68. Xformats.o:    astro.h screen.h
  69. X
  70. Xio.o:        screen.h
  71. X
  72. Xlisting.o:    screen.h
  73. X
  74. Xmain.o:        astro.h circum.h screen.h
  75. X
  76. Xmainmenu.o:    astro.h circum.h screen.h
  77. X
  78. Xmoon.o:        astro.h
  79. X
  80. Xmoonnf.o:    astro.h
  81. X
  82. Xnutation.o:    astro.h
  83. X
  84. Xobjx.o:        astro.h circum.h screen.h
  85. X
  86. Xobliq.o:    astro.h
  87. X
  88. Xparallax.o:    astro.h
  89. X
  90. Xpelement.o:    astro.h
  91. X
  92. Xplans.o:    astro.h
  93. X
  94. Xplot.o:        screen.h
  95. X
  96. Xpopup.o:    screen.h
  97. X
  98. Xprecess.o:    astro.h
  99. X
  100. Xreduce.o:    astro.h
  101. X
  102. Xrefract.o:    astro.h
  103. X
  104. Xriset.o:    astro.h
  105. X
  106. Xriset_c.o:    astro.h circum.h screen.h
  107. X
  108. Xsel_fld.o:    screen.h
  109. X
  110. Xsrch.o:        screen.h
  111. X
  112. Xsun.o:        astro.h
  113. X
  114. Xtime.o:        astro.h circum.h
  115. X
  116. Xutc_gst.o:    astro.h
  117. X
  118. Xversion.o:    screen.h
  119. X
  120. Xwatch.o:    astro.h circum.h screen.h
  121. END_OF_FILE
  122.   if test 1380 -ne `wc -c <'Makefile'`; then
  123.     echo shar: \"'Makefile'\" unpacked with wrong size!
  124.   fi
  125.   # end of 'Makefile'
  126. fi
  127. if test -f 'aa_hadec.c' -a "${1}" != "-c" ; then 
  128.   echo shar: Will not clobber existing file \"'aa_hadec.c'\"
  129. else
  130.   echo shar: Extracting \"'aa_hadec.c'\" \(1922 characters\)
  131.   sed "s/^X//" >'aa_hadec.c' <<'END_OF_FILE'
  132. X#include <stdio.h>
  133. X#include <math.h>
  134. X#include "astro.h"
  135. X
  136. X/* given latitude (n+, radians), lat, altitude (up+, radians), alt, and
  137. X * azimuth (angle round to the east from north+, radians),
  138. X * return hour angle (radians), ha, and declination (radians), dec.
  139. X */
  140. Xaa_hadec (lat, alt, az, ha, dec)
  141. Xdouble lat;
  142. Xdouble alt, az;
  143. Xdouble *ha, *dec;
  144. X{
  145. X    aaha_aux (lat, az, alt, ha, dec);
  146. X}
  147. X
  148. X/* given latitude (n+, radians), lat, hour angle (radians), ha, and declination
  149. X * (radians), dec,
  150. X * return altitude (up+, radians), alt, and
  151. X * azimuth (angle round to the east from north+, radians),
  152. X */
  153. Xhadec_aa (lat, ha, dec, alt, az)
  154. Xdouble lat;
  155. Xdouble ha, dec;
  156. Xdouble *alt, *az;
  157. X{
  158. X    aaha_aux (lat, ha, dec, az, alt);
  159. X}
  160. X
  161. X/* the actual formula is the same for both transformation directions so
  162. X * do it here once for each way.
  163. X * N.B. all arguments are in radians.
  164. X */
  165. Xstatic
  166. Xaaha_aux (lat, x, y, p, q)
  167. Xdouble lat;
  168. Xdouble x, y;
  169. Xdouble *p, *q;
  170. X{
  171. X    static double lastlat = -1000.;
  172. X    static double sinlastlat, coslastlat;
  173. X    double sy, cy;
  174. X    double sx, cx;
  175. X    double sq, cq;
  176. X    double a;
  177. X    double cp;
  178. X
  179. X    /* latitude doesn't change much, so try to reuse the sin and cos evals.
  180. X     */
  181. X    if (lat != lastlat) {
  182. X        sinlastlat = sin (lat);
  183. X        coslastlat = cos (lat);
  184. X        lastlat = lat;
  185. X    }
  186. X
  187. X    sy = sin (y);
  188. X    cy = cos (y);
  189. X    sx = sin (x);
  190. X    cx = cos (x);
  191. X
  192. X/* define GOODATAN2 if atan2 returns full range -PI through +PI.
  193. X */
  194. X#ifdef GOODATAN2
  195. X    *q = asin ((sy*sinlastlat) + (cy*coslastlat*cx));
  196. X    *p = atan2 (-cy*sx, -cy*cx*sinlastlat + sy*coslastlat);
  197. X#else
  198. X#define    EPS    (1e-20)
  199. X    sq = (sy*sinlastlat) + (cy*coslastlat*cx);
  200. X    *q = asin (sq);
  201. X    cq = cos (*q);
  202. X    a = coslastlat*cq;
  203. X    if (a > -EPS && a < EPS)
  204. X        a = a < 0 ? -EPS : EPS; /* avoid / 0 */
  205. X    cp = (sy - (sinlastlat*sq))/a;
  206. X    if (cp >= 1.0)    /* the /a can be slightly > 1 */
  207. X        *p = 0.0;
  208. X    else if (cp <= -1.0)
  209. X        *p = PI;
  210. X    else
  211. X        *p = acos ((sy - (sinlastlat*sq))/a);
  212. X    if (sx>0) *p = 2.0*PI - *p;
  213. X#endif
  214. X}
  215. END_OF_FILE
  216.   if test 1922 -ne `wc -c <'aa_hadec.c'`; then
  217.     echo shar: \"'aa_hadec.c'\" unpacked with wrong size!
  218.   fi
  219.   # end of 'aa_hadec.c'
  220. fi
  221. if test -f 'anomaly.c' -a "${1}" != "-c" ; then 
  222.   echo shar: Will not clobber existing file \"'anomaly.c'\"
  223. else
  224.   echo shar: Extracting \"'anomaly.c'\" \(901 characters\)
  225.   sed "s/^X//" >'anomaly.c' <<'END_OF_FILE'
  226. X#include <stdio.h>
  227. X#include <math.h>
  228. X#include "astro.h"
  229. X
  230. X#define    TWOPI    (2*PI)
  231. X
  232. X/* given the mean anomaly, ma, and the eccentricity, s, of elliptical motion,
  233. X * find the true anomaly, *nu, and the eccentric anomaly, *ea.
  234. X * all angles in radians.
  235. X */
  236. Xanomaly (ma, s, nu, ea)
  237. Xdouble ma, s;
  238. Xdouble *nu, *ea;
  239. X{
  240. X    double m, fea;
  241. X
  242. X    m = ma-TWOPI*(long)(ma/TWOPI);
  243. X    if (m > PI) m -= TWOPI;
  244. X    if (m < -PI) m += TWOPI;
  245. X    fea = m;
  246. X
  247. X    if (s < 1.0) {
  248. X        /* elliptical */
  249. X        double dla;
  250. X        while (1) {
  251. X        dla = fea-(s*sin(fea))-m;
  252. X        if (fabs(dla)<1e-6)
  253. X            break;
  254. X        dla /= 1-(s*cos(fea));
  255. X        fea -= dla;
  256. X        }
  257. X        *nu = 2*atan(sqrt((1+s)/(1-s))*tan(fea/2));
  258. X        } else {
  259. X        /* hyperbolic */
  260. X        double corr = 1;
  261. X        while (fabs(corr) > 0.000001) {
  262. X          corr = (m - s * sinh(fea) + fea) / (s*cosh(fea) - 1);
  263. X          fea += corr;
  264. X        }
  265. X        *nu = 2*atan(sqrt((s+1)/(s-1))*tanh(fea/2));
  266. X    }
  267. X    *ea = fea;
  268. X}
  269. END_OF_FILE
  270.   if test 901 -ne `wc -c <'anomaly.c'`; then
  271.     echo shar: \"'anomaly.c'\" unpacked with wrong size!
  272.   fi
  273.   # end of 'anomaly.c'
  274. fi
  275. if test -f 'astro.h' -a "${1}" != "-c" ; then 
  276.   echo shar: Will not clobber existing file \"'astro.h'\"
  277. else
  278.   echo shar: Extracting \"'astro.h'\" \(620 characters\)
  279.   sed "s/^X//" >'astro.h' <<'END_OF_FILE'
  280. X#ifndef PI
  281. X#define    PI        3.141592653589793
  282. X#endif
  283. X
  284. X/* conversions among hours (of ra), degrees and radians. */
  285. X#define    degrad(x)    ((x)*PI/180.)
  286. X#define    raddeg(x)    ((x)*180./PI)
  287. X#define    hrdeg(x)    ((x)*15.)
  288. X#define    deghr(x)    ((x)/15.)
  289. X#define    hrrad(x)    degrad(hrdeg(x))
  290. X#define    radhr(x)    deghr(raddeg(x))
  291. X
  292. X/* ratio of from synodic (solar) to sidereal (stellar) rate */
  293. X#define    SIDRATE        .9972695677
  294. X
  295. X/* manifest names for planets.
  296. X * N.B. must cooincide with usage in pelement.c and plans.c.
  297. X */
  298. X#define    MERCURY    0
  299. X#define    VENUS    1
  300. X#define    MARS    2
  301. X#define    JUPITER    3
  302. X#define    SATURN    4
  303. X#define    URANUS    5
  304. X#define    NEPTUNE    6
  305. X#define    PLUTO    7
  306. END_OF_FILE
  307.   if test 620 -ne `wc -c <'astro.h'`; then
  308.     echo shar: \"'astro.h'\" unpacked with wrong size!
  309.   fi
  310.   # end of 'astro.h'
  311. fi
  312. if test -f 'eq_ecl.c' -a "${1}" != "-c" ; then 
  313.   echo shar: Will not clobber existing file \"'eq_ecl.c'\"
  314. else
  315.   echo shar: Extracting \"'eq_ecl.c'\" \(1899 characters\)
  316.   sed "s/^X//" >'eq_ecl.c' <<'END_OF_FILE'
  317. X#include <stdio.h>
  318. X#include <math.h>
  319. X#include "astro.h"
  320. X
  321. X#define    EQtoECL    1
  322. X#define    ECLtoEQ    (-1)
  323. X
  324. X/* given the modified Julian date, mjd, and an equitorial ra and dec, each in
  325. X * radians, find the corresponding geocentric ecliptic latitude, *lat, and
  326. X * longititude, *lng, also each in radians.
  327. X * correction for the effect on the angle of the obliquity due to nutation is
  328. X * included.
  329. X */
  330. Xeq_ecl (mjd, ra, dec, lat, lng)
  331. Xdouble mjd, ra, dec;
  332. Xdouble *lat, *lng;
  333. X{
  334. X    ecleq_aux (EQtoECL, mjd, ra, dec, lng, lat);
  335. X}
  336. X
  337. X/* given the modified Julian date, mjd, and a geocentric ecliptic latitude,
  338. X * *lat, and longititude, *lng, each in radians, find the corresponding
  339. X * equitorial ra and dec, also each in radians.
  340. X * correction for the effect on the angle of the obliquity due to nutation is
  341. X * included.
  342. X */
  343. Xecl_eq (mjd, lat, lng, ra, dec)
  344. Xdouble mjd, lat, lng;
  345. Xdouble *ra, *dec;
  346. X{
  347. X    ecleq_aux (ECLtoEQ, mjd, lng, lat, ra, dec);
  348. X}
  349. X
  350. Xstatic
  351. Xecleq_aux (sw, mjd, x, y, p, q)
  352. Xint sw;            /* +1 for eq to ecliptic, -1 for vv. */
  353. Xdouble mjd, x, y;    /* sw==1: x==ra, y==dec.  sw==-1: x==lng, y==lat. */
  354. Xdouble *p, *q;        /* sw==1: p==lng, q==lat. sw==-1: p==ra, q==dec. */
  355. X{
  356. X    static double lastmjd = -10000;    /* last mjd calculated */
  357. X    static double seps, ceps;    /* sin and cos of mean obliquity */
  358. X    double sx, cx, sy, cy, ty;
  359. X
  360. X    if (mjd != lastmjd) {
  361. X        double eps;
  362. X        double deps, dpsi;
  363. X        obliquity (mjd, &eps);        /* mean obliquity for date */
  364. X        nutation (mjd, &deps, &dpsi);
  365. X        eps += deps;
  366. X            seps = sin(eps);
  367. X        ceps = cos(eps);
  368. X        lastmjd = mjd;
  369. X    }
  370. X
  371. X    sy = sin(y);
  372. X    cy = cos(y);                /* always non-negative */
  373. X        if (fabs(cy)<1e-20) cy = 1e-20;        /* insure > 0 */
  374. X        ty = sy/cy;
  375. X    cx = cos(x);
  376. X    sx = sin(x);
  377. X        *q = asin((sy*ceps)-(cy*seps*sx*sw));
  378. X        *p = atan(((sx*ceps)+(ty*seps*sw))/cx);
  379. X        if (cx<0) *p += PI;        /* account for atan quad ambiguity */
  380. X    range (p, 2*PI);
  381. X}
  382. END_OF_FILE
  383.   if test 1899 -ne `wc -c <'eq_ecl.c'`; then
  384.     echo shar: \"'eq_ecl.c'\" unpacked with wrong size!
  385.   fi
  386.   # end of 'eq_ecl.c'
  387. fi
  388. if test -f 'man.a.hdr' -a "${1}" != "-c" ; then 
  389.   echo shar: Will not clobber existing file \"'man.a.hdr'\"
  390. else
  391.   echo shar: Extracting \"'man.a.hdr'\" \(578 characters\)
  392.   sed "s/^X//" >'man.a.hdr' <<'END_OF_FILE'
  393. XFrom e_downey@hwking.cca.cr.rockwell.com Tue Mar 10 11:56:34 1992
  394. XReceived: from tasha.cca.cr.rockwell.com by sparky.IMD.Sterling.COM (5.65c/IDA-1.4.4)
  395. X    id AA15066; Tue, 10 Mar 1992 11:55:59 -0600
  396. XReturn-Path: <e_downey@hwking.cca.cr.rockwell.com>
  397. XReceived: by tasha.cca.cr.rockwell.com (5.57/Ultrix3.0-C)
  398. X    id AA27717; Tue, 10 Mar 92 11:54:19 -0600
  399. XDate: Tue, 10 Mar 92 11:54:19 -0600
  400. XFrom: e_downey@hwking.cca.cr.rockwell.com (Elwood C. Downey)
  401. XMessage-Id: <9203101754.AA27717@tasha.cca.cr.rockwell.com>
  402. XTo: sources-misc@imd.sterling.com
  403. XSubject: ephem, Man.a.shar
  404. XStatus: OR
  405. X
  406. END_OF_FILE
  407.   if test 578 -ne `wc -c <'man.a.hdr'`; then
  408.     echo shar: \"'man.a.hdr'\" unpacked with wrong size!
  409.   fi
  410.   # end of 'man.a.hdr'
  411. fi
  412. if test -f 'man.b.hdr' -a "${1}" != "-c" ; then 
  413.   echo shar: Will not clobber existing file \"'man.b.hdr'\"
  414. else
  415.   echo shar: Extracting \"'man.b.hdr'\" \(578 characters\)
  416.   sed "s/^X//" >'man.b.hdr' <<'END_OF_FILE'
  417. XFrom e_downey@hwking.cca.cr.rockwell.com Tue Mar 10 11:56:31 1992
  418. XReceived: from tasha.cca.cr.rockwell.com by sparky.IMD.Sterling.COM (5.65c/IDA-1.4.4)
  419. X    id AA15074; Tue, 10 Mar 1992 11:56:03 -0600
  420. XReturn-Path: <e_downey@hwking.cca.cr.rockwell.com>
  421. XReceived: by tasha.cca.cr.rockwell.com (5.57/Ultrix3.0-C)
  422. X    id AA27723; Tue, 10 Mar 92 11:54:26 -0600
  423. XDate: Tue, 10 Mar 92 11:54:26 -0600
  424. XFrom: e_downey@hwking.cca.cr.rockwell.com (Elwood C. Downey)
  425. XMessage-Id: <9203101754.AA27723@tasha.cca.cr.rockwell.com>
  426. XTo: sources-misc@imd.sterling.com
  427. XSubject: ephem, Man.b.shar
  428. XStatus: OR
  429. X
  430. END_OF_FILE
  431.   if test 578 -ne `wc -c <'man.b.hdr'`; then
  432.     echo shar: \"'man.b.hdr'\" unpacked with wrong size!
  433.   fi
  434.   # end of 'man.b.hdr'
  435. fi
  436. if test -f 'moonnf.c' -a "${1}" != "-c" ; then 
  437.   echo shar: Will not clobber existing file \"'moonnf.c'\"
  438. else
  439.   echo shar: Extracting \"'moonnf.c'\" \(1557 characters\)
  440.   sed "s/^X//" >'moonnf.c' <<'END_OF_FILE'
  441. X#include <stdio.h>
  442. X#include <math.h>
  443. X#include "astro.h"
  444. X
  445. X#define    unw(w,z)    ((w)-floor((w)/(z))*(z))
  446. X
  447. X/* given a modified Julian date, mjd, return the mjd of the new
  448. X * and full moons about then, mjdn and mjdf.
  449. X * TODO: exactly which ones does it find? eg:
  450. X *   5/28/1988 yields 5/15 and 5/31
  451. X *   5/29             6/14     6/29
  452. X */
  453. Xmoonnf (mjd, mjdn, mjdf)
  454. Xdouble mjd;
  455. Xdouble *mjdn, *mjdf;
  456. X{
  457. X    int mo, yr;
  458. X    double dy;
  459. X    double mjd0;
  460. X    double k, tn, tf, t;
  461. X
  462. X    mjd_cal (mjd, &mo, &dy, &yr);
  463. X    cal_mjd (1, 0., yr, &mjd0);
  464. X    k = (yr-1900+((mjd-mjd0)/365))*12.3685;
  465. X    k = floor(k+0.5);
  466. X    tn = k/1236.85;
  467. X    tf = (k+0.5)/1236.85;
  468. X    t = tn;
  469. X    m (t, k, mjdn);
  470. X    t = tf;
  471. X    k += 0.5;
  472. X    m (t, k, mjdf);
  473. X}
  474. X
  475. Xstatic
  476. Xm (t, k, mjd)
  477. Xdouble t, k;
  478. Xdouble *mjd;
  479. X{
  480. X    double t2, a, a1, b, b1, c, ms, mm, f, ddjd;
  481. X
  482. X    t2 = t*t;
  483. X    a = 29.53*k;
  484. X    c = degrad(166.56+(132.87-9.173e-3*t)*t);
  485. X    b = 5.8868e-4*k+(1.178e-4-1.55e-7*t)*t2+3.3e-4*sin(c)+7.5933E-1;
  486. X    ms = 359.2242+360*unw(k/1.236886e1,1)-(3.33e-5+3.47e-6*t)*t2;
  487. X    mm = 306.0253+360*unw(k/9.330851e-1,1)+(1.07306e-2+1.236e-5*t)*t2;
  488. X    f = 21.2964+360*unw(k/9.214926e-1,1)-(1.6528e-3+2.39e-6*t)*t2;
  489. X    ms = unw(ms,360);
  490. X    mm = unw(mm,360);
  491. X    f = unw(f,360);
  492. X    ms = degrad(ms);
  493. X    mm = degrad(mm);
  494. X    f = degrad(f);
  495. X    ddjd = (1.734e-1-3.93e-4*t)*sin(ms)+2.1e-3*sin(2*ms)
  496. X        -4.068e-1*sin(mm)+1.61e-2*sin(2*mm)-4e-4*sin(3*mm)
  497. X        +1.04e-2*sin(2*f)-5.1e-3*sin(ms+mm)-7.4e-3*sin(ms-mm)
  498. X        +4e-4*sin(2*f+ms)-4e-4*sin(2*f-ms)-6e-4*sin(2*f+mm)
  499. X        +1e-3*sin(2*f-mm)+5e-4*sin(ms+2*mm);
  500. X    a1 = (long)a;
  501. X    b = b+ddjd+(a-a1);
  502. X    b1 = (long)b;
  503. X    a = a1+b1;
  504. X    b = b-b1;
  505. X    *mjd = a + b;
  506. X}
  507. END_OF_FILE
  508.   if test 1557 -ne `wc -c <'moonnf.c'`; then
  509.     echo shar: \"'moonnf.c'\" unpacked with wrong size!
  510.   fi
  511.   # end of 'moonnf.c'
  512. fi
  513. if test -f 'obliq.c' -a "${1}" != "-c" ; then 
  514.   echo shar: Will not clobber existing file \"'obliq.c'\"
  515. else
  516.   echo shar: Extracting \"'obliq.c'\" \(421 characters\)
  517.   sed "s/^X//" >'obliq.c' <<'END_OF_FILE'
  518. X#include <stdio.h>
  519. X#include "astro.h"
  520. X
  521. X/* given the modified Julian date, mjd, find the obliquity of the
  522. X * ecliptic, *eps, in radians.
  523. X */
  524. Xobliquity (mjd, eps)
  525. Xdouble mjd;
  526. Xdouble *eps;
  527. X{
  528. X    static double lastmjd = -10000, lasteps;
  529. X
  530. X    if (mjd != lastmjd) {
  531. X        double t;
  532. X        t = mjd/36525.;
  533. X        lasteps = degrad(2.345229444E1
  534. X            - ((((-1.81E-3*t)+5.9E-3)*t+4.6845E1)*t)/3600.0);
  535. X        lastmjd = mjd;
  536. X    }
  537. X    *eps = lasteps;
  538. X}
  539. END_OF_FILE
  540.   if test 421 -ne `wc -c <'obliq.c'`; then
  541.     echo shar: \"'obliq.c'\" unpacked with wrong size!
  542.   fi
  543.   # end of 'obliq.c'
  544. fi
  545. if test -f 'parallax.c' -a "${1}" != "-c" ; then 
  546.   echo shar: Will not clobber existing file \"'parallax.c'\"
  547. else
  548.   echo shar: Extracting \"'parallax.c'\" \(2301 characters\)
  549.   sed "s/^X//" >'parallax.c' <<'END_OF_FILE'
  550. X#include <stdio.h>
  551. X#include <math.h>
  552. X#include "astro.h"
  553. X
  554. X/* given true ha and dec, tha and tdec, the geographical latitude, phi, the
  555. X * height above sea-level (as a fraction of the earths radius, 6378.16km),
  556. X * ht, and the equatorial horizontal parallax, ehp, find the apparent
  557. X * ha and dec, aha and adec allowing for parallax.
  558. X * all angles in radians. ehp is the angle subtended at the body by the
  559. X * earth's equator.
  560. X */
  561. Xta_par (tha, tdec, phi, ht, ehp, aha, adec)
  562. Xdouble tha, tdec, phi, ht, ehp;
  563. Xdouble *aha, *adec;
  564. X{
  565. X    static double last_phi, last_ht, rsp, rcp;
  566. X    double rp;    /* distance to object in Earth radii */
  567. X    double ctha;
  568. X    double stdec, ctdec;
  569. X    double tdtha, dtha;
  570. X    double caha;
  571. X
  572. X    /* avoid calcs involving the same phi and ht */
  573. X    if (phi != last_phi || ht != last_ht) {
  574. X        double cphi, sphi, u;
  575. X        cphi = cos(phi);
  576. X        sphi = sin(phi);
  577. X        u = atan(9.96647e-1*sphi/cphi);
  578. X        rsp = (9.96647e-1*sin(u))+(ht*sphi);
  579. X        rcp = cos(u)+(ht*cphi);
  580. X        last_phi  =  phi;
  581. X        last_ht  =  ht;
  582. X    }
  583. X
  584. X        rp = 1/sin(ehp);
  585. X
  586. X        ctha = cos(tha);
  587. X    stdec = sin(tdec);
  588. X    ctdec = cos(tdec);
  589. X        tdtha = (rcp*sin(tha))/((rp*ctdec)-(rcp*ctha));
  590. X        dtha = atan(tdtha);
  591. X    *aha = tha+dtha;
  592. X    caha = cos(*aha);
  593. X    range (aha, 2*PI);
  594. X        *adec = atan(caha*(rp*stdec-rsp)/(rp*ctdec*ctha-rcp));
  595. X}
  596. X
  597. X#ifdef NEEDIT
  598. X/* given the apparent ha and dec, aha and adec, the geographical latitude, phi,
  599. X * the height above sea-level (as a fraction of the earths radius, 6378.16km),
  600. X * ht, and the equatorial horizontal parallax, ehp, find the true ha and dec,
  601. X * tha and tdec allowing for parallax.
  602. X * all angles in radians. ehp is the angle subtended at the body by the
  603. X * earth's equator.
  604. X * uses ta_par() iteratively: find a set of true ha/dec that converts back
  605. X  *  to the given apparent ha/dec.
  606. X */
  607. Xat_par (aha, adec, phi, ht, ehp, tha, tdec)
  608. Xdouble aha, adec, phi, ht, ehp;
  609. Xdouble *tha, *tdec;
  610. X{
  611. X    double nha, ndec;    /* ha/dec corres. to current true guesses */
  612. X    double eha, edec;    /* error in ha/dec */
  613. X
  614. X    /* first guess for true is just the apparent */
  615. X    *tha = aha;
  616. X    *tdec = adec;
  617. X
  618. X    while (1) {
  619. X        ta_par (*tha, *tdec, phi, ht, ehp, &nha, &ndec);
  620. X        eha = aha - nha;
  621. X        edec = adec - ndec;
  622. X        if (fabs(eha)<1e-6 && fabs(edec)<1e-6)
  623. X        break;
  624. X        *tha += eha;
  625. X        *tdec += edec;
  626. X    }
  627. X}
  628. X#endif
  629. END_OF_FILE
  630.   if test 2301 -ne `wc -c <'parallax.c'`; then
  631.     echo shar: \"'parallax.c'\" unpacked with wrong size!
  632.   fi
  633.   # end of 'parallax.c'
  634. fi
  635. if test -f 'popup.c' -a "${1}" != "-c" ; then 
  636.   echo shar: Will not clobber existing file \"'popup.c'\"
  637. else
  638.   echo shar: Extracting \"'popup.c'\" \(1734 characters\)
  639.   sed "s/^X//" >'popup.c' <<'END_OF_FILE'
  640. X/* put up a one-line menu consisting of the given fields and let op move
  641. X * between them with the same methods as sel_fld().
  642. X * return index of which he picked, or -1 if hit END.
  643. X */
  644. X
  645. X#include <stdio.h>
  646. X#include "screen.h"
  647. X
  648. Xextern void bye();
  649. X
  650. X#define    FLDGAP    2    /* inter-field gap */
  651. X#define    MAXFLDS    32    /* max number of fields we can handle */
  652. X
  653. Xstatic char pup[] = "Select: ";
  654. X
  655. X/* put up an array of strings on prompt line and let op pick one.
  656. X * start with field fn.
  657. X * N.B. we do not do much error/bounds checking.
  658. X */
  659. Xpopup (fields, fn, nfields)
  660. Xchar *fields[];
  661. Xint fn;
  662. Xint nfields;
  663. X{
  664. X    int fcols[MAXFLDS];    /* column to use for each field */
  665. X    int i;
  666. X
  667. X    if (nfields > MAXFLDS)
  668. X        return (-1);
  669. X
  670. X    again:
  671. X    /* erase the prompt line; we are going to take it over */
  672. X    c_pos (R_PROMPT, C_PROMPT);
  673. X    c_eol();
  674. X
  675. X    /* compute starting column for each field */
  676. X    fcols[0] = sizeof(pup);
  677. X    for (i = 1; i < nfields; i++)
  678. X        fcols[i] = fcols[i-1] + strlen (fields[i-1]) + FLDGAP;
  679. X
  680. X    /* draw each field, with comma after all but last */
  681. X    c_pos (R_PROMPT, 1);
  682. X    (void) fputs (pup, stdout);
  683. X    for (i = 0; i < nfields; i++) {
  684. X        c_pos (R_PROMPT, fcols[i]);
  685. X        printf (i < nfields-1 ? "%s," : "%s", fields[i]);
  686. X    }
  687. X
  688. X    /* let op choose one now; begin at fn.
  689. X     */
  690. X    while (1) {
  691. X        c_pos (R_PROMPT, fcols[fn]);
  692. X        switch (read_char()) {
  693. X        case END: return (-1);
  694. X        case QUIT:
  695. X        f_prompt ("Exit ephem? (y) ");
  696. X        if (read_char() == 'y')
  697. X            bye();    /* never returns */
  698. X        goto again;
  699. X        case REDRAW: redraw_screen(2); goto again;
  700. X        case VERSION: version(); goto again;
  701. X        case '\r': case ' ': return (fn);
  702. X        case 'h':
  703. X        if (--fn < 0)
  704. X            fn = nfields - 1;
  705. X        break;
  706. X        case 'l':
  707. X        if (++fn >= nfields)
  708. X            fn = 0;
  709. X        break;
  710. X        }
  711. X    }
  712. X}
  713. END_OF_FILE
  714.   if test 1734 -ne `wc -c <'popup.c'`; then
  715.     echo shar: \"'popup.c'\" unpacked with wrong size!
  716.   fi
  717.   # end of 'popup.c'
  718. fi
  719. if test -f 'reduce.c' -a "${1}" != "-c" ; then 
  720.   echo shar: Will not clobber existing file \"'reduce.c'\"
  721. else
  722.   echo shar: Extracting \"'reduce.c'\" \(1691 characters\)
  723.   sed "s/^X//" >'reduce.c' <<'END_OF_FILE'
  724. X#include <math.h>
  725. X#include "astro.h"
  726. X
  727. X/* convert those orbital elements that change from epoch mjd0 to epoch mjd.
  728. X */
  729. Xreduce_elements (mjd0, mjd, inc0, ap0, om0, inc, ap, om)
  730. Xdouble mjd0;    /* initial epoch */
  731. Xdouble mjd;    /* desired epoch */
  732. Xdouble inc0;    /* initial inclination, rads */
  733. Xdouble ap0;    /* initial argument of perihelion, as an mjd */
  734. Xdouble om0;    /* initial long of ascending node, rads */
  735. Xdouble *inc;    /* desired inclination, rads */
  736. Xdouble *ap;    /* desired epoch of perihelion, as an mjd */
  737. Xdouble *om;    /* desired long of ascending node, rads */
  738. X{
  739. X    double t0, t1;
  740. X    double tt, tt2, t02, tt3;
  741. X    double eta, th, th0;
  742. X    double a, b;
  743. X    double dap;
  744. X    double cinc, sinc;
  745. X    double ot, sot, cot, ot1;
  746. X    double seta, ceta;
  747. X
  748. X    t0 = mjd0/365250.0;
  749. X    t1 = mjd/365250.0;
  750. X
  751. X    tt = t1-t0;
  752. X    tt2 = tt*tt;
  753. X        t02 = t0*t0;
  754. X    tt3 = tt*tt2;
  755. X        eta = (471.07-6.75*t0+.57*t02)*tt+(.57*t0-3.37)*tt2+.05*tt3;
  756. X        th0 = 32869.0*t0+56*t02-(8694+55*t0)*tt+3*tt2;
  757. X        eta = degrad(eta/3600.0);
  758. X        th0 = degrad((th0/3600.0)+173.950833);
  759. X        th = (50256.41+222.29*t0+.26*t02)*tt+(111.15+.26*t0)*tt2+.1*tt3;
  760. X        th = th0+degrad(th/3600.0);
  761. X    cinc = cos(inc0);
  762. X        sinc = sin(inc0);
  763. X    ot = om0-th0;
  764. X    sot = sin(ot);
  765. X        cot = cos(ot);
  766. X    seta = sin(eta);
  767. X        ceta = cos(eta);
  768. X    a = sinc*sot;
  769. X        b = ceta*sinc*cot-seta*cinc;
  770. X    ot1 = atan(a/b);
  771. X        if (b<0) ot1 += PI;
  772. X        b = sinc*ceta-cinc*seta*cot;
  773. X        a = -1*seta*sot;
  774. X    dap = atan(a/b);
  775. X        if (b<0) dap += PI;
  776. X
  777. X        *ap = ap0+dap;
  778. X    range (ap, 2*PI);
  779. X        *om = ot1+th;
  780. X    range (om, 2*PI);
  781. X
  782. X        if (inc0<.175)
  783. X        *inc = asin(a/sin(dap));
  784. X    else
  785. X        *inc = 1.570796327-asin((cinc*ceta)+(sinc*seta*cot));
  786. X}
  787. END_OF_FILE
  788.   if test 1691 -ne `wc -c <'reduce.c'`; then
  789.     echo shar: \"'reduce.c'\" unpacked with wrong size!
  790.   fi
  791.   # end of 'reduce.c'
  792. fi
  793. if test -f 'sex_dec.c' -a "${1}" != "-c" ; then 
  794.   echo shar: Will not clobber existing file \"'sex_dec.c'\"
  795. else
  796.   echo shar: Extracting \"'sex_dec.c'\" \(1183 characters\)
  797.   sed "s/^X//" >'sex_dec.c' <<'END_OF_FILE'
  798. X#include <math.h>
  799. X
  800. X/* given hours (or degrees), hd, minutes, m, and seconds, s, 
  801. X * return decimal hours (or degrees), *d.
  802. X * in the case of hours (angles) < 0, only the first non-zero element should
  803. X *   be negative.
  804. X */
  805. Xsex_dec (hd, m, s, d)
  806. Xint hd, m, s;
  807. Xdouble *d;
  808. X{
  809. X    int sign = 1;
  810. X
  811. X    if (hd < 0) {
  812. X        sign = -1;
  813. X        hd = -hd;
  814. X    } else if (m < 0) {
  815. X        sign = -1;
  816. X        m = -m;
  817. X    } else if (s < 0) {
  818. X        sign = -1;
  819. X        s = -s;
  820. X    }
  821. X
  822. X    *d = (((double)s/60.0 + (double)m)/60.0 + (double)hd) * sign;
  823. X}
  824. X
  825. X/* given decimal hours (or degrees), d.
  826. X * return nearest hours (or degrees), *hd, minutes, *m, and seconds, *s, 
  827. X * each always non-negative; *isneg is set to 1 if d is < 0, else to 0.
  828. X */
  829. Xdec_sex (d, hd, m, s, isneg)
  830. Xdouble d;
  831. Xint *hd, *m, *s, *isneg;
  832. X{
  833. X    double min;
  834. X
  835. X    if (d < 0) {
  836. X        *isneg = 1;
  837. X        d = -d;
  838. X    } else
  839. X        *isneg = 0;
  840. X
  841. X    *hd = (int)d;
  842. X    min = (d - *hd)*60.;
  843. X    *m = (int)min;
  844. X    *s = (int)((min - *m)*60. + 0.5);
  845. X
  846. X    if (*s == 60) {
  847. X        if ((*m += 1) == 60) {
  848. X        *hd += 1;
  849. X        *m = 0;
  850. X        }
  851. X        *s = 0;
  852. X    }
  853. X    /* no  negative 0's */
  854. X    if (*hd == 0 && *m == 0 && *s == 0)
  855. X        *isneg = 0;
  856. X}
  857. X
  858. X/* insure 0 <= *v < r.
  859. X */
  860. Xrange (v, r)
  861. Xdouble *v, r;
  862. X{
  863. X    *v -= r*floor(*v/r);
  864. X}
  865. END_OF_FILE
  866.   if test 1183 -ne `wc -c <'sex_dec.c'`; then
  867.     echo shar: \"'sex_dec.c'\" unpacked with wrong size!
  868.   fi
  869.   # end of 'sex_dec.c'
  870. fi
  871. if test -f 'sun.c' -a "${1}" != "-c" ; then 
  872.   echo shar: Will not clobber existing file \"'sun.c'\"
  873. else
  874.   echo shar: Extracting \"'sun.c'\" \(1760 characters\)
  875.   sed "s/^X//" >'sun.c' <<'END_OF_FILE'
  876. X#include <stdio.h>
  877. X#include <math.h>
  878. X#include "astro.h"
  879. X
  880. X/* given the modified JD, mjd, return the true geocentric ecliptic longitude
  881. X *   of the sun for the mean equinox of the date, *lsn, in radians, and the
  882. X *   sun-earth distance, *rsn, in AU. (the true ecliptic latitude is never more
  883. X *   than 1.2 arc seconds and so may be taken to be a constant 0.)
  884. X * if the APPARENT ecliptic longitude is required, correct the longitude for
  885. X *   nutation to the true equinox of date and for aberration (light travel time,
  886. X *   approximately  -9.27e7/186000/(3600*24*365)*2*pi = -9.93e-5 radians).
  887. X */
  888. Xsunpos (mjd, lsn, rsn)
  889. Xdouble mjd;
  890. Xdouble *lsn, *rsn;
  891. X{
  892. X    double t, t2;
  893. X    double ls, ms;    /* mean longitude and mean anomoay */
  894. X    double s, nu, ea; /* eccentricity, true anomaly, eccentric anomaly */
  895. X    double a, b, a1, b1, c1, d1, e1, h1, dl, dr;
  896. X
  897. X    t = mjd/36525.;
  898. X    t2 = t*t;
  899. X    a = 100.0021359*t;
  900. X    b = 360.*(a-(long)a);
  901. X    ls = 279.69668+.0003025*t2+b;
  902. X    a = 99.99736042000039*t;
  903. X    b = 360*(a-(long)a);
  904. X    ms = 358.47583-(.00015+.0000033*t)*t2+b;
  905. X    s = .016751-.0000418*t-1.26e-07*t2;
  906. X    anomaly (degrad(ms), s, &nu, &ea);
  907. X    a = 62.55209472000015*t;
  908. X    b = 360*(a-(long)a);
  909. X    a1 = degrad(153.23+b);
  910. X    a = 125.1041894*t;
  911. X    b = 360*(a-(long)a);
  912. X    b1 = degrad(216.57+b);
  913. X    a = 91.56766028*t;
  914. X    b = 360*(a-(long)a);
  915. X    c1 = degrad(312.69+b);
  916. X    a = 1236.853095*t;
  917. X    b = 360*(a-(long)a);
  918. X    d1 = degrad(350.74-.00144*t2+b);
  919. X    e1 = degrad(231.19+20.2*t);
  920. X    a = 183.1353208*t;
  921. X    b = 360*(a-(long)a);
  922. X    h1 = degrad(353.4+b);
  923. X    dl = .00134*cos(a1)+.00154*cos(b1)+.002*cos(c1)+.00179*sin(d1)+
  924. X                                .00178*sin(e1);
  925. X    dr = 5.43e-06*sin(a1)+1.575e-05*sin(b1)+1.627e-05*sin(c1)+
  926. X                        3.076e-05*cos(d1)+9.27e-06*sin(h1);
  927. X    *lsn = nu+degrad(ls-ms+dl);
  928. X    *rsn = 1.0000002*(1-s*cos(ea))+dr;
  929. X    range (lsn, 2*PI);
  930. X}
  931. END_OF_FILE
  932.   if test 1760 -ne `wc -c <'sun.c'`; then
  933.     echo shar: \"'sun.c'\" unpacked with wrong size!
  934.   fi
  935.   # end of 'sun.c'
  936. fi
  937. if test -f 'utc_gst.c' -a "${1}" != "-c" ; then 
  938.   echo shar: Will not clobber existing file \"'utc_gst.c'\"
  939. else
  940.   echo shar: Extracting \"'utc_gst.c'\" \(1189 characters\)
  941.   sed "s/^X//" >'utc_gst.c' <<'END_OF_FILE'
  942. X#include "astro.h"
  943. X
  944. X/* given a modified julian date, mjd, and a universally coordinated time, utc,
  945. X * return greenwich mean siderial time, *gst.
  946. X */
  947. Xutc_gst (mjd, utc, gst)
  948. Xdouble mjd;
  949. Xdouble utc;
  950. Xdouble *gst;
  951. X{
  952. X    double tnaught();
  953. X    static double lastmjd = -10000;
  954. X    static double t0;
  955. X
  956. X    if (mjd != lastmjd) {
  957. X        t0 = tnaught (mjd);
  958. X        lastmjd = mjd;
  959. X    }
  960. X    *gst = (1.0/SIDRATE)*utc + t0;
  961. X    range (gst, 24.0);
  962. X}
  963. X
  964. X/* given a modified julian date, mjd, and a greenwich mean siderial time, gst,
  965. X * return universally coordinated time, *utc.
  966. X */
  967. Xgst_utc (mjd, gst, utc)
  968. Xdouble mjd;
  969. Xdouble gst;
  970. Xdouble *utc;
  971. X{
  972. X    double tnaught();
  973. X    static double lastmjd = -10000;
  974. X    static double t0;
  975. X
  976. X    if (mjd != lastmjd) {
  977. X        t0 = tnaught (mjd);
  978. X        range (&t0, 24.0);
  979. X        lastmjd = mjd;
  980. X    }
  981. X    *utc = gst - t0;
  982. X    range (utc, 24.0);
  983. X    *utc *= SIDRATE;
  984. X}
  985. X
  986. Xstatic double
  987. Xtnaught (mjd)
  988. Xdouble mjd;    /* julian days since 1900 jan 0.5 */
  989. X{
  990. X    double dmjd;
  991. X    int m, y;
  992. X    double d;
  993. X    double t, t0;
  994. X
  995. X    mjd_cal (mjd, &m, &d, &y);
  996. X    cal_mjd (1, 0., y, &dmjd);
  997. X    t = dmjd/36525;
  998. X    t0 = 6.57098e-2 * (mjd - dmjd) - 
  999. X         (24 - (6.6460656 + (5.1262e-2 + (t * 2.581e-5))*t) -
  1000. X           (2400 * (t - (((double)y - 1900)/100))));
  1001. X    return (t0);
  1002. X}
  1003. END_OF_FILE
  1004.   if test 1189 -ne `wc -c <'utc_gst.c'`; then
  1005.     echo shar: \"'utc_gst.c'\" unpacked with wrong size!
  1006.   fi
  1007.   # end of 'utc_gst.c'
  1008. fi
  1009. echo shar: End of archive 9 \(of 9\).
  1010. cp /dev/null ark9isdone
  1011. MISSING=""
  1012. for I in 1 2 3 4 5 6 7 8 9 ; do
  1013.     if test ! -f ark${I}isdone ; then
  1014.     MISSING="${MISSING} ${I}"
  1015.     fi
  1016. done
  1017. if test "${MISSING}" = "" ; then
  1018.     echo You have unpacked all 9 archives.
  1019.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1020. else
  1021.     echo You still must unpack the following archives:
  1022.     echo "        " ${MISSING}
  1023. fi
  1024. exit 0
  1025. exit 0 # Just in case...
  1026.