weewx icon indicating copy to clipboard operation
weewx copied to clipboard

Moon almanac error

Open roe-dl opened this issue 8 months ago • 7 comments

The Seasons skin (and other skins, too) state moon rise at 00:20:58 CET on 2025-02-18 (today). But there is no moonrise on 2025-02-18 at 00:20:58 CET. There is no moonrise at all in timezone CET on 2025-02-18.

According to mooncalc.org (or mondverlauf.de for german speaking readers) the moon is visible:

Date From (rise) To (set)
2025-02-17 previous day 21:58:17 CET 08:41:52 CET
2025-02-18 previous day 23:09:03 CET 08:53:48 CET
2025-02-19 00:21:18 CET 09:08:38 CET
2025-02-20 01:35:01 CET 09:28:23 CET

Obviously, what is displayed as moonrise of 2025-02-18, is moonrise of the next day (2025-02-19).

Image

The Seasons skin does not display from when to when the moon is visible, but it displays those events that fall into the given day, even if they belong to different periods of visibility. Because of that behavior N/A would be the correct value for 2025-02-18 in timezone CET, as there is no moonrise between 2025-02-18 00:00:00 CET and 2025-02-18 23:59:59.99 CET.

To solve that we could change celestial.inc to always show moonrise and moonset that belong together and add a comment saying previous day or next day if that is the case:

  ## Moon
  ## Check that moon rise is before moon set
  #set $moontransit = $almanac.moon.transit
  #if $moontransit.raw is None
    #set $moontransit = $almanac.moon.next_transit
  #end if
  #set $moonrise = $almanac(almanac_time=$moontransit.raw).moon.previous_rise
  #set $moonset = $almanac(almanac_time=$moontransit.raw).moon.next_set
  #if $current.dateTime.raw>$moonset.raw
    ## in case the moon sets in the morning and rises in the evening
    #set $x = $almanac(almanac_time=$moonset.raw).moon.next_rise
    #if $x.raw<$day.end.raw
      #set $moonrise = $x
      #set $moontransit = $almanac(almanac_time=$x.raw).moon.next_transit
      #set $moonset = $almanac(almanac_time=$x.raw).moon.next_set
    #end if
  #end if
  #if $moonrise.raw<$day.start.raw
    #set $moonrisecomment = " " + $gettext("previous day")
  #else
    #set $moonrisecomment = ""
  #end if
  #if $moonset.raw>=$day.end.raw
    #set $moonsetcomment = " " + $gettext("next day")
  #else
    #set $moonsetcomment = ""
  #end if

and later on change

          <tr>
            <td class="label">$gettext("Rise")</td>
            <td class="data">$moonrise$moonrisecomment</td>
          </tr>
          <tr>
            <td class="label">$gettext("Transit")</td>
            <td class="data">$moontransit</td>
          </tr>
          <tr>
            <td class="label">$gettext("Set")</td>
            <td class="data">$moonset$moonsetcomment</td>
          </tr>

roe-dl avatar Feb 18 '25 07:02 roe-dl