I wrote a python script to convert the degrees numbers to a wind rose direction as seen in the "current conditions" part.
The wind rose is divided in 16 parts, so you got N, NNE, NE, ENE, E ............
16 Wind rose pictures are generated with the help of a program at http://www.642weather.com/weather/scripts-wind-graphics.php
The icons are placed in /home/weewx/skins/Standard and the script in /home/weewx
There is only one thing to edit, add a line (between line 73 and 74) at the "index.html.tmpl" file.
<tr>
<td class="stats_label">Wind</td>
<td class='stats_data'>$current.windSpeed from $current.windDir</td>
ADD this line <td> <img src="WindDirection.png"/> </td>
</tr>
And put this line in crontab "*/5 * * * * python2.7 /home/weewx/WindDirection.py"
That's all.
It's not the best way to do but its works.............(just started with learning python)
Also when weewx get a update, nothing as to be changed for the wind rose script.
Look at my webpage www.pa3aod.nl/index.html for the result.
The script:
import re
import shutil
file = open('/var/www/index.html', "r")
for line in file:
s = re.search(r"<td class='stats_data'>\d{1,3} km/h from (?P<number>[0-9]{1,3})°</td>",line)
if s:
print s.group('number')
Direction = int(s.group('number'))
if (Direction >= 0) and (Direction <= 11):
print "N"
shutil.copy2('/home/weewx/skins/Standard/N.png', '/var/www/WindDirection.png')
elif (Direction > 11) and (Direction < 34):
print "NNE"
shutil.copy2('/home/weewx/skins/Standard/NNE.png', '/var/www/WindDirection.png')
elif (Direction >= 34) and (Direction <= 56):
print "NE"
shutil.copy2('/home/weewx/skins/Standard/NE.png', '/var/www/WindDirection.png')
elif (Direction > 57) and (Direction < 79):
print "ENE"
shutil.copy2('/home/weewx/skins/Standard/ENE.png', '/var/www/WindDirection.png')
elif (Direction >= 79) and (Direction <= 101):
print "E"
shutil.copy2('/home/weewx/skins/Standard/E.png', '/var/www/WindDirection.png')
elif (Direction >= 102) and (Direction < 124):
print "ESE"
shutil.copy2('/home/weewx/skins/Standard/ESE.png', '/var/www/WindDirection.png')
elif (Direction >= 124) and (Direction <= 146):
print "SE"
shutil.copy2('/home/weewx/skins/Standard/SE.png', '/var/www/WindDirection.png')
elif (Direction > 147) and (Direction < 169):
print "SSE"
shutil.copy2('/home/weewx/skins/Standard/SSE.png', '/var/www/WindDirection.png')
elif (Direction >= 169) and (Direction <= 191):
print "S"
shutil.copy2('/home/weewx/skins/Standard/S.png', '/var/www/WindDirection.png')
elif (Direction > 191) and (Direction < 214):
print "SSW"
shutil.copy2('/home/weewx/skins/Standard/SSW.png', '/var/www/WindDirection.png')
elif (Direction >= 214) and (Direction < 236):
print "SW"
shutil.copy2('/home/weewx/skins/Standard/SW.png', '/var/www/WindDirection.png')
elif (Direction >=236) and (Direction < 259):
print "WSW"
shutil.copy2('/home/weewx/skins/Standard/WSW.png', '/var/www/WindDirection.png')
elif (Direction >= 259) and (Direction < 281):
print "W"
shutil.copy2('/home/weewx/skins/Standard/W.png', '/var/www/WindDirection.png')
elif (Direction >= 281) and (Direction < 304):
print "WNW"
shutil.copy2('/home/weewx/skins/Standard/WNW.png', '/var/www/WindDirection.png')
elif (Direction >= 304) and (Direction < 326):
print "NW"
shutil.copy2('/home/weewx/skins/Standard/NW.png', '/var/www/WindDirection.png')
elif (Direction >= 326) and (Direction <= 349):
print "NNW"
shutil.copy2('/home/weewx/skins/Standard/NNW.png', '/var/www/WindDirection.png')
elif (Direction > 349) and (Direction <= 360):
print "N"
shutil.copy2('/home/weewx/skins/Standard/N.png', '/var/www/WindDirection.png')
Does the code at least make a new index.html ? Or does it make a index.html file of zero bytes?
I made the pictures on my pc and ftp's them to the correct folder on the pi. Look at your index.html file and see if the code for the rose is being added.eg. <img src="rose0.png"/>
--
You received this message because you are subscribed to a topic in the Google Groups "Weewx user's group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/vwX11T8pBlM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
<svg version="1.1" baseProfile="full" width="200" height="200" xmlns="http://www.w3.org/2000/svg"> <circle cx="90" cy="85" r="75" stroke="black" stroke-width="5" stroke-dasharray="1,12.08" fill="transparent" /> <circle cx="90" cy="85" r="80" stroke="lightgray" stroke-width="10" fill="transparent" /> <polygon points="90 35, 100 75, 140 85, 100 95, 90 135, 80 95, 40 85, 80 75" fill="lightsalmon" transform="rotate(45 90 85)" /> <polygon points="90 25, 100 75, 150 85, 100 95, 90 145, 80 95, 30 85, 80 75" fill="salmon" /> <text x="90" y="22" font-size="16" text-anchor="middle" fill="gray">N</text> <text x="90" y="159" font-size="16" text-anchor="middle" fill="gray">S</text> <text x="22" y="91" font-size="16" text-anchor="middle" fill="gray">W</text> <text x="158" y="91" font-size="16" text-anchor="middle" fill="gray">E</text> <circle cx="90" cy="85" r="20" stroke="black" fill="white" /> <text x="90" y="90" font-size="16" text-anchor="middle" fill="black">$current.windSpeed.formatted</text> #if $current.windDir.formatted != " N/A" <polygon points="90 20, 95 65, 85 65" fill="black" transform="rotate($current.windDir.formatted 90 85)" /> #end if</svg>