in reply to Re^2: Sun Never Sets
in thread Sun Never Sets
This is a very old thread, but I found it by googling after I ran into the same bug. I believe that I have found the source of the bug, and a fix.
In the routine _sunrise_sunset, these lines appear:
my $sradius = 0.2666 / $sRA; if ($upper_limb) { $altit -= $sradius; }
Apparently the intent here is to shift the calculation from being referenced to the Sun's midpoint, to its upper limb, by subtracting the angular radius from the desired altitude. However, for some reason the radius variable is divided by the Sun's RA. Near the equinox, this can be arbitrarily close to zero, and so the altitude can become an arbitrarily large negative number, causing the calculation to fail. The fix is to remove the division by $sRA, i.e. just to write
my $sradius = 0.2666;
instead. In my test case, that fixed the problem, even with iteration enabled.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Sun Never Sets
by Anonymous Monk on Sep 10, 2012 at 05:29 UTC |