added Steve K9AN's sh/moon stuff
authorminima <minima>
Wed, 7 Nov 2001 23:15:03 +0000 (23:15 +0000)
committerminima <minima>
Wed, 7 Nov 2001 23:15:03 +0000 (23:15 +0000)
Changes
cmd/show/moon.pl
perl/Sun.pm

diff --git a/Changes b/Changes
index 45c754f3bf5bda910564bfbab5d7ffe94dab5661..9c42d4661df17e7d2a4239f129998ed726f6e1b4 100644 (file)
--- a/Changes
+++ b/Changes
@@ -2,6 +2,7 @@
 1. fix is_pctext so that it actually catches corrupt spots and announces.
 2. fix console.pl so that you can type in '0' again
 3. Fix problem with reply disappearing up its own bottom.
+4. Added Steve's latest sh/moon stuff
 06Nov01=======================================================================
 1. fix read so that sysop reading doesn't increment the read counter for 
 private mail not addressed to them.
index 8013345a1407cdfd061a2f293533e646e76185d7..6203797f787ad0df1ee7ae7745f9177ac7fc5805 100644 (file)
@@ -17,6 +17,7 @@ my $f;
 my $l;
 my $n_offset;
 my @list;
+my ($rise, $set, $az, $dec, $loss, $ifrac);
 
 while ($f = shift @f){
        if(!$n_offset){
@@ -70,7 +71,7 @@ if( !$n_offset ) {
 }
 
 foreach $l (@in) {
-       my ($rise, $set, $az, $dec, $loss )=Sun::rise_set($yr,$month,$day,$hr,$min,$l->[1],$l->[2],1);
+       ($rise, $set, $az, $dec, $loss, $ifrac)=Sun::rise_set($yr,$month,$day,$hr,$min,$l->[1],$l->[2],1);
        $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);
@@ -78,7 +79,5 @@ foreach $l (@in) {
        push @out,sprintf("%-6.6s %-30.30s %02d/%02d/%4d %s %s", $l->[3], $l->[0], $day, $month, $yr, $rise, $set);
        }
 }
-
-                       
-
+push @out,sprintf("Illuminated fraction of the Moon's disk is %4.2f",$ifrac);
 return (1, @out);
index 2fe033cd8e42911c37209f430120f402312dea98..759f99489a76199f0e2572f08b39d07ea852850a 100644 (file)
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#/usr/bin/perl -w
 #
 # This module was written by Steve Franke K9AN. 
 # November, 1999.
@@ -169,6 +169,7 @@ sub rise_set
        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);
        my $tt1 = ($julianday-1-2451545)/36525.;
@@ -198,10 +199,10 @@ sub rise_set
        }
 
        if ( $sun0_moon1 == 1 ) {
-               ($alpha1, $delta1, $distance)=get_moon_alpha_delta($tt1);
-               ($alpha2, $delta2, $distance)=get_moon_alpha_delta($tt2);
-               ($alpha3, $delta3, $distance)=get_moon_alpha_delta($tt3);
-               ($alphanow, $deltanow, $distancenow)=get_moon_alpha_delta($ttnow);
+               ($alpha1, $delta1, $distance, $ifrac)=get_moon_alpha_delta($tt1);
+               ($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.;
                $H=$thetanow-$lon-$alphanow;
                $H=reduce_angle_to_360($H);
@@ -315,7 +316,7 @@ sub rise_set
        }
        if ( $sun0_moon1 == 1 ) {
                return (sprintf("%s", $risetime), sprintf("%s",$settime), 
-                               $aznow+180,$hnow, -40*log10($distance/385000) );
+                       $aznow+180,$hnow, -40*log10($distance/385000), $ifracnow );
        }
 }
 sub get_moon_alpha_delta 
@@ -323,6 +324,9 @@ sub get_moon_alpha_delta
        #
        # Calculate the moon's right ascension and declination
        #
+       # As of October 2001, also calculate the illuminated fraction of the 
+       # moon's disk... (why not?)
+       #
        my $tt=shift;
 
        my $Lp=218.3164477+481267.88123421*$tt-
@@ -542,7 +546,20 @@ sub get_moon_alpha_delta
        my $delta=asin(cosdeg($beta)*sindeg($epsilon)*sindeg($lambda)+sindeg($beta)*cosdeg($epsilon))*$r2d;
        $delta = reduce_angle_to_360($delta);
 
-       return ($alpha,$delta,$distance);
+# $phase will be the "moon phase angle" from p. 346 of Meeus' book...
+       my $phase=180.0 - $D - 6.289 *sindeg($Mp)
+                               + 2.100 *sindeg($M)
+                               - 1.274 *sindeg(2.*$D - $Mp)
+                               - 0.658 *sindeg(2.*$D)
+                               - 0.214 *sindeg(2.*$Mp)
+                               - 0.110 *sindeg($D);
+
+# $illum_frac is the fraction of the disk that is illuminated, and will be
+# zero at new moon and 1.0 at full moon.
+
+       my $illum_frac = (1.0 + cosdeg( $phase ))/2.;   
+
+       return ($alpha,$delta,$distance,$illum_frac);
 }
  
 sub get_sun_alpha_delta