|
1 | 1 | # _Datapoint for Python_ |
2 | 2 |
|
3 | | -_This is a Python module for accessing weather data via the [Met Office](http://www.metoffice.gov.uk/)'s open data API |
| 3 | +_A Python module for accessing weather data via the [Met Office](http://www.metoffice.gov.uk/)'s open data API |
4 | 4 | known as [Datapoint](http://www.metoffice.gov.uk/datapoint)._ |
5 | 5 |
|
6 | 6 | __Disclaimer: This module is in no way part of the datapoint project/service. |
7 | 7 | This module is intended to simplify the use of Datapoint for small Python projects (e.g school projects). |
8 | 8 | No support for this module is provided by the Met Office and may break as the Datapoint service grows/evolves. |
9 | 9 | The author will make reasonable efforts to keep it up to date and fully featured.__ |
10 | 10 |
|
11 | | -## Project Setup |
| 11 | +## Installation |
12 | 12 |
|
13 | | -_How do I, as a developer, start working on the project?_ |
| 13 | +```Bash |
| 14 | +$ pip install datapoint |
| 15 | +``` |
14 | 16 |
|
15 | | -1. _What dependencies does it have (where are they expressed) and how do I install them?_ |
16 | | -2. _How can I see the project working before I change anything?_ |
| 17 | +You will also require a [Datapoint API key](http://www.metoffice.gov.uk/datapoint/API). |
| 18 | +## Example Usage |
17 | 19 |
|
18 | | -## Deploying |
| 20 | +```Python |
| 21 | +#!/usr/bin/env python |
19 | 22 |
|
20 | | -### _How to setup the deployment environment_ |
| 23 | +import datapoint |
21 | 24 |
|
22 | | -- _Required heroku addons, packages, or chef recipes._ |
23 | | -- _Required environment variables or credentials not included in git._ |
24 | | -- _Monitoring services and logging._ |
| 25 | +conn = datapoint.Manager(api_key="aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") |
25 | 26 |
|
26 | | -### _How to deploy_ |
| 27 | +site = conn.get_nearest_site(-0.124626, 51.500728) |
| 28 | +print site.name |
27 | 29 |
|
28 | | -## Troubleshooting & Useful Tools |
| 30 | +forecast = conn.get_forecast_for_site(site.id, "3hourly") |
29 | 31 |
|
30 | | -_Examples of common tasks_ |
| 32 | +for day in forecast.days: |
| 33 | +print "\n%s" % day.date |
| 34 | + for timestep in day.timesteps: |
| 35 | + print timestep.name |
| 36 | + print timestep.weather.text |
| 37 | + print "%s%s%s" % (timestep.temperature.value, |
| 38 | + u'\xb0', #Unicode character for degree symbol |
| 39 | + timestep.temperature.units) |
31 | 40 |
|
32 | | -> e.g. |
33 | | -> |
34 | | -> - How to make curl requests while authenticated via oauth. |
35 | | -> - How to monitor background jobs. |
36 | | -> - How to run the app through a proxy. |
| 41 | +``` |
| 42 | + |
| 43 | +Example output |
| 44 | +``` |
| 45 | +London |
| 46 | +
|
| 47 | +2014-07-16Z |
| 48 | +360 |
| 49 | +Sunny day |
| 50 | +16°C |
| 51 | +540 |
| 52 | +Sunny day |
| 53 | +22°C |
| 54 | +720 |
| 55 | +Partly cloudy (day) |
| 56 | +24°C |
| 57 | +900 |
| 58 | +Cloudy |
| 59 | +26°C |
| 60 | +1080 |
| 61 | +Cloudy |
| 62 | +25°C |
| 63 | +1260 |
| 64 | +Partly cloudy (night) |
| 65 | +23°C |
| 66 | +
|
| 67 | +... |
| 68 | +``` |
| 69 | + |
| 70 | +## Features |
| 71 | + * List forecast sites |
| 72 | + * Get nearest forecast site from lon and lat |
| 73 | + * Get the following 5 day forecast types for any site |
| 74 | + * Daily (Two timesteps, midday and midnight UTC) |
| 75 | + * 3 hourly (Eight timesteps, every 3 hours starting at midnight UTC) |
| 76 | + |
| 77 | +### Future Enhancements |
| 78 | + * Observations for any site |
| 79 | + * Ensure correct typecasting on returned data |
| 80 | + * [Capabilities](http://www.metoffice.gov.uk/datapoint/product/uk-3hourly-site-specific-forecast/detailed-documentation#5,000 UK locations three hourly forecasts capabilities feed) (List available data without actually retrieving data) |
| 81 | + * Text forecasts |
| 82 | + * And more... |
37 | 83 |
|
38 | 84 | ## Contributing changes |
39 | 85 |
|
40 | | -- _Internal git workflow_ |
41 | | -- _Pull request guidelines_ |
42 | | -- _Tracker project_ |
43 | | -- _Google group_ |
44 | | -- _irc channel_ |
45 | | -- _"Please open github issues"_ |
| 86 | +Please feel free to submit issues and pull requests. |
46 | 87 |
|
47 | 88 | ## License |
| 89 | + |
| 90 | +[MIT Licence](http://opensource.org/licenses/MIT) |
0 commit comments