From 8409ae7d77dc4c13bab2062703a094a4a12c1664 Mon Sep 17 00:00:00 2001 From: minima Date: Sat, 26 Feb 2005 12:19:18 +0000 Subject: [PATCH] add show/grayline command from K9AN --- Changes | 3 ++ cmd/Aliases | 1 + cmd/Commands_en.hlp | 31 ++++++++++++++++ cmd/show/grayline.pl | 70 ++++++++++++++++++++++++++++++++++++ cmd/show/sun.pl | 3 +- perl/Messages | 2 ++ perl/Sun.pm | 85 +++++++++++++++++++++++++++++++++----------- 7 files changed, 173 insertions(+), 22 deletions(-) create mode 100644 cmd/show/grayline.pl diff --git a/Changes b/Changes index d86ff4df..d2672319 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,6 @@ +26Feb05======================================================================= +1. Added show/grayline command from Steve K9AN. This is also aliased to +show/greyline :-) 25Feb05======================================================================= 1. Changed the way spot deduping is done. This is likely to make deduping much stricter. In essence a person cannot spot the same call on the same frequency diff --git a/cmd/Aliases b/cmd/Aliases index 42a9aa2a..971c5f1c 100644 --- a/cmd/Aliases +++ b/cmd/Aliases @@ -127,6 +127,7 @@ package CmdAlias; '^sho?w?/fdx/(\d+)', 'show/dx real $1', 'show/fdx', '^sho?w?/fdx/d(\d+)', 'show/dx real from $1', 'show/fdx', '^sho?w?/fdx', 'show/dx real', 'show/fdx', + '^sho?w?/gre?y?l?i?n?e?', 'show/grayline', 'show/grayline', '^sho?w?/myd?x?/(\d+)-(\d+)', 'show/dx filter $1-$2', 'show/mydx', '^sho?w?/myd?x?/(\d+)', 'show/dx filter $1', 'show/mydx', '^sho?w?/myd?x?/d(\d+)', 'show/dx filter from $1', 'show/mydx', diff --git a/cmd/Commands_en.hlp b/cmd/Commands_en.hlp index 592b7182..9e3982cb 100644 --- a/cmd/Commands_en.hlp +++ b/cmd/Commands_en.hlp @@ -2032,6 +2032,37 @@ See also TYPE - to see the contents of a file. Show the contents of all the filters that are set. This command displays all the filters set - for all the various categories. +=== 0^SHOW/GRAYLINE [ndays] [|]^Show Civil dawn/dusk times +This command is very similar to SHOW/SUN except that it shows the +start and end of "Official" or "Civil" Dawn and Dusk. This is defined +as when the Sun is 6 degrees below the horizon. + +If you don't specify any prefixes or callsigns, it will show the +times for your QTH (assuming you have set it with either SET/LOCATION +or SET/QRA), together with the current azimuth and elevation. + +If all else fails it will show the civil dawn and dusk times for +the node that you are connected to. + +For example:- + + SH/GRAYLINE + SH/GRAYLINE G1TLH W5UN + +You can also use this command to see into the past or the future, so +if you want to see yesterday's times then do:- + + SH/GRAYLINE -1 + +or in three days time:- + + SH/GRAYLINE +3 W9 + +Upto 366 days can be checked both in the past and in the future. + +Please note that the times are given as the UT times of the requested +UT day. + === 0^SHOW/HFSTATS [days] [date]^Show the HF DX Statistics Show the HF DX spots breakdown by band for the last no of days (default is 31), starting from a (default: today). diff --git a/cmd/show/grayline.pl b/cmd/show/grayline.pl new file mode 100644 index 00000000..c2c6fcff --- /dev/null +++ b/cmd/show/grayline.pl @@ -0,0 +1,70 @@ +#!/usr/bin/perl +# +# show dawn, sunrise, sunset, and dusk times for each callsign or prefix entered +# +# +my ($self, $line) = @_; +my @f = split /\s+/, $line; + +my @out; +my $f; +my $l; +my $n_offset; +my @list; + +while ($f = shift @f){ + if(!$n_offset){ + ($n_offset) = $f =~ /^([-+]?\d+)$/; + next if $n_offset; + } + push @list, $f; +} +$n_offset = 0 unless defined $n_offset; +$n_offset = 0 if $n_offset > 365; # can request moon rise/set up to 1 year ago or from now... +$n_offset = 0 if $n_offset < -365; + +my ($lat, $lon); # lats and longs in radians +my ($sec, $min, $hr, $day, $month, $yr) = (gmtime($main::systime+$n_offset*24*60*60))[0,1,2,3,4,5]; + +$month++; +$yr += 1900; + +my @in; + +if (@list) { + foreach $l (@list) { + my $user = DXUser->get_current(uc $l); + if ($user && $user->lat && $user->long) { + push @in, [$user->qth, $user->lat, -$user->long, uc $l ]; + } else { + # prefixes ---> + my @ans = Prefix::extract($l); + next if !@ans; + my $pre = shift @ans; + my $a; + foreach $a (@ans) { + $lat = $a->{lat}; + $lon = -$a->{long}; + push @in, [ $a->name, $lat, $lon, $pre ]; + } + } + } +} else { + if ($self->user->lat && $self->user->long) { + push @in, [$self->user->qth, $self->user->lat, -$self->user->long, $self->call ]; + } else { + push @in, [$main::myqth, $main::mylatitude, -$main::mylongitude, $main::mycall ]; + } +} + +push @out, $self->msg('grayline1'); +push @out, $self->msg('grayline2'); + +foreach $l (@in) { + my ($dawn, $rise, $set, $dusk, $az, $dec )=Sun::rise_set($yr,$month,$day,$hr,$min,$l->[1],$l->[2],0); + $l->[3] =~ s{(-\d+|/\w+)$}{}; + push @out,sprintf("%-6.6s %-30.30s %02d/%02d/%4d %s %s %s %s", $l->[3], $l->[0], $day, $month, $yr, $dawn, $rise, $set, $dusk); +} + + +return (1, @out); diff --git a/cmd/show/sun.pl b/cmd/show/sun.pl index d7c9766c..36aaa078 100644 --- a/cmd/show/sun.pl +++ b/cmd/show/sun.pl @@ -70,7 +70,8 @@ if( !$n_offset ) { } foreach $l (@in) { - my ($rise, $set, $az, $dec, $loss )=Sun::rise_set($yr,$month,$day,$hr,$min,$l->[1],$l->[2],0); + my ($dawn, $rise, $set, $dusk, $az, $dec )=Sun::rise_set($yr,$month,$day,$hr,$min,$l->[1],$l->[2],0); + $l->[3] =~ s{(-\d+|/\w+)$}{}; if( !$n_offset ) { push @out,sprintf("%-6.6s %-30.30s %02d/%02d/%4d %s %s %6.1f %6.1f", $l->[3], $l->[0], $day, $month, $yr, $rise, $set, $az, $dec); diff --git a/perl/Messages b/perl/Messages index 82ef55ef..a61c41df 100644 --- a/perl/Messages +++ b/perl/Messages @@ -115,6 +115,8 @@ package DXM; filter4 => '$_[0]$_[1] Filter $_[2] deleted for $_[3]', filter5 => 'need some filter commands...', filter6 => '$_[0]$_[1] Filter for $[2] not found', + grayline1 => ' Beg of End of', + grayline2 => 'Location dd/mm/yyyy Dawn Rise Set Dusk', grids => 'DX Grid enabled for $_[0]', gridu => 'DX Grid disabled for $_[0]', illcall => 'Sorry, $_[0] is an invalid callsign', diff --git a/perl/Sun.pm b/perl/Sun.pm index 0616d473..6b9b88eb 100644 --- a/perl/Sun.pm +++ b/perl/Sun.pm @@ -18,6 +18,8 @@ # # $Id$ # +# 2005/02/25 add calculation of civil dawn and dusk, defined to be times +# when solar zenith angle is 96 degrees. # 2001/12/16 Fixed Julian_Date_of_Epoch and now I actually use it... # 2001/09/15 some changes to take care of cases where the object # doesn't rise or set on a given day... @@ -167,14 +169,12 @@ sub rise_set my $lat = shift; my $lon = shift; my $sun0_moon1=shift; # 0 for sun, 1 for moon, 2 for venus... + my ($alpha1,$delta1,$alpha2,$delta2,$alpha3,$delta3); + my ($aznow,$hnow,$alphanow,$deltanow,$distance,$distancenow); + my ($h0,$H); + my ($risetime,$settime); + my ($dawntime,$dusktime); - my $norise = 0; - my $noset = 0; - my ($risehr,$risemin,$risetime,$sethr,$setmin,$settime); - - my ($alpha1,$alpha2,$alpha3,$delta1,$delta2,$delta3); - my ($m0,$m1,$m2,$theta,$alpha,$delta,$H,$az,$h,$h0,$aznow,$hnow,$corr); - my ($i,$arg,$argtest,$H0,$alphanow,$deltanow,$distance,$distancenow); my ($ifrac,$ifracnow); my $julianday=Julian_Day($year,$month,$day); @@ -196,12 +196,27 @@ sub rise_set ($alpha2, $delta2)=get_sun_alpha_delta($tt2); ($alpha3, $delta3)=get_sun_alpha_delta($tt3); ($alphanow, $deltanow)=get_sun_alpha_delta($ttnow); - $h0=-0.8333; $H=$thetanow-$lon-$alphanow; $H=reduce_angle_to_360($H); ($aznow,$hnow)=get_az_el($H,$deltanow,$lat); $hnow=$hnow + 1.02/(tandeg($hnow+10.3/($hnow+5.11)))/60; + $h0=-0.8333; # this is for sun rise and sun set + ($risetime,$settime)= + do_rise_set_calculations($h0,$theta0,$lat,$lon,$alpha1,$delta1, + $alpha2,$delta2,$alpha3,$delta3); + $h0=-6.0; # this is for civil dawn and dusk + ($dawntime,$dusktime)= + do_rise_set_calculations($h0,$theta0,$lat,$lon,$alpha1,$delta1, + $alpha2,$delta2,$alpha3,$delta3); + $dawntime = "------" if( $dawntime eq "NoRise" ); + $dusktime = "------" if( $dusktime eq "NoSet " ); + + return ( + sprintf("%s", $dawntime), sprintf("%s",$risetime), + sprintf("%s", $settime), sprintf("%s",$dusktime), + $aznow+180,$hnow + ); } if ( $sun0_moon1 == 1 ) { @@ -209,14 +224,41 @@ sub rise_set ($alpha2, $delta2, $distance, $ifrac)=get_moon_alpha_delta($tt2); ($alpha3, $delta3, $distance, $ifrac)=get_moon_alpha_delta($tt3); ($alphanow, $deltanow, $distancenow, $ifracnow)=get_moon_alpha_delta($ttnow); - $h0=0.7275*$r2d*asin(6378.14/$distancenow)-34./60.; + $h0=0.7275*$r2d*asin(6378.14/$distancenow)-34.0/60.; $H=$thetanow-$lon-$alphanow; $H=reduce_angle_to_360($H); ($aznow,$hnow)=get_az_el($H,$deltanow,$lat); $hnow=$hnow-$r2d*asin(sin(6378.14/$distancenow)*cosdeg($hnow))+ 1.02/(tandeg($hnow+10.3/($hnow+5.11)))/60; + ($risetime,$settime)= + do_rise_set_calculations($h0,$theta0,$lat,$lon,$alpha1,$delta1, + $alpha2,$delta2,$alpha3,$delta3); + return (sprintf("%s", $risetime), sprintf("%s",$settime), + $aznow+180,$hnow, -40*log10($distance/385000), $ifracnow ); + } +} + +sub do_rise_set_calculations +{ + my $norise = 0; + my $noset = 0; + my ($risehr,$risemin,$risetime,$sethr,$setmin,$settime); + my ($m0,$m1,$m2,$theta,$alpha,$delta,$H,$az,$h,$corr); + my ($i,$arg,$argtest,$H0); + + my $h0=shift; + my $theta0=shift; + my $lat=shift; + my $lon=shift; + my $alpha1=shift; + my $delta1=shift; + my $alpha2=shift; + my $delta2=shift; + my $alpha3=shift; + my $delta3=shift; + $arg = (sindeg($h0)-sindeg($lat)*sindeg($delta2))/(cosdeg($lat)*cosdeg($delta2)); if ( abs($arg) > 1. ) { # either up all day or down all day $norise = 1; # leave it to the user to examine @@ -254,7 +296,7 @@ sub rise_set $corr=-$H/360; $m0=$m0+$corr; $m0=$m0+1 if( $m0 < 0 ); - $m0=$m0-1 if( $m0 > 1 ); + $m0=$m0-1 if( $m0 >= 1 ); } @@ -271,7 +313,9 @@ sub rise_set ($az,$h)=get_az_el($H,$delta,$lat); $corr=($h-$h0)/(360*(cosdeg($delta)*cosdeg($lat)*sindeg($H))); $m1=$m1+$corr; - $norise=1 if( $m1 < 0 || $m1 > 1); +# $norise=1 if( $m1 < 0 || $m1 > 1); + $m1=$m1-1 if( $m1 >= 1); + $m1=$m1+1 if( $m1 < 0); } } @@ -282,6 +326,7 @@ sub rise_set $risemin=$risemin-60; $risehr=$risehr+1; } + $risehr=0 if($risehr==24); $risetime=sprintf("%02d:%02dZ",$risehr,$risemin); } else { $risetime="NoRise"; @@ -290,7 +335,7 @@ sub rise_set if( !$noset ){ $m2 = $m0 + $H0/360.; $m2=$m2+1 if( $m2 < 0 ); - $m2=$m2-1 if( $m2 > 1 ); + $m2=$m2-1 if( $m2 >= 1 ); for ($i=1; $i<=2; $i++) { $theta = $theta0+360.985647*$m2; $alpha=$alpha2+$m2*($aa+$ba+$m2*$ca)/2; @@ -300,7 +345,9 @@ sub rise_set ($az,$h)=get_az_el($H,$delta,$lat); $corr=($h-$h0)/(360*(cosdeg($delta)*cosdeg($lat)*sindeg($H))); $m2 = $m2 + $corr; - $noset=1 if( $m2 < 0 || $m2 > 1); +# $noset=1 if( $m2 < 0 || $m2 > 1); + $m2=$m2-1 if( $m2 >= 1); + $m2=$m2+1 if( $m2 < 0); } } @@ -311,20 +358,16 @@ sub rise_set $setmin=$setmin-60; $sethr=$sethr+1; } + $sethr=0 if($sethr==24); $settime=sprintf("%02d:%02dZ",$sethr,$setmin); } else { $settime="NoSet "; } + return $risetime,$settime; +} + - if ( $sun0_moon1 == 0 ) { - return (sprintf("%s", $risetime), sprintf("%s",$settime),$aznow+180,$hnow); - } - if ( $sun0_moon1 == 1 ) { - return (sprintf("%s", $risetime), sprintf("%s",$settime), - $aznow+180,$hnow, -40*log10($distance/385000), $ifracnow ); - } -} sub get_moon_alpha_delta { # -- 2.43.0