ecd@cs.umn.edu@ncs-med.UUCP (Elwood C. Downey) (03/11/90)
Posting-number: Volume 11, Issue 2 Submitted-by: ecd@cs.umn.edu@ncs-med.UUCP (Elwood C. Downey) Archive-name: ephem4.12/part01 This is my latest release of ephem, v4.12, a complete, highly portable, interactive astronomical ephemeris program. It displays planet and comet data, can display sky and solar system views, search for conditions, and create and display plots of information. It is written entirely in C for dumb (ANSI/ASCII) display terminals. Start by unpacking all 7 shar files, check the Manifest for all files, read the manual (Man.txt), the Readme, build ephem, customize the configuration file (ephem.cfg) and let me know what you think. Thanks. Elwood Downey {most any university, I presume}!umn-cs!ncs-med!ecd (umn-cs is U of Minnesota, CS Dept) (maybe someday I will know how to get an Internet address) ------------------------------------------------------------------------- # This is the first line of a "shell archive" file. # This means it contains several files that can be extracted into # the current directory when run with the sh shell, as follows: # sh < this_file_name # This is file 1. echo x Manifest sed -e 's/^X//' << 'EOFxEOF' > Manifest XFiles shipped as the ephem v4.12 package: X XMakefile just say "make" XMan.txt manual, ready for a very generic printer. XManifest this file. XReadme check here for hints before building. Xephem.cfg sample configuration file. you'll want to edit this for your X particular location and interests after reading the manual. X XThe source files: Xaa_hadec.c convert between alt/az and hour angle/dec. Xaltmenus.c draws the three alternate lower screens. Xanomaly.c compute anomaly. Xastro.h unit conversion macros and planet defines. Xcal_mjd.c converters to and from modified julian date. Xcircum.c main "astronomy" entry point that finds where anything is. Xcircum.h defines Now and Sky structures. Xcomet.c compute comet position from elements. Xcompiler.c compile and execute general expressions with screen fields. Xeq_ecl.c convert between equitorial and eclipitic coords. Xflog.c logs and retrieves screen locations for logging purposes. Xformats.c basic date, time, prompts, etc formats. Xio.c basic cursor and screen io control. Xmain.c main loop. Xmainmenu.c draws the top screen. Xmoon.c compute moon position. Xmoonnf.c compute new and full moon dates. Xnutation.c compute nutation correction. Xobjx.c set and make use of all the object-x info. Xobliq.c compute obliquity. Xparallax.c functions to compute earth rim parallax correction. Xpelement.c basic planet position polynomial coefficients. Xplans.c use polynomials to find planet location at any certain time. Xplot.c set fields for and manage plots. Xpopup.c handle the one-liner "popup" menus at the top of the screen. Xprecess.c compute precession correction. Xreduce.c convert elliptical elements from one epoch to another. Xrefract.c atmospheric refraction model. Xriset.c find basic rise/set sideral times of a fixed object. Xriset_c.c iteratively solve for local rise/set times of moving objects. Xscreen.h define all field locations and codes, extra planet codes. Xsel_fld.c handle cursor movement commands in the various screens. Xsex_dec.c convert between sexagesimal and decimal notation. Xsrch.c set and manage the various search functions. Xsun.c compute location of sun at any time. Xtime.c manage setting and getting the time from the os. Xutc_gst.c convert between UT1 and Greenwich sidereal time. Xversion.c current version notice, and revision history comments. Xwatch.c manage the screen during sky and solar system displays. EOFxEOF len=`wc -c < Manifest` if expr $len != 2381 > /dev/null then echo Length of Manifest is $len but it should be 2381. fi echo x Readme sed -e 's/^X//' << 'EOFxEOF' > Readme XGeneral Notes for version 4.12: X X1) Read the generic-printer-ready manual in Man.txt. X X2) Ephem does not gracefully ellar) rate */ X#define SIDRATE .9972695677 X X/* manifest names for planets. X * N.B. must cooincide with usage in pelement.c and plans.c. X */ X#define MERCURY 0 X#define VENUS 1 X#define MARS 2 X#define JUPITER 3 X#define SATURN 4 X#define URANUS 5 X#define NEPTUNE 6 X#define PLUTO 7 EOFxEOF len=`wc -c < astro.h` if expr $len != 620 > /dev/null then echo Length of astro.h is $len but it should be 620. fi echo x circum.h sed -e 's/^X//' << 'EOFxEOF' > circum.h X#define SPD (24.0*3600.0) /* seconds per day */ X X#define EOD (-9786) /* special epoch flag: use epoch of date */ X#define RTC (-1324) /* special tminc flag: use rt clock */ X#define NOMAG (-2134) /* special s_mag flag: means undefined */ X#define NOHELIO (-2314) /* special s_hlong flag: means it and s_hlat are X * undefined X */ X X#define STDHZN 0 /* rise/set times based on nominal conditions */ X#define ADPHZN 1 /* rise/set times based on exact current " */ X#define TWILIGHT 2 /* rise/set times for sun 18 degs below hor */ X X/* in (R_PLANTAB+6) X#define R_JUPITER (R_PLANTAB+7) X#define R_SATURN (R_PLANTAB+8) X#define R_URANUS (R_PLANTAB+9) X#define R_NEPTUNE (R_PLANTAB+10) X#define R_PLUTO (R_PLANTAB+11) X#define R_OBJX (R_PLANTAB+12) X#define C_OBJ 1 X#define C_RA 4 X#define C_DEC 12 X#define C_AZ 19 X#define C_ALT 26 X#define C_HLONG 33 X#define C_HLAT 40 X#define C_EDIST 47 X#define C_SDIST 54 X#define C_ELONG 61 X#define C_SIZE 68 X#define C_MAG 73 X#define C_PHASE 78 X X/* menu 2 screen items */ X#define C_RISETM 10 X#define C_RISEAZ 18 X#define C_TRANSTM 31 X#define C_TRANSALT 39 X#define C_SETTM 52 X#define C_SETAZ 60 X#define C_TUP 72 X X/* menu 3 items */ X#define C_SUN 4 X#define C_MOON 11 X#define C_MERCURY 18 X#define C_VENUS 25 X#define C_MARS 32 X#define C_JUPITER 39 X#define C_SATURN 46 X#define C_URANUS 53 X#define C_NEPTUNE 60 X#define C_PLUTO 67 X#define C_OBJX 74 X X#define PW (NC-C_PROMPT+1) /* total prompt line width */ X X/* macros to pack a row/col and menu selection flags all into an inttic int altmenu = F_MNU1; /* which alternate menu is up; one of F_MNUi */ Xstatic int alt2_stdhzn; /* whether to use STDHZN (aot ADPHZN) horizon algthm */ Xstatic int alt3_geoc; /* whether to use geocentric (aot topocentric) vantage*/ X X/* table of screen rows given a body #define from astro/h or screen.h */ Xstatic short bodyrow[NOBJ] = { X R_MERCURY, R_VENUS, R_MARS, R_JUPITER, R_SATURN, X R_URANUS, R_NEPTUNE, R_PLUTO, R_SUN, R_MOON, R_OBJX X}; X/* table of screen cols for third menu format, given body #define ... */ Xstatic short bodycol[NOBJ] = { X C_MERCURY, C_VENUS, C_MARS, C_JUPITER, C_SATURN, X C_URANUS, C_NEPTUNE, C_PLUTO, C_SUN, C_MOON, C_OBJX X}; X X/* let op decide which alternate menu should be up, X * including any menu-specific setup they might require. X * return 0 if things changed to require updating the alt menu; else -1. X */ Xaltmenu_setup() X{ X static char *flds[5] = { X "Data menu", "Rise/Set menu", "Separations menu" X }; X int newmenu = altmenu, newhzn = alt2_stdhzn, newgeoc = alt3_geoc; X int new; X int fn = altmenu == F_MNU1 ? 0 : altmenu == F_MNU2 ? 1 : 2; X X ask: X flds[3]= newhzn ? "Standard hzn" : "Adaptive hzn"; X flds[4]= newgeoc? "Geocentric" : "Topocentric"; X X switch (popup (flds, fn, 5)) { X case 0: newmenu = F_MNU1; break; X case 1: newmenu = F_MNU2; break; X case 2: newmenu = F_MNU3; break; X case 3: newhzn ^= 1; fn = 3; goto ask; X case 4: newgeoc ^= 1; fn = 4; goto ask; X default: return (-1); X } X X new = 0; X if (newmenu != altmenu) { X altmenu = newmenu; X new++; X } X if (newhzn != alt2_stdhzn) { X alt2_stdhzn = newhzn; X if (newmenu == F_MNU2) X new++; X } X if (newgeoc != alt3_geoc) { X alt3_geoc = newgeoc; X if (newmenu == F_MNU3) X new++; X } X return (new ? 0 : -1); X} X X/* erase the info for the given planet */ Xalt_nobody (p) Xint p; X{ X f_eol (bodyrow[p], C_RA); X} X Xalt_body (b, force, np) Xint b; /* which body, ala astro.h and screen.h defines */ Xint force; /* if !0 then draw for sure, else just if changed since lasF' > anomaly.c X#include <stdio.h> X#include <math.h> X#include "astro.h" X X#define TWOPI (2*PI) X X/* given the mean anomaly, ma, and the eccentricity, s, of elliptical motion, X * find the true anomaly, *nu, and the eccentric anomaly, *ea. X * all angles in radians. X */ Xanomaly (ma, s, nu, ea) Xdouble ma, s; Xdouble *nu, *ea; X{ X double m, dla, fea; X X m = ma-TWOPI*(long)(ma/TWOPI); X fea = m; X while (1) { X dla = fea-(s*sin(fea))-m; X if (fabs(dla)<1e-6) X break; X dla /= 1-(s*cos(fea)); X fea -= dla; X } X X *nu = 2*atan(sqrt((1+s)/(1-s))*tan(fea/2)); X *ea = fea; X} EOFxEOF len=`wc -c < anomaly.c` if expr $len != 557 > /dev/null then echo Length of anomaly.c is $len but it should be 557. fi echo x cal_mjd.c sed -e 's/^X//' << 'EOFxEOF' > cal_mjd.c X#include <stdio.h> X#include <math.h> X#include "astro.h" X X/* given a date in months, mn, days, dy, years, yr, X * return the modified Julian date (number of days elapsed since 1900 jan 0.5), X * *mjd. X */ Xcal_mjd (mn, dy, yr, mjd) Xtic Now last_now; X static double last_dawn, last_dusk; X static int last_status; X int new; X X if (same_cir (np, &last_now) && same_lday (np, &last_now)) { X *dawn = last_dawn; X *dusk = last_dusk; X *status = last_status; X new = 0; X } else { X double x; X (void) riset_cir (SUN,np,TWILIGHT,dawn,dusk,&x,&x,&x,&x,status); X last_dawn = *dawn; X last_dusk = *dusk; X last_status = *status; X last_now = *np; X new = 1; X } X return (new); X} X X/* find sun's circumstances now. X * as is the desired accuracy, in arc seconds; use 0.0 for best possible. X * return 0 if only alt/az changes, else 1 if all other stuff updated too. X */ Xsun_cir (as, np, sp) Xdouble as; XNow *np; XSky *sp; X{ X static Sky last_sky; X static Now last_now; X static double last_ra, last_dec; /* unprecessed ra/dec */ X double lst, alt, az; X double ehp, ha, dec; /* ehp: angular dia of earth from body */ X int new; X X if (same_cir (np, &last_now) && about_now (np, &last_now, as*.00028)) { X *sp = last_sky; X new = 0; X } else { X double lsn, rsn; X double deps, dpsi; X X last_now = *np; X sunpos (mjd, &lsn, &rsn); /* sun's true ecliptic long X * and dist X */ X nutation (mjd, &deps, &dpsi); /* correct for nutation */ X lsn += dpsi; X lsn -= degrad(20.4/3600); /* and light travel time */ X X sp->s_edist = rsn; X sp->s_sdist = 0.0; X sp->s_elong = 0.0; X sp->s_size = raddeg(4.65242e-3/rsn)*3600*2; X sp->s_mag = -26.8; X sp->s_hlong = lsn-PI; /* geo- to helio- centric */ X range (&sp->s_hlong, 2*PI); X sp->s_hlat = 0.0; X X ecl_eq (mjd, 0.0, lsn, &last_ra, &last_dec); X sp->s_ra = last_ra; X sp->s_dec = last_dec; X if (epoch != EOD) X precess (mjd, epoch, &sp->s_ra, &sp->s_dec); X new = 1; X } X X now_lst (np, &lst); X ha = hrrad(lst) - last_ra; X ehp = (2.0 * 6378.0 / 146.0e6) / sp->s_edist; X ta_par (ha, last_dec, lat, height, ehp, &ha, &dec); X hadec_aa (lat, ha, dec, &alt, &az); X refract (pressupsi; X range (&lam, 2*PI); X X sp->s_edist = 6378.14/sin(ehp); /* earth-moon dist, want km */ X sp->s_size = 3600*31.22512*sin(ehp);/* moon angular dia, seconds */ X X ecl_eq (mjd, bet, lam, &last_ra, &last_dec); X sp->s_ra = last_ra; X sp->s_dec = last_dec; X if (epoch != EOD) X precess (mjd, epoch, &sp->s_ra, &sp->s_dec); X X sunpos (mjd, &lsn, &rsn); X range (&lsn, 2*PI); X elongation (lam, bet, lsn, &el); X X /* solve triangle of earth, sun, and elongation for moon-sun dist */ X edistau = sp->s_edist/1.495979e8; /* km -> au */ X sp->s_sdist = X sqrt (edistau*edistau + rsn*rsn - 2.0*edistau*rsn*cos(el)); X X /* TODO: improve mag; this is based on a flat moon model. */ X sp->s_mag = -12.7 + 2.5*(log10(PI) - log10(PI/2*(1+1.e-6-cos(el)))); X X sp->s_elong = raddeg(el); /* want degrees */ X sp->s_phase = fabs(el)/PI*100.0; /* want non-negative % */ X sp->s_hlong = sp->s_hlat = 0.0; X new = 1; X } X X /* show topocentric alt/az by coif expr $len != 2390 > /dev/null then echo Length of comet.c is $len but it should be 2390. fi