METAR REPORTS & PYTHON



Hiya, I am not sure how many people will be interested in this. I've been
learning python for around six months and have developed a script that logs
the METAR reports given by airports around the world.
I set mine up to log Heathrow Airport as I am within around 25miles of
Heathrow, closer if you measure as the crow flies.

Anyway, it could be useful for anyone that has a weather station, or is
about to build their own(like me), to verify that the readings you are
taking are somewhat sensible. Obviously the only drawback is that you need
to live within a sensible distance from a METAR reporting site. There's a
huge list available from NOAA.

There's still some work I need to do, such as making the graphs look much
nicer and add further data etc etc.
Thanks to Tobias Klausman who wrote pymetar.py and Mr John Hunter for
matplotlib.
The script basically logs onto NOAA FTP and pulls the data in raw format.
Pymetar does all the clever work and converts the raw file to something
inteligible. Then my script logs whatever I've told it to log and produces
the graphs. YEY!!!!

Ofcourse there are websites on the net such as the Met office which will
show similar data. I only did this because I am learning, and you can't
learn by not doing!! ENJOY

#The script V0.1 - Please feel free to use and give credit where credit is
due.
# This is my weather monitor program. I wanted a live reference site so I
could check my own instruments once they are active.
# It's also to work as a sort of development script for the software that
will run when my instruments are ready.

import pymetar
import sys
import fpformat
import math
import time
import shutil
import os
print 'Downloading from NOAA FTP'

#which station would you like sir?
if len(sys.argv)<2:
station="egll"
else:
station=sys.argv[1]

rf=pymetar.ReportFetcher(station)
rep=rf.FetchReport()
rp=pymetar.ReportParser()
pr=rp.ParseReport(rep)

#Creates all the folders used for storing the data
if not os.path.exists(time.strftime('./%Y')):
os.mkdir(time.strftime('./%Y'))
if not os.path.exists(time.strftime('./%Y/%m')):
os.mkdir(time.strftime('./%Y/%m'))
if not os.path.exists(time.strftime('./%Y/%m/%d')):
os.mkdir(time.strftime('./%Y/%m/%d'))

#uses pymetar v0.12 to fetch sensible data
saveout = sys.stdout
metar = open(time.strftime('./%Y/%m/%d/%dTemp.dat'), 'a')
sys.stdout = metar
print pr.getTemperatureCelsius()
sys.stdout = saveout
metar.close()

saveout = sys.stdout
metar = open(time.strftime('./%Y/%m/%d/%dWindSpeed.dat'), 'a')
sys.stdout = metar
print pr.getWindSpeedMilesPerHour()
sys.stdout = saveout
metar.close()

saveout = sys.stdout
metar = open(time.strftime('./%Y/%m/%d/%dPressure.dat'), 'a')
sys.stdout = metar
print pr.getPressure()
sys.stdout = saveout
metar.close()

print 'Download Complete'
###############################################################
#Makes the pretty graphs from the dull data
import string
from pylab import *
from matplotlib.ticker import MultipleLocator, FormatStrFormatter

l = load(time.strftime('./%Y/%m/%d/%dTemp.dat'))
t = l
plot(l, 'o')
xlabel('Time')
ylabel('Temperature')
title('Temperature Log')
grid(True)
savefig(time.strftime('./%Y/%m/%d/%dTemp.png'))
close()

x = load(time.strftime('./%Y/%m/%d/%dWindSpeed.dat'))
s = x
plot(x, 'o')
xlabel('Time')
ylabel('wind speed')
title('Wind Speed')
grid(True)
savefig(time.strftime('./%Y/%m/%d/%dWind.png'))
close()

majorLocator = MultipleLocator(10)
z = load(time.strftime('./%Y/%m/%d/%dPressure.dat'))
k = z
plot(z, 'o')
ax = subplot(111)
ax.yaxis.set_major_locator(majorLocator)
ax.autoscale_view()
xlabel('Time')
ylabel('Pressure')
title('Pressure hpa')
grid(True)
savefig(time.strftime('./%Y/%m/%d/%dPressure.png'))
close()
#############################################################
print 'Graphs Complete'



.



Relevant Pages

  • RE: SP1 Install Errors
    ... I have received your logs files and emails. ... time difference between us, and as you know, SP1 log is a large file and we ... First attempt at executing script sp1_serv_uni.sql failed; ... Microsoft CSS Online Newsgroup Support ...
    (microsoft.public.windows.server.sbs)
  • RE: Domain Startup Scripting
    ... the following command always works and logs the appropriate info ... above which tells me it is accessing the script, ... could help me with troubleshooting a domain startup script routine. ... @echo off ...
    (microsoft.public.windows.server.scripting)
  • Re: Need some problemsolving-cgi/xml
    ... Did you check the server logs to see what ... Have you tested the script at ... > I get a CGI timeout error. ... How can I combine all these xml files/xsl to ...
    (comp.lang.perl.misc)
  • Re: GPO Logon Script that requires AD rights
    ... Preferring not to do this by hand, I whipped up a quick vbs script ... The script will run repeatedly, everytime someone logs on. ... From the shared log file you can create a spreadsheet with the Distinguished Names of each computer and the Distinguished Name of the OU they should be moved into. ... Then you can code a VBScript program to read the values from the final spreadsheet, bind to each OU, and use the MoveHere method to move the computer objects into the correct OU's. ...
    (microsoft.public.scripting.vbscript)