[comp.sources.misc] v11i033: starchart 3.2 Part 05/32

ccount@ATHENA.MIT.EDU (03/16/90)

Posting-number: Volume 11, Issue 33
Submitted-by: ccount@ATHENA.MIT.EDU
Archive-name: starchart/part05

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 5 (of 32)."
# Contents:  doc/observe.1 observe/datelib.c observe/observe.h
#   observe/satcalc.c starchart/interact.c starchart/starcust.c
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'doc/observe.1' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'doc/observe.1'\"
else
echo shar: Extracting \"'doc/observe.1'\" \(7858 characters\)
sed "s/^X//" >'doc/observe.1' <<'END_OF_FILE'
X.TH OBSERVE LOCAL "15 July 1989"
X.ad b
X.SH NAME
Xobserve \- observing session planning aid, ephemeris generation, and more.
X.SH SYNOPSIS
X.B observe
X[
X.BI \-m " longitude_hrs"
X[
X.I long_min
X[
X.I long_sec
X]
X]
X]
X.br
X.if t .ti +.5i
X[
X.BI \-l " latitude_hrs"
X[
X.I lat_min
X[
X.I lat_sec
X]
X]
X]
X.br
X.if t .ti +.5i
X[
X.BI \-a " altitude_meters"
X]
X[
X.BI \-z " time_zone_hrs"
X]
X.br
X.if t .ti +.5i
X[
X.B \-d
X\fI"start_date"\fR
X[
X\fI"end_date"\fR
X[
X.I interval_days
X]
X]
X]
X.br
X.if t .ti +.5i
X[
X.BI \-o[[\fIa\fR][\fIe\fR][\fIi\fR][\fIo\fR][\fIs\fR]] " outfilename_root"
X]
X.br
X.if t .ti +.5i
X[
X.B \-p
X[
X[\fIM\fR][\fIV\fR][\fIm\fR][\fIJ\fR][\fIs\fR][\fIU\fR][\fIN\fR]
X]
X]
X[
X.BI \-s i
X]
X.br
X.if t .ti +.5i
X[
X.BI \-f " filename format"
X]
X[
X.BI \-n " object_name"
X]
X
X
X.SH DESCRIPTION
XThe program is used to prepare for astronomical observations and for
Xephemeris calculation.  It can calculate the position of the major
Xplanets, the satellites of Jupiter and Saturn, and minor planets and
Xcomets given either orbital elements or a tabulated ephemeris.
XCoordinates of stationary objects may also be input.  It calculates
X(approximate) rise and set times, and transit times, of all objects to
Xbe observed.
X.PP
XThe information (coordinates, rise and set times) may be prepared for either
Xa single time or a sequence of times.
X.PP
XOutput includes a file containing the timetable of events for the evening or
Xevenings.  The coordinates of the sun and moon, plus any planets, minor
Xplanets, and comets are placed in a readable text file, with other calculated
Xvalues for solar system objects (e.g. distance to earth).  The coordinates
Xof all objects to be observed are placed in files in formats to be read by
Xthe other programs in this family, namely "dataconv" and the starchart
Xcharting programs.  If satellite positions are to be computed, these
Xcoordinates are placed in one file, and a separate PostScript file
Xgraphically showing their positions relative to the primary is also
Xproduced.
X.PP
XParameters set the location of the observer, control
Xwhat objects are to be observed, and designate the time or times of
Xinterest.
X.PP
XThe file \fIfilename\fR may be in one of several ephemeris
Xformats for a single object:
X.br
X.nf
X.ta \w'empb    'u
Xemp	- Format used in the Russian \fIEphemerides of minor planets\fR.
X.br
Xempb	- Format used in the Russian \fIEphemerides of minor planets\fR for
X	    bright and unusual asteroids.
X.br
Xaa	- Format used by Astronomical Almanac.
X.br
Xst	- Format commonly used by Sky and Telescope.
X.br
Xiau	- Format commonly used by IAU Circulars.
X.fi
X.PP
XOr it may be contain orbital elements for one or more objects:
X.br
X.nf
X.ta \w'par_e    'u
Xell_e	- elliptical orbital elements.
X.br
Xpar_e	- parabolic orbital elements.
X.fi
X.PP
XOr it may contain coordinates of fixed objects:
X.br
X.nf
X.ta \w'par_e    'u
Xobj	-  fixed object coordinates.
X.br
X.fi
X.PP
XIf the file \fIfilename\fR is in one of the ephemeris formats, it
Xcontains ephemeris data for object named "obj_name".
X.PP
XInterpolation of the data is performed from the date
Xspecified by the string \fIstart_date\fR until the \fIend_date\fR,
Xwith interval between interpolated points of \fIinterval\fR days.  The
X"lineread" and "sif" files contain commands to draw a solid vector
Xbetween calculated points, and draw the object symbol and label with
Xname.
X.PP
X
XAll ephemeris formats have date RA DEC, then other info.  Date is month in
Xcharacters, then date  How the month is encoded is format dependent,
Xexamples include "IX" "Sept." "Sep" "Sep." "September".  Year is
Xcurrent year unless specified in command line, and is the year of the
Xfirst date.  Dates must be in increasing order: 3 followed by 4,
XDecember followed by January.
X.PP
XThe orbital element formats may be used to conveniently calculate
Xcoordinates of asteroids and comets.
X.PP
XOutput files are named \fIoutfile_root.X\fR where X is:
X.nf
X.ta \w'.sat_PS    'u
Xaltaz	- altitude and azimuth of objects at sunrise and sunset, and
X	    morning and evening twilights.
X.br
Xeph	- ephemeris of sun, moon and objects specified.
X.br
Xobs	- observability of objects: rise and set times of objects,
X	    twilight times, etc.
X.br
Xstar	- "lineread" format file containing coordinates (equinox
X	   2000) of the object(s), sun, moon.
X.br
Xsif	- "sif" format file containing the same information as the
X	   .star file.  The separation character is ";".
X.br
Xsat	- Locations of the major satellites of Jupiter and Saturn with
X	   respect to the primary.
X.br
Xsat_PS	- PostScript file drawing either: one page showing appearance of
X	    Jupiter and Saturn with satellites, and relative sizes and
X	    orientations of Mercury, Venus, Mars, Jupiter, and Saturn,
X	    and the Moon; or several pages showing Jupiter and Saturn
X	    with moons on a sequence of times if a range of dates was
X	    specified.
X.PP
XThe default \fIoutfile_root\fR is set at compile time.  The usual
Xdefault is "planet" for historical reasons.  A character or characters
Ximmediately following the \fB-o\fR option may select a subset of these
Xfiles to be output.  The characters "aeios" specify the altaz, eph,
Xsif, obs, and star files respectively.
X.PP
XThe options controlling the location of the observer are
X.TP
X.B \-m
XMeridian of longitude, measured East of Greenwich.  The USA is West of
XGreenwich, and the longitude is negative for all USA locations.
X.TP
X.B \-l
XLatitude.
X.TP
X.B \-a
XAltitude in meters.
X.TP
X.B \-z
XTime zone in hours East of Greenwich, again, this number is negative
Xfor USA locations.  This does not include any effects of daylight
Xsavings.
X.fi
X.PP
XThe defaults for these parameters are set when the program is compiled.
X.PP
XThe date or dates of observation in UT are specified with the \fB-d\fR
Xflag.  The dates for the \fB-d\fR option are each specified as a string
Xconsisting of month, day, and optional year (use if different from the
Xcurrent year).  The month may be encoded as above, e.g. "Aug" for
Xaugust.  Using the first three letters of the English name for the
Xmonth always works,  as does the Roman numeral form.  Some other
Xcommon abbreviations also work.  The year may also be specified, the
Xdefault is the current year.  The day may be fractional, e.g. 1.25 is
X6 am UT on the first.  An optional third parameter is the increment of
Xtime to be used in stepping between the two dates.
X.PP
XThe positions of any or all of the major planets at the time(s) may be
Xcalculated.  This is specified either as \fB-p\fR which causes the
Xpositions of all planets to be calculated, or individual planets may
Xbe specified by following the \fB-p\fR with a letter or letters from
Xthe sequence "MVmJsUN".  The positions of the sun and moon are always
Xcalculated, since they always have some effect on observing
Xconditions.
X.PP
XThe \fB-s\fR option causes the ".sat"and ".sat_PS" files to be
Xproduced for the satellites of Jupiter and Saturn.  \fB-s\fR implies
X\fB-p\fR.  With the \fB-si\fR option the drawings in the PS file are
Xflipped north to south (if for one time) or east to west (if for
Xmultiple times) to produce an inverted view.
X.SH EXAMPLES
Xobserve -f cer.empb empb -d "Nov 3" "Nov 5"
X.br
Xobserve -si -d "aug 1 1980" "Aug 31"
X.br
Xobserve -f asteroids.ell_e ell_e -d "Sep 1" "sep 5" 0.25 -oe test
X.br
Xobserve -m -72 33 25 -l 54 40 -a 1050
X.SH FILES
XSee sample data files for formats.
X.SH BUGS
XMinor corrections such as parallax and nutation are not made.
X.PP
XPositions are accurate enough for most applications other than
Xoccultations.
X.PP
XRise and set times may be off by several minutes.
X.PP
XPositions opf Saturn's satellites are approximate, good enough for
Xidentification of satellites.
X.SH AUTHOR
XCraig Counterman
X.br
X.sp
Xparts from \fIplanet\fR by
X.br
XF.T. Mendenhall <ihnp4!inuxe!fred>
X.br
XJim Cobb <jcobb@gr.utah.edu>
X.br
XAlan Paeth <AWPaeth@watCGL>
X.SH SOURCES
X\fIAstronomical Formulae for Calculators\fR by Jean Meesus
X.br
X\fIAstronomical Almanac 1989\fR
END_OF_FILE
if test 7858 -ne `wc -c <'doc/observe.1'`; then
    echo shar: \"'doc/observe.1'\" unpacked with wrong size!
fi
# end of 'doc/observe.1'
fi
if test -f 'observe/datelib.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'observe/datelib.c'\"
else
echo shar: Extracting \"'observe/datelib.c'\" \(6401 characters\)
sed "s/^X//" >'observe/datelib.c' <<'END_OF_FILE'
X/*
X * datelib.c
X * date routines
X *
X * Copyright (c) 1990 by Craig Counterman. All rights reserved.
X *
X * This software may be redistributed freely, not sold.
X * This copyright notice and disclaimer of warranty must remain
X *    unchanged. 
X *
X * No representation is made about the suitability of this
X * software for any purpose.  It is provided "as is" without express or
X * implied warranty, to the extent permitted by applicable law.
X *
X */
X
X
X#ifndef  lint
Xstatic char rcsid[] =
X  "$Header: datelib.c,v 1.8 90/02/23 00:16:33 ccount Exp $";
X#endif
X
X
X#include <stdio.h>
X#include <math.h>
X#include <ctype.h>
X
X#ifndef SYSV
X#include <strings.h>
X#else
X#include <string.h>
X#endif /* SYSV */
X
X#include "date.h"
X
X/* Calendar = month, day, year, where day is type double
X   jd = julian date, type double
X   str = string format.  Year is optional, default must be specified.
X
Xfunctions:
Xcal_to_jd(day, month, year, &jd);
Xcal_to_str(day, month, year, string);  String must be char string[15];
Xjd_to_cal(jd, &day, &month, &year);
Xjd_to_str(jd, string);  String must be char string[15];
Xstr_to_jd(string, default_year, &jd);
X                              default_year is default year,
X                              used if not specified in string
Xstr_to_cal(string, &day, &month, &year);
X*/
X
Xvoid cal_to_jd(day, month, year, jd_p)
X     int month, year;
X     double day;
X     double *jd_p;
X{
X  int b, d, m, y;
X  long c;
X
X  m = month;
X  y = (year < 0) ? year + 1 : year;
X  if (month < 3) {
X    m += 12;
X    y -= 1;
X  }
X
X  if ((year < 1582) ||
X      (year == 1582 && ((month < 10)
X			|| ((month == 10) && (day < 15)))))
X    b = 0;
X  else {
X    int a;
X    a = y/100;
X    b = 2 - a + a/4;
X  }
X
X  if (y < 0)
X    c = (long)((365.25*y) - 0.75) + 1720995L;
X  else
X    c = (long)(365.25*y) + 1720995L;
X
X  d = 30.6001*(m+1);
X
X  *jd_p = (b + c + d + day - 0.5);
X}
X
Xstatic char *mname[] = {
X  "",  "Jan", "Feb", "Mar", "Apr", "May", "Jun",
X  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
X
X
Xvoid cal_to_str(day, month, year, str)
X     int month, year;
X     double day;
X     char str[];
X{
X  sprintf(str, "%.2f %s %d", day, mname[month], year);
X}
X
X
Xvoid jd_to_cal(jd, day, month, year)
X     double jd;
X     double *day;
X     int *month, *year;
X{
X  double d, f;
X  double i, a, b, ce, g;
X
X  d = jd + 0.5 - 2415020L;
X  i = floor(d);
X  f = d-i;
X  if (f == 1) {
X    f = 0;
X    i += 1;
X  }
X
X  if (jd > 2299160L) {		/* After the date change in 1582 */
X    a = floor((i/36524.25)+.9983573)+14;
X    i += 1 + a - floor(a/4.0);
X  }
X
X  b = floor((i/365.25)+.802601);
X  ce = i - floor((365.25*b)+.750001)+416;
X  g = floor(ce/30.6001);
X  *month = g - 1;
X  *day = ce - floor(30.6001*g)+f;
X  *year = b + 1899;
X
X  if (g > 13.5)
X    *month = g - 13;
X  if (*month < 2.5)
X    *year = b + 1900;
X  if (*year < 1)
X    *year -= 1;
X}
X
X
Xvoid jd_to_str(jd, str)
X     double jd;
X     char str[];
X{
X  int year, month;
X  double day;
X
X  jd_to_cal(jd, &day, &month, &year);
X
X  sprintf(str, "%.2f %s %d", day, mname[month], year);
X}
X
X
X
X
X
X/* Given date string and the year to be zero, give the day number:
XE.g.
X"100.3"             1988 => 100.3
X"1/1/1988"          1988 => 1.0
X"2/1/1989"          1988 => 398.0
X"October 3"         1988 => 
X*/
Xvoid str_to_jd(s, year, jd_p)
X     char *s;
X     int year;
X     double *jd_p;
X{
X  int mo, yr;
X  double dy;
X  double daynum;
X
X  /* see if it's just a number already */
X  if ((index(s, ' ')) == NULL) {
X    *jd_p = atof(s);
X    return;
X  };
X
X  str_to_cal(s, &dy, &mo, &yr);
X  if (yr == 0) yr = year;
X
X  daynum = dy;
X  cal_to_jd(daynum, mo, yr, jd_p);
X}
X
X/* interpret string as month, day and perhaps year.
Xyear 0 if no year in string, there is no year 0 in the calender.
XE.g.:
XOct. 1                  => 1 10 0
XIX 23                   => 23 9 0
X2/12/1987               => 12 2 1987
X5-2-88                  => 2 5 1988
XJanuary 23 1988         => 23 1 1988
X*/
X
Xvoid str_to_cal(s, dy, mo, yr)
X     char *s;
X     double *dy;
X     int *mo, *yr;
X{
X  int i, n;
X  char string1[100], string2[100];
X
X  /* Is there a dash? */
X  if ((index(s, '-')) != NULL) { /* YES */
X    n = sscanf(s, "%lf-%d-%d", dy, mo, yr);
X    if (n != 3) *yr = 0;
X    return;
X  }
X
X  /* Is there a slash? */
X  if ((index(s, '/')) != NULL) { /* YES */
X    n = sscanf(s, "%lf/%d/%d", dy, mo, yr);
X    if (n != 3) *yr = 0;
X    return;
X  }
X
X  /* Try Month day year or Month day, year
X     or day Month year */
X  /* first eliminate commas */
X  i = 0;
X  while (s[i]) {
X    if (s[i] == ',') s[i] = ' ';
X    i++;
X  }
X
X  n = sscanf(s, "%s %s %d", string1, string2, yr);
X  if (n < 2) {
X    fprintf(stderr, "Can't understand date %s\n", s);
X    exit(1);
X  } else if (n == 2) *yr = 0;
X
X  *mo = tr_mname(string1);
X  if (*mo < 1) {
X    *mo = tr_mname(string2);
X    *dy = atof(string1);
X  } else
X    *dy = atof(string2);
X
X  if (*mo < 1) {
X    fprintf(stderr, "Can't understand date %s\n", s);
X    exit(1);
X  }
X}
X
X/* translate date string to month number */
Xint tr_mname(s)
X     char *s;
X{
X  int i = -1;
X  while (s[++i]) if (isupper(s[i])) s[i] = tolower(s[i]);
X
X  if (!strcmp(s,"jan")
X      || !strcmp(s,"jan.")
X      || !strcmp(s,"i")
X      || !strcmp(s,"january"))
X    return 1;
X
X  if (!strcmp(s,"feb")
X      || !strcmp(s,"feb.")
X      || !strcmp(s,"ii")
X      || !strcmp(s,"febuary"))
X    return 2;
X
X  if (!strcmp(s,"mar")
X      || !strcmp(s,"mar.")
X      || !strcmp(s,"iii")
X      || !strcmp(s,"march"))
X    return 3;
X
X  if (!strcmp(s,"apr")
X      || !strcmp(s,"apr.")
X      || !strcmp(s,"iv")
X      || !strcmp(s,"april"))
X    return 4;
X
X  if (!strcmp(s,"may")
X      || !strcmp(s,"v"))
X    return 5;
X
X  if (!strcmp(s,"jun")
X      || !strcmp(s,"jun.")
X      || !strcmp(s,"vi")
X      || !strcmp(s,"june"))
X    return 6;
X
X  if (!strcmp(s,"jul")
X      || !strcmp(s,"jul.")
X      || !strcmp(s,"vii")
X      || !strcmp(s,"july"))
X    return 7;
X
X  if (!strcmp(s,"aug")
X      || !strcmp(s,"aug.")
X      || !strcmp(s,"viii")
X      || !strcmp(s,"august"))
X    return 8;
X
X  if (!strcmp(s,"sep")
X      || !strcmp(s,"sep.")
X      || !strcmp(s,"ix")
X      || !strcmp(s,"september"))
X    return 9;
X
X  if (!strcmp(s,"oct")
X      || !strcmp(s,"oct.")
X      || !strcmp(s,"x")
X      || !strcmp(s,"october"))
X    return 10;
X
X  if (!strcmp(s,"nov")
X      || !strcmp(s,"nov.")
X      || !strcmp(s,"xi")
X      || !strcmp(s,"november"))
X    return 11;
X
X  if (!strcmp(s,"dec")
X      || !strcmp(s,"dec.")
X      || !strcmp(s,"xii")
X      || !strcmp(s,"december"))
X    return 12;
X
X  return atoi(s);
X}
X
END_OF_FILE
if test 6401 -ne `wc -c <'observe/datelib.c'`; then
    echo shar: \"'observe/datelib.c'\" unpacked with wrong size!
fi
# end of 'observe/datelib.c'
fi
if test -f 'observe/observe.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'observe/observe.h'\"
else
echo shar: Extracting \"'observe/observe.h'\" \(6607 characters\)
sed "s/^X//" >'observe/observe.h' <<'END_OF_FILE'
X/*
X * observe.h
X * Types etc. needed for observe program
X *
X * Copyright (c) 1990 by Craig Counterman. All rights reserved.
X *
X * This software may be redistributed freely, not sold.
X * This copyright notice and disclaimer of warranty must remain
X *    unchanged. 
X *
X * No representation is made about the suitability of this
X * software for any purpose.  It is provided "as is" without express or
X * implied warranty, to the extent permitted by applicable law.
X *
X */
X/*
X * $Header: observe.h,v 1.7 90/02/19 17:22:04 ccount Exp $
X */
X
X
Xtypedef enum {
X  rise, rise_20, rise_30, transit, set_30, set_20, set, special, nothing
X} event_t;
X#define MAXEVENTS 7
X/* order is RISE = 0 to SET = 6 with TRANSIT = 3 */
X
Xtypedef enum {
X  rise_special, set_special, morning_twilight, evening_twilight, not_special
X} special_event_t;
X
Xtypedef struct {
X  double hour;			/* of event */
X  char *object;			/* event is happening to */
X  event_t event;
X  special_event_t special;
X				/* sun or moon rise or set,
X				   twilight */
X} observe_t;
X
Xtypedef enum {
X  planet_orbit,			/* Planet */
X  elliptical_orbit,		/* Elliptical Orbit */
X  parabolic_orbit,		/* Parabolic Orbit */
X  tabulated,			/* Tabulated */
X  no_orbit
X} orbtype_t;
X
Xtypedef enum {
X  asteroid,
X  comet,
X  no_type
X} bodytype_t;
X
Xtypedef struct {
X  double epoch_jd;
X  double equinox_year;
X  double a;			/* semimajor axis, A.U. */
X  double e;			/* eccentricity */
X  double i;			/* inclination (degrees) */
X  double omega;			/* argument of perihelion */
X  double Omega;			/* longitude of ascending node */
X  double n;			/* mean motion (degrees/day) */
X  double M;			/* Mean anomaly at epoch */
X} elliptical_elements_t;
X
Xtypedef struct {
X  double perihelion_date;	/* Time of passage in perihelion */
X  double equinox_year;
X  double q;			/* perihelion distance, A.U. */
X  double i;			/* inclination (degrees) */
X  double omega;			/* argument of perihelion */
X  double Omega;			/* longitude of ascending node */
X} parabolic_elements_t;
X
X
Xtypedef struct {
X  double beta_e;		/* planetocentric declination of Earth */
X  double p_n;			/* Position angle of the axis,
X				   measured east from north */
X  double lambda_e;		/* planetographic longitude of the central
X				   meridian, measured in the direction
X				   opposite to the dir. of rotation */
X} rotation_elements_t;
X
Xtypedef struct {
X  char *name;
X  char *type;
X  char *color;
X  double alpha, delta;		/* position in equinox of date */
X  double alpha2000, delta2000;	/* position in equinox 2000.0 */
X  double l, b;			/* ecliptical longitude and latitude */
X  double lambda, beta;		/* geocentric longitude and latitude */
X  double Cen;			/* Center */
X  double psi;			/* elongation */
X  double r, Delta;		/* Distance to sun, and earth */
X  double mag, phase, size;	/* magnitude, phase (degrees) size (arcsec) */
X  double illum_frac;		/* illuminated fraction of disk */
X  double chi;			/* position angle of bright limb */
X  rotation_elements_t rotation_elements;
X				/* beta_e, p_n, lambda_e */
X  observe_t eventlist[MAXEVENTS]; /* events: rise, set, etc. */
X  double rise_hour, set_hour, transit_hour;
X				/* times of these events */
X} planet_data_t;
X
Xtypedef struct {
X  char *name;
X  double alpha, delta;		/* position in equinox of date */
X  double alpha2000, delta2000;	/* position in equinox 2000.0 */
X  double beta;			/* Phase angle */
X  double psi;			/* Elongation */
X  double r, Delta;		/* Distance to sun, and earth */
X  double mag;			/* magnitude */
X  orbtype_t orbit_type;		/* Orbit type */
X  elliptical_elements_t elliptical_elements;
X  parabolic_elements_t parabolic_elements;
X  bodytype_t body_type;		/* Body type: asteroid or comet */
X  double H, G;			/* Magnitude of asteroid */
X  double g, kappa;		/* Magnitude of a comet */
X  observe_t eventlist[MAXEVENTS]; /* events: rise, set, etc. */
X  double rise_hour, set_hour, transit_hour;
X				/* times of these events */
X} wanderer_data_t;
X
Xtypedef struct {
X  char *name;
X  double alpha, delta;		/* position in equinox of date */
X  double alpha2000, delta2000;	/* position in equinox 2000.0 */
X  double R, Theta;		/* Distance to earth, Theta equinox of date */
X  double size;			/* size (arcsec) */
X  double rise_hour, set_hour, transit_hour;
X				/* times of these events */
X} sun_data_t;
X
Xtypedef struct {
X  char *name;
X  double alpha, delta;		/* position in equinox of date */
X  double alpha2000, delta2000;	/* position in equinox 2000.0 */
X  double lambda, beta, moon_pi;	/* geocentric longitude and latitude
X				   and horizontal parallax */
X  double Delta;			/* Distance to earth (km) */
X  double mag, phase, size;	/* magnitude, phase (degrees) size (arcsec) */
X  double illum_frac;		/* illuminated fraction */
X  double chi;			/* position angle of bright limb */
X  double rise_hour, set_hour, transit_hour;
X				/* times of these events */
X} moon_data_t;
X
X
Xtypedef struct {
X  char *name;
X  char type[3];
X  double alpha, delta;		/* position in original equinox */
X  double equinox;
X  double alpha2000, delta2000;	/* position in equinox 2000.0 */
X  double mag;
X  double size;
X  observe_t eventlist[MAXEVENTS]; /* events: rise, set, etc. */
X  double rise_hour, set_hour, transit_hour;
X				/* times of these events */
X} obj_data_t;
X
X
Xtypedef enum {
X  emp,				/* Eph. Minor Planet */
X  empb,				/* Eph. Minor Planet, bright */
X  aa,				/* Astro. Alman */
X  st,				/* Sky and Telescope */
X  iau,				/* IAU circular */
X  ell_e,			/* Elliptical Orbital elements:
X				   Calculate ephemeris */
X  par_e,			/* Parabolic Orbital elements:
X				   Calculate ephemeris */
X  obj,				/* Fixed object */
X  no_format
X} fformat_t;
X
X
Xtypedef struct {
X  double dx, dy, dz;		/* relative to planet,
X				   units of equatorial radius */
X  double dalpha, ddelta;	/* displacements in RA and dec. */
X  double mag;
X  char *name;
X} sat_t;
X
X
X/* functions */
Xvoid precess();
Xvoid anom_calc();
Xdouble gmst0_degrees();
Xvoid read_elliptical(), elliptical_pos();
Xvoid read_parabolic(), parabolic_pos();
Xvoid read_table(), tabulated_pos();
Xvoid read_objects(), obj_pos();
Xvoid calc_events(), add_events();
Xvoid get_time();
Xdouble now_zone();
Xint now_year();
Xvoid planet_pos(), moon_pos(), sun_pos();
Xvoid out_obs(), out_eph(), out_sat(), out_sat_end();
Xvoid out_sif(), out_sif_planet(), out_sif_body(),
X  out_sif_sun(), out_sif_moon();
Xvoid HeapSort(), HeapSort0();
Xdouble obl_jd(), obl_year();
Xvoid sun_rect();
Xdouble into_range();
X
Xdouble sunrise(), suntransit(), sunset(), moonrise(), moontransit(), moonset(),
X  morntwil(), evetwil(),
X  objrise(), objrise20(), objrise30(), objtransit(),
X  objset30(), objset20(), objset();
X  
X
X/* put here for VMS and pure-ANSI systems */
Xdouble atof();
END_OF_FILE
if test 6607 -ne `wc -c <'observe/observe.h'`; then
    echo shar: \"'observe/observe.h'\" unpacked with wrong size!
fi
# end of 'observe/observe.h'
fi
if test -f 'observe/satcalc.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'observe/satcalc.c'\"
else
echo shar: Extracting \"'observe/satcalc.c'\" \(8494 characters\)
sed "s/^X//" >'observe/satcalc.c' <<'END_OF_FILE'
X/*
X * satcalc.c
X * jupiter and saturn satellites positions
X *
X * Copyright (c) 1990 by Craig Counterman. All rights reserved.
X *
X * This software may be redistributed freely, not sold.
X * This copyright notice and disclaimer of warranty must remain
X *    unchanged. 
X *
X * No representation is made about the suitability of this
X * software for any purpose.  It is provided "as is" without express or
X * implied warranty, to the extent permitted by applicable law.
X *
X */
X
X#ifndef  lint
Xstatic char rcsid[] =
X  "$Header: satcalc.c,v 1.6 90/02/19 17:21:38 ccount Exp $";
X#endif
X
X#include <math.h>
X
X#include "observe.h"
X#include "degree.h"
X
X/* given jd, return sat_t list of gallilean satellites */
Xvoid jupsat(jd, jupiter, sats)
X     double jd;
X     planet_data_t jupiter;
X     sat_t sats[4];
X{
X  double d;			/* modified julian date */
X  double V;			/* long period term of Jupiter */
X  double M;			/* mean anomaly of earth */
X  double N;			/* mean anomaly of Jupiter */
X  double J;			/* differance in heliocentric longitude */
X  double A;			/* Center of earth */
X  double B;			/* Center of jupiter */
X  double K;
X  double R;			/* Radius vector of earth */
X  double r;			/* Radius vector of jupiter */
X  double Delta;			/* Distance from earth to jupiter */
X  double psi;			/* Phase angle */
X  double alpha, delta;		/* Position of jupiter at equinox of date */
X  double D_e;			/* == beta_e, planetocentric declination of earth */
X  double u_1, u_2, u_3, u_4;	/* angle */
X  double G, H;			/* correction terms */
X  double cor_u_1, cor_u_2, cor_u_3, cor_u_4; /* Corrections to u_ */
X  double r_1, r_2, r_3, r_4;	/* distance to center of Jupiter (radii) */
X  double X_1, X_2, X_3, X_4;	/* relative Positions (radii) */
X  double Y_1, Y_2, Y_3, Y_4;	/* relative Positions (radii) */
X  double Z_1, Z_2, Z_3, Z_4;	/* relative Positions (radii) */
X  double X, Y;
X  double dmag;
X
X  d = jd - 2415020.0;
X
X  alpha = jupiter.alpha;
X  delta = jupiter.delta;
X
X  Delta = jupiter.Delta;
X  psi = jupiter.phase;
X  B = jupiter.Cen;
X
X  D_e = jupiter.rotation_elements.beta_e;
X
X  u_1 = 84.5506 + 203.4058630 * (d - Delta * 0.00577167643528) + psi - B;
X  u_2 = 41.5015 + 101.2916323 * (d - Delta * 0.00577167643528) + psi - B;
X  u_3 = 109.9770 + 50.2345169 * (d - Delta * 0.00577167643528) + psi - B;
X  u_4 = 176.3586 + 21.4879802 * (d - Delta * 0.00577167643528) + psi - B;
X
X  u_1 = into_range(u_1);
X  u_2 = into_range(u_2);
X  u_3 = into_range(u_3);
X  u_4 = into_range(u_4);
X
X
X  G = 187.3 + 50.310674 * (d - Delta * 0.00577167643528);
X  H = 311.1 + 21.569229 * (d - Delta * 0.00577167643528);
X  
X  cor_u_1 =  0.472 * DSIN(2*(u_1 - u_2));
X  cor_u_2 =  1.073 * DSIN(2*(u_2 - u_3));
X  cor_u_3 =  0.174 * DSIN(G);
X  cor_u_4 =  0.845 * DSIN(H);
X  
X  r_1 = 5.9061 - 0.0244 * DCOS(2*(u_1 - u_2));
X  r_2 = 9.3972 - 0.0889 * DCOS(2*(u_2 - u_3));
X  r_3 = 14.9894 - 0.0227 * DCOS(G);
X  r_4 = 26.3649 - 0.1944 * DCOS(H);
X  
X  X_1 = r_1 * DSIN(u_1 + cor_u_1);
X  X_2 = r_2 * DSIN(u_2 + cor_u_2);
X  X_3 = r_3 * DSIN(u_3 + cor_u_3);
X  X_4 = r_4 * DSIN(u_4 + cor_u_4);
X
X  Z_1 = r_1 * DCOS(u_1 + cor_u_1);
X  Z_2 = r_2 * DCOS(u_2 + cor_u_2);
X  Z_3 = r_3 * DCOS(u_3 + cor_u_3);
X  Z_4 = r_4 * DCOS(u_4 + cor_u_4);
X  
X  Y_1 = - r_1 * DCOS(u_1 + cor_u_1) * DSIN(D_e);
X  Y_2 = - r_2 * DCOS(u_2 + cor_u_2) * DSIN(D_e);
X  Y_3 = - r_3 * DCOS(u_3 + cor_u_3) * DSIN(D_e);
X  Y_4 = - r_4 * DCOS(u_4 + cor_u_4) * DSIN(D_e);
X
X  dmag = 5.0 * log10(jupiter.r*jupiter.Delta)
X    - 2.5 * log10(jupiter.illum_frac);
X
X  sats[0].dx = X_1;
X  sats[0].dy = Y_1;
X  sats[0].dz = Z_1;
X  X = -X_1*jupiter.size/2.0;
X  Y = Y_1*jupiter.size/2.0;
X  sats[0].dalpha = X * DCOS(jupiter.rotation_elements.p_n)
X      + Y * DSIN(jupiter.rotation_elements.p_n);
X  sats[0].dalpha /= DCOS(jupiter.delta);
X  sats[0].ddelta = -X * DSIN(jupiter.rotation_elements.p_n)
X    + Y * DCOS(jupiter.rotation_elements.p_n);
X  sats[0].name = "Io";
X  sats[0].mag = -1.68 + dmag;
X  
X  sats[1].dx = X_2;
X  sats[1].dy = Y_2;
X  sats[1].dz = Z_2;
X  X = -X_2*jupiter.size/2.0;
X  Y = Y_2*jupiter.size/2.0;
X  sats[1].dalpha = X * DCOS(jupiter.rotation_elements.p_n)
X      + Y * DSIN(jupiter.rotation_elements.p_n);
X  sats[1].dalpha /= DCOS(jupiter.delta);
X  sats[1].ddelta = -X * DSIN(jupiter.rotation_elements.p_n)
X    + Y * DCOS(jupiter.rotation_elements.p_n);
X  sats[1].name = "Europa";
X  sats[1].mag = -1.41 + dmag;
X  
X  sats[2].dx = X_3;
X  sats[2].dy = Y_3;
X  sats[2].dz = Z_3;
X  X = -X_3*jupiter.size/2.0;
X  Y = Y_3*jupiter.size/2.0;
X  sats[2].dalpha = X * DCOS(jupiter.rotation_elements.p_n)
X      + Y * DSIN(jupiter.rotation_elements.p_n);
X  sats[2].dalpha /= DCOS(jupiter.delta);
X  sats[2].ddelta = -X * DSIN(jupiter.rotation_elements.p_n)
X    + Y * DCOS(jupiter.rotation_elements.p_n);
X  sats[2].name = "Ganymede";
X  sats[2].mag = -2.09 + dmag;
X  
X  sats[3].dx = X_4;
X  sats[3].dy = Y_4;
X  sats[3].dz = Z_4;
X  X = -X_4*jupiter.size/2.0;
X  Y = Y_4*jupiter.size/2.0;
X  sats[3].dalpha = X * DCOS(jupiter.rotation_elements.p_n)
X      + Y * DSIN(jupiter.rotation_elements.p_n);
X  sats[3].dalpha /= DCOS(jupiter.delta);
X  sats[3].ddelta = -X * DSIN(jupiter.rotation_elements.p_n)
X    + Y * DCOS(jupiter.rotation_elements.p_n);
X  sats[3].name = "Callisto";
X  sats[3].mag = -1.05 + dmag;
X}
X/* siderial Periods of satellites:
X 0.942421813
X 1.370217855
X 1.887802160
X 2.736914742
X 4.517500436
X15.94542068
X21.2766088
X79.3301825
X
Xsynodic (approx)
X 0.94250436287643326
X 1.3703923657888438
X 1.8881334260185879
X 2.7376110810451278
X 4.519397869256954
X 15.969085530060568
X 21.318764097751611
X 79.919403771981642
X
Xsemimajor axes
X185.52
X238.02
X294.66
X377.40
X527.04
X1221.83
X1481.1
X3561.3
X*/
X
Xstatic struct {
X  double off; /* angle of satellite at jd 2415020.0 */
X  double angvel; /* anbular velocity, degrees per day */
X  double r; /* Distance to saturn in saturn radii */
X  double mag; /* V(1,0) */
X  char *name; /* Name */
X} satsat_data[] = {
X  {49.0, 381.96109660576467, 3.092, 3.3, "Mimas"},
X  {98.7, 262.69848620527883, 3.967, 2.1, "Enceladus"},
X  {263.0, 190.66449173515979, 4.911, 0.6, "Tethys"},
X  {101.3, 131.50151330574105, 6.290, 0.8, "Dione"},
X  {11.2, 79.656629138338852, 8.784, 0.1, "Rhea"},
X  {183.7, 22.543557633424146, 20.364, -1.28, "Titan"},
X  {95.0, 16.886532368823739, 24.685, 4.63, "Hyperion"},
X  {338.4, 4.5045381097576426, 59.355, 1.5, "Iapetus"}
X};
X
X
X/* given jd, return sat_t list of major satellites of Saturn */
X/* Ignore many corrections to Saturn's orbit,
X   assume moons in circular orbits in Saturn's equatorial plane */
Xvoid satsat(jd, saturn, sats)
X     double jd;
X     planet_data_t saturn;
X     sat_t sats[8];
X{
X  double d;			/* modified julian date */
X  double M;			/* mean anomaly of earth */
X  double N;			/* mean anomaly of Saturn */
X  double J;			/* differance in heliocentric longitude */
X  double A;			/* Center of earth */
X  double B;			/* Center of saturn */
X  double K;
X  double R;			/* Radius vector of earth */
X  double r;			/* Radius vector of Saturn */
X  double Delta;			/* Distance from earth to Saturn */
X  double psi;			/* Phase angle */
X  double alpha, delta;		/* Position of Saturn at equinox of date */
X  double D_e;			/* == beta_e, planetocentric declination of earth */
X  double u[8];			/* angle */
X  double X[8];			/* relative Positions (radii) */
X  double Y[8];			/* relative Positions (radii) */
X  double Z[8];			/* relative Positions (radii) */
X  double dmag;
X  int i;
X  double x, y;
X
X  d = jd - 2415020.0;
X
X  alpha = saturn.alpha;
X  delta = saturn.delta;
X
X  Delta = saturn.Delta;
X  psi = saturn.phase;
X  B = saturn.Cen;
X
X  /* Position of Saturn at equinox of date */
X  D_e = saturn.rotation_elements.beta_e;
X
X  dmag = 5.0 * log10(saturn.r*saturn.Delta)
X    - 2.5 * log10(saturn.illum_frac);
X
X  for (i = 0; i < 8; i++) {
X    u[i] = satsat_data[i].off
X      + satsat_data[i].angvel * (d - Delta * 0.00577167643528) + psi - B;
X
X    u[i] = into_range(u[i]);
X
X    X[i] = satsat_data[i].r * DSIN(u[i]);
X    Z[i] = satsat_data[i].r * DCOS(u[i]);
X    Y[i] = - satsat_data[i].r * DCOS(u[i]) * DSIN(D_e);
X
X    sats[i].dx = X[i];
X    sats[i].dy = Y[i];
X    sats[i].dz = Z[i];
X    x = -X[i]*saturn.size/2.0;
X    y = Y[i]*saturn.size/2.0;
X
X    sats[i].dalpha = x * DCOS(saturn.rotation_elements.p_n)
X      + y * DSIN(saturn.rotation_elements.p_n);
X    sats[i].dalpha /= DCOS(saturn.delta);
X    sats[i].ddelta = -x * DSIN(saturn.rotation_elements.p_n)
X      + y * DCOS(saturn.rotation_elements.p_n);
X    sats[i].name = satsat_data[i].name;
X    sats[i].mag = satsat_data[i].mag + dmag;
X/*printf("%d: %f %f\n", i, u[i], into_range(270 - u[i]));*/
X  };
X}
X  
X  
X  
X  
END_OF_FILE
if test 8494 -ne `wc -c <'observe/satcalc.c'`; then
    echo shar: \"'observe/satcalc.c'\" unpacked with wrong size!
fi
# end of 'observe/satcalc.c'
fi
if test -f 'starchart/interact.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'starchart/interact.c'\"
else
echo shar: Extracting \"'starchart/interact.c'\" \(6247 characters\)
sed "s/^X//" >'starchart/interact.c' <<'END_OF_FILE'
X/*
X * User Interaction subroutines
X * 
X * 
X *
X * Copyright (c) 1990 by Craig Counterman. All rights reserved.
X *
X * This software may be redistributed freely, not sold.
X * This copyright notice and disclaimer of warranty must remain
X *    unchanged. 
X *
X * No representation is made about the suitability of this
X * software for any purpose.  It is provided "as is" without express or
X * implied warranty, to the extent permitted by applicable law.
X *
X */
X
Xstatic char rcsid[]="$Header: interact.c,v 1.7 90/03/10 15:33:02 ccount Exp $";
X
X#include <stdio.h>
X#include <math.h>
X
X#include "star3.h"
X#include "parse_input.h"
X#include "patchlevel.h"
X
X#define OPENFAIL 0
X#define LINELEN 82
X
X
X/* Externs */
Xextern int g_argc;
Xextern char **g_argv;
X
Xextern char *title;
X
X/* From starchart.c */
Xextern int user_interact;
X
Xextern double ra, de, sc;
Xextern double all_lbllim, all_maglim, all_gklim;
Xextern int use_lbllim, use_maglim, use_gklim;
X
Xextern double all_vmin, all_vmax;
Xextern int use_vmin;
Xextern int nomaglbls;
X
Xextern double all_rstep, all_dstep;
Xextern int use_rstep;
Xextern double all_rstrt, all_dstrt;
Xextern int no_ra_grid;
Xextern int no_dec_grid;
X
Xextern int all_invert;
X
Xextern int chart_type;
X
Xextern int all_proj_mode;
X
Xextern char *rcfile;
X
Xextern char *constfile;
Xextern char *boundfile;
Xextern char boundftype;
Xextern char *patternfile;
Xextern char pattftype;
Xextern char *cnamefile;
Xextern char cnameftype;
Xextern char *mapfiles[];
Xextern int mapftypes[];
Xextern int nummapfiles;
X
Xextern mapwindow *mapwin[];
Xextern int numwins;
X
Xextern int cur_function;
Xextern int cur_map_type;
Xextern int cur_map_tag;
Xextern char *cur_tag_field;
Xextern char *cur_file_name;
X
Xextern int read_mapwin_file;
Xextern int write_mapwin_file;
Xextern char mapwin_file[];
X
X
Xextern int all_layer[MAXLAYRS];
Xextern int numlayers;
X
X/* storage area big enough for inputs */
X#ifndef MAXPATHLEN
X#define MAXPATHLEN 1025
X#endif
Xextern char a_title[];
Xextern char a_starfile[];
Xextern char a_indexfile[];
Xextern char a_planetfile[];
Xextern char a_nebfile[];
Xextern char a_constfile[];
Xextern char a_boundfile[];
Xextern char a_patternfile[];
Xextern char a_cnamefile[];
Xextern char a_userfile[][MAXPATHLEN];
X
X/* local similar buffers */
Xchar a_constname[MAXPATHLEN];
Xchar a_rcfile[MAXPATHLEN];
Xchar *a_mapfile[MAXMAPFILES];
Xchar a_mapftypes[MAXMAPFILES][MAXPATHLEN];
X
X
X
X/* Scale multiplier, minimum,
X   mangitude change, maximum, for thumbnail */
X#define THSMUL 1.2
X#define THSMIN 12.0
X#define THMADJ 2.5
X#define THMMAX 8.0
X
Xextern mapwindow fullpage, mainmap, thumbmap;
X
X
X/* Adapted from code from Dean Payne deanp@hplsla.hp.com */
X/* Format of each line is
X	variable_name variable_value
Xor	variable_name=variable_value
X
Xvariable_value may be a string which extends to the end of line.
XLines must be 80 chars max.
XComments are anything after a #
XBlank lines are allowed.
X*/
XD_userinput()
X{
X  char sbuf[LINELEN], *var_name, *c_buf;
X  double f_buf;	/* value parsed as double */
X  int i_buf;	/* value parsed as integer */
X  int l_buf;	/* value parsed as TRUE or FALSE */
X  int ret_code, var_type;
X  static int first_time = TRUE; 
X  static int printed_notice = FALSE;
X
X    if (!user_interact)
X      if (first_time) {
X	first_time = FALSE;
X	return TRUE;
X      } else return FALSE;	/* If we don't really want user interaction,
X				   i.e. -u wasn't used,
X				   only do the main loop once */
X
X  if (!printed_notice) {
X    printf("Starchart Version %s, patchlevel %s\n", VERSION_STRING,
X	   PATCHLEVEL_STRING);
X    printf(
X    "This is a copyrighted program, however the source is freely available\n");
X    printf("and freely redistributable for noncommercial use.\n");
X    printf("Distributed 'as is', with no warranty.\n\n\n");
X    printed_notice = TRUE;
X  };
X
X
X  printf("Please type your commands:\n");
X  for (;;) {
X    fgets(sbuf, LINELEN, stdin);
X    if (ferror(stdin)) { fprintf(stderr, "file read error \n"); break; }
X    if (feof(stdin)) return TRUE;
X
X
X    if (!parse_line(sbuf, &var_name, &ret_code, &var_type,
X		    &c_buf, &f_buf, &i_buf, &l_buf)) {
X      /* Not recognized by parse routine,
X	 see if ident_rc can recognize it */
X      if (!(ident_rc(var_name, c_buf))) {
X	fprintf(stderr, "cannot interpret '%s = %s'\n", var_name, c_buf);
X	help_vars(var_name);
X      }
X    } else
X      switch (ret_code) {
X      case TINT:
X	fprintf(stderr, "int = %d\n", i_buf);
X	fprintf(stderr, "i_buf = %d\n", i_buf);
X	fprintf(stderr, "f_buf = %f\n", f_buf);
X	fprintf(stderr, "l_buf = %d\n", l_buf);
X	fprintf(stderr, "c_buf = %s\n", c_buf);
X	break;
X      case TFLO:
X	fprintf(stderr, "flo = %f\n", f_buf);
X	fprintf(stderr, "i_buf = %d\n", i_buf);
X	fprintf(stderr, "f_buf = %f\n", f_buf);
X	fprintf(stderr, "l_buf = %d\n", l_buf);
X	fprintf(stderr, "c_buf = %s\n", c_buf);
X	break;
X      case TBOOL:
X	fprintf(stderr, "bool = %d\n", l_buf);
X	fprintf(stderr, "i_buf = %d\n", i_buf);
X	fprintf(stderr, "f_buf = %f\n", f_buf);
X	fprintf(stderr, "l_buf = %d\n", l_buf);
X	fprintf(stderr, "c_buf = %s\n", c_buf);
X	break;
X      case TNONE:
X	fprintf(stderr, "none = %s\n", c_buf);
X	fprintf(stderr, "i_buf = %d\n", i_buf);
X	fprintf(stderr, "f_buf = %f\n", f_buf);
X	fprintf(stderr, "l_buf = %d\n", l_buf);
X	fprintf(stderr, "c_buf = %s\n", c_buf);
X	break;
X      case TCHAR:
X	fprintf(stderr, "char = %s\n", c_buf);
X	fprintf(stderr, "i_buf = %d\n", i_buf);
X	fprintf(stderr, "f_buf = %f\n", f_buf);
X	fprintf(stderr, "l_buf = %d\n", l_buf);
X	fprintf(stderr, "c_buf = %s\n", c_buf);
X	break;
X      case END_INPUT:
X	return TRUE;
X	break;
X      case EXIT:
X	exit(0);
X	break;
X      case HELP_ME:
X	help_vars("");
X	break;
X      case SHOW_ME:
X	rc_write(stderr);
X	break;
X      case WRITE_RC_FILE:
X	{
X	  FILE *tfile;
X
X	  if ((tfile = fopen(c_buf, "w")) != NULL)
X	    if (rc_write(tfile)) {
X	      fclose(tfile);
X	      printf("wrote %s\n", c_buf);
X	    };
X	};
X	break;
X      default:
X	/* Identified but not special to this routine,
X	   try to set variables */
X	if (!set_varvals(var_name, ret_code, var_type,
X		    c_buf, f_buf, i_buf, l_buf)) {
X	  fprintf(stderr, "cannot interpret '%s = %s'\n", var_name, c_buf);
X	  help_vars(var_name);
X	};
X	break;
X      };
X
X    /* Always call ident_rc */
X    ident_rc(var_name, c_buf);
X  }
X  
X  
X  return TRUE;
X}
X
XD_mapwininput()
X{
X  return TRUE;
X}
X
XD_break()
X{
X  return FALSE;
X}
X
END_OF_FILE
if test 6247 -ne `wc -c <'starchart/interact.c'`; then
    echo shar: \"'starchart/interact.c'\" unpacked with wrong size!
fi
# end of 'starchart/interact.c'
fi
if test -f 'starchart/starcust.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'starchart/starcust.c'\"
else
echo shar: Extracting \"'starchart/starcust.c'\" \(8320 characters\)
sed "s/^X//" >'starchart/starcust.c' <<'END_OF_FILE'
X/*
X * Customizing functions
X */
X
X/*
X * Produced for starchart 3.0 by Craig Counterman Jan, 1989
X *
X * Copyright (c) 1989 by Craig Counterman
X * Portions Copyright (c) 1987 by Alan Paeth (awpaeth@watcgl)
X *
X * Copyright (c) 1990 by Craig Counterman. All rights reserved.
X *
X * This software may be redistributed freely, not sold.
X * This copyright notice and disclaimer of warranty must remain
X *    unchanged. 
X *
X * No representation is made about the suitability of this
X * software for any purpose.  It is provided "as is" without express or
X * implied warranty, to the extent permitted by applicable law.
X *
X */
X
X
Xstatic char rcsid[]="$Header: starcust.c,v 2.4 90/03/10 15:34:28 ccount Exp $";
X
X#include <stdio.h>
X#include <math.h>
X#ifndef SYSV
X#include <strings.h>
X#else
X#include <string.h>
X#endif
X
X#include "star3.h"
X
X#ifndef MAXPATHLEN
X#define MAXPATHLEN 1025
X#endif
X
X/* Externs */
Xextern int g_argc;
Xextern char **g_argv;
X
X
X/* title, mapwin, and numwins are the
X   mostly device independent specifications for the plot */
Xextern char *title;	/* Title of page */
X
Xextern mapwindow *mapwin[MAXWINDOWS];
Xextern int numwins;
X
X/*
Xmapwindow s_mapwin[MAXWINDOWS];
Xchar s_filenames[MAXWINDOWS][MAXMAPFILES][MAXPATHLEN];
Xchar s_tag_fields[MAXWINDOWS][81];
X*/
X
Xextern int cur_function;
Xextern int cur_map_type;
Xextern int cur_map_tag;
Xextern char *cur_tag_field;
X
Xextern int read_mapwin_file;
Xextern int write_mapwin_file;
Xextern char mapwin_file[];
X
X/* Set by initxform
X   One could use elements of the mapwindow structure,
X   but these should be faster for the current window */
Xextern int xproj_mode;
Xextern double xwest, xeast, xnorth, xsouth, xbot;
Xextern int cenx, ceny, strty;
Xextern double xracen, sindlcen, cosdlcen, chart_scale;
Xextern double yscale;
Xextern double xc_scale;
Xextern double inv_;
X
X/* Scale multiplier, minimum,
X   mangitude change, maximum, for thumbnail,*/
Xextern double th_smul;
Xextern double th_smin;
Xextern double th_madj;
Xextern double th_mmax;
X
X
X#define MAX(a,b) ((a)>(b)?(a):(b))
X#define MIN(a,b) ((a)<(b)?(a):(b))
X
Xchar *malloc();
X
X/* Other functions */
Xident_arg(argi)		/* argc and argv are already available as externs */ 
X     int *argi;		/* The argument which can't be understood */
X{
X  /*printf("Identify '%s' '%s'\n", g_argv[*argi], g_argv[*argi+1]);*/
X
X  return FALSE;
X}
X/* Return TRUE and increment argi if the argument has been interpreted.
X   Return FALSE if the argument is an error */
X
X
Xident_rc(var_name, var_val)
X     char *var_name, *var_val;
X{
X  /*printf("Identify '%s' '%s'\n", var_name, var_val);*/
X
X  return FALSE;
X}
X/* Return TRUE if the variable has been interpreted.
X   Return FALSE if the variable is an error */
X
X
X/* Do final adjustments before drawing begins */
Xfix_mapwin()
X{
X  int i, j;
X  FILE *mfile;
X
X  for (i = 0; i < numwins; i++) {
X    if (mapwin[i]->map_type == THUMBNAIL) {
X      /* No constellation names in thumbnail */
X      for (j =0; j < mapwin[i]->nlayers; j++) {
X	if (mapwin[i]->layer[j] == CONSTLNAMES)
X	  mapwin[i]->layer[j] = SKIP;
X	if (mapwin[i]->layer[j] == LEGENDS)
X	  mapwin[i]->layer[j] = SKIP;
X      }
X
X      /* No grids, don't invert */
X      mapwin[i]->draw_ragrid = FALSE;
X      mapwin[i]->draw_decgrid = FALSE;
X      mapwin[i]->invert = FALSE;
X
X      if ((mapwin[i]->proj_mode == STEREOGR) ||
X	  (mapwin[i]->proj_mode == GNOMONIC) ||
X	  (mapwin[i]->proj_mode == ORTHOGR)) {
X      /* If the parent map of this thumbnail map is stereographic,
X	 gnomonic, or orthographic,
X	 double the scale, for Sanson's projection */
X	mapwin[i]->scale *= 2.0;
X
X	if ((90.0 - fabs(mapwin[i]->dlcen)) < (mapwin[i]->scale/2.0)) {
X	  /* pole is in map shouldn't draw this map */
X	  if (i == (numwins-1)) numwins--;
X	  else {
X	    for (j = i; j < numwins; j++)
X	      mapwin[j] = mapwin[i];
X	    numwins--;
X	  }
X	}
X      }
X
X
X
X      /* Thumbnail must be Sanson's */
X      mapwin[i]->proj_mode = SANSONS;
X
X
X      /* Do scale, mag adjustments for thumbnail */
X      mapwin[i]->scale = MAX(mapwin[i]->scale * th_smul, th_smin);
X
X      for (j =0; j < mapwin[i]->numfiles; j++) {
X	mapwin[i]->file[j].maglim =  MIN(th_mmax,
X					 mapwin[i]->maglim - th_madj);
X	mapwin[i]->file[j].lbllim = MIN(mapwin[i]->maglim,
X					mapwin[i]->lbllim - th_madj);
X	mapwin[i]->file[j].gklim = MIN(mapwin[i]->maglim,
X				       mapwin[i]->gklim - th_madj);
X	mapwin[i]->file[j].draw_maglbl = FALSE;
X      }
X    }
X  }
X  
X  /* Read mapwin structures from mapwin file */
X  if ((read_mapwin_file)  && ((mfile = fopen(mapwin_file, "r")) != NULL)) {
X    read_mfile(mfile);
X    fclose(mfile);
X  }
X}
X
Xchar s_title[81];
X
Xread_mfile(mfile)
X     FILE *mfile;
X{
X  int i, j;
X  int n, o, p;
X  char line[300];
X  
X  /* Check tag on file as being mapwin format */
X  n = fscanf(mfile, "%[^\n]\n", line);
X  if (!strcmp(line,
X	      "#mapwin format 1 file: don't edit this line or change order of lines in this file\n"))
X    return FALSE;
X
X  /* set mapwin pointer to real storage
X     set filename pointers and tag_field pointer to real storage */
X/*
X  for (i = 0; i < MAXWINDOWS; i++) {
X    mapwin[i] = &s_mapwin[i];
X    s_mapwin[i].tag_field = s_tag_fields[i];
X    for (j = 0; j < MAXMAPFILES; j++)
X      s_mapwin[i].file[j].name = s_filenames[i][j];
X  };
X*/
X
X  /* read the title */
X  fscanf(mfile, "title=%[^\n]\n", s_title);
X  title = s_title;
X
X  /* read number of mapwins */
X  fscanf(mfile, "numwins=%d\n", &numwins);
X  for (i = 0; i < numwins; i++) {
X    fscanf(mfile, "mapwin=%d\n",&n);
X    if (n != i) fprintf(stderr, "Error in mapwin file");
X    n = i;
X
X    /* Allocate space for this mapwin */
X    mapwin[n] = (mapwindow *) malloc(sizeof(mapwindow));
X    mapwin[n]->tag_field = (char *) malloc(MAXPATHLEN);
X    
X    fscanf(mfile, "width=%d\n", &(mapwin[n]->width));
X    fscanf(mfile, "height=%d\n", &(mapwin[n]->height));
X    fscanf(mfile, "x_offset=%d\n", &(mapwin[n]->x_offset));
X    fscanf(mfile, "y_offset=%d\n", &(mapwin[n]->y_offset));
X    
X    fscanf(mfile, "maglim=%lf\n", &(mapwin[n]->maglim));
X    fscanf(mfile, "lbllim=%lf\n", &(mapwin[n]->lbllim));
X    fscanf(mfile, "gklim=%lf\n", &(mapwin[n]->gklim));
X    
X    
X    fscanf(mfile, "map_type=%d\n", &(mapwin[n]->map_type));
X    
X    
X    fscanf(mfile, "tag=%d\n", &(mapwin[n]->tag));
X    
X    fscanf(mfile, "tag_field=%s\n", mapwin[n]->tag_field);
X    
X    
X    fscanf(mfile, "proj_mode=%d\n", &(mapwin[n]->proj_mode));
X    
X    
X    fscanf(mfile, "draw_ragrid=%d\n", &(mapwin[n]->draw_ragrid));
X    fscanf(mfile, "draw_decgrid=%d\n", &(mapwin[n]->draw_decgrid));
X    
X    fscanf(mfile, "ra_step=%lf\n", &(mapwin[n]->ra_step));
X    fscanf(mfile, "dec_step=%lf\n", &(mapwin[n]->dec_step));
X    
X    fscanf(mfile, "ra_strt=%lf\n", &(mapwin[n]->ra_strt));
X    fscanf(mfile, "dec_strt=%lf\n", &(mapwin[n]->dec_strt));
X    
X    
X    fscanf(mfile, "invert=%d\n", &(mapwin[n]->invert));
X    
X    fscanf(mfile, "racen=%lf\n", &(mapwin[n]->racen));
X    fscanf(mfile, "dlcen=%lf\n", &(mapwin[n]->dlcen));
X    fscanf(mfile, "scale=%lf\n", &(mapwin[n]->scale));
X    
X    fscanf(mfile, "c_scale=%lf\n", &(mapwin[n]->c_scale));
X    
X    fscanf(mfile, "nlayers=%d\n", &(mapwin[n]->nlayers));
X    for (j = 0; j < mapwin[n]->nlayers; j++) {
X      fscanf(mfile, "layer[%d] = %d\n", &o, &p);
X      mapwin[n]->layer[o] = p;
X    }
X    
X    fscanf(mfile, "numfiles=%d\n", &(mapwin[n]->numfiles));
X    for (j = 0; j < mapwin[n]->numfiles; j++) {
X      fscanf(mfile, "file=%d\n", &o);
X      if (o != j) fprintf(stderr, "Error in mapwin file");
X      o = j;
X
X      /* Allocate space for the file name */
X      mapwin[n]->file[o].name = (char *) malloc(MAXPATHLEN);
X
X
X      fscanf(mfile, "name=%s\n", (mapwin[n]->file[o].name));
X      fscanf(mfile, "type=%d\n", &(mapwin[n]->file[o].type));
X      fscanf(mfile, "maglim=%lf\n", &(mapwin[n]->file[o].maglim));
X      fscanf(mfile, "lbllim=%lf\n", &(mapwin[n]->file[o].lbllim));
X      fscanf(mfile, "gklim=%lf\n", &(mapwin[n]->file[o].gklim));
X      fscanf(mfile, "draw_maglbl=%d\n", &(mapwin[n]->file[o].draw_maglbl));
X      fscanf(mfile, "maglmin=%lf\n", &(mapwin[n]->file[o].maglmin));
X      fscanf(mfile, "maglmax=%lf\n", &(mapwin[n]->file[o].maglmax));
X    }
X  }
X  
X  /* Check tag on file as being mapwin format */
X  n = fscanf(mfile, "%[^\n]\n", line);
X  if (!strcmp(line,
X	      "#mapwin format 1 file: don't edit this line or change order of lines in this file\n"))
X    return FALSE;
X  
X  return TRUE;
X}
X
END_OF_FILE
if test 8320 -ne `wc -c <'starchart/starcust.c'`; then
    echo shar: \"'starchart/starcust.c'\" unpacked with wrong size!
fi
# end of 'starchart/starcust.c'
fi
echo shar: End of archive 5 \(of 32\).
cp /dev/null ark5isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 32 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0