Climate API¶
-
class
wbpy.ModelledDataset(*args, **kwargs)[source]¶ -
dates(use_datetime=False)[source]¶ Return dataset date start/end pairs.
Parameters: use_datetime – If True, return dates as datetime.date() object instead of strings.
-
as_dict(sres='a2', use_datetime=False)[source]¶ Return dataset data as dictionary.
Keys are: data[gcm][location][date]
Parameters: - sres – Which SRES to use for future values. The API supports A2 and B1, although not all GCMs have data for both.
- use_datetime – Use datetime.date() objects for date keys, instead of strings.
-
-
class
wbpy.ClimateAPI(fetch=None)[source]¶ Request data from the World Bank Climate API.
You can override the default tempfile cache by passing a function
fetch, which requests a URL and returns the response as a string.-
get_instrumental(data_type, interval, locations)[source]¶ Get historical data for temperature or precipitation.
Parameters: - data_type – Either
prfor precipitation, ortasfor temperature. - interval – Either
year,monthordecade. - locations – A list of API location codes - either ISO alpha-2 or alpha-3 country codes, or basin ID numbers.
- data_type – Either
-
get_modelled(data_type, interval, locations)[source]¶ Get modelled data for precipitation or temperature.
Parameters: - data_type – The data statistic ID. See
self.ARG_DEFINITIONS["modelled_types"]for IDs and values. - interval – The interval ID. See
self.ARG_DEFINITIONS["modelled_intervals"]for IDs and values. - locations – A list of API location codes - either ISO alpha-2 or alpha-3 country codes, or basin ID numbers.
- data_type – The data statistic ID. See
-