Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
allw = getAllCurrentWeather()
# here's a list of Illinois-area wban_codes (from python scripts/get_weather_station_bboxes.py where whitelist_urls=['ce29323c565cbd4a97eb61c73426fb01'] (idol_public_works_prohibited_contractors)
illinois_wbans = [u'14855', u'54808', u'14834', u'04838', u'04876', u'03887', u'04871', u'04873', u'04831', u'04879', u'04996', u'14880', u'04899', u'94892', u'94891', u'04890', u'54831', u'94870', u'04894', u'94854', u'14842', u'93822', u'04807', u'04808', u'54811', u'94822', u'94846', u'04868', u'04845', u'04896', u'04867', u'04866', u'04889', u'14816', u'04862', u'94866', u'04880', u'14819']
#illinois_w = getCurrentWeather(wban_codes=illinois_wbans)
metars = []
om = None
rain_metar = None
all_metars = []
for w in allw:
#for w in illinois_w:
try:
metar = Metar(w)
except ParserError, e:
print "parser error! on error" , e
all_metars.append(metar)
wban = getWban(metar)
if (wban in illinois_wbans):
print w
if (wban =='94846'):
om = metar # ohare metar
if metar.precip_1hr:
rain_metar = metar
print "got Wban from metar: ", wban
metars.append(metar)
#print "metar is", metar
dumpMetar(metar)
from lxml import objectify
current_METAR_url = 'https://aviationweather.gov/adds/dataserver_current/current/'
#xml_METAR_url = 'https://aviationweather.gov/adds/dataserver_current/httpparam?datasource=metars&requesttype=retrieve&format=xml&hoursBeforeNow=1.25&stationString=KORD'
weather_etl = weather.WeatherETL(debug=True)
# An example code:
# - In this example, we have "few clouds at 1500 feet, broken clouds at 4,000 feet w/ cumulonimbus,
# broken at 6,500 feet, overcast at 20,000 feet"
# - Visibility is 2 statute miles
#code = "METAR KEWR 111851Z VRB03G19KT 2SM R04R/3000VP6000FT TSRA BR FEW015 BKN040CB BKN065 OVC200 22/22 A2987 RMK AO2 PK WND 29028/1817 WSHFT 1812 TSB05RAB22 SLP114 FRQ LTGICCCCG TS OHD AND NW-N-E MOV NE P0013 T02270215"
code = "METAR KEWR 111851Z VRB03G19KT 2SM R04R/3000VP6000FT TSRA BR FEW015 BKN040CB BKN065 OVC200 22/22 A2987 RMK AO2 PK WND 29028/1817 WSHFT 1812 TSB05RAB22 SLP114 FRQ LTGICCCCG TS OHD AND NW-N-E MOV NE P0013 T02270215"
# using the python-metar library
obs = Metar(code)
def all_callSigns():
sql = "SELECT call_sign FROM weather_stations ORDER by call_sign"
result=engine.execute(sql)
#x = result.first()
return [x[0] for x in result.fetchall()]
def callSign2Wban(call_sign):
sql = "SELECT wban_code FROM weather_stations where call_sign='%s'" % call_sign
result = engine.execute(sql)
#print "result=", result
x = result.first()
wban = None
if x:
wban = x[0]
def dumpRawMetar(raw_metar):
print "raw_metar=", raw_metar
obs = Metar(raw_metar)
dumpMetar(obs)
def dumpRawMetar(raw_metar):
print(("raw_metar=", raw_metar))
obs = Metar(raw_metar)
dumpMetar(obs)
def getMetar(metar_string):
m = Metar(metar_string)
return m