/* Disc file input routines to read initialization parameters * or file containing orbital elements. */ #include "../track/wirotypes.h" #include "../track/wiro.h" extern struct wiro_memory *tinfo; #include #include "kep.h" static double PI = 3.141592653589793238466; extern char *intfmt, *strfmt;/* see dms.c */ static char starnam[80] = {'s','t','a','r','.','c','a','t','\0'}; static char orbnam[80] = "/usr/local/wiro/files/orbit.cat"; /* {'o','r','b','i','t','.','c','a','t','\0'}; */ static int linenum = 1; /* Read initialization file aa.ini * and adjust topocentric coordinates of observer. * * The following items will be read in automatically from the disc file * named aa.ini, if one is provided. The file contains one ASCII * string number per line so is easily edited. * * Terrestrial geocentric latitude and longitude of observer * in degrees East of Greenwich, North of equator * (kfiles.c converts from geodetic latitude input.) */ double tlong = -105.9765278; /* Jelm */ double tlat = 41.05494; /* geocentric */ double glat = 41.05494; /* geodetic */ /* Parameters for calculation of azimuth and elevation */ double attemp = 20.0; /* atmospheric temperature, degrees Centigrade */ double atpress = 1013.0; /* atmospheric pressure, millibars */ /* Distance from observer to center of earth, in earth radii */ double trho = 0.9985; static double flat = 298.257222; static double aearth = 6378137.; static double height = 0.0; extern double tlong, tlat, glat, trho, attemp, atpress, dtgiven; kinit() { double a, b, fl, co, si, u; FILE *f, *fopen(); char s[84]; printf( "\n\t Derived from Steve Moshier's Ephemeris Program v5.0\n\n" ); #if BandS printf( "Planetary perturbations are from Bretagnon and Simon.\n" ); #else printf( "Planetary perturbations are from Meeus.\n" ); #endif height = 2941.0; /* WIRO height in meters */ u = glat * DTR; /* Reduction from geodetic latitude to geocentric latitude * AA page K5 */ co = cos(u); si = sin(u); fl = 1.0 - 1.0/flat; fl = fl*fl; si = si*si; u = 1.0/sqrt( co*co + fl*si ); a = aearth*u + height; b = aearth*fl*u + height; trho = sqrt( a*a*co*co + b*b*si ); tlat = RTD * acos( a*co/trho ); if( glat < 0.0 ) tlat = -tlat; trho /= aearth; printf( "temperature %.1lf C\n", attemp ); printf( "pressure %.0lf mb\n", atpress ); jdflag = 2; /* assume input time is UT */ } /* Program to read in a file containing orbital parameters */ extern struct orbit earth; getorbit(el) struct orbit *el; { FILE *f, *fincat(); char s1[100], s2[100], *u, *v; int i; strcpy(orbnam,CATALOGS); strcat(orbnam, "orbit.cat"); getnum( "Name of orbit catalogue file: ", orbnam, strfmt ); f = fincat( orbnam, 2, s1, s2 ); if( f == 0 ) { printf("No such file\n"); exit(1); return(-1); /* failure flag */ } printf( "%s\n", s1 ); printf( "%s\n", s2 ); /* Read in ASCII floating point numbers */ sscanf( s1, "%lf %lf %lf %lf %lf %lf", &el->epoch, &el->i, &el->W, &el->w, &el->a, &el->dm ); sscanf( s2, "%lf %lf %lf %lf %lf %15s", &el->ecc, &el->M, &el->equinox, &el->mag, &el->sdiam, &el->obname[0] ); el->obname[15] = '\0'; strcpy(OBJECT_NAME,el->obname); /* copy name of object to screen */ /* Clear out the rest of the data structure */ el->oelmnt = 0; el->celmnt = 0; el->L = 0.0; el->r = 0.0; el->plat = 0.0; if( strcmp( &el->obname[0], "Earth" ) ) { return(0); } else { u = (char *)&earth; v = (char *)el; for( i=0; iepoch, &rh, &rm, &rs, &dd, &dm, &ds, &el->mura, &el->mudec, &el->v, &el->px, &x, &el->obname[0] ); x = el->epoch; if( x == 2000.0 ) x = J2000; else if( x == 1950.0 ) x = B1950; else if( x == 1900.0 ) x = J1900; else x = J2000 + 365.25 * (x - 2000.0); el->epoch = x; /* read the right ascension */ el->ra = 2.0 * PI * (3600.0*rh + 60.0*rm + rs)/86400.0; /* read the declination */ sign = 1; if( (dd < 0.0) || (dm < 0.0) || (ds < 0.0) ) sign = -1; z = (3600.0*fabs(dd) + 60.0*fabs(dm) + fabs(ds))/RTS; if( sign < 0 ) z = -z; el->dec = z; #if DEBUG printf( "%.2lf\n", el->epoch ); printf( "%.0lf %.0lf %.3lf\n", rh, rm, rs ); printf( "%.8lf\n", el->ra ); printf( "%.0lf %.0lf %.3lf\n", dd, dm, ds ); printf( "%.8lf\n", el->dec ); printf( "d %.3lf mua %.3lf mud %.3lf v %.3lf\n", el->px, el->mura, el->mudec, el->v ); #endif el->mura *= 15.0/RTS; /* s/century -> "/century -> rad/century */ el->mudec /= RTS; z = el->px; if( z < 1.0 ) { if( z <= 0.0 ) el->px = 0.0; else el->px = STR * z; /* assume px in arc seconds */ } else { el->px = 1.0/(RTS * z); /* parsecs -> radians */ } return(0); } /* Open catalogue and find line number */ FILE *fincat( name, n, str1, str2 ) char *name; int n; /* number of lines per catalogue entry */ char *str1, *str2; { int i; FILE *f, *fopen(); f = fopen( name, "r" ); if( f == 0 ) { printf( "Can't find file %s\n", name ); return(0); /* failure flag */ } getnum( "Line number", &linenum, intfmt ); if( linenum <= 0 ) goto failure; for( i=0; i 1 ) { fgets( str2, 98, f ); if( *str2 == '-' ) goto endf; } } fclose(f); return( f ); endf: printf( "End of file reached.\n" ); failure: fclose(f); return(0); }