43 options.AddDoubleParam(
"L,longitude",
"Geographic observer longitude (degrees, east positive)",-93.62) ;
44 options.AddDoubleParam(
"B,latitude",
"Geographic observer latitude (degrees)", 42.0347) ;
45 options.AddDoubleParam(
"e,elevation",
"Observer elevation above sea-level (meters)", 287.0) ;
46 options.AddDoubleParam(
"o,UTCOffset",
"Observer offset from UTC time (default is current system UTC offset)",
CETime::SystemUTCOffset_hrs()) ;
47 options.AddIntParam(
"u,UpdateFrequency",
"Number of milliseconds between updates", 1000) ;
48 options.AddIntParam(
"a,algorithm",
"Sets the algorithm used to compute planet positions (1=SOFA,2=JPL)",1) ;
49 options.AddBoolParam(
"m,DrawMap",
"Draws a crude map of the southern sky with visible planets",
true) ;
58 void DrawSkyMap(std::vector<CEObservation> &coords,
int line) ;
66 int main(
int argc,
char** argv)
70 if (opt.ParseCommandLine(argc, argv))
return 0.0 ;
73 std::vector<CEPlanet*> planets(8) ;
83 for (
int i=0; i<planets.size(); i++) {
84 if (opt.AsInt(
"algorithm") == 1) {
86 }
else if (opt.AsInt(
"algorithm") == 2) {
96 CEObserver observer(opt.AsDouble(
"longitude"), opt.AsDouble(
"latitude"),
101 std::vector<CEObservation> coords(planets.size());
111 int update_freq(opt.AsInt(
"UpdateFrequency")) ;
116 if ( (mainwin = initscr()) == NULL ) {
117 fprintf(stderr,
"Error initialising ncurses.\n");
123 mvaddstr(line+6,5,
" +-----------+---------------+---------------+--------+--------+---------+") ;
124 mvaddstr(line+7,5,
" | Name | RA | DEC | Az | Alt | Zenith |") ;
125 mvaddstr(line+8,5,
" +-----------+---------------+---------------+--------+--------+---------+") ;
126 mvaddstr(line+9+planets.size(),5,
" +-----------+---------------+---------------+--------+--------+---------+") ;
129 std::vector<double> ra_vec, dec_vec, az(planets.size()), zen(planets.size()) ;
132 usleep(update_freq*1000);
140 std::string jd_str =
"JD : " + std::to_string(date) +
" ("+ std::to_string(jd_tdb) +
")";
141 std::string date_str =
"Date : " + std::to_string(
int(date.
Gregorian())) ;
142 std::string utc_str =
"UTC : " + std::to_string(date.
GetTime_UTC()) ;
143 std::string local_str =
"Local: " + std::to_string(date.
GetTime(observer.UTCOffset())) ;
144 mvaddstr(line+1,1, jd_str.c_str()) ;
145 mvaddstr(line+2,1, utc_str.c_str()) ;
146 mvaddstr(line+3,1, date_str.c_str()) ;
147 mvaddstr(line+4,1, local_str.c_str()) ;
150 for (
int p=0; p<planets.size(); p++) {
152 ra = planets[p]->XCoordinate_Deg(jd_tdb) ;
153 dec = planets[p]->YCoordinate_Deg(jd_tdb) ;
161 std::snprintf(str, 200,
" |%10s | %2.0fh %2.0fm %4.1fs |%+3.0fd %2.0fm %4.1fs |%8.3f|%8.3f|%8.3f |",
162 planets[p]->Name().c_str(),
163 ra_vec[0], ra_vec[1], ra_vec[2],
164 dec_vec[0], dec_vec[1], dec_vec[2],
165 coords[p].GetAzimuth_Deg(),
166 90.0-coords[p].GetZenith_Deg(),
167 coords[p].GetZenith_Deg()) ;
169 mvaddstr(line+9+p,5,str) ;
173 if (opt.AsBool(
"DrawMap"))
DrawSkyMap(coords, line+9+planets.size()+2) ;
185 void DrawSkyMap(std::vector<CEObservation> &coords,
int line)
191 for (
int p=0; p<coords.size(); p++) {
192 az = coords[p].GetAzimuth_Deg() ;
193 if ((az < 90.0) || (az > 270.0)) continue ;
194 zen = coords[p].GetZenith_Deg() ;
195 if (zen > 90.0) continue ;
196 int x = 6+(az-90.0)/2.0 ;
197 int y = line+(zen/5.0)+1 ;
198 std::string abbrv( coords[p].Body()->Name() ) ;
200 mvaddstr(y, x, abbrv.c_str()) ;
209 mvaddstr(line++, 1,
" 90 +--------------+--------------+--------------+--------------+--------------+--------------+") ;
210 mvaddstr(line++, 1,
"A | . . | . . |") ;
211 mvaddstr(line++, 1,
"L 80 | . . | . . |") ;
212 mvaddstr(line++, 1,
"T | . . | . . |") ;
213 mvaddstr(line++, 1,
"I 70 | . . | . . |") ;
214 mvaddstr(line++, 1,
"T | . . | . . |") ;
215 mvaddstr(line++, 1,
"U 60 |............................................|............................................|") ;
216 mvaddstr(line++, 1,
"D | . . | . . |") ;
217 mvaddstr(line++, 1,
"E 50 | . . | . . |") ;
218 mvaddstr(line++, 1,
" | . . | . . |") ;
219 mvaddstr(line++, 1,
" 40 | . . | . . |") ;
220 mvaddstr(line++, 1,
" | . . | . . |") ;
221 mvaddstr(line++, 1,
" 30 |............................................|............................................|") ;
222 mvaddstr(line++, 1,
" | . . | . . |") ;
223 mvaddstr(line++, 1,
" 20 | . . | . . |") ;
224 mvaddstr(line++, 1,
" | . . | . . |") ;
225 mvaddstr(line++, 1,
" 10 | . . | . . |") ;
226 mvaddstr(line++, 1,
" | . . | . . |") ;
227 mvaddstr(line++, 1,
" 0 |______________.______________.______________|______________.______________.______________|") ;
228 mvaddstr(line++, 1,
" 90 120 150 180 210 240 270") ;
229 mvaddstr(line++, 1,
" E AZIMUTH S AZIMUTH W") ;
238 mvaddstr(line++, 1,
"DESCRIPTION:") ;
239 mvaddstr(line++, 3,
"This program prints the current positions of the planets to the terminal.") ;