Is it possible to use tags to get the year with the highest rainfall?

122 views
Skip to first unread message

mike.t...@noworries.plus.com

unread,
Aug 31, 2026, 1:46:30 AMAug 31
to weewx-user
I want to report the years with the highest and lowest total rainfalls. I can do it programmatically by looping through all the years. However I thought it may be possible using tags. I've tried a few variants but it's defeated me, for example alltime.rain.sum provides totals rainfall for all years. 
Thanks    

Tom Keffer

unread,
Aug 31, 2026, 8:06:42 AMAug 31
to weewx...@googlegroups.com
See if the extension weewx-xaggs does what you want.

On Sun, Aug 30, 2026 at 10:46 PM mike.t...@noworries.plus.com <mike.t...@noworries.plus.com> wrote:
I want to report the years with the highest and lowest total rainfalls. I can do it programmatically by looping through all the years. However I thought it may be possible using tags. I've tried a few variants but it's defeated me, for example alltime.rain.sum provides totals rainfall for all years. 
Thanks    

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/weewx-user/d520fe0d-63fa-4298-ad93-517dc13c47ban%40googlegroups.com.

mike.t...@noworries.plus.com

unread,
Aug 31, 2026, 8:59:41 AMAug 31
to weewx-user
Thanks Tom. Reviewing  weewx-xaggs  it looks like the historical tag can only be applied to a day unless I've missed something?

Manuel Hilgert

unread,
Aug 31, 2026, 9:19:25 AMAug 31
to weewx-user

No extension needed. $alltime.years iterates over the years, and $alltime.start and $alltime.end say where the data begins and ends. That is enough to compare only the years you have in full:

#set $wettest = None
#set $wettest_year = None
#set $driest = None
#set $driest_year = None
#for $yr in $alltime.years
  #if $yr.start.raw >= $alltime.start.raw and $yr.end.raw <= $alltime.end.raw
    #set $total = $yr.rain.sum
    #if $total.raw is not None
      #if $wettest is None or $total.raw > $wettest.raw
        #set $wettest = $total
        #set $wettest_year = $yr.dateTime.format("%Y")
      #end if
      #if $driest is None or $total.raw < $driest.raw
        #set $driest = $total
        #set $driest_year = $yr.dateTime.format("%Y")
      #end if
    #end if
  #end if
#end for
Wettest year: $wettest_year, $wettest
Driest year: $driest_year, $driest

The test on $yr.start and $yr.end is what keeps the first and the current year out. Without it, the driest year is the current one until December, and the wettest is whichever partial year is long enough.

$alltime.years follows the calendar year, not rain_year_start.

mike.t...@noworries.plus.com

unread,
Aug 31, 2026, 11:13:58 AMAug 31
to weewx-user
Thanks Manuel. Your loop code is very similar to mine. I was thinking that I might be able to do the same using tags, but I guess not,
Reply all
Reply to author
Forward
0 new messages