SpecialK
Posts: 135
Registered: 4-9-2014
Member Is Offline
|
|
Trivial Current Wind Conditions Tracker
In anticipation/excitement of my gear ariving (thanks beamerbob/ad72!), I went ahead and wrote a script that pulls local weather conditions from
wunderground's PWS api and plugged it into something called geektool which is like active desktop for OSX. Nothing about the script itself is OS
Specific so it should work on windows. That being said, I don't use windows, so I don't know off the top of my head to embed it into a windows
desktop. Nonetheless, I thought I'd share it with you guys, in case theres some other OSX geeks here that may find it useful.
I literally wrote this in 10 minutes, so it's neither robust nor particularly novel. That being said, its been working for me!
Code: |
#!/usr/bin/python
import urllib2
import json
import time
import sys
HEADINGS = {
0 : 'N',
1 : 'NNE',
2 : 'E',
3 : 'SSE',
4 : 'S',
5 : 'SSW',
6 : 'W',
7 : 'NNW',
}
def getStationCurrentStatus(stationID):
url = "http://stationdata.wunderground.com/cgi-bin/stationlookup?station=%s&format=json"
resp = json.load(urllib2.urlopen(url % stationID))
return resp.get('conds').get(stationID)
def degToDir(deg):
deg = round((deg)/45) % 8
return HEADINGS[deg]
def main():
if len(sys.argv) <= 1:
return
recentData = getStationCurrentStatus(sys.argv[1])
if recentData is None:
return
speed = float(recentData['windspeedmph'])
gust = float(recentData['windgustmph'])
print "Wind: %0.1f / %0.1f MPH" % (speed, gust)
if gust != 0:
print "Quality: %0.1f" % (speed/gust)
print "Dir: %s" % degToDir(int(recentData['winddir']))
lastUpdated = time.time()-float(recentData['lu'])
print "(%0.1f sec ago)" % (lastUpdated)
main()
|
Run it with your favorite PWS station ID from wunderground... as an example:
Code: |
./windinfo.py KCASANFR79
Wind: 1.7 / 3.5 MPH
Quality: 0.5
Dir: SSE
(2.3 sec ago)
|
Just drop it into geektool and you have continuously updating wind/gust/direction info for your favorite PWS
Looks like this on my desktop:
(Note that for my local PWS, gust seems to be broken as it always reads the same as avg wind speed)
15m PL Charger II / 19m FS Speed 3 DLX / 13m PL Venom 1 / 9m HQ Montana 7 / 3m HQ Scout III / Trampa Holy Pro 15° /MBS Comp 90
|
|
dangerdan
Posts: 200
Registered: 9-5-2013
Location: Hamilton Ontario
Member Is Offline
|
|
GeekTool is an application for Mac OS 10.6+ according to Google
HQ Apha V 1.5
HQ Beamer V 2.0
HQ Beamer V 3.0
HQ Toxic V 4.0
Cross Sonic V 5.0
|
|
SpecialK
Posts: 135
Registered: 4-9-2014
Member Is Offline
|
|
Yep! Works fine in 10.9 Mavericks.
15m PL Charger II / 19m FS Speed 3 DLX / 13m PL Venom 1 / 9m HQ Montana 7 / 3m HQ Scout III / Trampa Holy Pro 15° /MBS Comp 90
|
|
hardstatic
Posts: 21
Registered: 4-17-2014
Member Is Offline
|
|
This is very cool, thanks for sharing. Works like a champ!
Flexifoil Rage 1.8 / Sting 2.4
Ozone Quattro 1.6 / Flow 3m / Octane 4m, 5m
|
|
SpecialK
Posts: 135
Registered: 4-9-2014
Member Is Offline
|
|
Awesome! I'm glad someone else got some use out of it!
15m PL Charger II / 19m FS Speed 3 DLX / 13m PL Venom 1 / 9m HQ Montana 7 / 3m HQ Scout III / Trampa Holy Pro 15° /MBS Comp 90
|
|