Skip to content
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

Object-oriented library interface #4

Open
amotl opened this issue Jun 3, 2019 · 1 comment
Open

Object-oriented library interface #4

amotl opened this issue Jun 3, 2019 · 1 comment

Comments

@amotl
Copy link
Member

amotl commented Jun 3, 2019

@JohannesRol follows a more object-oriented library interface approach with his dwdopendata package. There, you will create a location object from a factory function obtaining the geolocation and subsequently be able to invoke appropriate methods on that object for acquiring actual weather information.

We like that approach, so it would be nice to see a similar interface here.


Original example

import dwdopendata as dwd

# Acquire location object from coordinates of nearest station.
location = dwd.location(51.898, 8.9876)

# Acquire wind speed data for specific location and time range from specified resolution dataset.
wind_speed = location.wind('2019-05-01T00:00:00', '2019-05-02T00:00:00', '10min')
@amotl
Copy link
Member Author

amotl commented Jun 3, 2019

Another proposal

from dwdweather import DwdWeather

# Create main application object with given resolution dataset.
dwd = DwdWeather(resolution='10_minutes')

# Acquire station object by looking up nearest station by given coordinates.
station = dwd.nearest_station(latitude=51.898, longitude=8.9876)

# Acquire wind speed data for specific location and time range.
wind_speed = station.wind(dtstart='2019-05-01T00:00:00', dtend='2019-05-02T00:00:00')

Rationale

As finding the appropriate station depends on the resolution dataset (hourly, 10_minutes, etc.), this information must be available to the machinery before performing any station lookup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant