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.


In reply to Re^3: Sun Never Sets by Anonymous Monk
in thread Sun Never Sets by monarch

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.