Skip to content

Commit 3f44351

Browse files
Update docs
1 parent 4851567 commit 3f44351

File tree

10 files changed

+258
-383
lines changed

10 files changed

+258
-383
lines changed

Pipfile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,19 @@ verify_ssl = true
44
name = "pypi"
55

66
[packages]
7-
requests = "==2.31.0"
8-
appdirs = "==1.4.4"
9-
requests-mock = "==1.11.0"
10-
geojson = "==3.1.0"
7+
requests = "*"
8+
appdirs = "*"
9+
requests-mock = "*"
10+
geojson = "*"
1111
datapoint = {file = ".", editable = true}
1212

1313
[dev-packages]
14+
black = "*"
15+
isort = "*"
16+
flake8 = "*"
17+
flake8-bugbear = "*"
18+
pytest = "*"
19+
flake8-pytest-style = "*"
1420

1521
[documentation]
1622
sphinx = "*"

Pipfile.lock

Lines changed: 185 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/source/forecast_sites_map.png

-146 KB
Binary file not shown.

docs/source/getting-started.rst

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,73 +7,57 @@ simple script which prints out data in just 6 lines of Python.
77
API Key
88
-------
99

10-
To access DataPoint you need to
11-
`register <http://www.metoffice.gov.uk/datapoint/API>`__ with the Met
12-
Office and get yourself an API key. The process is simple and just
13-
ensures that you don’t abuse the service.
10+
To access DataPoint you need to `register <https://datahub.metoffice.gov.uk/>`__
11+
with the Met Office and get yourself an API key. The process is simple and just
12+
ensures that you don’t abuse the service. You will need access to the
13+
Site-Specific forecast API.
1414

15-
Connecting to DataPoint
15+
Connecting to DataHub
1616
-----------------------
1717

18-
Now that we have an API key we can import the module:
18+
Now that you have an API key you can import the module:
1919

2020
::
2121

2222
import datapoint
2323

24-
And create a connection to DataPoint:
24+
And create a connection to DataHub:
2525

2626
::
2727

28-
conn = datapoint.connection(api_key="aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
28+
manager = datapoint.Manager(api_key="aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
2929

30-
This creates a :ref:`manager` object which manages our connection and interacts
31-
with DataPoint for us, we’ll discuss Manager Objects in depth later but for now
32-
you just need to know that it looks after your API key and has a load of methods
33-
to return data from DataPoint.
30+
This creates a `manager` object which manages the connection and interacts
31+
with DataHub.
3432

35-
Getting data from DataPoint
33+
Getting data from DataHub
3634
---------------------------
3735

38-
So now that we have our Manager Object with a connection to DataPoint we can
39-
request some data. Our goal is to request some forecast data but first we need
40-
to know the site ID for the location we want data for. Luckily the Manager
41-
Object has a method to return a :ref:`site` object, which contains the ID among
42-
other things, from a specified latitude and longitude.
43-
44-
We can simply request a Site Object like so:
45-
46-
::
47-
48-
site = conn.get_nearest_forecast_site(51.500728, -0.124626)
49-
50-
For now we’re just going to use this object to get us our forecast but
51-
you’ll find more information about what the Site Object contains later.
52-
53-
Let’s call another of the Manager Object’s methods to give us a
54-
:ref:`forecast` object for our site:
36+
So now that you have a Manager object with a connection to DataHub you can
37+
request some data. To do this, use the `manager` object:
5538

5639
::
5740

58-
forecast = conn.get_forecast_for_site(site.location_id, "3hourly")
41+
forecast = manager.get_forecast(51, 0, "hourly")
5942

60-
We’ve given this method two parameters, the site ID for the forecast we want and
61-
also a forecast type of “3hourly”. We’ll discuss the forecast types later on.
43+
This takes three parameters: the latitude and longitude of the location you want
44+
a forecast for and also a forecast type of “hourly”. We’ll discuss the forecast
45+
types later on.
6246

6347
This Forecast Object which has been returned to us contains lots of information
6448
which we will cover in a later section, right now we’re just going to get the
65-
:ref:`timestep` object which represents right this minute:
49+
data for the current time:
6650

6751
::
6852

69-
current_timestep = forecast.now()
53+
current_weather = forecast.now()
7054

71-
This Timestep Object contains many different details about the weather
72-
but for now we’ll just print out the weather text.
55+
This is a dict which contains many different details about the weather
56+
but for now we’ll just print out one field.
7357

7458
::
7559

76-
print current_timestep.weather.text
60+
print(current_weather["feelsLikeTemperature"])
7761

7862
And there you have it. If you followed all the steps you should have
7963
printed out the current weather for your chosen location.

docs/source/index.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@ datapoint-python documentation
1212

1313
install
1414
getting-started
15-
locations
16-
objects
15+
migration

0 commit comments

Comments
 (0)