It's also in the NOAA files that are updated
every 5 minutes. The following works with two caveats. First, there may be a "built-in" more straightforward way to do it within weewx AND my Python programming is in its infancy. Second, if you do this in python 2.7 instead of Python 3.x, you'll have to change the print statements and anything else to fit version 3's syntax changes.
(1) Save the following code in a file called
find_high_rain_day.py, and run it once an hour
sometime after minute 5 with cron in a bash script that includes
python3 find_high_rain_day.py
import pandas as pd
import calendar
import datetime
now = datetime.datetime.now()
n = calendar.monthrange(now.year, now.month)[1]
mname = now.strftime("%b")
# Define the column locations and give them unique names. It doesn't matter
# what they are called except for two. We only use DAY and RAIN
headings = ['DAY','B','C','D','E','F','G','H',
'RAIN','J','K','L','M']
colspecs = [(1, 3), (7, 11), (13, 18), (20, 25), (28, 32), (34, 39),
(41, 45), (47, 53), (54, 60), (64, 67), (69, 74), (76, 81),
(84, 88)]
import glob
import os
list_of_files = glob.glob('/var/www/html/weewx/NOAA/*')
latest_file = max(list_of_files, key=os.path.basename)
df = pd.read_fwf(latest_file,names=headings,header=0, colspecs=colspecs,skiprows=12,nrows=n)
maxrain = df['RAIN'].max() # maximum value in rain column
i = df['RAIN'].idxmax() # row index for day with max rain
maxrainday = df['DAY'][i] # day for max rain
import sys
sys.stdout = open('/etc/weewx/skins/Standard/high_rain.txt', 'w')
if maxrainday < 10:
prefix = '0'
else:
prefix = ''
print(maxrain," cm on ",prefix,maxrainday," ",mname,sep="", end=" ")
sys.stdout.close()
This will generate a file "/etc/weewx/skins/Standard/high_rain.txt"
(2) Put the following line in your /etc/weewx/skins/Standard/index.html.tmpl file wherever you want the monthly day with the most rain listed on your website:
#include raw "/etc/weewx/skins/Standard/high_rain.txt"
I tested it on my Raspberry Pi and it seemed to work OK. YMMV.
- Paul VE1DX