home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-03-14 | 54.5 KB | 1,576 lines |
- Newsgroups: comp.sources.misc
- From: e_downey@hwking.cca.cr.rockwell.com (Elwood C. Downey)
- Subject: v28i085: ephem - an interactive astronomical ephemeris, v4.28, Part02/09
- Message-ID: <1992Mar10.215648.15881@sparky.imd.sterling.com>
- X-Md4-Signature: e315f154a49e96281bca55b6668366d5
- Date: Tue, 10 Mar 1992 21:56:48 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: e_downey@hwking.cca.cr.rockwell.com (Elwood C. Downey)
- Posting-number: Volume 28, Issue 85
- Archive-name: ephem/part02
- Environment: UNIX, VMS, DOS, MAC
- Supersedes: ephem-4.21: Volume 14, Issue 76-81
-
- #! /bin/sh
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # The tool that generated this appeared in the comp.sources.unix newsgroup;
- # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
- # Contents: Man.txt.b nutation.c watch.c
- # Wrapped by kent@sparky on Tue Mar 10 14:34:05 1992
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 2 (of 9)."'
- if test -f 'Man.txt.b' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Man.txt.b'\"
- else
- echo shar: Extracting \"'Man.txt.b'\" \(37262 characters\)
- sed "s/^X//" >'Man.txt.b' <<'END_OF_FILE'
- X
- X
- X
- X - 16 -
- X
- X
- X 7.2. Magnitude models
- X
- X Ephem supports two different magnitude models. One, denoted here as g/k,
- X is generally used for comets and is always used for hyperbolic and
- X parabolic objects and optionally for elliptical objects. The other,
- X denoted H/G, is generally used for asteroids in the Astronomical Almanac
- X and may be used with elliptical objects.
- X
- X 7.2.1. g/k model
- X
- X This model requires two parameters to be specified. One, the absolute
- X magnitude, g, is the visual magnitude of the object if it were one AU from
- X both the sun and the earth. The other, the luminosity index, k,
- X characterizes the brightness change of the object as a function of its
- X distance from the sun. This is generally zero, or very small, for inactive
- X objects like asteroids. The model may be expressed as:
- X
- X m = g + 5*log10(D) + 2.5*k*log10(r)
- X where:
- X m = resulting visual magnitude;
- X g = absolute visual magnitude;
- X D = comet-earth distance, in AU;
- X k = luminosity index; and
- X r = comet-sun distance.
- X
- X Note that this model does not take into account the phase angle of
- X sunlight.
- X
- X When using this model for elliptical objects, the first of the two
- X magnitude fields must be preceded by a letter "g" in both the ephem.db
- X database file and the corresponding quick-choice elliptical object
- X definition prompt; otherwise the default magnitude model for elliptical
- X objects is the H/G model.
- X
- X 7.2.2. H/G model
- X
- X This model also requires two parameters. The first, H, is the magnitude of
- X the object when one AU from the sun and the earth. The other, G, attempts
- X to model the reflection characteristics of a passive surface, such as an
- X asteroid. The model may be expressed with the following code fragment:
- X
- X beta = acos((rp*rp + rho*rho - rsn*rsn)/ (2*rp*rho));
- X psi_t = exp(log(tan(beta/2.0))*0.63);
- X Psi_1 = exp(-3.33*psi_t);
- X psi_t = exp(log(tan(beta/2.0))*1.22);
- X Psi_2 = exp(-1.87*psi_t);
- X m = H + 5.0*log10(rp*rho) - 2.5*log10((1-G)*Psi_1 + G*Psi_2);
- X where:
- X m = resulting visual magnitude
- X rp = distance from sun to object
- X rho = distance from earth to object
- X rsn = distance from sun to earth
- X
- X Note that this model does not take into account the phase angle of
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X - 17 -
- X
- X
- X sunlight.
- X
- X This is the default magnitude model for elliptical objects but it can also
- X be explicitly indicated when the first of the two magnitude fields is
- X preceded by a letter "H" in both the ephem.db database file and the
- X corresponding quick-choice elliptical object definition prompt.
- X
- X 7.3. Database File
- X
- X You may save a list of objects in a file to be used for setting OBJX and
- X OBJY. The default name of this file is ephem.db. You may also set it from
- X the command line with the -d option, or set it with the EPHEMDB
- X environment variable.
- X
- X The file consists of one object per line. All lines that do not begin
- X with an alpha character are ignored and may be used for comments. Each
- X line contains several fields, each separated by a comma. The first field
- X is the name of the object. The second field is the type of the object,
- X that is, one of the strings "fixed", "elliptical", "hyperbolic" or
- X "parabolic"; actually, "f", "e", "h" and "p" are sufficient. The
- X remaining fields depend on the type of object. They are exactly the same
- X parameters, and in the same order, as ephem asks for when defining the
- X object from the menu. The size field is last and is optional for
- X compatibility with older versions.
- X
- X 8. Plotting
- X
- X Each time a field is drawn on the screen during a full screen update cycle
- X (that as, during automatic looping or a manual "q" command character from
- X the main menu but not from a screen redraw from control-l or when an
- X individual planet is turned on or a single time field is changed) its
- X full-precision value may be written to a file. This implies you may not
- X plot a field from other than the current menu at the time plotting is on.
- X You can append several plot runs together, however, if necessary.
- X
- X Each line in the file consists of a tag character followed by two or three
- X floating point variables, all separated by commas. If there are two
- X values, they should be interpreted to be x and y (or perhaps r and theta).
- X If there is a third, it is a z or trace value.
- X
- X For efficiency on systems that can compute a screen full faster than they
- X can display it, screen updates are suppressed while plotting is on and
- X NStep is greater than 1. This can greatly reduce the time to generate a
- X long plot file. Fields are still logged for plotting; they just are not
- X drawn on the screen.
- X
- X The Plot field controls plotting. Whether plotting is currently active is
- X indicated by "on" or "off" immediately to its right.
- X
- X Picking "Plot" brings up a quick-choice menu, as follows:
- X
- X Select: Select fields, Display a plot file, Cartesian coords, Begin plotting
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X - 18 -
- X
- X
- X 8.1. Defining plot fields
- X
- X Select the "Select fields" option. You will be asked to move the cursor
- X to the field you want to use as the x coordinate (abscissa), then asked to
- X choose the y coordinate (ordinate), then asked to choose an optional z
- X trace variable and finally a tag character. (Of course, you may have in
- X mind fields that are more appropriately displayed in other than Cartesian
- X coordinates, in which case think of x, y and z as dimensions.) If you type
- X q for either x or y then no more fields will be defined. If you type q
- X for the z field there will be no z field. You can not label a plot line
- X with the letter "q" at this time.
- X
- X This then repeats so you may choose up to ten of these sets for any given
- X plot run. Each set defines what will become a line on the final plot.
- X Note that you may select the "Search" field to indicate use of the current
- X search function; that function must be defined by the time plotting is
- X turned on.
- X
- X If you turn plotting off and back on the fields selected for plotting are
- X reactivated the same as they were last time. You may change them if
- X desired, of course, but there is no need to redefine them if you do not
- X wish to change them.
- X
- X 8.2. Displaying a plot file
- X
- X Select the "Display a plot file" option to generate a crude plot on the
- X screen of an existing plot file previously created by ephem. The entries
- X in the file will be drawn on the screen using their tag characters; the
- X plot remains on the screen until you type any character.
- X
- X The plot may be made in polar or Cartesian coordinates, depending on the
- X setting of the plotting mode in the quick-choice (see next section).
- X
- X 8.3. Cartesian or Polar coords
- X
- X This toggles the plotting mode coordinate system. The mode remains until
- X changed. Polar coordinates assume the first numeric field in the plot
- X file is the radius, and the second is the angle counterclockwise from
- X right, in degrees.
- X
- X 8.4. Begin Plotting
- X
- X If plot field lines are defined then the third option, "Begin plotting"
- X will be available. You will be asked for the name of the file to use. If
- X it already exists you will be asked whether to overwrite it or append to
- X it. You will also be asked for a title line that will become the next
- X line of the file, automatically prefixed with a "*" to make it a comment
- X line. Once you have chosen a file, plotting is on and the top menu
- X plotting status field changes to "on". The default plot file name is
- X ephem.plt. The values are written to the plot file each time they are
- X updated on the screen until you select "Plot" again and select the "Stop"
- X option to turn plotting back off.
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X - 19 -
- X
- X
- X 8.5. Stopping Plotting
- X
- X If plotting is on, then selecting the Plot field in the top section will
- X turn plotting off. You may pick Plot again and resume with the same fields
- X by selecting "Begin plotting" again.
- X
- X Note that due to internal buffering the plot file will not be completely
- X written to disk until plotting is turned off.
- X
- X 9. Listing
- X
- X This feature works very much like Plotting. However, the fields you select
- X define columns of a table generated as ephem runs. These columns are look
- X exactly like their corresponding fields on the ephem screen and so are far
- X more readable than plot files.
- X
- X See the section on Plotting for an explanation of the quick-choice menu.
- X The general operation is very much the same.
- X
- X 10. Watching
- X
- X You may generate a simple drawing on the screen of the local sky in two
- X forms or the solar system by selecting "Watch". It will bring up a
- X quick-choice menu as follows:
- X
- X Select: Sky dome, Alt/az sky, Solar system, No trails
- X
- X
- X 10.1. Trails
- X
- X You may either erase after each iteration or leave the tags up, referred
- X to as "trails". Picking the right-most choice will toggle between "No
- X trails" and "Leave trails"; you should set it as desired before you select
- X the style of sky plot you wish. Ephem will remember your selection.
- X
- X 10.2. Sky dome
- X
- X This draws the currently active planets within a circle that represents
- X the locally visible hemisphere. This is similar to the formats commonly
- X used in the popular astronomy magazines. East is left, south is down,
- X west is right and north is up.
- X
- X 10.3. Alt/az sky
- X
- X This is a cylindrical projection showing the currently active planets as
- X they would appear in the sky looking southwards at the current time and
- X date. The coordinate system is such that 0 degrees azimuth (north)
- X through 360 degrees (north, once around) is mapped to the horizontal
- X screen dimension, and 0 degrees altitude (level) through 90 degrees (the
- X zenith) is mapped to the vertical dimension. Thus, the bottom row is the
- X horizon and all across the top is the zenith.
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X - 20 -
- X
- X
- X 10.4. Solar System
- X
- X This selection draws the currently active planets as they would appear
- X looking "down from the top" of the ecliptic, with the sun at the center
- X and zero hours right ascension towards the right. The scale is adjusted
- X to roughly fill the screen according to the outer-most active planet.
- X Note that the scaling does not take into account the distances of the user
- X defined objects so, if they don't appear, select a planet that is at least
- X as far out as they are. The screen transformation assumes a screen aspect
- X width/height ratio of 4/3. Down the left column of the screen is the
- X heliocentric altitude of the planet above or below the ecliptic, drawn to
- X the same scale as the circular display. Values so close as to land on the
- X same line are sorted left to right; the S and E symbols always denote
- X heliocentric altitude 0.
- X
- X In each style of display, pressing RETURN advances the time by whatever
- X amount StpSz is set to. Pressing "h" advances the time by one hour, "d"
- X advances by one day, and "w" advances by one week (seven days). Pressing
- X "q" returns to the watch quick-choice menu from which you may select
- X another display style or return to the main tabular display by typing
- X another "q". Pressing any other key starts an automatic loop with each
- X step advancing by StpSz; pressing any key stops the looping.
- X
- X As symbols are placed, collisions (overstrikes) are avoided by moving
- X characters in such a way as to maintain increasing sorted order towards
- X the right.
- X
- X When you return to the main menu, the last watched time will be maintained
- X as the current time. The StpSz is not changed.
- X
- X 11. Searching
- X
- X Ephem can search for arbitrary conditions to exist among most displayed
- X fields. You first enter a function, then select from among three forms of
- X equation solvers to iteratively solve for the next time when the function
- X meets the requirements of the solver. The solver selects the next time for
- X which it wants the function evaluated and sets StpSz so that the next
- X iteration will occur at that time. The solvers continue to iterate until
- X either they achieve their goal or NStep reaches 0.
- X
- X You may set NStep to be quite large and let ephem search unattended or set
- X it to 1 and watch it converge one step at a time. You may also plot at the
- X same time as search to record the exact steps ephem took to converge.
- X (But recall that screen updates are suppressed if plotting is also on).
- X
- X The "Search" selection in the top half of the screen controls all
- X searching. Picking it brings up a quick-choice menu as follows:
- X
- X Select: Find extreme, Find 0, Binary, New function, Accuracy
- X
- X
- X 11.1. Find extreme
- X
- X This search algorithm searches for a local maximum or a minimum in the
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X - 21 -
- X
- X
- X search function, whichever it finds first. It begins by evaluating the
- X search function at the current time then for two more times each separated
- X by StpSz. It then fits these three points to a parabola and solves it for
- X the time of its maximum (or minimum). StpSz is set so that the next
- X iteration will evaluate at this point. This parabolic fit solution keeps
- X repeating until StpSz changes by less than the desired accuracy or until
- X the curve becomes so flat that an extrema appears too broad to find.
- X
- X 11.2. Find 0
- X
- X This search algorithm uses the secant method to solve for the time at
- X which the search function is zero. The function is evaluated at the
- X current time and then again StpSz later to establish a slope for which the
- X x-intercept is found as the next zero guess. This is used to set StpSz for
- X the next desired time value and the slope hunting process repeats until
- X StpSz changes by less than the desired accuracy.
- X
- X 11.3. Binary
- X
- X This search algorithm must be used with a search function that yields a
- X boolean result, ie, a true or false value. The idea is that the function
- X is assumed to be one truth value when evaluated at the present time, and
- X the opposite truth value when it is evaluated StpSz later. The algorithm
- X will then do a binary search for the time when the truth value changes.
- X
- X The binary algorithm does not begin until the state change is bounded in
- X time. Initially, as long as the truth value at StpSz is the same as the
- X previous value the algorithm will just keep moving in time by StpSz
- X looking for when the state changes. That is, a linear search is initiated
- X to bound the state change, then the binary search proceeds.
- X
- X 11.4. Define a New function
- X
- X Select "New function" to display the current search function. If you type
- X "q" it will be left unchanged. If you type RETURN it will be erased. If
- X you type anything else it will be compiled and, if there are no errors, it
- X will become the new search function. Once a valid function has been
- X stored, it will remain unless changed. If a search function is selected
- X and there is as yet no valid search function defined, you will
- X automatically be asked to enter one as though you had selected "New
- X function."
- X
- X A search function consists of intrinsic functions, field-specifiers,
- X constants and operators, and precedence may be overridden with
- X parentheses.
- X
- X
- X 11.4.1. Intrinsic functions
- X
- X In this release, the only intrinsic functions available are abs(), which
- X returns the absolute value of its argument, and sqrt(), which returns the
- X square root of its argument.
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X - 22 -
- X
- X
- X 11.4.2. Field Specifiers
- X
- X A field in the bottom half of the menu is generally specified in the form
- X of "object_name.column_name". The object_name is enough of the planet or
- X moon name to be unique. Use "x" or "y" for the user-specified object X or
- X Y. The column_name is from the following table, depending on which menu
- X is up. In all cases additional characters may be entered but are ignored.
- X Also, you may use x, y and z to specify those columns of the Galilean
- X moons menu.
- X
- X Planet Data Menu Rise/Set Menu Separation Menu
- X ------------------ -------------------- ---------------
- X al Alt hr Hrs Up, or j Jup
- X az Az hu Hrs Up ma Mars
- X d Dec raz Rise Az me Merc
- X ed Ea Dst rt Rise Time mo Moon
- X el Elong saz Set Az n Nep
- X hla Helio Lat st Set Time pl Pluto
- X hlo Helio Long ta Transit Alt sa Saturn
- X ph Phs tt Transit Time su Sun
- X ra R.A. u Uranus
- X sd Sn Dst ve Venus
- X si Size
- X vm VMag
- X
- X
- X A few fields do not use this "dot" notation. The following top-half
- X fields are indicated using these codes:
- X
- X da Dawn
- X du Dusk
- X n NiteLn
- X
- X
- X Use "jI" and "jII" to indicate one of the two rotational systems of
- X Jupiter's central meridian longitude.
- X
- X Remember, searching may only involve fields being calculated for display
- X at the time the solver is active. While you can syntactically include any
- X field in a search function it is useless to define a search that uses
- X fields from other than the menu that is selected at the time the search is
- X running.
- X
- X 11.4.3. Constants
- X
- X Constants may be integers or floating point numbers. The latter may be
- X expressed in scientific notation if desired. Examples include 100, .9,
- X 1.234, 1e10 and 1.2e-4. Any number may be preceded by - to make it
- X negative.
- X
- X 11.4.4. Operators
- X
- X The collection of arithmetic, relational and boolean operators provided
- X mimics those of C language as listed in the following table, in decreasing
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X - 23 -
- X
- X
- X order of precedence. Operators grouped together have the same precedence
- X and all have left-to-right associativity. Parentheses may be used as
- X desired.
- X
- X Symbol Meaning Resulting type
- X ------ -------------------- --------------
- X * multiply arithmetic
- X / divide arithmetic
- X
- X + add arithmetic
- X - subtract arithmetic
- X
- X > greater than boolean
- X >= greater than or equal boolean
- X < less than boolean
- X <= less than or equal boolean
- X
- X == equality boolean
- X != inequality boolean
- X
- X && logical and boolean
- X
- X || logical or boolean
- X
- X
- X 11.5. Specifying Search Accuracy
- X
- X Selecting "Accuracy" allows you to specify when the search will stop. The
- X search algorithms will stop when StpSz becomes equal to or less than this
- X value. The default is one minute. If ephem has not yet converged to the
- X specified accuracy but NStep has decremented to 1, the searching will stop
- X but the search status field will still indicate which search procedure is
- X in effect. To try more iterations you may increase NStep and resume
- X searching. If the accuracy was achieved, the search status field will
- X switch to "off" with the number of "unused" steps remaining in NStep and
- X the last step size in the StpSz fields.
- X
- X 11.6. Stop
- X
- X If searching is on, this option will also appear on the quick-choice menu
- X and may be selected to turn off the search.
- X
- X 11.7. Example Searches
- X
- X As an example, let's find when Pluto again becomes the furthest planet
- X from Sol. You may find when the difference in their sun distance is zero,
- X or you might use a binary search on the condition that Pluto's sun
- X distance is larger then Neptune's.
- X
- X To try the former approach select Search, select "Find 0", specify the
- X search function to be:
- X
- X pl.sd - nep.sd
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X - 24 -
- X
- X
- X set StpSz to something large like 10d, NStep to allow several iterations
- X like 20, and then type "q" to start the search and watch ephem do the
- X hunt. Ephem will settle on about 21:02 1/10/1999 UT.
- X
- X To try a binary search, you first need to have some idea of when the event
- X will occur so you can eliminate the initial linear search for the state
- X change. We can start at, say, 1/1/1999, set StpSz to 30d, select Binary
- X search, specify the search function to be:
- X
- X pl.sd > nep.sd
- X
- X and go. Once it brackets the state change note how StpSz keeps being cut
- X in half but can go in either direction (sign) as it divides each interval
- X in half. Ephem will converge on the same answer.
- X
- X 11.8. Another Example
- X
- X To find the time of last quarter moon during December, 1989, use the "Find
- X 0" search algorithm to solve "moon.el + 90". (At last quarter, the moon
- X is 90 degrees west of the sun, or -90 east in ephem's elongation display.)
- X Set the initial time to mid-month, 12/15/1989, StpSz to 1 day and NStep to
- X 10. Ephem takes only a few iterations to settle on 23:57 12/19 UT.
- X
- X 11.9. Caution
- X
- X Beware that most celestial phenomena are generally pseudo-periodic in
- X nature. In early search steps ephem can easily skip over a local maxima
- X and find a later one, which, while correct, may not be what was desired.
- X In general, the closer you can be when you start the search the better
- X ephem can refine it; it is not as good with very broad searches that can
- X go "wild". Set StpSz large enough to offer significant change in the
- X function value, but small enough not to skip too far.
- X
- X For example, Saturn and Neptune had three close approaches during 1989.
- X If you did not know this then just asking ephem to find a minimum would
- X have produced different results depending on the starting conditions.
- X When starting a search for a certain class of event it is a good idea to
- X first use the plotting or watching facility of ephem to get a broad
- X picture of the general circumstances then use ephem's search facility to
- X refine a given region (or create and inspect a plot file and do your own
- X interpolation directly from it separately).
- X
- X Similarly, ephem's searching techniques are not good for eclipses because
- X the moon and sun are close every month; the trick is sorting through the
- X frequent conjunctions for ones that are particularly close. One needs a
- X way of establishing an envelope fit to the local extrema of a cyclic
- X function in order to find a more global extreme.
- X
- X 12. Implementation Notes
- X
- X Remember that everything is for the current local time and day. So, for
- X example, the calendar marks moon events in local time; commercial
- X calendars usually mark the UT date. Similarly, the rise/set times are for
- X the current local day.
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X - 25 -
- X
- X
- X The program uses a horizontal plane tangent to the earth as the horizon
- X for all altitude calculations, rise/set events, etc. This is not the same
- X as the angle up from the local horizon unless the observer is directly on
- X the ground due to earth's curvature. The effect can be found from:
- X
- X sin(a)**2 = (h**2 + 2Rh) / (R+h)**2
- X where:
- X R = radius of earth
- X h = height above ground (same units as R)
- X a = increase in altitude
- X
- X For example, the effect is more than two arc minutes at a height of 5
- X feet.
- X
- X Visual magnitudes are not very accurate ... I haven't bothered to fix.
- X
- X The accuracy of ephem can not be specifically stated since the Duffett-
- X Smith book does not warrant its planet position polynomials to any given
- X degree. I know for sure that better accuracy could be achieved if ephem
- X used TDT but I have not yet decided on a suitable algorithm. Allowing for
- X this manually, (see the Wish List section) comparisons with the
- X Astronomical Almanac are often within a few arcseconds.
- X
- X The program uses double precision throughout. While this precision might
- X seem a little ridiculous, it is actually more efficient for most
- X traditional K&R C compilers and the search functions seem to be are far
- X more stable.
- X
- X Searching and plotting always use full precision but if neither of these
- X are turned on pure display and watching only recompute a given planets new
- X location if the time has changed enough to effect the required display
- X precision, based on the planets mean apparent orbital motion.
- X
- X The sun-moon distance is the solution for the third side of a planar
- X triangle whose two other sides are the earth-moon distance and earth-sun
- X distance separated by the angle of elongation.
- X
- X Beware of computing with the user-defined objects before they are properly
- X defined.
- X
- X If a floating point exception occurs ephem will stop further computations
- X on the current screen update and stop any automatic looping.
- X
- X 12.1. Program limits
- X
- X The search function is limited to a maximum of 32 instructions (each
- X constant, field spec, and operation is one instruction), with no more than
- X a total of 16 constants and field specs. At run time, the function can not
- X require more than 16 stacked values (due to operator precedence or
- X explicit parenthetical expressions) to evaluate.
- X
- X No more than 32 different fields can be tracked simultaneously for
- X plotting and/or searching.
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X - 26 -
- X
- X
- X No more than 10 lines may be plotted at once.
- X
- X The maximum file name length is 14 characters.
- X
- X 13. DOS Installation Procedure
- X
- X You must be running DOS V2.0 or later, though somewhere between V2.0 and
- X V3.21 the behavior of control-c to terminate the program was fixed. An
- X 8087 floating point chip will be used if present.
- X
- X The distribution floppy contains five files:
- X README describes last minute items and details of this release.
- X MAN.TXT is this manual, hopefully formatted and printable on most any
- X printer.
- X EPHEM.EXE is the executable program.
- X EPHEM.CFG is a sample configuration file.
- X EPHEM.DB is a sample database.
- X To run the program, make working copies of these files in a directory and
- X run "ephem" from that directory.
- X
- X 13.1. Setting TZ
- X
- X Before running ephem, you should set a DOS environment variable, TZ. It
- X is is used to establish the timezone name and hours offset whenever the
- X "Now" shorthand is used from ephem, either from the configuration startup
- X file or whenever any time field is changed manually. Set it in the
- X following form:
- X
- X set TZ=SSSnDDD
- X
- X where
- X
- X SSS is the 3-letter abbreviation for the local standard timezone;
- X
- X n is a number between -23 to 24 indicating the number of hours that are
- X subtracted from GMT to obtain local standard time;
- X
- X DDD is an optional 3-letter abbreviation for the local daylight savings
- X time zone name. Leave it off if you do not have savings time in your
- X area or it is not currently in effect. If the changeover dates differ
- X from the internal algorithm, just use SSS and n directly.
- X
- X For example, in the midwestern United States with savings times set
- X TZ=CST6CDT
- X
- X If for some reason your system does not change to savings time at the
- X right time, then omit the DDD parameter and just set the SSS and n to
- X exactly what you want.
- X
- X You can put this in your AUTOEXEC.BAT file so it gets set each time you
- X boot DOS.
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X - 27 -
- X
- X
- X 14. Known Bugs and Wish List
- X
- X incorporate Terrestrial Dynamical Time (known as Ephemeris Time prior to
- X 1984). TDT is about 57 seconds ahead of UT1 in 1990.
- X
- X it's too easy to turn on objx/y before it's defined and bomb out.
- X
- X add explicit searching for eclipses and occultations.
- X
- X in watch mode, RTC reverts back to being based off the time when watch was
- X first entered.
- X
- X add a facility (or tool) to find g/k from a set of observed magnitudes.
- X
- X add search criteria and a screen-based selection mechanism for database
- X objects.
- X
- X add plot options to reverse x and/or y direction and add some tick marks.
- X
- X continue pursuit of moon and other information for other planets.
- X
- X add shorthands for some sidereal and synodic step sizes.
- X
- X the built-in elements for pluto need to be updated. the elements for pluto
- X in the included ephem.db database sampler are more accurate.
- X
- X plotting or listing rise/set that doesn't happen just reshows the last
- X entry.
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X - 28 -
- X
- X
- X 15. Sample Screens
- X
- X Here are sample ephem screens. They are generated using the first sample
- X ephem.cfg file (listed in the section describing the configuration file).
- X There is one for each of the possible screen formats. The rise/set screen
- X was done using the Adaptive option. The separations screen was done using
- X the Topocentric option.
- X
- X
- X
- XMove to another field, RETURN to change this field, ? for help, or q to run
- X
- XCDT 19:00:00 4/30/1990 | LST 8:19:50 | Lat 44:50:37 | April 1990
- XUTC 0:00:00 5/01/1990 | | Long 93:42:08 | Su Mo Tu We Th Fr Sa
- XJulianDat 2448012.50000 | Dawn 4:10 | Elev 800 ft | 1 2 3 4 5 6 7
- XWatch | Dusk 22:15 | Temp 40 F | 8 FM 10 11 12 13 14
- XListing off | NiteLn 5:55 | AtmPr 29.50 in | 15 16 17 18 19 20 21
- XSearch off | | TZ 5:00:00 | 22 23 NM 25 26 27 28
- XPlot off | NStep 1 | Epoch 2000.0 | 29 30
- XMenu Planet Data | StpSz RT CLOCK | Pause 0 |
- X--------------------------------------------------------------------------------
- XOCX R.A. Dec Az Alt H Long H Lat Ea Dst Sn Dst Elong Size VMag Phs
- XSu 2:32.3 14:58 278:40 12:38 220:22 1.0075 1905 -27
- XMo 8:09.9 21:11 186:06 65:53 119:55 1:04 234821 1.0071 79.5 1897 -12 44
- XMe 2:49.4 17:39 277:48 17:26 214:08 1:43 0.5764 0.4360 4.9 11.7 1.6 1
- XVe 23:49.4 -2:25 296:53 -27:39 282:39 -1:30 0.9288 0.7276 -43.9 18.2 -4.8 64
- XMa 22:39.8 -10:09 308:17 -44:14 297:56 -1:43 1.5438 1.4067 -62.9 6.1 0.3 89
- XJu 6:30.9 23:23 235:13 59:04 106:16 0:08 5.6806 5.1941 56.6 34.6 -2.0 99
- XSa 19:49.6 -20:53 17:24 -65:14 289:45 0:10 9.7077 10.017 -105.0 17.1 1.1 100
- XUr 18:41.9 -23:24 51:18 -60:39 276:55 -0:18 18.864 19.401 -120.9 3.5 5.6 100
- XNe 19:03.2 -21:46 40:51 -62:01 282:48 0:51 29.754 30.207 -115.8 2.1 7.9 100
- XPl 15:14.8 -1:26 81:18 -10:37 226:18 15:28 28.693 29.658 -162.9 0.3 13.6 100
- XX 0:08.3 36:01 316:59 5:58 238:20 26:29 0.5622 0.6657 -38.4 0.0 1.5 33
- XY 15:22.9 -2:40 80:43 -12:54 226:17 10:49 2.3635 3.3381 -162.5 0.0 10.1100
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X - 29 -
- X
- X
- XMove to another field, RETURN to change this field, ? for help, or q to run
- X
- XCDT 19:00:00 4/30/1990 | LST 8:19:50 | Lat 44:50:37 | April 1990
- XUTC 0:00:00 5/01/1990 | | Long 93:42:08 | Su Mo Tu We Th Fr Sa
- XJulianDat 2448012.50000 | Dawn 4:10 | Elev 800 ft | 1 2 3 4 5 6 7
- XWatch | Dusk 22:15 | Temp 40 F | 8 FM 10 11 12 13 14
- XListing off | NiteLn 5:55 | AtmPr 29.50 in | 15 16 17 18 19 20 21
- XSearch off | | TZ 5:00:00 | 22 23 NM 25 26 27 28
- XPlot off | NStep 1 | Epoch 2000.0 | 29 30
- XMenu Rise/Set Info | StpSz RT CLOCK | Pause 0 |
- X--------------------------------------------------------------------------------
- XOCX Rise Time Rise Az Trans Time Trans Alt Set Time Set Az Hours Up
- XSu 6:05 67:48 13:12 60:01 20:20 292:28 14:15
- XMo 10:54 57:14 18:49 66:01 1:56 304:46 15:02
- XMe 6:13 63:34 13:30 62:51 20:47 296:04 14:34
- XVe 4:35 93:02 10:29 42:33 16:23 267:14 11:48
- XMa 3:57 103:53 9:20 34:52 14:43 256:17 10:45
- XJu 9:24 54:59 17:11 68:33 1:00 305:01 15:36
- XSa 1:56 119:18 6:31 24:17 11:06 240:42 9:10
- XUr 1:01 123:08 5:24 21:47 9:46 236:52 8:45
- XNe 1:14 120:39 5:45 23:24 10:16 239:21 9:02
- XPl 19:55 91:11 1:57 43:46 7:55 268:48 12:00
- XX 1:41 32:26 10:51 81:10 20:00 327:20 18:19
- XY 20:08 92:55 2:06 42:29 7:59 267:01 11:50
- X
- X
- X
- XMove to another field, RETURN to change this field, ? for help, or q to run
- X
- XCDT 19:00:00 4/30/1990 | LST 8:19:50 | Lat 44:50:37 | April 1990
- XUTC 0:00:00 5/01/1990 | | Long 93:42:08 | Su Mo Tu We Th Fr Sa
- XJulianDat 2448012.50000 | Dawn 4:10 | Elev 800 ft | 1 2 3 4 5 6 7
- XWatch | Dusk 22:15 | Temp 40 F | 8 FM 10 11 12 13 14
- XListing off | NiteLn 5:55 | AtmPr 29.50 in | 15 16 17 18 19 20 21
- XSearch off | | TZ 5:00:00 | 22 23 NM 25 26 27 28
- XPlot off | NStep 1 | Epoch 2000.0 | 29 30
- XMenu Separations | StpSz RT CLOCK | Pause 0 |
- X--------------------------------------------------------------------------------
- XOCX Sun Moon Merc Venus Mars Jup Sat Uranus Nep Pluto X Y
- XSu 79:32 4:52 43:59 62:55 56:31 105: 121: 116: 163: 38:21 162:
- XMo 79:32 74:49 124: 142: 23:01 175: 160: 164: 106: 99:52 108:
- XMe 4:52 74:49 48:43 67:39 51:50 110: 126: 121: 163: 39:57 163:
- XVe 43:59 124: 48:43 18:56 100: 61:09 77:00 71:58 129: 38:49 126:
- XMa 62:55 142: 67:39 18:56 119: 42:14 58:04 53:04 111: 50:48 108:
- XJu 56:31 23:01 51:50 100: 119: 162: 177: 172: 128: 80:40 130:
- XSa 105: 175: 110: 61:09 42:14 162: 15:52 10:50 69:37 83:36 67:17
- XUr 121: 160: 126: 77:00 58:04 177: 15:52 5:11 54:43 97:18 52:21
- XNe 116: 164: 121: 71:58 53:04 172: 10:50 5:11 59:06 92:24 56:46
- XPl 163: 106: 163: 129: 111: 128: 69:37 54:43 59:06 125: 2:22
- XX 38:21 99:52 39:57 38:49 50:48 80:40 83:36 97:18 92:24 125: 124:
- XY 162: 108: 163: 126: 108: 130: 67:17 52:21 56:46 2:22 124:
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X - 30 -
- X
- X
- XMove to another field, RETURN to change this field, ? for help, or q to run
- X
- XCDT 19:00:00 4/30/1990 | LST 8:19:50 | Lat 44:50:37 | April 1990
- XUTC 0:00:00 5/01/1990 | | Long 93:42:08 | Su Mo Tu We Th Fr Sa
- XJulianDat 2448012.50000 | Dawn 4:10 | Elev 800 ft | 1 2 3 4 5 6 7
- XWatch | Dusk 22:15 | Temp 40 F | 8 FM 10 11 12 13 14
- XListing off | NiteLn 5:55 | AtmPr 29.50 in | 15 16 17 18 19 20 21
- XSearch off | | TZ 5:00:00 | 22 23 NM 25 26 27 28
- XPlot off | NStep 1 | Epoch 2000.0 | 29 30
- XMenu Jupiter Aux | StpSz RT CLOCK | Pause 0 |
- X--------------------------------------------------------------------------------
- X
- X Central Meridian Longitude (degs): 337.545 (Sys I) 267.021 (Sys II)
- X (GRS is at approximately 30 degs in System II)
- X
- X Jupiter Radii
- X X (+E) Y (+N) Z (+towards)
- X I Io 0.950 -0.181 -5.808
- X II Europa -4.052 0.261 8.384
- X III Ganymede -8.502 0.385 12.350
- X IV Callisto 26.029 0.160 5.119
- X
- X G E JI C
- X West East
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- END_OF_FILE
- if test 37262 -ne `wc -c <'Man.txt.b'`; then
- echo shar: \"'Man.txt.b'\" unpacked with wrong size!
- fi
- # end of 'Man.txt.b'
- fi
- if [ -f Man.txt.a ]
- then
- echo adding Man.txt.b to Man.txt.a to form Man.txt
- cat Man.txt.a Man.txt.b > Man.txt
- echo removing Man.txt.a and Man.txt.b
- rm Man.txt.a Man.txt.b
- fi
- if test -f 'nutation.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'nutation.c'\"
- else
- echo shar: Extracting \"'nutation.c'\" \(2011 characters\)
- sed "s/^X//" >'nutation.c' <<'END_OF_FILE'
- X#include <stdio.h>
- X#include <math.h>
- X#include "astro.h"
- X
- X/* given the modified JD, mjd, find the nutation in obliquity, *deps, and
- X * the nutation in longitude, *dpsi, each in radians.
- X */
- Xnutation (mjd, deps, dpsi)
- Xdouble mjd;
- Xdouble *deps, *dpsi;
- X{
- X static double lastmjd = -10000, lastdeps, lastdpsi;
- X double ls, ld; /* sun's mean longitude, moon's mean longitude */
- X double ms, md; /* sun's mean anomaly, moon's mean anomaly */
- X double nm; /* longitude of moon's ascending node */
- X double t, t2; /* number of Julian centuries of 36525 days since
- X * Jan 0.5 1900.
- X */
- X double tls, tnm, tld; /* twice above */
- X double a, b; /* temps */
- X
- X if (mjd == lastmjd) {
- X *deps = lastdeps;
- X *dpsi = lastdpsi;
- X return;
- X }
- X
- X t = mjd/36525.;
- X t2 = t*t;
- X
- X a = 100.0021358*t;
- X b = 360.*(a-(long)a);
- X ls = 279.697+.000303*t2+b;
- X
- X a = 1336.855231*t;
- X b = 360.*(a-(long)a);
- X ld = 270.434-.001133*t2+b;
- X
- X a = 99.99736056000026*t;
- X b = 360.*(a-(long)a);
- X ms = 358.476-.00015*t2+b;
- X
- X a = 13255523.59*t;
- X b = 360.*(a-(long)a);
- X md = 296.105+.009192*t2+b;
- X
- X a = 5.372616667*t;
- X b = 360.*(a-(long)a);
- X nm = 259.183+.002078*t2-b;
- X
- X /* convert to radian forms for use with trig functions.
- X */
- X tls = 2*degrad(ls);
- X nm = degrad(nm);
- X tnm = 2*nm;
- X ms = degrad(ms);
- X tld = 2*degrad(ld);
- X md = degrad(md);
- X
- X /* find delta psi and eps, in arcseconds.
- X */
- X lastdpsi = (-17.2327-.01737*t)*sin(nm)+(-1.2729-.00013*t)*sin(tls)
- X +.2088*sin(tnm)-.2037*sin(tld)+(.1261-.00031*t)*sin(ms)
- X +.0675*sin(md)-(.0497-.00012*t)*sin(tls+ms)
- X -.0342*sin(tld-nm)-.0261*sin(tld+md)+.0214*sin(tls-ms)
- X -.0149*sin(tls-tld+md)+.0124*sin(tls-nm)+.0114*sin(tld-md);
- X lastdeps = (9.21+.00091*t)*cos(nm)+(.5522-.00029*t)*cos(tls)
- X -.0904*cos(tnm)+.0884*cos(tld)+.0216*cos(tls+ms)
- X +.0183*cos(tld-nm)+.0113*cos(tld+md)-.0093*cos(tls-ms)
- X -.0066*cos(tls-nm);
- X
- X /* convert to radians.
- X */
- X lastdpsi = degrad(lastdpsi/3600);
- X lastdeps = degrad(lastdeps/3600);
- X
- X lastmjd = mjd;
- X *deps = lastdeps;
- X *dpsi = lastdpsi;
- X}
- END_OF_FILE
- if test 2011 -ne `wc -c <'nutation.c'`; then
- echo shar: \"'nutation.c'\" unpacked with wrong size!
- fi
- # end of 'nutation.c'
- fi
- if test -f 'watch.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'watch.c'\"
- else
- echo shar: Extracting \"'watch.c'\" \(12217 characters\)
- sed "s/^X//" >'watch.c' <<'END_OF_FILE'
- X/* these functions allow you to watch the sky or the solar system via a
- X * simple character-graphics representation on the screen.
- X * the interaction starts by using the current time. then control with
- X * END returns to table form; or
- X * RETURN advances time by one StpSz; or
- X * h advances once by 1 hour; or
- X * d advances once by 24 hours (1 day); or
- X * w advances once by 7 days (1 week); or
- X * any other key free runs by StpSz until any key is hit.
- X */
- X
- X#include <stdio.h>
- X#include <math.h>
- X#include "astro.h"
- X#include "circum.h"
- X#include "screen.h"
- X
- X#define SSZCOL 1 /* column to show solar system z coords */
- X#define PARK_ROW 1 /* cursor park loc after each screen */
- X#define PARK_COL NC /* cursor park loc after each screen */
- X
- X#define DOMESKY 0 /* flags for watch_sky() */
- X#define ALTAZSKY 1 /* flags for watch_sky() */
- X
- X#define SKYACC 3600. /* desired sky plot accuracy, in arc seconds */
- X#define SSACC 3600. /* desired solar system plot accuracy, in arc secs */
- X
- X/* macros to convert row(col) in range 1..NR(1..NC) to fraction in range 0..1 */
- X#define NEARONE 0.9999999
- X#define r2fr(r) (((r)-1)/(NEARONE*NR)+1/NC/2)
- X#define c2fc(c) (((c)-1)/(NEARONE*NC)+1/NC/2)
- X#define fr2r(fr) ((int)((fr)*(NEARONE*NR))+1)
- X#define fc2c(fc) ((int)((fc)*(NEARONE*NC))+1)
- X
- X/* single-character tag for each body.
- X * order must match the #defines in astro.h and screen.h additions.
- X */
- Xstatic char body_tags[] = "evmjsunpSMxy";
- X
- X/* multiple and single loop prompts */
- Xstatic char frprompt[] = "Running... press any key to stop.";
- Xstatic char qprompt[] =
- X"q to quit, RETURN/h/d/w to step by StpSz/hr/day/wk, or any other to freerun";
- X
- X/* used to locate, record and then erase last plotted chars */
- Xtypedef struct {
- X double l_fr, l_fc; /* 2d coords as 0..1 (upper left corner is (0,0)) */
- X int l_r, l_c; /* screen 2d coords (upper left corner is [1,1]) */
- X char l_tag; /* char to use to print on screen */
- X} LastDraw;
- X
- Xstatic int trails; /* !0 if want to leave trails */
- X
- Xwatch (np, tminc, wbodies)
- XNow *np; /* time now and on each step */
- Xdouble tminc; /* hrs to increment time by each step */
- Xint wbodies; /* each bit is !=0 if want that body */
- X{
- X static char *flds[4] = {
- X "Sky dome", "Alt/az sky", "Solar system"
- X };
- X static int fn; /* begin with 0, then remember for next time */
- X int didone = 0;
- X
- X while (1) {
- X int nf;
- X flds[3] = trails ? "Leave trails" : "No trails";
- X if ((nf = popup (flds, fn, 4)) < 0)
- X break;
- X fn = nf;
- X switch (nf) {
- X case 0: watch_sky (DOMESKY, np, tminc, wbodies); didone = 1; break;
- X case 1: watch_sky (ALTAZSKY, np, tminc, wbodies); didone = 1; break;
- X case 2: watch_solarsystem (np, tminc, wbodies); didone = 1; break;
- X case 3: trails ^= 1; break;
- X }
- X }
- X
- X if (didone)
- X redraw_screen(2);
- X}
- X
- X/* full alt/az or dome sky view (like the popular astro mags).
- X * alt/az: north is at left and right of screen, south at center.
- X * 0 elevation is at bottom of screen, zenith at the top.
- X * dome: east is left, north is up.
- X */
- Xstatic
- Xwatch_sky (style, np, tminc, wbodies)
- Xint style; /* DOMESKY or ALTAZSKY */
- XNow *np; /* time now and on each step */
- Xdouble tminc; /* hrs to increment time by each step */
- Xint wbodies; /* each bit is !=0 if want */
- X{
- X static char east[] = "East";
- X static char west[] = "West";
- X static char north[] = "North";
- X static char south[] = "South";
- X double tminc0 = tminc; /* remember the original */
- X /* two draw buffers so we can leave old up while calc new then
- X * erase and draw in one quick operation. always calc new in newp
- X * buffer and erase previous from lastp. buffers alternate roles.
- X */
- X LastDraw ld0[NOBJ], ld1[NOBJ], *lp, *lastp = ld0, *newp = ld1;
- X int nlast = 0, nnew;
- X int once = 1;
- X double lmjd, tmp;
- X Sky s;
- X int p;
- X
- X /* clear screen and put up the permanent labels */
- X c_erase();
- X if (style == DOMESKY) {
- X double a;
- X for (a = 0.0; a < 2*PI; a += PI/8)
- X f_char (fr2r(.5-sin(a)/2.),
- X fc2c(.5+cos(a)/2./ASPECT) + ((a>PI/2 && a<3*PI/2) ? -1 : 1),
- X '*');
- X f_string (fr2r(.5), fc2c(.5-.5/ASPECT)-7, "East");
- X f_string (fr2r(1.), fc2c(.5)-2, south);
- X f_string (fr2r(.5), fc2c(.5+.5/ASPECT)+4, "West");
- X f_string (2, NC/2-2, north);
- X } else {
- X f_string (NR, 1, north);
- X f_string (NR, NC/4, east);
- X f_string (NR, NC/2, south);
- X f_string (NR, 3*NC/4, west);
- X f_string (NR, NC-5, north); /* -1 more to avoid scrolling */
- X f_string (2, NC/2-3, "Zenith");
- X }
- X f_string (2, 1, tznm);
- X f_string (3, 1, "LST");
- X
- X while (1) {
- X if (once)
- X print_updating();
- X
- X /* calculate desired stuff into newp[] */
- X nnew = 0;
- X for (p = nxtbody(-1); p != -1; p = nxtbody(p))
- X if (wbodies & (1<<p)) {
- X (void) body_cir (p, SKYACC, np, &s);
- X if (s.s_alt > 0.0) {
- X LastDraw *lnp = newp + nnew;
- X if (style == DOMESKY) {
- X tmp = 0.5 - s.s_alt/PI;
- X lnp->l_fr = 0.5 - tmp*cos(s.s_az);
- X lnp->l_fc = 0.5 - tmp*sin(s.s_az)/ASPECT;
- X } else {
- X lnp->l_fr = 1.0 - s.s_alt/(PI/2);
- X lnp->l_fc = s.s_az/(2*PI);
- X }
- X lnp->l_tag = body_tags[p];
- X nnew++;
- X }
- X }
- X set_screencoords (newp, nnew);
- X
- X /* unless we want trails,
- X * erase any previous tags (in same order as written) from lastp[].
- X */
- X if (!trails)
- X for (lp = lastp; --nlast >= 0; lp++)
- X f_char (lp->l_r, lp->l_c, ' ');
- X
- X /* print LOCAL time and date we will be using */
- X lmjd = mjd - tz/24.0;
- X f_time (2, 5, mjd_hr(lmjd));
- X f_date (2, 14, mjd_day(lmjd));
- X now_lst (np, &tmp);
- X f_time (3, 5, tmp);
- X
- X /* now draw new stuff from newp[] and park the cursor */
- X for (lp = newp; lp < newp + nnew; lp++)
- X f_char (lp->l_r, lp->l_c, lp->l_tag);
- X c_pos (PARK_ROW, PARK_COL);
- X fflush (stdout);
- X
- X /* swap new and last roles and save new count */
- X if (newp == ld0)
- X newp = ld1, lastp = ld0;
- X else
- X newp = ld0, lastp = ld1;
- X nlast = nnew;
- X
- X if (!once)
- X slp_sync();
- X
- X if (once || (chk_char()==0 && read_char()!=0)) {
- X if (readwcmd (tminc0, &tminc, &once) < 0)
- X break;
- X }
- X
- X /* advance time */
- X inc_mjd (np, tminc);
- X }
- X}
- X
- X/* solar system view, "down from the top", first point of aries to the right.
- X * always include earth.
- X */
- Xstatic
- Xwatch_solarsystem (np, tminc, wbodies)
- XNow *np; /* time now and on each step */
- Xdouble tminc; /* hrs to increment time by each step */
- Xint wbodies;
- X{
- X /* max au of each planet from sun; in astro.h #defines order */
- X static double auscale[] = {.38, .75, 1.7, 5.2, 11., 20., 31., 50.};
- X double tminc0 = tminc; /* remember the original */
- X /* two draw buffers so we can leave old up while calc new then
- X * erase and draw in one quick operation. always calc new in newp
- X * buffer and erase previous from lastp. buffers alternate roles.
- X */
- X LastDraw ld0[2*NOBJ], ld1[2*NOBJ], *lp, *lastp = ld0, *newp = ld1;
- X int nlast = 0, nnew;
- X int once = 1;
- X double lmjd;
- X double scale;
- X Sky s;
- X int p;
- X
- X /* set screen scale: largest au we will have to plot.
- X * never make it less than 1 au (with fudge) since we always show earth.
- X */
- X scale = 1.1;
- X for (p = MARS; p <= PLUTO; p++)
- X if ((wbodies & (1<<p)) && auscale[p] > scale)
- X scale = auscale[p];
- X
- X /* clear screen and put up the permanent labels */
- X c_erase();
- X f_string (2, 1, tznm);
- X
- X while (1) {
- X if (once)
- X print_updating();
- X
- X /* calculate desired stuff into newp[].
- X * fake a sun at center and add earth first.
- X * (we get earth's loc when ask for sun)
- X */
- X nnew = 0;
- X set_ss (newp+nnew, 0.0, 0.0, 0.0, 'S');
- X nnew += 2;
- X (void) body_cir (SUN, SSACC, np, &s);
- X set_ss (newp+nnew, s.s_edist/scale, s.s_hlong, 0.0, 'E');
- X nnew += 2;
- X for (p = MERCURY; p <= PLUTO; p++)
- X if (p != MOON && (wbodies & (1<<p))) {
- X (void) body_cir (p, SSACC, np, &s);
- X set_ss (newp+nnew, s.s_sdist/scale, s.s_hlong, s.s_hlat,
- X body_tags[p]);
- X nnew += 2;
- X }
- X for (p = OBJX; p != -1; p = (p == OBJX) ? OBJY : -1)
- X if (wbodies & (1<<p)) {
- X (void) body_cir (p, SSACC, np, &s);
- X if (s.s_hlong != NOHELIO && s.s_sdist <= scale) {
- X set_ss (newp+nnew, s.s_sdist/scale, s.s_hlong, s.s_hlat,
- X body_tags[p]);
- X nnew += 2;
- X }
- X }
- X
- X set_screencoords (newp, nnew);
- X
- X /* unless we want trails,
- X * erase any previous tags (in same order as written) from lastp[].
- X */
- X if (!trails)
- X for (lp = lastp; --nlast >= 0; lp++)
- X safe_f_char (lp->l_r, lp->l_c, ' ');
- X
- X /* print LOCAL time and date we will be using */
- X lmjd = mjd - tz/24.0;
- X f_time (2, 5, mjd_hr(lmjd));
- X f_date (2, 14, mjd_day(lmjd));
- X
- X /* now draw new stuff from newp[] and park the cursor */
- X for (lp = newp; lp < newp + nnew; lp++)
- X safe_f_char (lp->l_r, lp->l_c, lp->l_tag);
- X c_pos (PARK_ROW, PARK_COL);
- X fflush (stdout);
- X
- X /* swap new and last roles and save new count */
- X if (newp == ld0)
- X newp = ld1, lastp = ld0;
- X else
- X newp = ld0, lastp = ld1;
- X nlast = nnew;
- X
- X if (!once)
- X slp_sync();
- X
- X if (once || (chk_char()==0 && read_char()!=0)) {
- X if (readwcmd (tminc0, &tminc, &once) < 0)
- X break;
- X }
- X
- X /* advance time */
- X inc_mjd (np, tminc);
- X }
- X}
- X
- X/* fill in two LastDraw solar system entries,
- X * one for the x/y display, one for the z.
- X */
- Xstatic
- Xset_ss (lp, dist, lg, lt, tag)
- XLastDraw *lp;
- Xdouble dist, lg, lt; /* scaled heliocentric distance, longitude and lat */
- Xchar tag;
- X{
- X lp->l_fr = 0.5 - dist*sin(lg)*0.5;
- X lp->l_fc = 0.5 + dist*cos(lg)*0.5/ASPECT;
- X lp->l_tag = tag;
- X lp++;
- X /* row is to show course helio altitude but since we resolve collisions
- X * by adjusting columns we can get more detail by smaller variations
- X * within one column.
- X */
- X lp->l_fr = 0.5 - dist*sin(lt)*0.5;
- X lp->l_fc = c2fc(SSZCOL) + (1 - lp->l_fr)/NC;
- X lp->l_tag = tag;
- X}
- X
- X/* given a list of LastDraw structs with their l_{fr,fc} filled in,
- X * fill in their l_{r,c}.
- X * TODO: better collision avoidance.
- X */
- Xstatic
- Xset_screencoords (lp, np)
- XLastDraw lp[];
- Xint np;
- X{
- X LastDraw *lpi; /* the current basis for comparison */
- X LastDraw *lpj; /* the sweep over other existing cells */
- X int i; /* index of the current basis cell, lpi */
- X int j; /* index of sweep cell, lpj */
- X int n; /* total cells placed so far (ie, # to check) */
- X
- X /* idea is to place each new item onto the screen.
- X * after each placement, look for collisions.
- X * if find a colliding pair, move the one with the greater l_fc to
- X * the right one cell, then rescan for more collisions.
- X * this will yield a result that is sorted by columns by l_fc.
- X * TODO: don't just move to the right, try up too for true 2d adjusts.
- X */
- X for (n = 0; n < np; n++) {
- X lpi = lp + n;
- X i = n;
- X lpi->l_r = fr2r(lpi->l_fr);
- X lpi->l_c = fc2c(lpi->l_fc);
- X chk:
- X for (j = 0; j < n; j++) {
- X lpj = lp + j;
- X if (i!=j && lpi->l_r == lpj->l_r && lpi->l_c == lpj->l_c) {
- X if (lpj->l_fc > lpi->l_fc) {
- X /* move lpj and use it as basis for checks now */
- X lpi = lpj;
- X i = j;
- X }
- X if (++lpi->l_c > NC)
- X lpi->l_c = 1;
- X goto chk;
- X }
- X }
- X }
- X}
- X
- X/* since the solar system scaling is only approximate, and doesn't include
- X * object x/y at all, characters might get mapped off screen. this funtion
- X * guards against drawing chars off screen. it also moves a char being drawn
- X * on the lower right corner of the screem left one to avoid scrolling.
- X */
- Xstatic
- Xsafe_f_char (r, c, tag)
- Xint r, c;
- Xchar tag;
- X{
- X if (r >= 1 && r <= NR && c >= 1 && c <= NC) {
- X if (r == NR && c == NC)
- X c -= 1;
- X f_char (r, c, tag);
- X }
- X}
- X
- X/* see what the op wants to do now and update prompt/times accordingly.
- X * return -1 if we are finished, else 0.
- X */
- Xstatic int
- Xreadwcmd (tminc0, tminc, once)
- Xdouble tminc0;
- Xdouble *tminc;
- Xint *once;
- X{
- X f_prompt (qprompt);
- X
- X switch (read_char()) {
- X case END: /* back to table */
- X return (-1);
- X case '\r': case ' ': /* one StpSz step */
- X *tminc = tminc0;
- X *once = 1;
- X break;
- X case 'h': /* one 1-hour step */
- X *tminc = 1.0;
- X *once = 1;
- X break;
- X case 'd': /* one 24-hr step */
- X *tminc = 24.0;
- X *once = 1;
- X break;
- X case 'w': /* 7 day step */
- X *tminc = 7*24.0;
- X *once = 1;
- X break;
- X default: /* free-run */
- X *once = 0;
- X f_prompt (frprompt);
- X }
- X return (0);
- X}
- END_OF_FILE
- if test 12217 -ne `wc -c <'watch.c'`; then
- echo shar: \"'watch.c'\" unpacked with wrong size!
- fi
- # end of 'watch.c'
- fi
- echo shar: End of archive 2 \(of 9\).
- cp /dev/null ark2isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 9 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
-