csparpa / pyowm

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

api discards relevant time #297

Closed rhl- closed 4 years ago

rhl- commented 4 years ago

Hi,

I noticed that:

You appear to use this: https://github.com/csparpa/pyowm/blob/a5d8733412168516f869c84600812e0046c209f9/pyowm/weatherapi25/parsers/observationparser.py#L66

as your "reference time".

However, it appears that the OpenWeatherMap API itself provides an epoch timestamp for when the data was recorded by them as the field dt in it's spec.

That dt timestamp is clearly more relevant as that is truly when the OWM server timestamps the weather data.

Also, I am not sure what the value is in forcing the user to round the nanos since epoch time?

csparpa commented 4 years ago

Hello @rhl- I get your points, let me try to explain

Observation objects are a PyOWM abstraction - which builds upon the concepts of Location and Weather being provided by the OpenWeatherMap API. Basically:

OBSERVATION = TIMESTAMP + LOCATION + WEATHER

here the TIMESTAMP refers to when the weather data has been fetched from OWM by PyOWM. Such a timestamp may differ from the one related to the embedded Weather object:

https://github.com/csparpa/pyowm/blob/a5d8733412168516f869c84600812e0046c209f9/pyowm/weatherapi25/weather.py#L407

As per OWM API docs, this latter timestamp refers Time of data calculation, unix, UTC

So the two timestamps mean different things, and on purpose, as they mean different things

As per your second point, you're right - thanks for notifying!