python-weather icon indicating copy to clipboard operation
python-weather copied to clipboard

Temperature is incorrect and with/without state produces different results

Open jkc120 opened this issue 3 years ago • 6 comments

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

jkc120 avatar Sep 07 '22 15:09 jkc120

Thanks for the report, though i'm sure this could be an issue with the wttr.in API itself the library is using.

null8626 avatar Sep 09 '22 15:09 null8626

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 Atlanta yields 75 degrees
  • query Atlanta, GA yields 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.

null8626 avatar Sep 09 '22 15:09 null8626

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.

wizpig64 avatar Sep 09 '22 16:09 wizpig64

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

jkc120 avatar Sep 12 '22 22:09 jkc120

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

null8626 avatar Sep 13 '22 23:09 null8626

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: @.***>

jkc120 avatar Oct 11 '22 07:10 jkc120

Sounds like it!

null8626 avatar May 18 '23 11:05 null8626