csparpa / pyowm

A Python wrapper around the OpenWeatherMap web API
https://pyowm.readthedocs.io
MIT License
789 stars 171 forks source link

One Call History #314

Closed grrodre closed 4 years ago

grrodre commented 4 years ago

May I be wrong or not properly using it. But it seems that when using _one_callhistory the returned dictionary use also _forecasthourly key whereas the documentation gives hourly. That's a little confusing if it is really an historical data or a forecasted data.

`one_call = mgr.one_call_history(lat=52.52, lon=13.40)

one_call.forecast_hourly `

https://github.com/csparpa/pyowm/blob/53370082a87a90a07a43c6a34fde83002795c89a/pyowm/weatherapi25/one_call.py#L94

csparpa commented 4 years ago

Hi @grrodre I agree with you, but that's exactly how the OWM One Call API works

It might be easier to think of One Call objects such as "photograhps" of observed+forecasted weather data, taken at a specific timestamp. So if you query for a photograph taken in the past, that photo carries along forecasts that might still refer to the past: this depends on

  1. how deeply you go back in time when querying the photograph.
  2. remember that the One Call API provides "Hourly forecast for 48 hours" and "Daily forecast for 7 days" (reference)

To make myself more clear:


# this call retrieves One Call dataset given for: TODAY
one_call = mgr.one_call(lat=52.52, lon=13.40)

# this call retrieves One Call dataset given for: TODAY - 5 DAYS
one_call_history = mgr.one_call_history(lat=52.52, lon=13.40)

one_call.forecast_hourly             # this is the hourly weather forecast given for TODAY and referring to the time interval. TODAY + 48 HOURS (so it's in the future)
one_call_history.forecast_hourly     # this is the hourly weather forecast that was given 5 DAYS AGO and referring to the time interval: [TODAY - 5 DAYS] + 48 HOURS

The same applies to forecast_dailydata

For the moment I'll update the docs so that doesn't sound so confusing

Thanks for pointing this out!

grrodre commented 4 years ago

Hello @csparpa and thank you for your detailed response.

Your explanation make sense, however I think i expressed myself wrong. I meant the One Call API documentation and specific the https://openweathermap.org/api/one-call-api#history history one. The key here is hourly whereas in pyowm is _forecasthourly. That lead me to confusion.

Regards.

csparpa commented 4 years ago

I see your point

IMO PyOWM uses a name ("forecast_hourly") that explains better the meaning of the data with respect to the one used by the JSON in the One Call API (they use "hourly"). So that would possibly be good - at least, improving the lack of semantics in the One Call API

Anyway, is it now clear what the forecasted data in OneCall objects mean ?

csparpa commented 4 years ago

@grrodre I assume this is OK. In case, pls open the issue again

grrodre commented 4 years ago

Ciao @csparpa . Thank for your message and sorry not to reply before. I ended up using directly the api from openweathermaps.

Regargs.