]> scm.dxcluster.org Git - spider.git/blob - cmd/show/satellite.pl
added show/satellite command
[spider.git] / cmd / show / satellite.pl
1 #!/usr/bin/perl
2 #
3 # show satellite az/el 
4 #
5 # 1999/12/9 Steve Franke K9AN
6 #
7
8
9 my ($self, $satname) = @_;
10 my @out;
11
12 my ($lat, $lon, $alt, $jtime); # lats and longs in radians
13 my ($sec, $min, $hr, $day, $mon, $yr) = (gmtime($main::systime))[0,1,2,3,4,5];
14 #printf("%2.2d %2.2d %2.2d %2.2d %2.2d\n",$min,$hr,$day,$mon,$yr);
15
16 $mon++;
17 $yr += 1900;
18 $lat=$main::mylatitude;
19 $lon=$main::mylongitude;
20 $alt=0.0;
21
22 $jtime=Sun::Julian_Day($yr,$mon,$day)+$hr/24+$min/60/24;
23 ($yr,$mon,$day,$hr,$min)=Sun::Calendar_date_and_time_from_JD($jtime);
24 #printf("%2.2d %2.2d %2.2d %2.2d %2.2d\n",$min,$hr,$day,$mon,$yr);
25 push @out,sprintf("Tracking table for $satname");
26 push @out,sprintf("dd/mm  UTC   Lat    Lon    Alt(km)  Az     El   Dist(km)");
27 my ($slat,$slon,$salt,$az,$el,$distance)=
28         Sun::get_satellite_pos(
29           $jtime,$lat*$d2r,$lon*$d2r,$alt,$satname);
30 push @out,sprintf(   # print the current satellite position
31         "Now   %2.2d:%2.2d %6.1f %6.1f %6.1f  %6.1f %6.1f %6.1f", 
32         $hr,$min,$slat*$r2d,$slon*$r2d,$salt,
33         $az*$r2d,$el*$r2d,$distance);
34
35 my $numsteps=0;
36 my $step = 2; # tracking table resolution in minutes
37 $jtime=$jtime+$step/24/60;
38 while ( $numsteps < 6*60/$step ) # for now, look 6 hours ahead for tracking table
39         {
40         my ($yr,$mon,$day,$hr,$min)=Sun::Calendar_date_and_time_from_JD($jtime);
41         my ($slat,$slon,$salt,$az,$el,$distance)=
42                 Sun::get_satellite_pos(
43                 $jtime,$lat*$d2r,$lon*$d2r,$alt,$satname);
44         if( $el*$r2d > -5 ) {
45                 push @out,sprintf(
46                         "%2.2d/%2.2d %2.2d:%2.2d %6.1f %6.1f %6.1f  %6.1f %6.1f %6.1f", 
47                         $day,$mon,$hr,$min,$slat*$r2d,$slon*$r2d,$salt,
48                         $az*$r2d,$el*$r2d,$distance);
49                 }
50         $numsteps++;
51         $jtime=$jtime+$step/60/24;
52         }
53
54 return (1,@out);
55
56