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

  1. Newsgroups: comp.sources.misc
  2. From: e_downey@hwking.cca.cr.rockwell.com (Elwood C. Downey)
  3. Subject:  v28i085:  ephem - an interactive astronomical ephemeris, v4.28, Part02/09
  4. Message-ID: <1992Mar10.215648.15881@sparky.imd.sterling.com>
  5. X-Md4-Signature: e315f154a49e96281bca55b6668366d5
  6. Date: Tue, 10 Mar 1992 21:56:48 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 85
  11. Archive-name: ephem/part02
  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:  Man.txt.b nutation.c watch.c
  21. # Wrapped by kent@sparky on Tue Mar 10 14:34:05 1992
  22. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  23. echo If this archive is complete, you will see the following message:
  24. echo '          "shar: End of archive 2 (of 9)."'
  25. if test -f 'Man.txt.b' -a "${1}" != "-c" ; then 
  26.   echo shar: Will not clobber existing file \"'Man.txt.b'\"
  27. else
  28.   echo shar: Extracting \"'Man.txt.b'\" \(37262 characters\)
  29.   sed "s/^X//" >'Man.txt.b' <<'END_OF_FILE'
  30. X
  31. X
  32. X
  33. X                                       - 16 -
  34. X
  35. X
  36. X     7.2.  Magnitude models
  37. X
  38. X     Ephem supports two different magnitude models. One, denoted here as g/k,
  39. X     is generally used for comets and is always used for hyperbolic and
  40. X     parabolic objects and optionally for elliptical objects. The other,
  41. X     denoted H/G, is generally used for asteroids in the Astronomical Almanac
  42. X     and may be used with elliptical objects.
  43. X
  44. X     7.2.1.  g/k model
  45. X
  46. X     This model requires two parameters to be specified.  One, the absolute
  47. X     magnitude, g, is the visual magnitude of the object if it were one AU from
  48. X     both the sun and the earth.  The other, the luminosity index, k,
  49. X     characterizes the brightness change of the object as a function of its
  50. X     distance from the sun. This is generally zero, or very small, for inactive
  51. X     objects like asteroids.  The model may be expressed as:
  52. X
  53. X         m = g + 5*log10(D) + 2.5*k*log10(r)
  54. X       where:
  55. X         m = resulting visual magnitude;
  56. X         g = absolute visual magnitude;
  57. X         D = comet-earth distance, in AU;
  58. X         k = luminosity index; and
  59. X         r = comet-sun distance.
  60. X
  61. X     Note that this model does not take into account the phase angle of
  62. X     sunlight.
  63. X
  64. X     When using this model for elliptical objects, the first of the two
  65. X     magnitude fields must be preceded by a letter "g" in both the ephem.db
  66. X     database file and the corresponding quick-choice elliptical object
  67. X     definition prompt; otherwise the default magnitude model for elliptical
  68. X     objects is the H/G model.
  69. X
  70. X     7.2.2.  H/G model
  71. X
  72. X     This model also requires two parameters. The first, H, is the magnitude of
  73. X     the object when one AU from the sun and the earth. The other, G, attempts
  74. X     to model the reflection characteristics of a passive surface, such as an
  75. X     asteroid. The model may be expressed with the following code fragment:
  76. X
  77. X         beta = acos((rp*rp + rho*rho - rsn*rsn)/ (2*rp*rho));
  78. X         psi_t = exp(log(tan(beta/2.0))*0.63);
  79. X         Psi_1 = exp(-3.33*psi_t);
  80. X         psi_t = exp(log(tan(beta/2.0))*1.22);
  81. X         Psi_2 = exp(-1.87*psi_t);
  82. X         m = H + 5.0*log10(rp*rho) - 2.5*log10((1-G)*Psi_1 + G*Psi_2);
  83. X       where:
  84. X         m   = resulting visual magnitude
  85. X         rp  = distance from sun to object
  86. X         rho = distance from earth to object
  87. X         rsn = distance from sun to earth
  88. X
  89. X     Note that this model does not take into account the phase angle of
  90. X
  91. X
  92. X
  93. X
  94. X
  95. X
  96. X
  97. X
  98. X
  99. X                                       - 17 -
  100. X
  101. X
  102. X     sunlight.
  103. X
  104. X     This is the default magnitude model for elliptical objects but it can also
  105. X     be explicitly indicated when the first of the two magnitude fields is
  106. X     preceded by a letter "H" in both the ephem.db database file and the
  107. X     corresponding quick-choice elliptical object definition prompt.
  108. X
  109. X     7.3.  Database File
  110. X
  111. X     You may save a list of objects in a file to be used for setting OBJX and
  112. X     OBJY. The default name of this file is ephem.db. You may also set it from
  113. X     the command line with the -d option, or set it with the EPHEMDB
  114. X     environment variable.
  115. X
  116. X     The file consists of one object per line.  All lines that do not begin
  117. X     with an alpha character are ignored and may be used for comments.  Each
  118. X     line contains several fields, each separated by a comma.  The first field
  119. X     is the name of the object.  The second field is the type of the object,
  120. X     that is, one of the strings "fixed", "elliptical", "hyperbolic" or
  121. X     "parabolic"; actually, "f", "e", "h" and "p" are sufficient.  The
  122. X     remaining fields depend on the type of object.  They are exactly the same
  123. X     parameters, and in the same order, as ephem asks for when defining the
  124. X     object from the menu.  The size field is last and is optional for
  125. X     compatibility with older versions.
  126. X
  127. X     8.  Plotting
  128. X
  129. X     Each time a field is drawn on the screen during a full screen update cycle
  130. X     (that as, during automatic looping or a manual "q" command character from
  131. X     the main menu but not from a screen redraw from control-l or when an
  132. X     individual planet is turned on or a single time field is changed) its
  133. X     full-precision value may be written to a file.  This implies you may not
  134. X     plot a field from other than the current menu at the time plotting is on.
  135. X     You can append several plot runs together, however, if necessary.
  136. X
  137. X     Each line in the file consists of a tag character followed by two or three
  138. X     floating point variables, all separated by commas. If there are two
  139. X     values, they should be interpreted to be x and y (or perhaps r and theta).
  140. X     If there is a third, it is a z or trace value.
  141. X
  142. X     For efficiency on systems that can compute a screen full faster than they
  143. X     can display it, screen updates are suppressed while plotting is on and
  144. X     NStep is greater than 1. This can greatly reduce the time to generate a
  145. X     long plot file. Fields are still logged for plotting; they just are not
  146. X     drawn on the screen.
  147. X
  148. X     The Plot field controls plotting.  Whether plotting is currently active is
  149. X     indicated by "on" or "off" immediately to its right.
  150. X
  151. X     Picking "Plot" brings up a quick-choice menu, as follows:
  152. X
  153. X     Select: Select fields, Display a plot file, Cartesian coords, Begin plotting
  154. X
  155. X
  156. X
  157. X
  158. X
  159. X
  160. X
  161. X
  162. X
  163. X
  164. X
  165. X                                       - 18 -
  166. X
  167. X
  168. X     8.1.  Defining plot fields
  169. X
  170. X     Select the "Select fields" option.  You will be asked to move the cursor
  171. X     to the field you want to use as the x coordinate (abscissa), then asked to
  172. X     choose the y coordinate (ordinate), then asked to choose an optional z
  173. X     trace variable and finally a tag character.  (Of course, you may have in
  174. X     mind fields that are more appropriately displayed in other than Cartesian
  175. X     coordinates, in which case think of x, y and z as dimensions.) If you type
  176. X     q for either x or y then no more fields will be defined.  If you type q
  177. X     for the z field there will be no z field.  You can not label a plot line
  178. X     with the letter "q" at this time.
  179. X
  180. X     This then repeats so you may choose up to ten of these sets for any given
  181. X     plot run.  Each set defines what will become a line on the final plot.
  182. X     Note that you may select the "Search" field to indicate use of the current
  183. X     search function; that function must be defined by the time plotting is
  184. X     turned on.
  185. X
  186. X     If you turn plotting off and back on the fields selected for plotting are
  187. X     reactivated the same as they were last time. You may change them if
  188. X     desired, of course, but there is no need to redefine them if you do not
  189. X     wish to change them.
  190. X
  191. X     8.2.  Displaying a plot file
  192. X
  193. X     Select the "Display a plot file" option to generate a crude plot on the
  194. X     screen of an existing plot file previously created by ephem.  The entries
  195. X     in the file will be drawn on the screen using their tag characters; the
  196. X     plot remains on the screen until you type any character.
  197. X
  198. X     The plot may be made in polar or Cartesian coordinates, depending on the
  199. X     setting of the plotting mode in the quick-choice (see next section).
  200. X
  201. X     8.3.  Cartesian or Polar coords
  202. X
  203. X     This toggles the plotting mode coordinate system.  The mode remains until
  204. X     changed.  Polar coordinates assume the first numeric field in the plot
  205. X     file is the radius, and the second is the angle counterclockwise from
  206. X     right, in degrees.
  207. X
  208. X     8.4.  Begin Plotting
  209. X
  210. X     If plot field lines are defined then the third option, "Begin plotting"
  211. X     will be available.  You will be asked for the name of the file to use.  If
  212. X     it already exists you will be asked whether to overwrite it or append to
  213. X     it.  You will also be asked for a title line that will become the next
  214. X     line of the file, automatically prefixed with a "*" to make it a comment
  215. X     line.  Once you have chosen a file, plotting is on and the top menu
  216. X     plotting status field changes to "on".  The default plot file name is
  217. X     ephem.plt.  The values are written to the plot file each time they are
  218. X     updated on the screen until you select "Plot" again and select the "Stop"
  219. X     option to turn plotting back off.
  220. X
  221. X
  222. X
  223. X
  224. X
  225. X
  226. X
  227. X
  228. X
  229. X
  230. X
  231. X                                       - 19 -
  232. X
  233. X
  234. X     8.5.  Stopping Plotting
  235. X
  236. X     If plotting is on, then selecting the Plot field in the top section will
  237. X     turn plotting off. You may pick Plot again and resume with the same fields
  238. X     by selecting "Begin plotting" again.
  239. X
  240. X     Note that due to internal buffering the plot file will not be completely
  241. X     written to disk until plotting is turned off.
  242. X
  243. X     9.  Listing
  244. X
  245. X     This feature works very much like Plotting. However, the fields you select
  246. X     define columns of a table generated as ephem runs. These columns are look
  247. X     exactly like their corresponding fields on the ephem screen and so are far
  248. X     more readable than plot files.
  249. X
  250. X     See the section on Plotting for an explanation of the quick-choice menu.
  251. X     The general operation is very much the same.
  252. X
  253. X     10.  Watching
  254. X
  255. X     You may generate a simple drawing on the screen of the local sky in two
  256. X     forms or the solar system by selecting "Watch".  It will bring up a
  257. X     quick-choice menu as follows:
  258. X
  259. X     Select: Sky dome, Alt/az sky, Solar system, No trails
  260. X
  261. X
  262. X     10.1.  Trails
  263. X
  264. X     You may either erase after each iteration or leave the tags up, referred
  265. X     to as "trails". Picking the right-most choice will toggle between "No
  266. X     trails" and "Leave trails"; you should set it as desired before you select
  267. X     the style of sky plot you wish.  Ephem will remember your selection.
  268. X
  269. X     10.2.  Sky dome
  270. X
  271. X     This draws the currently active planets within a circle that represents
  272. X     the locally visible hemisphere.  This is similar to the formats commonly
  273. X     used in the popular astronomy magazines.  East is left, south is down,
  274. X     west is right and north is up.
  275. X
  276. X     10.3.  Alt/az sky
  277. X
  278. X     This is a cylindrical projection showing the currently active planets as
  279. X     they would appear in the sky looking southwards at the current time and
  280. X     date.  The coordinate system is such that 0 degrees azimuth (north)
  281. X     through 360 degrees (north, once around) is mapped to the horizontal
  282. X     screen dimension, and 0 degrees altitude (level) through 90 degrees (the
  283. X     zenith) is mapped to the vertical dimension. Thus, the bottom row is the
  284. X     horizon and all across the top is the zenith.
  285. X
  286. X
  287. X
  288. X
  289. X
  290. X
  291. X
  292. X
  293. X
  294. X
  295. X
  296. X
  297. X                                       - 20 -
  298. X
  299. X
  300. X     10.4.  Solar System
  301. X
  302. X     This selection draws the currently active planets as they would appear
  303. X     looking "down from the top" of the ecliptic, with the sun at the center
  304. X     and zero hours right ascension towards the right.  The scale is adjusted
  305. X     to roughly fill the screen according to the outer-most active planet.
  306. X     Note that the scaling does not take into account the distances of the user
  307. X     defined objects so, if they don't appear, select a planet that is at least
  308. X     as far out as they are.  The screen transformation assumes a screen aspect
  309. X     width/height ratio of 4/3.  Down the left column of the screen is the
  310. X     heliocentric altitude of the planet above or below the ecliptic, drawn to
  311. X     the same scale as the circular display.  Values so close as to land on the
  312. X     same line are sorted left to right; the S and E symbols always denote
  313. X     heliocentric altitude 0.
  314. X
  315. X     In each style of display, pressing RETURN advances the time by whatever
  316. X     amount StpSz is set to.  Pressing "h" advances the time by one hour, "d"
  317. X     advances by one day, and "w" advances by one week (seven days).  Pressing
  318. X     "q" returns to the watch quick-choice menu from which you may select
  319. X     another display style or return to the main tabular display by typing
  320. X     another "q".  Pressing any other key starts an automatic loop with each
  321. X     step advancing by StpSz; pressing any key stops the looping.
  322. X
  323. X     As symbols are placed, collisions (overstrikes) are avoided by moving
  324. X     characters in such a way as to maintain increasing sorted order towards
  325. X     the right.
  326. X
  327. X     When you return to the main menu, the last watched time will be maintained
  328. X     as the current time.  The StpSz is not changed.
  329. X
  330. X     11.  Searching
  331. X
  332. X     Ephem can search for arbitrary conditions to exist among most displayed
  333. X     fields.  You first enter a function, then select from among three forms of
  334. X     equation solvers to iteratively solve for the next time when the function
  335. X     meets the requirements of the solver. The solver selects the next time for
  336. X     which it wants the function evaluated and sets StpSz so that the next
  337. X     iteration will occur at that time. The solvers continue to iterate until
  338. X     either they achieve their goal or NStep reaches 0.
  339. X
  340. X     You may set NStep to be quite large and let ephem search unattended or set
  341. X     it to 1 and watch it converge one step at a time. You may also plot at the
  342. X     same time as search to record the exact steps ephem took to converge.
  343. X     (But recall that screen updates are suppressed if plotting is also on).
  344. X
  345. X     The "Search" selection in the top half of the screen controls all
  346. X     searching.  Picking it brings up a quick-choice menu as follows:
  347. X
  348. X     Select: Find extreme, Find 0, Binary, New function, Accuracy
  349. X
  350. X
  351. X     11.1.  Find extreme
  352. X
  353. X     This search algorithm searches for a local maximum or a minimum in the
  354. X
  355. X
  356. X
  357. X
  358. X
  359. X
  360. X
  361. X
  362. X
  363. X                                       - 21 -
  364. X
  365. X
  366. X     search function, whichever it finds first. It begins by evaluating the
  367. X     search function at the current time then for two more times each separated
  368. X     by StpSz. It then fits these three points to a parabola and solves it for
  369. X     the time of its maximum (or minimum). StpSz is set so that the next
  370. X     iteration will evaluate at this point.  This parabolic fit solution keeps
  371. X     repeating until StpSz changes by less than the desired accuracy or until
  372. X     the curve becomes so flat that an extrema appears too broad to find.
  373. X
  374. X     11.2.  Find 0
  375. X
  376. X     This search algorithm uses the secant method to solve for the time at
  377. X     which the search function is zero. The function is evaluated at the
  378. X     current time and then again StpSz later to establish a slope for which the
  379. X     x-intercept is found as the next zero guess. This is used to set StpSz for
  380. X     the next desired time value and the slope hunting process repeats until
  381. X     StpSz changes by less than the desired accuracy.
  382. X
  383. X     11.3.  Binary
  384. X
  385. X     This search algorithm must be used with a search function that yields a
  386. X     boolean result, ie, a true or false value. The idea is that the function
  387. X     is assumed to be one truth value when evaluated at the present time, and
  388. X     the opposite truth value when it is evaluated StpSz later. The algorithm
  389. X     will then do a binary search for the time when the truth value changes.
  390. X
  391. X     The binary algorithm does not begin until the state change is bounded in
  392. X     time.  Initially, as long as the truth value at StpSz is the same as the
  393. X     previous value the algorithm will just keep moving in time by StpSz
  394. X     looking for when the state changes.  That is, a linear search is initiated
  395. X     to bound the state change, then the binary search proceeds.
  396. X
  397. X     11.4.  Define a New function
  398. X
  399. X     Select "New function" to display the current search function.  If you type
  400. X     "q" it will be left unchanged.  If you type RETURN it will be erased.  If
  401. X     you type anything else it will be compiled and, if there are no errors, it
  402. X     will become the new search function.  Once a valid function has been
  403. X     stored, it will remain unless changed.  If a search function is selected
  404. X     and there is as yet no valid search function defined, you will
  405. X     automatically be asked to enter one as though you had selected "New
  406. X     function."
  407. X
  408. X     A search function consists of intrinsic functions, field-specifiers,
  409. X     constants and operators, and precedence may be overridden with
  410. X     parentheses.
  411. X
  412. X
  413. X     11.4.1.  Intrinsic functions
  414. X
  415. X     In this release, the only intrinsic functions available are abs(), which
  416. X     returns the absolute value of its argument, and sqrt(), which returns the
  417. X     square root of its argument.
  418. X
  419. X
  420. X
  421. X
  422. X
  423. X
  424. X
  425. X
  426. X
  427. X
  428. X
  429. X                                       - 22 -
  430. X
  431. X
  432. X     11.4.2.  Field Specifiers
  433. X
  434. X     A field in the bottom half of the menu is generally specified in the form
  435. X     of "object_name.column_name". The object_name is enough of the planet or
  436. X     moon name to be unique.  Use "x" or "y" for the user-specified object X or
  437. X     Y.  The column_name is from the following table, depending on which menu
  438. X     is up. In all cases additional characters may be entered but are ignored.
  439. X     Also, you may use x, y and z to specify those columns of the Galilean
  440. X     moons menu.
  441. X
  442. X     Planet Data Menu        Rise/Set Menu               Separation Menu
  443. X     ------------------      --------------------        ---------------
  444. X     al      Alt             hr      Hrs Up, or          j       Jup
  445. X     az      Az              hu      Hrs Up              ma      Mars
  446. X     d       Dec             raz     Rise Az             me      Merc
  447. X     ed      Ea Dst          rt      Rise Time           mo      Moon
  448. X     el      Elong           saz     Set Az              n       Nep
  449. X     hla     Helio Lat       st      Set Time            pl      Pluto
  450. X     hlo     Helio Long      ta      Transit Alt         sa      Saturn
  451. X     ph      Phs             tt      Transit Time        su      Sun
  452. X     ra      R.A.                                        u       Uranus
  453. X     sd      Sn Dst                                      ve      Venus
  454. X     si      Size
  455. X     vm      VMag
  456. X
  457. X
  458. X     A few fields do not use this "dot" notation.  The following top-half
  459. X     fields are indicated using these codes:
  460. X
  461. X     da      Dawn
  462. X     du      Dusk
  463. X     n       NiteLn
  464. X
  465. X
  466. X     Use "jI" and "jII" to indicate one of the two rotational systems of
  467. X     Jupiter's central meridian longitude.
  468. X
  469. X     Remember, searching may only involve fields being calculated for display
  470. X     at the time the solver is active.  While you can syntactically include any
  471. X     field in a search function it is useless to define a search that uses
  472. X     fields from other than the menu that is selected at the time the search is
  473. X     running.
  474. X
  475. X     11.4.3.  Constants
  476. X
  477. X     Constants may be integers or floating point numbers. The latter may be
  478. X     expressed in scientific notation if desired. Examples include 100, .9,
  479. X     1.234, 1e10 and 1.2e-4.  Any number may be preceded by - to make it
  480. X     negative.
  481. X
  482. X     11.4.4.  Operators
  483. X
  484. X     The collection of arithmetic, relational and boolean operators provided
  485. X     mimics those of C language as listed in the following table, in decreasing
  486. X
  487. X
  488. X
  489. X
  490. X
  491. X
  492. X
  493. X
  494. X
  495. X                                       - 23 -
  496. X
  497. X
  498. X     order of precedence.  Operators grouped together have the same precedence
  499. X     and all have left-to-right associativity. Parentheses may be used as
  500. X     desired.
  501. X
  502. X     Symbol  Meaning                 Resulting type
  503. X     ------  --------------------    --------------
  504. X     *       multiply                arithmetic
  505. X     /       divide                  arithmetic
  506. X
  507. X     +       add                     arithmetic
  508. X     -       subtract                arithmetic
  509. X
  510. X     >       greater than            boolean
  511. X     >=      greater than or equal   boolean
  512. X     <       less than               boolean
  513. X     <=      less than or equal      boolean
  514. X
  515. X     ==      equality                boolean
  516. X     !=      inequality              boolean
  517. X
  518. X     &&      logical and             boolean
  519. X
  520. X     ||      logical or              boolean
  521. X
  522. X
  523. X     11.5.  Specifying Search Accuracy
  524. X
  525. X     Selecting "Accuracy" allows you to specify when the search will stop.  The
  526. X     search algorithms will stop when StpSz becomes equal to or less than this
  527. X     value. The default is one minute.  If ephem has not yet converged to the
  528. X     specified accuracy but NStep has decremented to 1, the searching will stop
  529. X     but the search status field will still indicate which search procedure is
  530. X     in effect. To try more iterations you may increase NStep and resume
  531. X     searching. If the accuracy was achieved, the search status field will
  532. X     switch to "off" with the number of "unused" steps remaining in NStep and
  533. X     the last step size in the StpSz fields.
  534. X
  535. X     11.6.  Stop
  536. X
  537. X     If searching is on, this option will also appear on the quick-choice menu
  538. X     and may be selected to turn off the search.
  539. X
  540. X     11.7.  Example Searches
  541. X
  542. X     As an example, let's find when Pluto again becomes the furthest planet
  543. X     from Sol.  You may find when the difference in their sun distance is zero,
  544. X     or you might use a binary search on the condition that Pluto's sun
  545. X     distance is larger then Neptune's.
  546. X
  547. X     To try the former approach select Search, select "Find 0", specify the
  548. X     search function to be:
  549. X
  550. X     pl.sd - nep.sd
  551. X
  552. X
  553. X
  554. X
  555. X
  556. X
  557. X
  558. X
  559. X
  560. X
  561. X                                       - 24 -
  562. X
  563. X
  564. X     set StpSz to something large like 10d, NStep to allow several iterations
  565. X     like 20, and then type "q" to start the search and watch ephem do the
  566. X     hunt.  Ephem will settle on about 21:02 1/10/1999 UT.
  567. X
  568. X     To try a binary search, you first need to have some idea of when the event
  569. X     will occur so you can eliminate the initial linear search for the state
  570. X     change. We can start at, say, 1/1/1999, set StpSz to 30d, select Binary
  571. X     search, specify the search function to be:
  572. X
  573. X     pl.sd > nep.sd
  574. X
  575. X     and go. Once it brackets the state change note how StpSz keeps being cut
  576. X     in half but can go in either direction (sign) as it divides each interval
  577. X     in half.  Ephem will converge on the same answer.
  578. X
  579. X     11.8.  Another Example
  580. X
  581. X     To find the time of last quarter moon during December, 1989, use the "Find
  582. X     0" search algorithm to solve "moon.el + 90".  (At last quarter, the moon
  583. X     is 90 degrees west of the sun, or -90 east in ephem's elongation display.)
  584. X     Set the initial time to mid-month, 12/15/1989, StpSz to 1 day and NStep to
  585. X     10. Ephem takes only a few iterations to settle on 23:57 12/19 UT.
  586. X
  587. X     11.9.  Caution
  588. X
  589. X     Beware that most celestial phenomena are generally pseudo-periodic in
  590. X     nature.  In early search steps ephem can easily skip over a local maxima
  591. X     and find a later one, which, while correct, may not be what was desired.
  592. X     In general, the closer you can be when you start the search the better
  593. X     ephem can refine it; it is not as good with very broad searches that can
  594. X     go "wild". Set StpSz large enough to offer significant change in the
  595. X     function value, but small enough not to skip too far.
  596. X
  597. X     For example, Saturn and Neptune had three close approaches during 1989.
  598. X     If you did not know this then just asking ephem to find a minimum would
  599. X     have produced different results depending on the starting conditions.
  600. X     When starting a search for a certain class of event it is a good idea to
  601. X     first use the plotting or watching facility of ephem to get a broad
  602. X     picture of the general circumstances then use ephem's search facility to
  603. X     refine a given region (or create and inspect a plot file and do your own
  604. X     interpolation directly from it separately).
  605. X
  606. X     Similarly, ephem's searching techniques are not good for eclipses because
  607. X     the moon and sun are close every month; the trick is sorting through the
  608. X     frequent conjunctions for ones that are particularly close. One needs a
  609. X     way of establishing an envelope fit to the local extrema of a cyclic
  610. X     function in order to find a more global extreme.
  611. X
  612. X     12.  Implementation Notes
  613. X
  614. X     Remember that everything is for the current local time and day. So, for
  615. X     example, the calendar marks moon events in local time; commercial
  616. X     calendars usually mark the UT date.  Similarly, the rise/set times are for
  617. X     the current local day.
  618. X
  619. X
  620. X
  621. X
  622. X
  623. X
  624. X
  625. X
  626. X
  627. X                                       - 25 -
  628. X
  629. X
  630. X     The program uses a horizontal plane tangent to the earth as the horizon
  631. X     for all altitude calculations, rise/set events, etc.  This is not the same
  632. X     as the angle up from the local horizon unless the observer is directly on
  633. X     the ground due to earth's curvature.  The effect can be found from:
  634. X
  635. X             sin(a)**2 = (h**2 + 2Rh) / (R+h)**2
  636. X         where:
  637. X             R = radius of earth
  638. X             h = height above ground (same units as R)
  639. X             a = increase in altitude
  640. X
  641. X     For example, the effect is more than two arc minutes at a height of 5
  642. X     feet.
  643. X
  644. X     Visual magnitudes are not very accurate ... I haven't bothered to fix.
  645. X
  646. X     The accuracy of ephem can not be specifically stated since the Duffett-
  647. X     Smith book does not warrant its planet position polynomials to any given
  648. X     degree. I know for sure that better accuracy could be achieved if ephem
  649. X     used TDT but I have not yet decided on a suitable algorithm.  Allowing for
  650. X     this manually, (see the Wish List section) comparisons with the
  651. X     Astronomical Almanac are often within a few arcseconds.
  652. X
  653. X     The program uses double precision throughout. While this precision might
  654. X     seem a little ridiculous, it is actually more efficient for most
  655. X     traditional K&R C compilers and the search functions seem to be are far
  656. X     more stable.
  657. X
  658. X     Searching and plotting always use full precision but if neither of these
  659. X     are turned on pure display and watching only recompute a given planets new
  660. X     location if the time has changed enough to effect the required display
  661. X     precision, based on the planets mean apparent orbital motion.
  662. X
  663. X     The sun-moon distance is the solution for the third side of a planar
  664. X     triangle whose two other sides are the earth-moon distance and earth-sun
  665. X     distance separated by the angle of elongation.
  666. X
  667. X     Beware of computing with the user-defined objects before they are properly
  668. X     defined.
  669. X
  670. X     If a floating point exception occurs ephem will stop further computations
  671. X     on the current screen update and stop any automatic looping.
  672. X
  673. X     12.1.  Program limits
  674. X
  675. X     The search function is limited to a maximum of 32 instructions (each
  676. X     constant, field spec, and operation is one instruction), with no more than
  677. X     a total of 16 constants and field specs. At run time, the function can not
  678. X     require more than 16 stacked values (due to operator precedence or
  679. X     explicit parenthetical expressions) to evaluate.
  680. X
  681. X     No more than 32 different fields can be tracked simultaneously for
  682. X     plotting and/or searching.
  683. X
  684. X
  685. X
  686. X
  687. X
  688. X
  689. X
  690. X
  691. X
  692. X
  693. X                                       - 26 -
  694. X
  695. X
  696. X     No more than 10 lines may be plotted at once.
  697. X
  698. X     The maximum file name length is 14 characters.
  699. X
  700. X     13.  DOS Installation Procedure
  701. X
  702. X     You must be running DOS V2.0 or later, though somewhere between V2.0 and
  703. X     V3.21 the behavior of control-c to terminate the program was fixed.  An
  704. X     8087 floating point chip will be used if present.
  705. X
  706. X     The distribution floppy contains five files:
  707. X     README describes last minute items and details of this release.
  708. X     MAN.TXT is this manual, hopefully formatted and printable on most any
  709. X     printer.
  710. X     EPHEM.EXE is the executable program.
  711. X     EPHEM.CFG is a sample configuration file.
  712. X     EPHEM.DB is a sample database.
  713. X     To run the program, make working copies of these files in a directory and
  714. X     run "ephem" from that directory.
  715. X
  716. X     13.1.  Setting TZ
  717. X
  718. X     Before running ephem, you should set a DOS environment variable, TZ.  It
  719. X     is is used to establish the timezone name and hours offset whenever the
  720. X     "Now" shorthand is used from ephem, either from the configuration startup
  721. X     file or whenever any time field is changed manually.  Set it in the
  722. X     following form:
  723. X
  724. X          set TZ=SSSnDDD
  725. X
  726. X     where
  727. X
  728. X     SSS  is the 3-letter abbreviation for the local standard timezone;
  729. X
  730. X     n    is a number between -23 to 24 indicating the number of hours that are
  731. X          subtracted from GMT to obtain local standard time;
  732. X
  733. X     DDD  is an optional 3-letter abbreviation for the local daylight savings
  734. X          time zone name. Leave it off if you do not have savings time in your
  735. X          area or it is not currently in effect. If the changeover dates differ
  736. X          from the internal algorithm, just use SSS and n directly.
  737. X
  738. X     For example, in the midwestern United States with savings times set
  739. X     TZ=CST6CDT
  740. X
  741. X     If for some reason your system does not change to savings time at the
  742. X     right time, then omit the DDD parameter and just set the SSS and n to
  743. X     exactly what you want.
  744. X
  745. X     You can put this in your AUTOEXEC.BAT file so it gets set each time you
  746. X     boot DOS.
  747. X
  748. X
  749. X
  750. X
  751. X
  752. X
  753. X
  754. X
  755. X
  756. X
  757. X
  758. X
  759. X                                       - 27 -
  760. X
  761. X
  762. X     14.  Known Bugs and Wish List
  763. X
  764. X     incorporate Terrestrial Dynamical Time (known as Ephemeris Time prior to
  765. X     1984).  TDT is about 57 seconds ahead of UT1 in 1990.
  766. X
  767. X     it's too easy to turn on objx/y before it's defined and bomb out.
  768. X
  769. X     add explicit searching for eclipses and occultations.
  770. X
  771. X     in watch mode, RTC reverts back to being based off the time when watch was
  772. X     first entered.
  773. X
  774. X     add a facility (or tool) to find g/k from a set of observed magnitudes.
  775. X
  776. X     add search criteria and a screen-based selection mechanism for database
  777. X     objects.
  778. X
  779. X     add plot options to reverse x and/or y direction and add some tick marks.
  780. X
  781. X     continue pursuit of moon and other information for other planets.
  782. X
  783. X     add shorthands for some sidereal and synodic step sizes.
  784. X
  785. X     the built-in elements for pluto need to be updated. the elements for pluto
  786. X     in the included ephem.db database sampler are more accurate.
  787. X
  788. X     plotting or listing rise/set that doesn't happen just reshows the last
  789. X     entry.
  790. X
  791. X
  792. X
  793. X
  794. X
  795. X
  796. X
  797. X
  798. X
  799. X
  800. X
  801. X
  802. X
  803. X
  804. X
  805. X
  806. X
  807. X
  808. X
  809. X
  810. X
  811. X
  812. X
  813. X
  814. X
  815. X
  816. X
  817. X
  818. X
  819. X
  820. X
  821. X
  822. X
  823. X
  824. X
  825. X                                       - 28 -
  826. X
  827. X
  828. X     15.  Sample Screens
  829. X
  830. X     Here are sample ephem screens. They are generated using the first sample
  831. X     ephem.cfg file (listed in the section describing the configuration file).
  832. X     There is one for each of the possible screen formats.  The rise/set screen
  833. X     was done using the Adaptive option.  The separations screen was done using
  834. X     the Topocentric option.
  835. X
  836. X
  837. X
  838. XMove to another field, RETURN to change this field, ? for help, or q to run
  839. X
  840. XCDT 19:00:00  4/30/1990 | LST    8:19:50 | Lat   44:50:37 |      April 1990
  841. XUTC  0:00:00  5/01/1990 |                | Long  93:42:08 | Su Mo Tu We Th Fr Sa
  842. XJulianDat 2448012.50000 | Dawn      4:10 | Elev    800 ft |  1  2  3  4  5  6  7
  843. XWatch                   | Dusk     22:15 | Temp      40 F |  8 FM 10 11 12 13 14
  844. XListing             off | NiteLn    5:55 | AtmPr 29.50 in | 15 16 17 18 19 20 21
  845. XSearch              off |                | TZ     5:00:00 | 22 23 NM 25 26 27 28
  846. XPlot                off | NStep        1 | Epoch   2000.0 | 29 30
  847. XMenu        Planet Data | StpSz RT CLOCK | Pause        0 |
  848. X--------------------------------------------------------------------------------
  849. XOCX  R.A.    Dec    Az     Alt  H Long H Lat  Ea Dst Sn Dst Elong  Size VMag Phs
  850. XSu  2:32.3  14:58 278:40  12:38 220:22        1.0075               1905  -27
  851. XMo  8:09.9  21:11 186:06  65:53 119:55   1:04 234821 1.0071   79.5 1897  -12  44
  852. 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
  853. 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
  854. 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
  855. 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
  856. 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
  857. 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
  858. 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
  859. 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
  860. 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
  861. XY  15:22.9  -2:40  80:43 -12:54 226:17  10:49 2.3635 3.3381 -162.5  0.0 10.1100
  862. X
  863. X
  864. X
  865. X
  866. X
  867. X
  868. X
  869. X
  870. X
  871. X
  872. X
  873. X
  874. X
  875. X
  876. X
  877. X
  878. X
  879. X
  880. X
  881. X
  882. X
  883. X
  884. X
  885. X
  886. X
  887. X
  888. X
  889. X
  890. X
  891. X                                       - 29 -
  892. X
  893. X
  894. XMove to another field, RETURN to change this field, ? for help, or q to run
  895. X
  896. XCDT 19:00:00  4/30/1990 | LST    8:19:50 | Lat   44:50:37 |      April 1990
  897. XUTC  0:00:00  5/01/1990 |                | Long  93:42:08 | Su Mo Tu We Th Fr Sa
  898. XJulianDat 2448012.50000 | Dawn      4:10 | Elev    800 ft |  1  2  3  4  5  6  7
  899. XWatch                   | Dusk     22:15 | Temp      40 F |  8 FM 10 11 12 13 14
  900. XListing             off | NiteLn    5:55 | AtmPr 29.50 in | 15 16 17 18 19 20 21
  901. XSearch              off |                | TZ     5:00:00 | 22 23 NM 25 26 27 28
  902. XPlot                off | NStep        1 | Epoch   2000.0 | 29 30
  903. XMenu      Rise/Set Info | StpSz RT CLOCK | Pause        0 |
  904. X--------------------------------------------------------------------------------
  905. XOCX Rise Time    Rise Az  Trans Time  Trans Alt  Set Time    Set Az    Hours Up
  906. XSu     6:05       67:48     13:12       60:01     20:20      292:28     14:15
  907. XMo    10:54       57:14     18:49       66:01      1:56      304:46     15:02
  908. XMe     6:13       63:34     13:30       62:51     20:47      296:04     14:34
  909. XVe     4:35       93:02     10:29       42:33     16:23      267:14     11:48
  910. XMa     3:57      103:53      9:20       34:52     14:43      256:17     10:45
  911. XJu     9:24       54:59     17:11       68:33      1:00      305:01     15:36
  912. XSa     1:56      119:18      6:31       24:17     11:06      240:42      9:10
  913. XUr     1:01      123:08      5:24       21:47      9:46      236:52      8:45
  914. XNe     1:14      120:39      5:45       23:24     10:16      239:21      9:02
  915. XPl    19:55       91:11      1:57       43:46      7:55      268:48     12:00
  916. XX      1:41       32:26     10:51       81:10     20:00      327:20     18:19
  917. XY     20:08       92:55      2:06       42:29      7:59      267:01     11:50
  918. X
  919. X
  920. X
  921. XMove to another field, RETURN to change this field, ? for help, or q to run
  922. X
  923. XCDT 19:00:00  4/30/1990 | LST    8:19:50 | Lat   44:50:37 |      April 1990
  924. XUTC  0:00:00  5/01/1990 |                | Long  93:42:08 | Su Mo Tu We Th Fr Sa
  925. XJulianDat 2448012.50000 | Dawn      4:10 | Elev    800 ft |  1  2  3  4  5  6  7
  926. XWatch                   | Dusk     22:15 | Temp      40 F |  8 FM 10 11 12 13 14
  927. XListing             off | NiteLn    5:55 | AtmPr 29.50 in | 15 16 17 18 19 20 21
  928. XSearch              off |                | TZ     5:00:00 | 22 23 NM 25 26 27 28
  929. XPlot                off | NStep        1 | Epoch   2000.0 | 29 30
  930. XMenu        Separations | StpSz RT CLOCK | Pause        0 |
  931. X--------------------------------------------------------------------------------
  932. XOCX Sun  Moon   Merc  Venus  Mars   Jup    Sat  Uranus  Nep  Pluto    X     Y
  933. XSu        79:32   4:52 43:59  62:55 56:31   105:  121:   116:  163:  38:21  162:
  934. XMo  79:32        74:49  124:   142: 23:01   175:  160:   164:  106:  99:52  108:
  935. XMe   4:52 74:49        48:43  67:39 51:50   110:  126:   121:  163:  39:57  163:
  936. XVe  43:59  124:  48:43        18:56  100:  61:09 77:00  71:58  129:  38:49  126:
  937. XMa  62:55  142:  67:39 18:56         119:  42:14 58:04  53:04  111:  50:48  108:
  938. XJu  56:31 23:01  51:50  100:   119:         162:  177:   172:  128:  80:40  130:
  939. XSa   105:  175:   110: 61:09  42:14  162:        15:52  10:50 69:37  83:36 67:17
  940. XUr   121:  160:   126: 77:00  58:04  177:  15:52         5:11 54:43  97:18 52:21
  941. XNe   116:  164:   121: 71:58  53:04  172:  10:50  5:11        59:06  92:24 56:46
  942. XPl   163:  106:   163:  129:   111:  128:  69:37 54:43  59:06         125:  2:22
  943. XX   38:21 99:52  39:57 38:49  50:48 80:40  83:36 97:18  92:24  125:         124:
  944. XY    162:  108:   163:  126:   108:  130:  67:17 52:21  56:46  2:22   124:
  945. X
  946. X
  947. X
  948. X
  949. X
  950. X
  951. X
  952. X
  953. X
  954. X
  955. X
  956. X
  957. X                                       - 30 -
  958. X
  959. X
  960. XMove to another field, RETURN to change this field, ? for help, or q to run
  961. X
  962. XCDT 19:00:00  4/30/1990 | LST    8:19:50 | Lat   44:50:37 |      April 1990
  963. XUTC  0:00:00  5/01/1990 |                | Long  93:42:08 | Su Mo Tu We Th Fr Sa
  964. XJulianDat 2448012.50000 | Dawn      4:10 | Elev    800 ft |  1  2  3  4  5  6  7
  965. XWatch                   | Dusk     22:15 | Temp      40 F |  8 FM 10 11 12 13 14
  966. XListing             off | NiteLn    5:55 | AtmPr 29.50 in | 15 16 17 18 19 20 21
  967. XSearch              off |                | TZ     5:00:00 | 22 23 NM 25 26 27 28
  968. XPlot                off | NStep        1 | Epoch   2000.0 | 29 30
  969. XMenu        Jupiter Aux | StpSz RT CLOCK | Pause        0 |
  970. X--------------------------------------------------------------------------------
  971. X
  972. X     Central Meridian Longitude (degs):   337.545 (Sys I)  267.021 (Sys II)
  973. X               (GRS is at approximately 30 degs in System II)
  974. X
  975. X                                        Jupiter Radii
  976. X                            X (+E)         Y (+N)      Z (+towards)
  977. X        I   Io               0.950         -0.181         -5.808
  978. X        II  Europa          -4.052          0.261          8.384
  979. X        III Ganymede        -8.502          0.385         12.350
  980. X        IV  Callisto        26.029          0.160          5.119
  981. X
  982. X                           G     E     JI                                    C
  983. X West                                                                     East
  984. X
  985. X
  986. X
  987. X
  988. X
  989. X
  990. X
  991. X
  992. X
  993. X
  994. X
  995. X
  996. X
  997. X
  998. X
  999. X
  1000. X
  1001. X
  1002. X
  1003. X
  1004. X
  1005. X
  1006. X
  1007. X
  1008. X
  1009. X
  1010. X
  1011. X
  1012. X
  1013. X
  1014. X
  1015. X
  1016. X
  1017. X
  1018. X
  1019. X
  1020. END_OF_FILE
  1021.   if test 37262 -ne `wc -c <'Man.txt.b'`; then
  1022.     echo shar: \"'Man.txt.b'\" unpacked with wrong size!
  1023.   fi
  1024.   # end of 'Man.txt.b'
  1025. fi
  1026. if [ -f Man.txt.a ]
  1027. then
  1028.         echo adding Man.txt.b to Man.txt.a to form Man.txt
  1029.         cat Man.txt.a Man.txt.b > Man.txt
  1030.         echo removing Man.txt.a and Man.txt.b
  1031.         rm Man.txt.a Man.txt.b
  1032. fi
  1033. if test -f 'nutation.c' -a "${1}" != "-c" ; then 
  1034.   echo shar: Will not clobber existing file \"'nutation.c'\"
  1035. else
  1036.   echo shar: Extracting \"'nutation.c'\" \(2011 characters\)
  1037.   sed "s/^X//" >'nutation.c' <<'END_OF_FILE'
  1038. X#include <stdio.h>
  1039. X#include <math.h>
  1040. X#include "astro.h"
  1041. X
  1042. X/* given the modified JD, mjd, find the nutation in obliquity, *deps, and
  1043. X * the nutation in longitude, *dpsi, each in radians.
  1044. X */
  1045. Xnutation (mjd, deps, dpsi)
  1046. Xdouble mjd;
  1047. Xdouble *deps, *dpsi;
  1048. X{
  1049. X    static double lastmjd = -10000, lastdeps, lastdpsi;
  1050. X    double ls, ld;    /* sun's mean longitude, moon's mean longitude */
  1051. X    double ms, md;    /* sun's mean anomaly, moon's mean anomaly */
  1052. X    double nm;    /* longitude of moon's ascending node */
  1053. X    double t, t2;    /* number of Julian centuries of 36525 days since
  1054. X             * Jan 0.5 1900.
  1055. X             */
  1056. X    double tls, tnm, tld;    /* twice above */
  1057. X    double a, b;    /* temps */
  1058. X
  1059. X    if (mjd == lastmjd) {
  1060. X        *deps = lastdeps;
  1061. X        *dpsi = lastdpsi;
  1062. X        return;
  1063. X    }
  1064. X        
  1065. X    t = mjd/36525.;
  1066. X    t2 = t*t;
  1067. X
  1068. X    a = 100.0021358*t;
  1069. X    b = 360.*(a-(long)a);
  1070. X    ls = 279.697+.000303*t2+b;
  1071. X
  1072. X    a = 1336.855231*t;
  1073. X    b = 360.*(a-(long)a);
  1074. X    ld = 270.434-.001133*t2+b;
  1075. X
  1076. X    a = 99.99736056000026*t;
  1077. X    b = 360.*(a-(long)a);
  1078. X    ms = 358.476-.00015*t2+b;
  1079. X
  1080. X    a = 13255523.59*t;
  1081. X    b = 360.*(a-(long)a);
  1082. X    md = 296.105+.009192*t2+b;
  1083. X
  1084. X    a = 5.372616667*t;
  1085. X    b = 360.*(a-(long)a);
  1086. X    nm = 259.183+.002078*t2-b;
  1087. X
  1088. X    /* convert to radian forms for use with trig functions.
  1089. X     */
  1090. X    tls = 2*degrad(ls);
  1091. X    nm = degrad(nm);
  1092. X    tnm = 2*nm;
  1093. X    ms = degrad(ms);
  1094. X    tld = 2*degrad(ld);
  1095. X    md = degrad(md);
  1096. X
  1097. X    /* find delta psi and eps, in arcseconds.
  1098. X     */
  1099. X    lastdpsi = (-17.2327-.01737*t)*sin(nm)+(-1.2729-.00013*t)*sin(tls)
  1100. X           +.2088*sin(tnm)-.2037*sin(tld)+(.1261-.00031*t)*sin(ms)
  1101. X           +.0675*sin(md)-(.0497-.00012*t)*sin(tls+ms)
  1102. X           -.0342*sin(tld-nm)-.0261*sin(tld+md)+.0214*sin(tls-ms)
  1103. X           -.0149*sin(tls-tld+md)+.0124*sin(tls-nm)+.0114*sin(tld-md);
  1104. X    lastdeps = (9.21+.00091*t)*cos(nm)+(.5522-.00029*t)*cos(tls)
  1105. X           -.0904*cos(tnm)+.0884*cos(tld)+.0216*cos(tls+ms)
  1106. X           +.0183*cos(tld-nm)+.0113*cos(tld+md)-.0093*cos(tls-ms)
  1107. X           -.0066*cos(tls-nm);
  1108. X
  1109. X    /* convert to radians.
  1110. X     */
  1111. X    lastdpsi = degrad(lastdpsi/3600);
  1112. X    lastdeps = degrad(lastdeps/3600);
  1113. X
  1114. X    lastmjd = mjd;
  1115. X    *deps = lastdeps;
  1116. X    *dpsi = lastdpsi;
  1117. X}
  1118. END_OF_FILE
  1119.   if test 2011 -ne `wc -c <'nutation.c'`; then
  1120.     echo shar: \"'nutation.c'\" unpacked with wrong size!
  1121.   fi
  1122.   # end of 'nutation.c'
  1123. fi
  1124. if test -f 'watch.c' -a "${1}" != "-c" ; then 
  1125.   echo shar: Will not clobber existing file \"'watch.c'\"
  1126. else
  1127.   echo shar: Extracting \"'watch.c'\" \(12217 characters\)
  1128.   sed "s/^X//" >'watch.c' <<'END_OF_FILE'
  1129. X/* these functions allow you to watch the sky or the solar system via a
  1130. X * simple character-graphics representation on the screen. 
  1131. X * the interaction starts by using the current time. then control with
  1132. X *    END returns to table form; or
  1133. X *    RETURN advances time by one StpSz; or
  1134. X *    h advances once by 1 hour; or
  1135. X *    d advances once by 24 hours (1 day); or
  1136. X *    w advances once by 7 days (1 week); or
  1137. X *    any other key free runs by StpSz until any key is hit.
  1138. X */
  1139. X
  1140. X#include <stdio.h>
  1141. X#include <math.h>
  1142. X#include "astro.h"
  1143. X#include "circum.h"
  1144. X#include "screen.h"
  1145. X
  1146. X#define    SSZCOL    1        /* column to show solar system z coords */
  1147. X#define    PARK_ROW    1    /* cursor park loc after each screen */
  1148. X#define    PARK_COL    NC    /* cursor park loc after each screen */
  1149. X
  1150. X#define    DOMESKY        0    /* flags for watch_sky() */
  1151. X#define    ALTAZSKY    1    /* flags for watch_sky() */
  1152. X
  1153. X#define    SKYACC    3600.    /* desired sky plot accuracy, in arc seconds */
  1154. X#define    SSACC    3600.    /* desired solar system plot accuracy, in arc secs */
  1155. X
  1156. X/* macros to convert row(col) in range 1..NR(1..NC) to fraction in range 0..1 */
  1157. X#define    NEARONE        0.9999999
  1158. X#define    r2fr(r)        (((r)-1)/(NEARONE*NR)+1/NC/2)
  1159. X#define    c2fc(c)        (((c)-1)/(NEARONE*NC)+1/NC/2)
  1160. X#define    fr2r(fr)    ((int)((fr)*(NEARONE*NR))+1)
  1161. X#define    fc2c(fc)    ((int)((fc)*(NEARONE*NC))+1)
  1162. X
  1163. X/* single-character tag for each body.
  1164. X * order must match the #defines in astro.h and screen.h additions.
  1165. X */
  1166. Xstatic char body_tags[] = "evmjsunpSMxy";
  1167. X
  1168. X/* multiple and single loop prompts */
  1169. Xstatic char frprompt[] = "Running... press any key to stop.";
  1170. Xstatic char qprompt[]  =
  1171. X"q to quit, RETURN/h/d/w to step by StpSz/hr/day/wk, or any other to freerun";
  1172. X
  1173. X/* used to locate, record and then erase last plotted chars */
  1174. Xtypedef struct {
  1175. X    double l_fr, l_fc;    /* 2d coords as 0..1 (upper left corner is (0,0)) */
  1176. X    int     l_r, l_c;    /* screen 2d coords (upper left corner is [1,1]) */
  1177. X    char l_tag;        /* char to use to print on screen */
  1178. X} LastDraw;
  1179. X
  1180. Xstatic int trails;    /* !0 if want to leave trails */
  1181. X
  1182. Xwatch (np, tminc, wbodies)
  1183. XNow *np;    /* time now and on each step */
  1184. Xdouble tminc;    /* hrs to increment time by each step */
  1185. Xint wbodies;    /* each bit is !=0 if want that body */
  1186. X{
  1187. X    static char *flds[4] = {
  1188. X        "Sky dome", "Alt/az sky", "Solar system"
  1189. X    };
  1190. X    static int fn;    /* begin with 0, then remember for next time */
  1191. X    int didone = 0;
  1192. X
  1193. X    while (1) {
  1194. X        int nf;
  1195. X        flds[3] = trails ? "Leave trails" : "No trails";
  1196. X        if ((nf = popup (flds, fn, 4)) < 0)
  1197. X        break;
  1198. X        fn = nf;
  1199. X        switch (nf) {
  1200. X        case 0: watch_sky (DOMESKY, np, tminc, wbodies); didone = 1; break;
  1201. X        case 1: watch_sky (ALTAZSKY, np, tminc, wbodies); didone = 1; break;
  1202. X        case 2: watch_solarsystem (np, tminc, wbodies); didone = 1; break;
  1203. X        case 3: trails ^= 1; break;
  1204. X        }
  1205. X    }
  1206. X
  1207. X    if (didone)
  1208. X        redraw_screen(2);
  1209. X}
  1210. X
  1211. X/* full alt/az or dome sky view (like the popular astro mags).
  1212. X * alt/az: north is at left and right of screen, south at center.
  1213. X *   0 elevation is at bottom of screen, zenith at the top.
  1214. X * dome: east is left, north is up.
  1215. X */
  1216. Xstatic
  1217. Xwatch_sky (style, np, tminc, wbodies)
  1218. Xint style;    /* DOMESKY or ALTAZSKY */
  1219. XNow *np;    /* time now and on each step */
  1220. Xdouble tminc;    /* hrs to increment time by each step */
  1221. Xint wbodies;    /* each bit is !=0 if want */
  1222. X{
  1223. X    static char east[] = "East";
  1224. X    static char west[] = "West";
  1225. X    static char north[] = "North";
  1226. X    static char south[] = "South";
  1227. X    double tminc0 = tminc;    /* remember the original */
  1228. X    /* two draw buffers so we can leave old up while calc new then
  1229. X     * erase and draw in one quick operation. always calc new in newp
  1230. X     * buffer and erase previous from lastp. buffers alternate roles.
  1231. X     */
  1232. X    LastDraw ld0[NOBJ], ld1[NOBJ], *lp, *lastp = ld0, *newp = ld1;
  1233. X    int nlast = 0, nnew;
  1234. X    int once = 1;
  1235. X    double lmjd, tmp;
  1236. X    Sky s;
  1237. X    int p;
  1238. X
  1239. X    /* clear screen and put up the permanent labels */
  1240. X    c_erase();
  1241. X    if (style == DOMESKY) {
  1242. X        double a;
  1243. X        for (a = 0.0; a < 2*PI; a += PI/8)
  1244. X        f_char (fr2r(.5-sin(a)/2.),
  1245. X            fc2c(.5+cos(a)/2./ASPECT) + ((a>PI/2 && a<3*PI/2) ? -1 : 1),
  1246. X            '*');
  1247. X        f_string (fr2r(.5), fc2c(.5-.5/ASPECT)-7, "East");
  1248. X        f_string (fr2r(1.), fc2c(.5)-2, south);
  1249. X        f_string (fr2r(.5), fc2c(.5+.5/ASPECT)+4, "West");
  1250. X        f_string (2, NC/2-2, north);
  1251. X    } else {
  1252. X        f_string (NR, 1, north);
  1253. X        f_string (NR, NC/4, east);
  1254. X        f_string (NR, NC/2, south);
  1255. X        f_string (NR, 3*NC/4, west);
  1256. X        f_string (NR, NC-5, north);   /* -1 more to avoid scrolling */
  1257. X        f_string (2, NC/2-3, "Zenith");
  1258. X    }
  1259. X    f_string (2, 1, tznm);
  1260. X    f_string (3, 1, "LST");
  1261. X
  1262. X    while (1) {
  1263. X        if (once)
  1264. X        print_updating();
  1265. X
  1266. X        /* calculate desired stuff into newp[] */
  1267. X        nnew = 0;
  1268. X        for (p = nxtbody(-1); p != -1; p = nxtbody(p))
  1269. X        if (wbodies & (1<<p)) {
  1270. X            (void) body_cir (p, SKYACC, np, &s);
  1271. X            if (s.s_alt > 0.0) {
  1272. X            LastDraw *lnp = newp + nnew;
  1273. X            if (style == DOMESKY) {
  1274. X                tmp = 0.5 - s.s_alt/PI;
  1275. X                lnp->l_fr = 0.5 - tmp*cos(s.s_az);
  1276. X                lnp->l_fc = 0.5 - tmp*sin(s.s_az)/ASPECT;
  1277. X            } else {
  1278. X                lnp->l_fr = 1.0 - s.s_alt/(PI/2);
  1279. X                lnp->l_fc = s.s_az/(2*PI);
  1280. X            }
  1281. X            lnp->l_tag = body_tags[p];
  1282. X            nnew++;
  1283. X            }
  1284. X        }
  1285. X        set_screencoords (newp, nnew);
  1286. X
  1287. X        /* unless we want trails,
  1288. X         * erase any previous tags (in same order as written) from lastp[].
  1289. X         */
  1290. X        if (!trails)
  1291. X        for (lp = lastp; --nlast >= 0; lp++)
  1292. X            f_char (lp->l_r, lp->l_c, ' ');
  1293. X
  1294. X        /* print LOCAL time and date we will be using */
  1295. X        lmjd = mjd - tz/24.0;
  1296. X        f_time (2, 5, mjd_hr(lmjd));
  1297. X        f_date (2, 14, mjd_day(lmjd));
  1298. X        now_lst (np, &tmp);
  1299. X        f_time (3, 5, tmp);
  1300. X
  1301. X        /* now draw new stuff from newp[] and park the cursor */
  1302. X        for (lp = newp; lp < newp + nnew; lp++)
  1303. X        f_char (lp->l_r, lp->l_c, lp->l_tag);
  1304. X        c_pos (PARK_ROW, PARK_COL);
  1305. X        fflush (stdout);
  1306. X
  1307. X        /* swap new and last roles and save new count */
  1308. X        if (newp == ld0)
  1309. X        newp = ld1, lastp = ld0;
  1310. X        else
  1311. X        newp = ld0, lastp = ld1;
  1312. X        nlast = nnew;
  1313. X
  1314. X        if (!once)
  1315. X        slp_sync();
  1316. X
  1317. X        if (once || (chk_char()==0 && read_char()!=0)) {
  1318. X        if (readwcmd (tminc0, &tminc, &once) < 0)
  1319. X            break;
  1320. X        }
  1321. X
  1322. X        /* advance time */
  1323. X        inc_mjd (np, tminc);
  1324. X    }
  1325. X}
  1326. X
  1327. X/* solar system view, "down from the top", first point of aries to the right.
  1328. X * always include earth.
  1329. X */
  1330. Xstatic
  1331. Xwatch_solarsystem (np, tminc, wbodies)
  1332. XNow *np;    /* time now and on each step */
  1333. Xdouble tminc;    /* hrs to increment time by each step */
  1334. Xint wbodies;
  1335. X{
  1336. X    /* max au of each planet from sun; in astro.h #defines order */
  1337. X    static double auscale[] = {.38, .75, 1.7, 5.2, 11., 20., 31., 50.};
  1338. X    double tminc0 = tminc;    /* remember the original */
  1339. X    /* two draw buffers so we can leave old up while calc new then
  1340. X     * erase and draw in one quick operation. always calc new in newp
  1341. X     * buffer and erase previous from lastp. buffers alternate roles.
  1342. X     */
  1343. X    LastDraw ld0[2*NOBJ], ld1[2*NOBJ], *lp, *lastp = ld0, *newp = ld1;
  1344. X    int nlast = 0, nnew;
  1345. X    int once = 1;
  1346. X    double lmjd;
  1347. X    double scale;
  1348. X    Sky s;
  1349. X    int p;
  1350. X
  1351. X    /* set screen scale: largest au we will have to plot.
  1352. X     * never make it less than 1 au (with fudge) since we always show earth.
  1353. X     */
  1354. X    scale = 1.1;
  1355. X    for (p = MARS; p <= PLUTO; p++)
  1356. X        if ((wbodies & (1<<p)) && auscale[p] > scale)
  1357. X        scale = auscale[p];
  1358. X
  1359. X    /* clear screen and put up the permanent labels */
  1360. X    c_erase();
  1361. X    f_string (2, 1, tznm);
  1362. X
  1363. X    while (1) {
  1364. X        if (once)
  1365. X        print_updating();
  1366. X
  1367. X        /* calculate desired stuff into newp[].
  1368. X         * fake a sun at center and add earth first.
  1369. X         * (we get earth's loc when ask for sun)
  1370. X         */
  1371. X        nnew = 0;
  1372. X        set_ss (newp+nnew, 0.0, 0.0, 0.0, 'S');
  1373. X        nnew += 2;
  1374. X        (void) body_cir (SUN, SSACC, np, &s);
  1375. X        set_ss (newp+nnew, s.s_edist/scale, s.s_hlong, 0.0, 'E');
  1376. X        nnew += 2;
  1377. X        for (p = MERCURY; p <= PLUTO; p++)
  1378. X        if (p != MOON && (wbodies & (1<<p))) {
  1379. X            (void) body_cir (p, SSACC, np, &s);
  1380. X            set_ss (newp+nnew, s.s_sdist/scale, s.s_hlong, s.s_hlat,
  1381. X                                body_tags[p]);
  1382. X            nnew += 2;
  1383. X        }
  1384. X        for (p = OBJX; p != -1; p = (p == OBJX) ? OBJY : -1)
  1385. X        if (wbodies & (1<<p)) {
  1386. X            (void) body_cir (p, SSACC, np, &s);
  1387. X            if (s.s_hlong != NOHELIO && s.s_sdist <= scale) {
  1388. X            set_ss (newp+nnew, s.s_sdist/scale, s.s_hlong, s.s_hlat,
  1389. X                                body_tags[p]);
  1390. X            nnew += 2;
  1391. X            }
  1392. X        }
  1393. X
  1394. X        set_screencoords (newp, nnew);
  1395. X
  1396. X        /* unless we want trails,
  1397. X         * erase any previous tags (in same order as written) from lastp[].
  1398. X         */
  1399. X        if (!trails)
  1400. X        for (lp = lastp; --nlast >= 0; lp++)
  1401. X            safe_f_char (lp->l_r, lp->l_c, ' ');
  1402. X
  1403. X        /* print LOCAL time and date we will be using */
  1404. X        lmjd = mjd - tz/24.0;
  1405. X        f_time (2, 5, mjd_hr(lmjd));
  1406. X        f_date (2, 14, mjd_day(lmjd));
  1407. X
  1408. X        /* now draw new stuff from newp[] and park the cursor */
  1409. X        for (lp = newp; lp < newp + nnew; lp++)
  1410. X        safe_f_char (lp->l_r, lp->l_c, lp->l_tag);
  1411. X        c_pos (PARK_ROW, PARK_COL);
  1412. X        fflush (stdout);
  1413. X
  1414. X        /* swap new and last roles and save new count */
  1415. X        if (newp == ld0)
  1416. X        newp = ld1, lastp = ld0;
  1417. X        else
  1418. X        newp = ld0, lastp = ld1;
  1419. X        nlast = nnew;
  1420. X
  1421. X        if (!once)
  1422. X        slp_sync();
  1423. X
  1424. X        if (once || (chk_char()==0 && read_char()!=0)) {
  1425. X        if (readwcmd (tminc0, &tminc, &once) < 0)
  1426. X            break;
  1427. X        }
  1428. X
  1429. X        /* advance time */
  1430. X        inc_mjd (np, tminc);
  1431. X    }
  1432. X}
  1433. X
  1434. X/* fill in two LastDraw solar system entries,
  1435. X * one for the x/y display, one for the z.
  1436. X */
  1437. Xstatic
  1438. Xset_ss (lp, dist, lg, lt, tag)
  1439. XLastDraw *lp;
  1440. Xdouble dist, lg, lt;    /* scaled heliocentric distance, longitude and lat */
  1441. Xchar tag;
  1442. X{
  1443. X    lp->l_fr = 0.5 - dist*sin(lg)*0.5;
  1444. X    lp->l_fc = 0.5 + dist*cos(lg)*0.5/ASPECT;
  1445. X    lp->l_tag = tag;
  1446. X    lp++;
  1447. X    /* row is to show course helio altitude but since we resolve collisions
  1448. X     * by adjusting columns we can get more detail by smaller variations
  1449. X     * within one column.
  1450. X     */
  1451. X    lp->l_fr = 0.5 - dist*sin(lt)*0.5;
  1452. X    lp->l_fc = c2fc(SSZCOL) + (1 - lp->l_fr)/NC;
  1453. X    lp->l_tag = tag;
  1454. X}
  1455. X
  1456. X/* given a list of LastDraw structs with their l_{fr,fc} filled in,
  1457. X * fill in their l_{r,c}.
  1458. X * TODO: better collision avoidance.
  1459. X */
  1460. Xstatic
  1461. Xset_screencoords (lp, np)
  1462. XLastDraw lp[];
  1463. Xint np;
  1464. X{
  1465. X    LastDraw *lpi;    /* the current basis for comparison */
  1466. X    LastDraw *lpj;    /* the sweep over other existing cells */
  1467. X    int i;        /* index of the current basis cell, lpi */
  1468. X    int j;        /* index of sweep cell, lpj */
  1469. X    int n;        /* total cells placed so far (ie, # to check) */
  1470. X
  1471. X    /* idea is to place each new item onto the screen.
  1472. X     * after each placement, look for collisions.
  1473. X     * if find a colliding pair, move the one with the greater l_fc to
  1474. X     * the right one cell, then rescan for more collisions.
  1475. X     * this will yield a result that is sorted by columns by l_fc.
  1476. X     * TODO: don't just move to the right, try up too for true 2d adjusts.
  1477. X     */
  1478. X    for (n = 0; n < np; n++) {
  1479. X        lpi = lp + n;
  1480. X        i = n;
  1481. X        lpi->l_r = fr2r(lpi->l_fr);
  1482. X        lpi->l_c = fc2c(lpi->l_fc);
  1483. X      chk:
  1484. X        for (j = 0; j < n; j++) {
  1485. X        lpj = lp + j;
  1486. X        if (i!=j && lpi->l_r == lpj->l_r && lpi->l_c == lpj->l_c) {
  1487. X            if (lpj->l_fc > lpi->l_fc) {
  1488. X            /* move lpj and use it as basis for checks now */
  1489. X            lpi = lpj;
  1490. X            i = j;
  1491. X            }
  1492. X            if (++lpi->l_c > NC)
  1493. X            lpi->l_c = 1;
  1494. X            goto chk;
  1495. X        }
  1496. X        }
  1497. X    }
  1498. X}
  1499. X
  1500. X/* since the solar system scaling is only approximate, and doesn't include
  1501. X * object x/y at all, characters might get mapped off screen. this funtion
  1502. X * guards against drawing chars off screen. it also moves a char being drawn
  1503. X * on the lower right corner of the screem left one to avoid scrolling.
  1504. X */
  1505. Xstatic
  1506. Xsafe_f_char (r, c, tag)
  1507. Xint r, c;
  1508. Xchar tag;
  1509. X{
  1510. X    if (r >= 1 && r <= NR && c >= 1 && c <= NC) {
  1511. X        if (r == NR && c == NC)
  1512. X        c -= 1;
  1513. X        f_char (r, c, tag);
  1514. X    }
  1515. X}
  1516. X
  1517. X/* see what the op wants to do now and update prompt/times accordingly.
  1518. X * return -1 if we are finished, else 0.
  1519. X */
  1520. Xstatic int
  1521. Xreadwcmd (tminc0, tminc, once)
  1522. Xdouble tminc0;
  1523. Xdouble *tminc;
  1524. Xint *once;
  1525. X{
  1526. X    f_prompt (qprompt);
  1527. X
  1528. X    switch (read_char()) {
  1529. X    case END:         /* back to table */
  1530. X        return (-1);
  1531. X    case '\r': case ' ':    /* one StpSz step */
  1532. X        *tminc = tminc0;
  1533. X        *once = 1;
  1534. X        break;
  1535. X    case 'h':        /* one 1-hour step */
  1536. X        *tminc = 1.0;
  1537. X        *once = 1;
  1538. X        break;
  1539. X    case 'd':        /* one 24-hr step */
  1540. X        *tminc = 24.0;
  1541. X        *once = 1;
  1542. X        break;
  1543. X    case 'w':        /* 7 day step */
  1544. X        *tminc = 7*24.0;
  1545. X        *once = 1;
  1546. X        break;
  1547. X    default:        /* free-run */
  1548. X        *once = 0;
  1549. X        f_prompt (frprompt);
  1550. X    }
  1551. X    return (0);
  1552. X}
  1553. END_OF_FILE
  1554.   if test 12217 -ne `wc -c <'watch.c'`; then
  1555.     echo shar: \"'watch.c'\" unpacked with wrong size!
  1556.   fi
  1557.   # end of 'watch.c'
  1558. fi
  1559. echo shar: End of archive 2 \(of 9\).
  1560. cp /dev/null ark2isdone
  1561. MISSING=""
  1562. for I in 1 2 3 4 5 6 7 8 9 ; do
  1563.     if test ! -f ark${I}isdone ; then
  1564.     MISSING="${MISSING} ${I}"
  1565.     fi
  1566. done
  1567. if test "${MISSING}" = "" ; then
  1568.     echo You have unpacked all 9 archives.
  1569.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1570. else
  1571.     echo You still must unpack the following archives:
  1572.     echo "        " ${MISSING}
  1573. fi
  1574. exit 0
  1575. exit 0 # Just in case...
  1576.