#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(
int argc,
char *argv[]) {
int i, j, n_tab, obj_num, dummy;
char ob_type[15], cat_path[128], star_name[32], full_star_name[128];
char name[128];
double jd_tt, jd_ut, jd_ut1, tlong, glat, tlat, trho, height, y, m, d;
double e_pos[3], e_vel[3], geo_ra, geo_dec, topo_ra, topo_dec, alt, az;
double dist, last, tab_int, dut1, delta_t;
printf("Enter the observer east longitude (degrees): ");
dummy = scanf("%lf", &tlong);
printf("Enter the observer north geodetic latitude (degrees): ");
dummy = scanf("%lf", &glat);
printf("Enter the observer altitude (m above sea level): ");
dummy = scanf("%lf", &height);
printf("Enter the starting UT date (JD 0 0 or year month fractional_day): ");
dummy = scanf("%lf %lf %lf", &y, &m, &d);
if (m == 0 && d == 0)
jd_ut = y;
else
printf("Enter tabulation intervals (days) and number of tabulations: ");
dummy = scanf("%lf %d", &tab_int, &n_tab);
printf("nHere is a list of options:n");
printf(" P . . . . . use built-in planetary ephemerisn");
printf(" J . . . . . use a JPL ephemeris filen");
printf(" O . . . . . use an aephem orbital elements filen");
printf(" C . . . . . use a star cataloguen");
printf("Please enter one of these options: ");
dummy = scanf("%15s", ob_type);
switch(ob_type[0]) {
case 'P': case 'p':
printf("Here is a list of available objects:n");
}
printf("Enter the object number: ");
dummy = scanf("%d", &i);
printf("That is not a valid option.n");
exit(0);
}
break;
case 'J': case 'j':
printf("Enter the name of the JPL file: ");
dummy = scanf("%127s", cat_path);
printf("Could not load JPL ephemeris file: %s.n",
exit(0);
}
printf("Here is a list of JPL objects:n");
printf("Enter the object number: ");
dummy = scanf("%d", &obj_num);
if (obj_num < 0 || obj_num >= AE_N_SS_BODIES) {
printf("That is not a valid option.n");
exit(0);
}
break;
case 'O': case 'o':
printf("Enter the name of the orbital file: ");
dummy = scanf("%127s", cat_path);
printf("Enter the name of the orbit, as it appears in %s: ", cat_path);
dummy = scanf("%31s", star_name);
exit(0);
}
ob_type[0] = 'p';
break;
case 'C': case 'c':
printf("Enter the name of the catalogue file: ");
dummy = scanf("%127s", cat_path);
printf("Enter the name of the object, as it appears in %s: ", cat_path);
dummy = scanf("%31s", star_name);
exit(0);
}
break;
default:
printf("You must enter 'P', 'O' or 'C'.n");
exit(0);
}
printf("n");
printf("Observer R_{earth}: %gn", trho);
for (i = 0; i < n_tab; i++, jd_ut += tab_int) {
switch (ob_type[0]) {
case 'P': case 'p':
&dist);
break;
case 'J': case 'j':
printf("%.10fn", jd_tt);
&dist))) {
printf("Could not do geocentric reduction: %s.",
exit(0);
}
break;
case 'C': case 'c':
dist = 0;
break;
}
topo_ra = geo_ra;
topo_dec = geo_dec;
ae_topocentric(jd_tt, jd_ut1, tlat, glat, tlong, trho, NULL, NULL, dist,
&topo_ra, &topo_dec);
if (!i) {
switch (ob_type[0]) {
case 'J': case 'j': case 'P': case 'p':
printf("Object is %s, located in %s.n", name,
(topo_ra, topo_dec, jd_tt)] + 4);
printf("+--------------+--------+----------+-----------------+-------"
"-----------+------------+-----------------+------------------"
"+------------------+------------------+n");
printf("| JD (UT1) | dT (s) | DUT1 (s) | Geocentric RA | "
"Geocentric Dec. | Dist. (AU) | Topocentric RA | "
"Topocentric Dec. | Azimuth | Altitude |n");
printf("+--------------+--------+----------+-----------------+-------"
"-----------+------------+-----------------+------------------"
"+------------------+------------------+n");
break;
case 'C': case 'c':
printf("Star is %s with vis. mag. of %g.n", full_star_name,
star.mag);
printf("+--------------+--------+----------+-----------------+-------"
"-----------+-----------------+------------------+------------"
"------+------------------+n");
printf("| JD (UT1) | dT (s) | DUT1 (s) | Geocentric RA | "
"Geocentric Dec. | Topocentric RA | Topocentric Dec. | "
"Azimuth | Altitude |n");
printf("+--------------+--------+----------+-----------------+-------"
"-----------+-----------------+------------------+------------"
"------+------------------+n");
break;
}
}
switch (ob_type[0]) {
case 'p': case 'P': case 'j': case 'J':
break;
case 'c': case 'C':
printf(
"| %12.4f | %5.2f | %5.2f | " ae_hms_sfmt " | " ae_dms_sfmt
" | " ae_hms_sfmt " | " ae_dms_sfmt
" | " ae_dms_sfmt
" | "
ae_dms_sfmt
" |n", jd_ut1, delta_t, dut1,
ae_hms_arg(geo_ra),
break;
}
}
switch (ob_type[0]) {
case 'p': case 'P': case 'j': case 'J':
printf("+--------------+--------+----------+-----------------+-------"
"-----------+------------+-----------------+------------------"
"+------------------+------------------+n");
break;
case 'c': case 'C':
printf("+--------------+--------+----------+-----------------+-------"
"-----------+-----------------+------------------+------------"
"------+------------------+n");
break;
}
return 0;
}