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.
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.