-
-
Notifications
You must be signed in to change notification settings - Fork 30
Description
I'm getting wildly inaccurate temperatures and I cannot pinpoint why. I thought it was because the city was obscure/smaller, but even for some larger cities, it's way off.
Here's some sample code:
import python_weather
import asyncio
import os
import sys
import re
from uszipcode import SearchEngine
async def getweather(place):
async with python_weather.Client(format=python_weather.IMPERIAL) as client:
weather = await client.get(place)
print(weather.current.temperature)
print(weather.current.description)
if __name__ == "__main__":
city = sys.argv[1]
place = city
if re.match(r'^\d{5}', city):
engine = SearchEngine()
zipcode = engine.by_zipcode(city)
city = zipcode.major_city
state = zipcode.state
place = f"{city}, {state}"
asyncio.run(getweather(place))
Output for "Folsom, CA":
% ./w.py "Folsom, CA"
75
Sunny
weather.com reports sunny and 82 and accuweather 85, so 75 seems way off. Even for Atlanta, GA it's off:
% ./w.py "Atlanta, GA"
74
Partly cloudy
weather.com reports partly cloudy and 78, and accuweather 79.
Note that I'm not even using the zip code lookup. I've also tried without the state with different (but also inaccuate) results:
% ./w.py Atlanta
71
Partly cloudy
Here's the version I'm using with Python 3.9:
% /usr/bin/python3.9 -c 'import python_weather; print(python_weather.version)'
0.4.1
Thanks,
Josh