python-weather
python-weather copied to clipboard
Temperature is incorrect and with/without state produces different results
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
Thanks for the report, though i'm sure this could be an issue with the wttr.in API itself the library is using.
Today i tried looking up Atlanta, GA on weather.com and it yielded the temperature as 76 degrees.
After comparing it with wttr.in's results:
- query
Atlantayields 75 degrees - query
Atlanta, GAyields 71 degrees
So, this could be either an issue with the API being inaccurate, or the fact that the API doesn't handle requests in a {city}, {state} format well.
For what it's worth, wttr.in's data for my region seems to be about 10 degrees (f) off from what google (citing weather.com) shows me, too.
Things seem off even by zip code. Example for Folsom, CA's zip:
% ./w.py 95630 84 Haze
Google's weather result reports 89 and sunny.
And for Richmond, CA, Google's weather reports 71 and mostly sunny as compared to:
% ./w.py 94805 83 Sunny
Things seem off even by zip code. Example for Folsom, CA's zip:
% ./w.py 95630 84 Haze
Google's weather result reports 89 and sunny.
And for Richmond, CA, Google's weather reports 71 and mostly sunny as compared to:
% ./w.py 94805 83 Sunny
the reason could be what i've said earlier
Correct, the CLI wttr.in seems to match with this module, so it seems to be related to the backend data source?
On Fri, Sep 9, 2022 at 9:49 AM Phillip Marshall @.***> wrote:
For what it's worth, wttr.in's data for my region seems to be about 10 degrees (f) off from what google (citing weather.com) shows me, too.
— Reply to this email directly, view it on GitHub https://github.com/null8626/python-weather/issues/31#issuecomment-1242217939, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTIMYMPC3RDWX27NO7VUHDV5NTDJANCNFSM6AAAAAAQG33I2Q . You are receiving this because you authored the thread.Message ID: @.***>
Sounds like it!