This is the base model object and provides low level access.
More...
|
| Cached property(_getCached) |
|
| ObservationSitelist property(_getObList) |
| This provides the list of observation sites.
|
|
| ForecastSitelist property(_getFcList) |
| This provides the list of forecast sites.
|
|
|
def | _getCached |
|
def | _getObList |
|
def | _getFcList |
|
def | _makeApiRequest |
| All data requests made to the DataPoint API come through this method.
|
|
def | _getObservationTimes |
| This method provides the list of times for which observations are available.
|
|
def | _getForecastDays |
| This method provides a list of days for which forecasts are available.
|
|
def | _getForecastTimes |
| This method provides a list of times for which forecasts are available.
|
|
def | _getObservationSitelist |
| Warning: may not be completely reliable.
|
|
def | _getForecastSitelist |
| Warning: may not be completely reliable.
|
|
def | _getFcsXMLSitelist |
| This version retrieves XML and seems to be more reliable! No idea why that should be.
|
|
def | _getObsXMLSitelist |
| This version retrieves observation sites using an XML request.
|
|
def | _getPlaces |
| This method obtains a list of places corresponding to a given location.
|
|
def | _getNearestObservationId |
| A method to get round the lack of 'nearestlatlon' for observations.
|
|
|
| _key |
| Holds client api-key.
|
|
| _url |
| Holds current DataPoint api URL.
|
|
| _currentLocation |
|
| _placeList |
|
| _obCached |
|
| _fcCached |
|
| _obsSitelist |
|
| _fcsSitelist |
|
This is the base model object and provides low level access.
Definition at line 45 of file base.py.
def pymetoffice.base.baseModel.__init__ |
( |
|
self, |
|
|
|
url, |
|
|
|
key |
|
) |
| |
Constructor.
- Parameters
-
url | This is mandatory and must be the current base url for the Met Office DataPoint services. at the time of writing, this is http://datapoint.metoffice.gov.uk It has changed in the past and may well do so again. |
key | This is mandatory and you must obtain a key from the Met Office DataPoint web site. Currently, this is free for modest usage (<= 5000 data requests per day and <= 100 requests/minute). Register (free) at http://www.metoffice.gov.uk/datapoint (currently). |
Definition at line 59 of file base.py.
def pymetoffice.base.baseModel._getFcsXMLSitelist |
( |
|
self | ) |
|
|
private |
This version retrieves XML and seems to be more reliable! No idea why that should be.
Definition at line 256 of file base.py.
def pymetoffice.base.baseModel._getForecastDays |
( |
|
self | ) |
|
|
private |
This method provides a list of days for which forecasts are available.
- Returns
- List of times in yyyymmddThhmmZ format
Definition at line 179 of file base.py.
def pymetoffice.base.baseModel._getForecastSitelist |
( |
|
self | ) |
|
|
private |
Warning: may not be completely reliable.
This method obtains the list of sites for forecasts. As currently coded it is unreliable as it does not always manage to collect all data from the connection. However, the failure rate is much lower than for observation sites.
- Returns
- List of Site objects.
Definition at line 238 of file base.py.
def pymetoffice.base.baseModel._getForecastTimes |
( |
|
self | ) |
|
|
private |
This method provides a list of times for which forecasts are available.
- Returns
- List of times in yyyymmddThhmmZ format
Definition at line 193 of file base.py.
def pymetoffice.base.baseModel._getNearestObservationId |
( |
|
self, |
|
|
|
place |
|
) |
| |
|
private |
A method to get round the lack of 'nearestlatlon' for observations.
Definition at line 312 of file base.py.
def pymetoffice.base.baseModel._getObservationSitelist |
( |
|
self | ) |
|
|
private |
Warning: may not be completely reliable.
Work in progress. This method obtains the list of observation sites. As currently coded it is ok but may fail if the list of sites increases dramatically. The problem is not always managing to collect all data from the connection. Actually, this is consistently quite unreliable!
- Returns
- List of Site objects.
Definition at line 213 of file base.py.
def pymetoffice.base.baseModel._getObservationTimes |
( |
|
self | ) |
|
|
private |
This method provides the list of times for which observations are available.
- Returns
- List of times in yyyymmddThhmmZ format
Definition at line 165 of file base.py.
def pymetoffice.base.baseModel._getObsXMLSitelist |
( |
|
self | ) |
|
|
private |
This version retrieves observation sites using an XML request.
Really provided for completeness.
- Returns
- List of Site objects where observations are made.
Definition at line 280 of file base.py.
def pymetoffice.base.baseModel._getPlaces |
( |
|
self, |
|
|
|
location |
|
) |
| |
|
private |
This method obtains a list of places corresponding to a given location.
Definition at line 303 of file base.py.
def pymetoffice.base.baseModel._makeApiRequest |
( |
|
self, |
|
|
|
access, |
|
|
|
datatype, |
|
|
|
datacategory, |
|
|
|
dataclass, |
|
|
|
datasource, |
|
|
|
dataformat, |
|
|
|
datarequest, |
|
|
|
requestargs |
|
) |
| |
|
private |
All data requests made to the DataPoint API come through this method.
It is made as future-proof as reasonably possible but does assume that the API will stick to the URL+parameter-string format for requests Note: some Met Office documentation leaves out the second folder (currently data). The API would not work for me with this omission. The same documentation gives a previous base url.
- Parameters
-
access | Currently 'public' |
datatype | Currently 'data' |
datacategory | one of the following at present: val for values (quite a lot of requests)
layer usually used for maps and related requests
txt usually for requests where the interesting data is text |
dataclass | Currently 'wxobs' for observations and 'wxfcs' for forecasts. |
datasource | This has different meanings for different types of requests. 'all' for many requests a layer name for map requests 'mountain area' for mountain forecasts 'nationalpark' for National Park forecasts. |
dataformat | Currently available formats are 'xml' and 'json' |
datarequest | The Met Office calls this location which is rather misleading. For many requests it is a location, either as id number as a string. It may also be an image format 'png' or 'gif' at present. This is used for requests returning image data (maps etc). It may also be 'sitelist' or 'capabilities' which do what they say on the tin. |
requestargs | This must be a dictionary of the other parameters required by the request. The mandatory entry in the dictionary of 'key':api-access-key is added automatically, where the api access key is obtained as described above. |
- Returns
- A 2-tuple consisting of: a string which is the raw xml or json according to the dataformat requested (the caller must parse the data as needed) and the URL used for the request (for diagnostic purposes, mostly discarded).
Definition at line 143 of file base.py.
pymetoffice.base.baseModel._key |
|
private |
Holds client api-key.
Definition at line 62 of file base.py.
pymetoffice.base.baseModel._url |
|
private |
Holds current DataPoint api URL.
Definition at line 64 of file base.py.
pymetoffice.base.baseModel.ForecastSitelist property(_getFcList) |
|
static |
This provides the list of forecast sites.
At the time of writing, there are just over 120 of these.
Definition at line 94 of file base.py.
pymetoffice.base.baseModel.ObservationSitelist property(_getObList) |
|
static |
This provides the list of observation sites.
At the time of writing, there are just over 5000 of these.
Definition at line 90 of file base.py.
The documentation for this class was generated from the following file: