-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strange behaviour during iterative requests #395
Comments
@mrneilbutler My guess without looking through the code again is that weather_at_ids doesn't get the current observation but the last hourly update. You can see that by looking at the reference time that's returned in the Weather Object. @csparpa can likely verify my guess but after doing a quick test on my own with the examples from the documentation it appears to be the case. Each station called seperately run at 19:10Z mgr = owm.weather_manager()
my_city_id = 2643743 #London
wobs = mgr.weather_at_id(my_city_id)
wweather = wobs.weather
wwind = wweather.wind()
print(wobs)
print(wweather)
print(wwind)
my_city_id = 4517009
wobs = mgr.weather_at_id(my_city_id)
wweather = wobs.weather
wwind = wweather.wind()
print(wobs)
print(wweather)
print(wwind)
my_city_id = 5056033
wobs = mgr.weather_at_id(my_city_id)
wweather = wobs.weather
wwind = wweather.wind()
print(wobs)
print(wweather)
print(wwind) Output:
Multiple stations run at 19:15 UTC my_list_of_city_ids = [2643743 , 4517009, 5056033]
listOfObservations = mgr.weather_at_ids(my_list_of_city_ids)
weatherList = [obs.weather for obs in listOfObservations]
windList = [weather.wind() for weather in weatherList]
print(listOfObservations[0])
print(listOfObservations)
print(weatherList[0])
print(weatherList)
print(windList[0])
print(windList) Output:
|
Thanks!! Interesting - that's something I can live with. I had an error where a request was in a function and the reference time in the weather object hadn't changed for 12+ hours. This looked like the same problem. Maybe they're two different things. Also, the different calls could explain the absence of gust, then, I guess. |
@mrneilbutler @geofbaum thank you for investigating this. I will be able to do my part in the upcoming days What I can tell you now is that recently a few issues arose with the legacy OWM API endpoints (which are called by former PyOWM methods such as weahter_at_id and the likes)... My 2 cents on this: OWM is silently telling us to switch to using the OneCall endpoints only... Which @mrneilbutler is by the way something you can already do from your code via PyOWM, and it would be interesting to see if data misalignments also happen in that case! |
I have been having trouble with pyowm not returning the most recent weather data when the request is inside a function definition or a list iteration. (I apologise if my terminology here is incorrect). It seems to return the result for a request from the first time that request was made in that specific way. I have refined the code to show the specific bug:
owm = OWM('removed key')
mgr = owm.weather_manager()
placesIDs = ['removed list of places']
wobs = mgr.weather_at_id(placesIDs[0])
wweather = wobs.weather
wwind = wweather.wind()
print(wobs)
print(wweather)
print(wwind)
listOfObservations = mgr.weather_at_ids(placesIDs)
weatherList = [obs.weather for obs in listOfObservations]
windList = [weather.wind() for weather in weatherList]
print(listOfObservations[0])
print(weatherList[0])
print(windList[0])
The two lumps of code should return the exact same data. However they do not. This is the print out:
<pyowm.weatherapi25.observation.Observation - reception_time=2022-04-01 17:04:14+00:00>
<pyowm.weatherapi25.weather.Weather - reference_time=2022-04-01 17:04:13+00:00, status=clouds, detailed_status=broken clouds>
{'speed': 2.84, 'deg': 313, 'gust': 5.77}
<pyowm.weatherapi25.observation.Observation - reception_time=2022-04-01 17:04:14+00:00>
<pyowm.weatherapi25.weather.Weather - reference_time=2022-04-01 16:09:47+00:00, status=clouds, detailed_status=broken clouds>
{'speed': 3.11, 'deg': 328}
The weather managers are the same but the .weathers are not and the wind data is different. This is not limited to wind but as a bonus I have noticed that the gust information is stripped from the data created through the iterative method.
This behviour is preserved on Thonny on windows and Raspberry Pi and directly on python3 on Raspberry Pi.
Hopefully I haven't wasted your time!
The text was updated successfully, but these errors were encountered: