pyowm documentation - read the docs · pyowm documentation, release an abstract class representing...

76
pyowm Documentation Release Claudio Sparpaglione Dec 23, 2017

Upload: ngoquynh

Post on 17-Apr-2018

231 views

Category:

Documents


8 download

TRANSCRIPT

Page 1: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm DocumentationRelease

Claudio Sparpaglione

Dec 23, 2017

Page 2: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a
Page 3: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

Contents

1 pyowm package 31.1 Subpackages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.1.1 pyowm.abstractions package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.1.1.1 Submodules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.1.1.2 pyowm.abstractions.jsonparser module . . . . . . . . . . . . . . . . . . . . . . . . 31.1.1.3 pyowm.abstractions.linkedlist module . . . . . . . . . . . . . . . . . . . . . . . . 31.1.1.4 pyowm.abstractions.owm module . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.1.1.5 pyowm.abstractions.owmcache module . . . . . . . . . . . . . . . . . . . . . . . . 51.1.1.6 Module contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

1.1.2 pyowm.caches package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.1.2.1 Submodules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.1.2.2 pyowm.caches.lrucache module . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.1.2.3 pyowm.caches.nullcache module . . . . . . . . . . . . . . . . . . . . . . . . . . . 71.1.2.4 Module contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

1.1.3 pyowm.commons package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71.1.3.1 Submodules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71.1.3.2 pyowm.commons.frontlinkedlist module . . . . . . . . . . . . . . . . . . . . . . . 71.1.3.3 pyowm.commons.weather_client module . . . . . . . . . . . . . . . . . . . . . . . 91.1.3.4 pyowm.commons.airpollution_client module . . . . . . . . . . . . . . . . . . . . . 91.1.3.5 pyowm.commons.uv_client module . . . . . . . . . . . . . . . . . . . . . . . . . . 111.1.3.6 Module contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

1.1.4 pyowm.exceptions package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111.1.4.1 Submodules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111.1.4.2 pyowm.exceptions.api_call_error module . . . . . . . . . . . . . . . . . . . . . . . 111.1.4.3 pyowm.exceptions.api_response_error module . . . . . . . . . . . . . . . . . . . . 121.1.4.4 pyowm.exceptions.not_found_error module . . . . . . . . . . . . . . . . . . . . . 121.1.4.5 pyowm.exceptions.parse_response_error module . . . . . . . . . . . . . . . . . . . 121.1.4.6 pyowm.exceptions.unauthorized_error module . . . . . . . . . . . . . . . . . . . . 121.1.4.7 Module contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

1.1.5 pyowm.stationsapi30 package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131.1.5.1 Subpackages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131.1.5.2 Submodules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131.1.5.3 pyowm.stationsapi30.buffer module . . . . . . . . . . . . . . . . . . . . . . . . . . 131.1.5.4 pyowm.stationsapi30.measurement module . . . . . . . . . . . . . . . . . . . . . . 141.1.5.5 pyowm.stationsapi30.persistence_backend module . . . . . . . . . . . . . . . . . . 151.1.5.6 pyowm.stationsapi30.station module . . . . . . . . . . . . . . . . . . . . . . . . . 16

i

Page 4: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

1.1.5.7 pyowm.stationsapi30.station_parser module . . . . . . . . . . . . . . . . . . . . . 171.1.5.8 pyowm.stationsapi30.stations_manager module . . . . . . . . . . . . . . . . . . . 171.1.5.9 Module contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

1.1.6 pyowm.utils package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191.1.6.1 Submodules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191.1.6.2 pyowm.utils.temputils module . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191.1.6.3 pyowm.utils.timeformatutils module . . . . . . . . . . . . . . . . . . . . . . . . . 201.1.6.4 pyowm.utils.timeutils module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211.1.6.5 pyowm.utils.xmlutils module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231.1.6.6 Module contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

1.1.7 pyowm.webapi25 package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241.1.7.1 Subpackages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241.1.7.2 Submodules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241.1.7.3 pyowm.webapi25.cityidregistry module . . . . . . . . . . . . . . . . . . . . . . . 241.1.7.4 pyowm.webapi25.configuration25 module . . . . . . . . . . . . . . . . . . . . . . 251.1.7.5 pyowm.webapi25.forecast module . . . . . . . . . . . . . . . . . . . . . . . . . . 251.1.7.6 pyowm.webapi25.forecaster module . . . . . . . . . . . . . . . . . . . . . . . . . 271.1.7.7 pyowm.webapi25.forecastparser module . . . . . . . . . . . . . . . . . . . . . . . 311.1.7.8 pyowm.webapi25.historian module . . . . . . . . . . . . . . . . . . . . . . . . . . 311.1.7.9 pyowm.webapi25.location module . . . . . . . . . . . . . . . . . . . . . . . . . . 341.1.7.10 pyowm.webapi25.observation module . . . . . . . . . . . . . . . . . . . . . . . . 351.1.7.11 pyowm.webapi25.observationlistparser module . . . . . . . . . . . . . . . . . . . 361.1.7.12 pyowm.webapi25.observationparser module . . . . . . . . . . . . . . . . . . . . . 361.1.7.13 pyowm.webapi25.owm25 module . . . . . . . . . . . . . . . . . . . . . . . . . . . 371.1.7.14 pyowm.webapi25.station module . . . . . . . . . . . . . . . . . . . . . . . . . . . 461.1.7.15 pyowm.webapi25.stationhistory module . . . . . . . . . . . . . . . . . . . . . . . 471.1.7.16 pyowm.webapi25.stationhistoryparser module . . . . . . . . . . . . . . . . . . . . 491.1.7.17 pyowm.webapi25.stationlistparser module . . . . . . . . . . . . . . . . . . . . . . 491.1.7.18 pyowm.webapi25.stationparser module . . . . . . . . . . . . . . . . . . . . . . . . 491.1.7.19 pyowm.webapi25.weather module . . . . . . . . . . . . . . . . . . . . . . . . . . 501.1.7.20 pyowm.webapi25.weathercoderegistry module . . . . . . . . . . . . . . . . . . . . 531.1.7.21 pyowm.webapi25.weatherhistoryparser module . . . . . . . . . . . . . . . . . . . 531.1.7.22 pyowm.webapi25.weatherutils module . . . . . . . . . . . . . . . . . . . . . . . . 531.1.7.23 pyowm.webapi25.uvindex module . . . . . . . . . . . . . . . . . . . . . . . . . . 541.1.7.24 pyowm.webapi25.uvindexparser module . . . . . . . . . . . . . . . . . . . . . . . 561.1.7.25 pyowm.webapi25.coindex module . . . . . . . . . . . . . . . . . . . . . . . . . . 561.1.7.26 pyowm.webapi25.coindexparser module . . . . . . . . . . . . . . . . . . . . . . . 571.1.7.27 pyowm.webapi25.ozone module . . . . . . . . . . . . . . . . . . . . . . . . . . . 581.1.7.28 pyowm.webapi25.ozone_parser module . . . . . . . . . . . . . . . . . . . . . . . 591.1.7.29 Module contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

1.2 Submodules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601.3 pyowm.constants module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601.4 Module contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

2 Indices and tables 61

Python Module Index 63

ii

Page 5: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

Contents:

Contents 1

Page 6: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

2 Contents

Page 7: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

CHAPTER 1

pyowm package

1.1 Subpackages

1.1.1 pyowm.abstractions package

1.1.1.1 Submodules

1.1.1.2 pyowm.abstractions.jsonparser module

Module containing an abstract base class for JSON OWM web API responses parsing

class pyowm.abstractions.jsonparser.JSONParserBases: object

A global abstract class representing a JSON to object parser.

parse_JSON(JSON_string)Returns a proper object parsed from the input JSON_string. Subclasses know from their specific typewhich object is to be parsed and returned

Parameters JSON_string (str) – a JSON text string

Returns an object

Raises ParseResponseError if it is impossible to find or parse the data needed to build the re-sulting object

1.1.1.3 pyowm.abstractions.linkedlist module

Module containing abstractions for defining a linked list data structure

class pyowm.abstractions.linkedlist.LinkedListBases: object

3

Page 8: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

An abstract class representing a Linked List data structure. Each element in the list should contain data and areference to the next element in the list.

add(data)Adds a new node to the list. Implementations should decide where to put this new element (at the top, inthe middle or at the end of the list) and should therefore update pointers to next elements and the list’s size.

Parameters data (object) – the data to be inserted in the new list node

contains(data)Checks if the provided data is stored in at least one node of the list.

Parameters data (object) – data of the seeked node

Returns a boolean

index_of(data)Finds the position of a node in the list. The index of the first occurrence of the data is returned (indexesstart at 0)

Parameters data – data of the seeked node

Type object

Returns the int index or -1 if the node is not in the list

pop()Removes the last node from the list

Returns the object data that was stored in the last node

remove(data)Removes a node from the list. Implementations should decide the policy to be followed when list itemshaving the same data are to be removed, and should therefore update pointers to next elements and thelist’s size.

Parameters data (object) – the data to be removed in the new list node

size()Returns the number of elements in the list

Returns an int

1.1.1.4 pyowm.abstractions.owm module

Module containing the abstract PyOWM library main entry point interface

class pyowm.abstractions.owm.OWMBases: object

A global abstract class representing the OWM web API. Every query to the API is done programmatically via aconcrete instance of this class. Subclasses should provide a method for every OWM web API endpoint.

get_API_key()Returns the OWM API key

Returns the OWM API key string

get_API_version()Returns the currently supported OWM web API version

Returns the OWM web API version string

4 Chapter 1. pyowm package

Page 9: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

get_version()Returns the current version of the PyOWM library

Returns the current PyOWM library version string

is_API_online()Returns True if the OWM web API is currently online. A short timeout is used to determine API serviceavailability.

Returns bool

set_API_key(API_key)Updates the OWM API key

Parameters API_key (str) – the new value for the OWM API key

1.1.1.5 pyowm.abstractions.owmcache module

Module containing the abstract PyOWM cache provider

class pyowm.abstractions.owmcache.OWMCacheBases: object

A global abstract class representing a caching provider which can be used to lookup the JSON responses tothe most recently or most frequently issued OWM web API requests. The purpose of the caching mechanismis to avoid OWM web API requests and therefore network traffic: the implementations should be adapted tothe time/memory requirements of the OWM data clients (i.e: a “slimmer” cache with lower lookup times buthigher miss rates or a “fatter” cache with higher memory consumption and higher hit rates?). Subclasses shouldimplement a proper caching algorithms bearing in mind that different weather data types may have differentchange rates: in example, observed weather can change very frequently while long-period weather forecastschange less frequently. External caching mechanisms (eg: memcached, redis, etc..) can be used by extendingthis class into a proper decorator for the correspondent Python bindings.

get(request_url)In case of a hit, returns the JSON string which represents the OWM web API response to the request beingidentified by a specific string URL.

Parameters request_url (str) – an URL that uniquely identifies the request whose re-sponse is to be looked up

Returns a JSON str in case of cache hit or None otherwise

set(request_url, response_json)Adds the specified response_json value to the cache using as a lookup key the request_url of the requestthat generated the value.

Parameters

• request_url (str) – the request URL

• response_json (str) – the response JSON

1.1. Subpackages 5

Page 10: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

1.1.1.6 Module contents

1.1.2 pyowm.caches package

1.1.2.1 Submodules

1.1.2.2 pyowm.caches.lrucache module

Module containing LRU cache related class

class pyowm.caches.lrucache.LRUCache(cache_max_size=20, item_lifetime_millis=600000)Bases: pyowm.abstractions.owmcache.OWMCache

This cache is made out of a ‘table’ dict and the ‘usage_recency’ linked list.’table’ maps uses requests’ URLs askeys and stores JSON raw responses as values. ‘usage_recency’ tracks down the “recency” of the OWM webAPI requests: the more recent a request, the more the element will be far from the “death” point of the recencylist. Items in ‘usage_recency’ are the requests’ URLs themselves. The implemented LRU caching mechanismis the following:

• cached elements must expire after a certain time passed into the cache. So when an element is looked upand found in the cache, its insertion timestamp is compared to the current one: if the difference is higherthan a prefixed value, then the lookup is considered a MISS: the element is removed either from ‘table’and from ‘usage_recency’ and must be requested again to the OWM web API. If the time difference is ok,then the lookup is considered a HIT.

• when a GET results in a HIT, promote the element to the front of the recency list updating its cacheinsertion timestamp and return the data to the cache clients

• when a GET results in a MISS, return None

• when a SET is issued, check if the maximum size of the cache has been reached: if so, discard the leastrecently used item from the recency list and the dict; then add the element to ‘table’ recording its timestampand finally add it at the front of the recency list.

Parameters

• cache_max_size (int) – the maximum size of the cache in terms of cached OWM webAPI responses. A reasonable default value is provided.

• item_lifetime_millis (int) – the maximum lifetime allowed for a cache item inmilliseconds. A reasonable default value is provided.

Returns a new LRUCache instance

clean()Empties the cache

get(request_url)In case of a hit, returns the JSON string which represents the OWM web API response to the request beingidentified by a specific string URL and updates the recency of this request.

Parameters request_url (str) – an URL that uniquely identifies the request whose re-sponse is to be looked up

Returns a JSON str in case of cache hit or None otherwise

set(request_url, response_json)Checks if the maximum size of the cache has been reached and in case discards the least recently useditem from ‘usage_recency’ and ‘table’; then adds the response_json to be cached to the ‘table’ dict using

6 Chapter 1. pyowm package

Page 11: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

as a lookup key the request_url of the request that generated the value; finally adds it at the front of‘usage_recency’

Parameters

• request_url (str) – the request URL that uniquely identifies the request whose re-sponse is to be cached

• response_json (str) – the response JSON to be cached

size()Returns the number of elements that are currently stored into the cache

Returns an int

1.1.2.3 pyowm.caches.nullcache module

Module containing a null-object cache for OWM web API responses

class pyowm.caches.nullcache.NullCacheBases: pyowm.abstractions.owmcache.OWMCache

A null-object implementation of the OWMCache abstract class

get(request_url)Always returns None (nothing will ever be cached or looked up!)

Parameters request_url (str) – the request URL

Returns None

set(request_url, response_json)Does nothing.

Parameters

• request_url (str) – the request URL

• response_json (str) – the response JSON

1.1.2.4 Module contents

1.1.3 pyowm.commons package

1.1.3.1 Submodules

1.1.3.2 pyowm.commons.frontlinkedlist module

Module containing class related to the implementation of linked-list data structure

class pyowm.commons.frontlinkedlist.FrontLinkedListBases: pyowm.abstractions.linkedlist.LinkedList

Implementation of a linked-list data structure. Insertions are performed at the front of the list and so are O(1)while deletions take O(n) because they can be performed against any of the linked list’s elements. Each elementin the list is a LinkedListNode instance; after instantiation, the list contains no elements.

Parameters

• first_node (LinkedListNode) – reference to the first LinkedListNode element inthe list

1.1. Subpackages 7

Page 12: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

• last_node (LinkedListNode) – reference to the last LinkedListNode element in thelist

add(data)Adds a new data node to the front list. The provided data will be encapsulated into a new instance ofLinkedListNode class and linked list pointers will be updated, as well as list’s size.

Parameters data (object) – the data to be inserted in the new list node

contains(data)Checks if the provided data is stored in at least one node of the list.

Parameters data (object) – the seeked data

Returns a boolean

first_node()

index_of(data)Finds the position of a node in the list. The index of the first occurrence of the data is returned (indexesstart at 0)

Parameters data – data of the seeked node

Type object

Returns the int index or -1 if the node is not in the list

pop()Removes the last node from the list

remove(data)Removes a data node from the list. If the list contains more than one node having the same data that shallbe removed, then the node having the first occurrency of the data is removed.

Parameters data (object) – the data to be removed in the new list node

size()Returns the number of elements in the list

Returns an int

class pyowm.commons.frontlinkedlist.FrontLinkedListIterator(obj)Bases: object

Iterator over the LinkedListNode elements of a LinkedList class instance. The implementation keeps a copyof the iterated list so avoid concurrency problems when iterating over it. This can nevertheless be memory-consuming when big lists have to be iterated over.

Parameters obj (object) – the iterable object (LinkedList)

Returns a FrontLinkedListIterator instance

next()Compatibility for Python 2.x, delegates to function: __next__() Returns the next Weather item

Returns the next Weather item

class pyowm.commons.frontlinkedlist.LinkedListNode(data, next_node)Class representing an element of the LinkedList

Parameters

• data (object) – the actual data that this node holds

• next (LinkedListNode) – reference to the next LinkedListNode instance in the list

8 Chapter 1. pyowm package

Page 13: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

data()Returns the data in this node

Returns an object

next()Returns the next LinkedListNode in the list

Returns a LinkedListNode instance

update_next(linked_list_node)

Parameters linked_list_node (LinkedListNode) – the new reference to the nextLinkedListNode element

1.1.3.3 pyowm.commons.weather_client module

Module containing classes for HTTP client/server interactions

class pyowm.commons.weather_client.WeatherHttpClient(API_key, cache, subscrip-tion_type=’free’)

Bases: object

API_SUBSCRIPTION_SUBDOMAINS = {'pro': 'pro', 'free': 'api'}An HTTP client class for the OWM web API. The class can leverage a caching mechanism

Parameters

• API_key (Unicode) – a Unicode object representing the OWM web API key

• cache (an OWMCache concrete instance) – an OWMCache concrete instance that will beused to cache OWM web API responses.

• subscription_type (str) – the type of OWM web API subscription to be wrapped.The value is used to pick the proper API subdomain for HTTP calls. Defaults to: ‘free’

call_API(API_endpoint_URL, params_dict, timeout=<object object>)Invokes a specific OWM web API endpoint URL, returning raw JSON data.

Parameters

• API_endpoint_URL (str) – the API endpoint to be invoked

• params_dict (dict) – a dictionary containing the query parameters to be used in theHTTP request (given as key-value couples in the dict)

• timeout (int) – how many seconds to wait for connection establishment (defaults tosocket._GLOBAL_DEFAULT_TIMEOUT)

Returns a string containing raw JSON data

Raises APICallError

1.1.3.4 pyowm.commons.airpollution_client module

class pyowm.commons.airpollution_client.AirPollutionHttpClient(API_key,cache)

Bases: object

An HTTP client class for the OWM Air Pollution web API. The class can leverage a caching mechanism

Parameters

1.1. Subpackages 9

Page 14: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

• API_key (Unicode) – a Unicode object representing the OWM Air Pollution web APIkey

• cache (an OWMCache concrete instance) – an OWMCache concrete instance that will beused to cache OWM Air Pollution web API responses.

get_coi(params_dict, timeout=<object object>)Invokes the CO Index endpoint

Parameters

• params_dict – dict of parameters

• timeout (int) – how many seconds to wait for connection establishment (defaults tosocket._GLOBAL_DEFAULT_TIMEOUT)

Returns a string containing raw JSON data

Raises ValueError, APICallError

get_no2(params_dict, timeout=<object object>)Invokes the NO2 Index endpoint

Parameters

• params_dict – dict of parameters

• timeout (int) – how many seconds to wait for connection establishment (defaults tosocket._GLOBAL_DEFAULT_TIMEOUT)

Returns a string containing raw JSON data

Raises ValueError, APICallError

get_o3(params_dict, timeout=<object object>)Invokes the O3 Index endpoint

Parameters

• params_dict – dict of parameters

• timeout (int) – how many seconds to wait for connection establishment (defaults tosocket._GLOBAL_DEFAULT_TIMEOUT)

Returns a string containing raw JSON data

Raises ValueError, APICallError

get_so2(params_dict, timeout=<object object>)Invokes the SO2 Index endpoint

Parameters

• params_dict – dict of parameters

• timeout (int) – how many seconds to wait for connection establishment (defaults tosocket._GLOBAL_DEFAULT_TIMEOUT)

Returns a string containing raw JSON data

Raises ValueError, APICallError

10 Chapter 1. pyowm package

Page 15: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

1.1.3.5 pyowm.commons.uv_client module

class pyowm.commons.uv_client.UltraVioletHttpClient(API_key, cache)Bases: object

An HTTP client class for the OWM UV web API. The class can leverage a caching mechanism

Parameters

• API_key (Unicode) – a Unicode object representing the OWM UV web API key

• cache (an OWMCache concrete instance) – an OWMCache concrete instance that will beused to cache OWM UV web API responses.

get_uvi(params_dict, timeout=<object object>)Invokes the UV Index endpoint

Parameters

• params_dict – dict of parameters

• timeout (int) – how many seconds to wait for connection establishment (defaults tosocket._GLOBAL_DEFAULT_TIMEOUT)

Returns a string containing raw JSON data

Raises ValueError, APICallError

1.1.3.6 Module contents

1.1.4 pyowm.exceptions package

1.1.4.1 Submodules

1.1.4.2 pyowm.exceptions.api_call_error module

Module containing APICallError class

exception pyowm.exceptions.api_call_error.APICallError(message, trigger-ing_error=None)

Bases: pyowm.exceptions.OWMError

Error class that represents generic failures when invoking OWM web API, in example due to network errors.

Parameters

• message (str) – the message of the error

• triggering_error (an Exception subtype) – optional Exception object that triggeredthis error (defaults to None)

exception pyowm.exceptions.api_call_error.BadGatewayError(message, trigger-ing_error=None)

Bases: pyowm.exceptions.api_call_error.APICallError

Error class that represents 502 errors - i.e when upstream backend cannot communicate with API gateways.

Parameters

• message (str) – the message of the error

• triggering_error (an Exception subtype) – optional Exception object that triggeredthis error (defaults to None)

1.1. Subpackages 11

Page 16: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

1.1.4.3 pyowm.exceptions.api_response_error module

Module containing APIResponseError class

exception pyowm.exceptions.api_response_error.APIResponseError(message)Bases: pyowm.exceptions.OWMError

Error class that represents HTTP error status codes in OWM web API responses.

Parameters cause (str) – the message of the error

Returns a APIResponseError instance

1.1.4.4 pyowm.exceptions.not_found_error module

Module containing NotFoundError class

exception pyowm.exceptions.not_found_error.NotFoundError(message)Bases: pyowm.exceptions.OWMError

Error class that represents the situation when an entity is not found into a collection of entities.

Parameters cause (str) – the message of the error

Returns a NotFoundError instance

1.1.4.5 pyowm.exceptions.parse_response_error module

Module containing ParseResponseError class

exception pyowm.exceptions.parse_response_error.ParseResponseError(message)Bases: pyowm.exceptions.OWMError

Error class that represents failures when parsing payload data in HTTP responses sent by the OWM web API.

Parameters cause (str) – the message of the error

Returns a ParseResponseError instance

1.1.4.6 pyowm.exceptions.unauthorized_error module

Module containing Unauthorized class

exception pyowm.exceptions.unauthorized_error.UnauthorizedError(message)Bases: pyowm.exceptions.OWMError

Error class that represents the situation when an entity cannot be retrieved due to user subscription unsufficientcapabilities.

Parameters cause (str) – the message of the error

Returns a UnauthorizedError instance

1.1.4.7 Module contents

Module containing the OWMError class as base for all other OWM errors

exception pyowm.exceptions.OWMErrorBases: exceptions.Exception

12 Chapter 1. pyowm package

Page 17: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

1.1.5 pyowm.stationsapi30 package

1.1.5.1 Subpackages

pyowm.stationsapi30.xsd package

Submodules

pyowm.stationsapi30.xsd.xmlnsconfig module

Module contents

1.1.5.2 Submodules

1.1.5.3 pyowm.stationsapi30.buffer module

class pyowm.stationsapi30.buffer.Buffer(station_id)

append(measurement)Appends the specified Measurement object to the buffer :param measurement: a measurement.Measurement instance

append_from_dict(the_dict)Creates a measurement.Measurement object from the supplied dict and then appends it to the buffer:param the_dict: dict

append_from_json(json_string)Creates a measurement.Measurement object from the supplied JSON string and then appends it tothe buffer :param json_string: the JSON formatted string

created_at = None

creation_time(timeformat=’unix’)Returns the UTC time of creation of this aggregated measurement

Parameters timeformat (str) – the format for the time value. May be: ‘unix’ (de-fault) for UNIX time, ‘iso’ for ISO8601-formatted string in the format YYYY-MM-DDHH:MM:SS+00 or date for a datetime.datetime object

Returns an int or a str or a datetime.datetime object or None

Raises ValueError

empty()Drops all measurements of this buffer instance

measurements = None

sort_chronologically()Sorts the measurements of this buffer in chronological order

sort_reverse_chronologically()Sorts the measurements of this buffer in reverse chronological order

station_id = None

1.1. Subpackages 13

Page 18: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

1.1.5.4 pyowm.stationsapi30.measurement module

class pyowm.stationsapi30.measurement.AggregatedMeasurement(station_id,timestamp, ag-gregated_on,temp=None, hu-midity=None,wind=None, pres-sure=None, precipi-tation=None)

A class representing an aggregation of measurements done by the Stations API on a specific time-frame. Valuesfor the aggregation time-frame can be: ‘m’ (minute), ‘h’ (hour) or ‘d’ (day)

Parameters

• station_id (str) – unique station identifier

• timestamp (int) – reference UNIX timestamp for this measurement

• aggregated_on (string between 'm','h' and 'd') – aggregation time-frame for this measurement

• temp (dict or None) – optional dict containing temperature data

• humidity (dict or None) – optional dict containing humidity data

• wind (dict or None) – optional dict containing wind data

• pressure (dict or None) – optional dict containing pressure data

• precipitation (dict or None) – optional dict containing precipitation data

ALLOWED_AGGREGATION_TIME_FRAMES = ['m', 'h', 'd']

creation_time(timeformat=’unix’)Returns the UTC time of creation of this aggregated measurement

Parameters timeformat (str) – the format for the time value. May be: ‘unix’ (de-fault) for UNIX time, ‘iso’ for ISO8601-formatted string in the format YYYY-MM-DDHH:MM:SS+00 or date for a datetime.datetime object

Returns an int or a str or a datetime.datetime object or None

Raises ValueError

to_JSON()Dumps object fields into a JSON formatted string

Returns the JSON string

to_dict()Dumps object fields into a dict

Returns a dict

14 Chapter 1. pyowm package

Page 19: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

class pyowm.stationsapi30.measurement.Measurement(station_id, timestamp, tempera-ture=None, wind_speed=None,wind_gust=None, wind_deg=None,pressure=None, humidity=None,rain_1h=None, rain_6h=None,rain_24h=None, snow_1h=None,snow_6h=None, snow_24h=None,dew_point=None, hu-midex=None, heat_index=None,visibility_distance=None,visibility_prefix=None,clouds_distance=None,clouds_condition=None,clouds_cumulus=None,weather_precipitation=None,weather_descriptor=None,weather_intensity=None,weather_proximity=None,weather_obscuration=None,weather_other=None)

creation_time(timeformat=’unix’)Returns the UTC time of creation of this raw measurement

Parameters timeformat (str) – the format for the time value. May be: ‘unix’ (de-fault) for UNIX time, ‘iso’ for ISO8601-formatted string in the format YYYY-MM-DDHH:MM:SS+00 or date for a datetime.datetime object

Returns an int or a str or a datetime.datetime object or None

Raises ValueError

classmethod from_dict(the_dict)

to_JSON()Dumps object fields into a JSON formatted string

Returns the JSON string

to_dict()Dumps object fields into a dictionary

Returns a dict

1.1.5.5 pyowm.stationsapi30.persistence_backend module

Module containing asbtract classes and a few convenience implementations of raw measurements I/O

class pyowm.stationsapi30.persistence_backend.JSONPersistenceBackend(json_file_path,sta-tion_id)

Bases: pyowm.stationsapi30.persistence_backend.PersistenceBackend

A PersistenceBackend loading/saving data to a JSON file. Data will be saved as a JSON list, each element beingrepresenting data of a pyowm.stationsapi30.measurement.Measurement object.

Parameters

• json_file_path (str) – path to the JSON file

1.1. Subpackages 15

Page 20: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

• station_id (str) – unique OWM-provided ID of the station whose data is read/saved

load_to_buffer()

persist_buffer(buffer)

class pyowm.stationsapi30.persistence_backend.PersistenceBackendBases: object

A global abstract class representing an I/O manager for buffer objects containing raw measurements.

load_to_buffer()Reads meteostation measurement data into a pyowm.stationsapi30.buffer.Buffer object.

Returns a pyowm.stationsapi30.buffer.Buffer instance

persist_buffer(buffer)Saves data contained into a pyowm.stationsapi30.buffer.Buffer object in a durable form.

Parameters buffer (pyowm.stationsapi30.buffer.Buffer instance) – the Buffer object to be per-sisted

1.1.5.6 pyowm.stationsapi30.station module

class pyowm.stationsapi30.station.Station(id, created_at, updated_at, external_id, name,lon, lat, alt, rank)

A class representing a meteostation in Stations API. A reference about OWM stations can be found at: http://openweathermap.org/stations

Parameters

• id (str) – unique OWM identifier for the station

• created_at (str in format %Y-%m-%dT%H:%M:%S.%fZ) – UTC timestampmarking the station registration.

• updated_at (str in format %Y-%m-%dT%H:%M:%S.%fZ) – UTC timestampmarking the last update to this station

• external_id (str) – user-given identifier for the station

• name (str) – user-given name for the station

• lon (float) – longitude of the station

• lat (float) – latitude of the station

• alt (float) – altitude of the station

• rank (int) – station rank

creation_time(timeformat=’unix’)Returns the UTC time of creation of this station

Parameters timeformat (str) – the format for the time value. May be: ‘unix’ (de-fault) for UNIX time, ‘iso’ for ISO8601-formatted string in the format YYYY-MM-DDHH:MM:SS+00 or date for a datetime.datetime object

Returns an int or a str or a datetime.datetime object or None

Raises ValueError

last_update_time(timeformat=’unix’)Returns the UTC time of the last update on this station’s metadata

16 Chapter 1. pyowm package

Page 21: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

Parameters timeformat (str) – the format for the time value. May be: ‘unix’ (de-fault) for UNIX time, ‘iso’ for ISO8601-formatted string in the format YYYY-MM-DDHH:MM:SS+00 or date for a datetime.datetime object

Returns an int or a str or a datetime.datetime object or None

Raises ValueError

to_JSON()Dumps object fields into a JSON formatted string

Returns the JSON string

to_XML(xml_declaration=True, xmlns=True)Dumps object fields to an XML-formatted string. The ‘xml_declaration’ switch enables printing of aleading standard XML line containing XML version and encoding. The ‘xmlns’ switch enables printingof qualified XMLNS prefixes.

Parameters

• XML_declaration (bool) – if True (default) prints a leading XML declaration line

• xmlns (bool) – if True (default) prints full XMLNS prefixes

Returns an XML-formatted string

1.1.5.7 pyowm.stationsapi30.station_parser module

Module containing a concrete implementation for JSONParser abstract class, returning a Station instance

class pyowm.stationsapi30.station_parser.StationParserBases: pyowm.abstractions.jsonparser.JSONParser

Concrete JSONParser implementation building a pyowm.stationsapi30.station.Station instance out of raw JSONdata

parse_JSON(JSON_string)Parses a pyowm.stationsapi30.station.Station instance out of raw JSON data.

Parameters JSON_string (str) – a raw JSON string

Returns a pyowm.stationsapi30.station.Station* instance or None if no data is available

Raises ParseResponseError if it is impossible to find or parse the data needed to build the result

parse_dict(data_dict)Parses a dictionary representing the attributes of a pyowm.stationsapi30.station.Station entity :paramdata_dict: dict :return: pyowm.stationsapi30.station.Station

1.1.5.8 pyowm.stationsapi30.stations_manager module

Object that can read/write meteostations metadata and extract related measurements

class pyowm.stationsapi30.stations_manager.StationsManager(API_key)Bases: object

A manager objects that provides a full interface to OWM Stations API. Mainly it implements CRUD methodson Station entities and the corresponding measured datapoints.

Parameters API_key (str) – the OWM web API key (defaults to None)

Returns a StationsManager instance

1.1. Subpackages 17

Page 22: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

Raises AssertionError when no API Key is provided

create_station(external_id, name, lat, lon, alt=None)Create a new station on the Station API with the given parameters

Parameters

• external_id (str) – the user-given ID of the station

• name (str) – the name of the station

• lat (float) – latitude of the station

• lon (float) – longitude of the station

• alt (float) – altitude of the station

Returns the new pyowm.stationsapi30.station.Station object

delete_station(station)Deletes the Station API record identified by the ID of the provided pyowm.stationsapi30.station.Station,along with all its related measurements

Parameters station (pyowm.stationsapi30.station.Station) – the py-owm.stationsapi30.station.Station object to be deleted

Returns None if deletion is successful, an exception otherwise

get_measurements(station_id, aggregated_on, from_timestamp, to_timestamp, limit=100)Reads measurements of a specified station recorded in the specified time window and aggregated onminute, hour or day. Optionally, the number of resulting measurements can be limited.

Parameters

• station_id (str) – unique station identifier

• aggregated_on (string between 'm','h' and 'd') – aggregation time-frame for this measurement

• from_timestamp (int) – Unix timestamp corresponding to the beginning of the timewindow

• to_timestamp (int) – Unix timestamp corresponding to the end of the time window

• limit (int) – max number of items to be returned. Defaults to 100

Returns list of pyowm.stationsapi30.measurement.AggregatedMeasurement objects

get_station(id)Retrieves a named station registered on the Stations API.

Parameters id (str) – the ID of the station

Returns a pyowm.stationsapi30.station.Station object

get_stations()Retrieves all of the user’s stations registered on the Stations API.

Returns list of pyowm.stationsapi30.station.Station objects

send_buffer(buffer)Posts to the Stations API data about the Measurement objects contained into the provided Buffer instance.

Parameters buffer (pyowm.stationsapi30.buffer.Buffer instance) – the py-owm.stationsapi30.buffer.Buffer instance whose measurements are to be posted

Returns None if creation is successful, an exception otherwise

18 Chapter 1. pyowm package

Page 23: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

send_measurement(measurement)Posts the provided Measurement object’s data to the Station API.

Parameters measurement (pyowm.stationsapi30.measurement.Measurement instance) – thepyowm.stationsapi30.measurement.Measurement object to be posted

Returns None if creation is successful, an exception otherwise

send_measurements(list_of_measurements)Posts data about the provided list of Measurement objects to the Station API. The objects may be relatedto different station IDs.

Parameters list_of_measurements (list of pyowm.stationsapi30.measurement.Measurementinstances) – list of pyowm.stationsapi30.measurement.Measurement objects to be posted

Returns None if creation is successful, an exception otherwise

stations_api_version()

update_station(station)Updates the Station API record identified by the ID of the provided pyowm.stationsapi30.station.Stationobject with all of its fields

Parameters station (pyowm.stationsapi30.station.Station) – the py-owm.stationsapi30.station.Station object to be updated

Returns None if update is successful, an exception otherwise

1.1.5.9 Module contents

1.1.6 pyowm.utils package

1.1.6.1 Submodules

1.1.6.2 pyowm.utils.temputils module

Module containing utility functions for temperature and wind units conversion

pyowm.utils.temputils.kelvin_dict_to(d, target_temperature_unit)Converts all the values in a dict from Kelvin temperatures to the specified temperature format.

Parameters

• d (dict) – the dictionary containing Kelvin temperature values

• target_temperature_unit (str) – the target temperature unit, may be: ‘celsius’ or‘fahrenheit’

Returns a dict with the same keys as the input dict and converted temperature values as values

Raises ValueError when unknown target temperature units are provided

pyowm.utils.temputils.kelvin_to_celsius(kelvintemp)Converts a numeric temperature from Kelvin degrees to Celsius degrees

Parameters kelvintemp (int/long/float) – the Kelvin temperature

Returns the float Celsius temperature

Raises TypeError when bad argument types are provided

pyowm.utils.temputils.kelvin_to_fahrenheit(kelvintemp)Converts a numeric temperature from Kelvin degrees to Fahrenheit degrees

1.1. Subpackages 19

Page 24: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

Parameters kelvintemp (int/long/float) – the Kelvin temperature

Returns the float Fahrenheit temperature

Raises TypeError when bad argument types are provided

pyowm.utils.temputils.metric_wind_dict_to_imperial(d)Converts all the wind values in a dict from meters/sec (metric measurement system) to miles/hour (imperialmeasurement system) .

Parameters d (dict) – the dictionary containing metric values

Returns a dict with the same keys as the input dict and values converted to miles/hour

1.1.6.3 pyowm.utils.timeformatutils module

Module containing utility functions for time formats conversion

class pyowm.utils.timeformatutils.UTCBases: datetime.tzinfo

dst(dt)

tzname(dt)

utcoffset(dt)

pyowm.utils.timeformatutils.timeformat(timeobject, timeformat)Formats the specified time object to the target format type.

Parameters

• timeobject (int, datetime.datetime or ISO8601-formatted string with patternYYYY-MM-DD HH:MM:SS+00) – the object conveying the time value

• timeformat (str) – the target format for the time conversion. May be: ‘unix’ (outputsan int UNIXtime), ‘date’ (outputs a datetime.datetime object) or ‘iso’ (outputs anISO8601-formatted string with pattern YYYY-MM-DD HH:MM:SS+00)

Returns the formatted time

Raises ValueError when unknown timeformat switches are provided or when negative time valuesare provided

pyowm.utils.timeformatutils.to_ISO8601(timeobject)Returns the ISO8601-formatted string corresponding to the time value conveyed by the specified object, whichcan be either a UNIXtime, a datetime.datetime object or an ISO8601-formatted string in the formatYYYY-MM-DD HH:MM:SS+00‘.

Parameters timeobject (int, datetime.datetime or ISO8601-formatted string) – the ob-ject conveying the time value

Returns an ISO8601-formatted string with pattern YYYY-MM-DD HH:MM:SS+00‘

Raises TypeError when bad argument types are provided, ValueError when negative UNIXtimes areprovided

pyowm.utils.timeformatutils.to_UNIXtime(timeobject)Returns the UNIXtime corresponding to the time value conveyed by the specified object, which can be eithera UNIXtime, a datetime.datetime object or an ISO8601-formatted string in the format YYYY-MM-DDHH:MM:SS+00‘.

Parameters timeobject (int, datetime.datetime or ISO8601-formatted string) – the ob-ject conveying the time value

20 Chapter 1. pyowm package

Page 25: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

Returns an int UNIXtime

Raises TypeError when bad argument types are provided, ValueError when negative UNIXtimes areprovided

pyowm.utils.timeformatutils.to_date(timeobject)Returns the datetime.datetime object corresponding to the time value conveyed by the specified object,which can be either a UNIXtime, a datetime.datetime object or an ISO8601-formatted string in theformat YYYY-MM-DD HH:MM:SS+00‘.

Parameters timeobject (int, datetime.datetime or ISO8601-formatted string) – the ob-ject conveying the time value

Returns a datetime.datetime object

Raises TypeError when bad argument types are provided, ValueError when negative UNIXtimes areprovided

1.1.6.4 pyowm.utils.timeutils module

Module containing utility functions for time values generation/management

pyowm.utils.timeutils.last_hour(date=None)Gives the datetime.datetime object corresponding to the last hour before now or before the specifieddatetime.datetime object.

Parameters date (datetime.datetime object) – the date you want an hour to be subtractedfrom (if left None, the current date and time will be used)

Returns a datetime.datetime object

pyowm.utils.timeutils.last_month(date=None)Gives the datetime.datetime object corresponding to the last month before now or before the specifieddatetime.datetime object. A month corresponds to 30 days.

Parameters date (datetime.datetime object) – the date you want a month to be subtractedfrom (if left None, the current date and time will be used)

Returns a datetime.datetime object

pyowm.utils.timeutils.last_three_hours(date=None)Gives the datetime.datetime object corresponding to last three hours before now or before the specifieddatetime.datetime object.

Parameters date (datetime.datetime object) – the date you want three hours to be sub-tracted from (if left None, the current date and time will be used)

Returns a datetime.datetime object

pyowm.utils.timeutils.last_week(date=None)Gives the datetime.datetime object corresponding to the last week before now or before the specifieddatetime.datetime object. A week corresponds to 7 days.

Parameters date (datetime.datetime object) – the date you want a week to be subtractedfrom (if left None, the current date and time will be used)

Returns a datetime.datetime object

pyowm.utils.timeutils.last_year(date=None)Gives the datetime.datetime object corresponding to the last year before now or before the specifieddatetime.datetime object. A year corresponds to 365 days.

1.1. Subpackages 21

Page 26: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

Parameters date (datetime.datetime object) – the date you want a year to be subtractedfrom (if left None, the current date and time will be used)

Returns a datetime.datetime object

pyowm.utils.timeutils.next_hour(date=None)Gives the datetime.datetime object corresponding to the next hour from now or from the specifieddatetime.datetime object.

Parameters date (datetime.datetime object) – the date you want an hour to be added (ifleft None, the current date and time will be used)

Returns a datetime.datetime object

pyowm.utils.timeutils.next_month(date=None)Gives the datetime.datetime object corresponding to the next month after now or after the specifieddatetime.datetime object. A month corresponds to 30 days.

Parameters date (datetime.datetime object) – the date you want a month to be added to (ifleft None, the current date and time will be used)

Returns a datetime.datetime object

pyowm.utils.timeutils.next_three_hours(date=None)Gives the datetime.datetime object corresponding to the next three hours from now or from the specifieddatetime.datetime object.

Parameters date (datetime.datetime object) – the date you want three hours to be added(if left None, the current date and time will be used)

Returns a datetime.datetime object

pyowm.utils.timeutils.next_week(date=None)Gives the datetime.datetime object corresponding to the next week from now or from the specifieddatetime.datetime object. A week corresponds to 7 days.

Parameters date (datetime.datetime object) – the date you want a week to be added (if leftNone, the current date and time will be used)

Returns a datetime.datetime object

pyowm.utils.timeutils.next_year(date=None)Gives the datetime.datetime object corresponding to the next year after now or after the specifieddatetime.datetime object. A month corresponds to 30 days.

Parameters date (datetime.datetime object) – the date you want a year to be added to (ifleft None, the current date and time will be used)

Returns a datetime.datetime object

pyowm.utils.timeutils.now(timeformat=’date’)Returns the current time in the specified timeformat.

Parameters timeformat (str) – the target format for the time conversion. May be: ‘date’(default - outputs a datetime.datetime object), ‘unix’ (outputs a long UNIXtime) or ‘iso’(outputs an ISO8601-formatted string with pattern YYYY-MM-DD HH:MM:SS+00)

Returns the current time value

Raises ValueError when unknown timeformat switches are provided or when negative time valuesare provided

pyowm.utils.timeutils.tomorrow(hour=None, minute=None)Gives the datetime.datetime object corresponding to tomorrow. The default value for optional parameters

22 Chapter 1. pyowm package

Page 27: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

is the current value of hour and minute. I.e: when called without specifying values for parameters, the resultingobject will refer to the time = now + 24 hours; when called with only hour specified, the resulting object willrefer to tomorrow at the specified hour and at the current minute.

Parameters

• hour (int) – the hour for tomorrow, in the format 0-23 (defaults to None)

• minute (int) – the minute for tomorrow, in the format 0-59 (defaults to None)

Returns a datetime.datetime object

Raises ValueError when hour or minute have bad values

pyowm.utils.timeutils.yesterday(hour=None, minute=None)Gives the datetime.datetime object corresponding to yesterday. The default value for optional parametersis the current value of hour and minute. I.e: when called without specifying values for parameters, the resultingobject will refer to the time = now - 24 hours; when called with only hour specified, the resulting object willrefer to yesterday at the specified hour and at the current minute.

Parameters

• hour (int) – the hour for yesterday, in the format 0-23 (defaults to None)

• minute (int) – the minute for yesterday, in the format 0-59 (defaults to None)

Returns a datetime.datetime object

Raises ValueError when hour or minute have bad values

1.1.6.5 pyowm.utils.xmlutils module

Module containing utility functions for generating XML strings

pyowm.utils.xmlutils.DOM_node_to_XML(tree, xml_declaration=True)Prints a DOM tree to its Unicode representation.

Parameters

• tree (an xml.etree.ElementTree.Element object) – the input DOM tree

• xml_declaration (bool) – if True (default) prints a leading XML declaration line

Returns Unicode object

pyowm.utils.xmlutils.annotate_with_XMLNS(tree, prefix, URI)Annotates the provided DOM tree with XMLNS attributes and adds XMLNS prefixes to the tags of the treenodes.

Parameters

• tree (an xml.etree.ElementTree.ElementTree or xml.etree.ElementTree.Element object) – the input DOM tree

• prefix (str) – XMLNS prefix for tree nodes’ tags

• URI (str) – the URI for the XMLNS definition file

pyowm.utils.xmlutils.create_DOM_node_from_dict(d, name, parent_node)Dumps dict data to an xml.etree.ElementTree.SubElement DOM subtree object and attaches it tothe specified DOM parent node. The created subtree object is named after the specified name. If the supplieddict is None no DOM node is created for it as well as no DOM subnodes are generated for eventual Nonevalues found inside the dict

Parameters

1.1. Subpackages 23

Page 28: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

• d (dict) – the input dictionary

• name (str) – the name for the DOM subtree to be created

• parent_node (xml.etree.ElementTree.Element or derivative objects) – theparent DOM node the newly created subtree must be attached to

Returns xml.etree.ElementTree.SubElementTree object

1.1.6.6 Module contents

1.1.7 pyowm.webapi25 package

1.1.7.1 Subpackages

pyowm.webapi25.cityids package

Submodules

Module contents

pyowm.webapi25.xsd package

Submodules

pyowm.webapi25.xsd.xmlnsconfig module

XMLNS configuration

Module contents

1.1.7.2 Submodules

1.1.7.3 pyowm.webapi25.cityidregistry module

class pyowm.webapi25.cityidregistry.CityIDRegistry(filepath_regex)

MATCHINGS = {'exact': <function <lambda>>, 'like': <function <lambda>>, 'nocase': <function <lambda>>}

id_for(*args, **kwargs)Returns the long ID corresponding to the first city found that matches the provided city name. The lookupis case insensitive.

Deprecated since version 3.0.0: Use ids_for() instead.

Parameters city_name (str) – the city name whose ID is looked up

Returns a long or None if the lookup fails

ids_for(city_name, country=None, matching=’nocase’)Returns a list of tuples in the form (long, str, str) corresponding to the int IDs and relative toponymsand 2-chars country of the cities matching the provided city name. The rule for identifying matchings isaccording to the provided matching parameter value. If country is provided, the search is restricted to the

24 Chapter 1. pyowm package

Page 29: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

cities of the specified country. :param country: two character str representing the country where to searchfor the city. Defaults to None, which means: search in all countries. :param matching: str among exact(literal, case-sensitive matching), nocase (literal, case-insensitive matching) and like (matches cities whosename contains as a substring the string fed to the function, no matter the case). Defaults to nocase. :raisesValueError if the value for matching is unknown :return: list of tuples

location_for(*args, **kwargs)Returns the Location object corresponding to the first city found that matches the provided city name. Thelookup is case insensitive.

Parameters city_name (str) – the city name you want a Location for

Returns a Location instance or None if the lookup fails

Deprecated since version 3.0.0: Use locations_for() instead.

locations_for(city_name, country=None, matching=’nocase’)Returns a list of Location objects corresponding to the int IDs and relative toponyms and 2-chars country ofthe cities matching the provided city name. The rule for identifying matchings is according to the providedmatching parameter value. If country is provided, the search is restricted to the cities of the specifiedcountry. :param country: two character str representing the country where to search for the city. Defaultsto None, which means: search in all countries. :param matching: str among exact (literal, case-sensitivematching), nocase (literal, case-insensitive matching) and like (matches cities whose name contains as asubstring the string fed to the function, no matter the case). Defaults to nocase. :raises ValueError if thevalue for matching is unknown :return: list of webapi25.location.Location objects

1.1.7.4 pyowm.webapi25.configuration25 module

1.1.7.5 pyowm.webapi25.forecast module

Module containing weather forecast classes and data structures.

class pyowm.webapi25.forecast.Forecast(interval, reception_time, location, weathers)Bases: object

A class encapsulating weather forecast data for a certain location and relative to a specific time interval (forecastfor every three hours or for every day)

Parameters

• interval (str) – the time granularity of the forecast. May be: ‘3h’ for three hoursforecast or ‘daily’ for daily ones

• reception_time (int) – GMT UNIXtime of the forecast reception from the OWMweb API

• location (Location) – the Location object relative to the forecast

• weathers (list) – the list of Weather objects composing the forecast

Returns a Forecast instance

Raises ValueError when negative values are provided

actualize()Removes from this forecast all the Weather objects having a reference timestamp in the past with respectto the current timestamp

count_weathers()Tells how many Weather items compose the forecast

Returns the Weather objects total

1.1. Subpackages 25

Page 30: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

get(index)Lookups up into the Weather items list for the item at the specified index

Parameters index (int) – the index of the Weather object in the list

Returns a Weather object

get_interval()Returns the time granularity of the forecast

Returns str

get_location()Returns the Location object relative to the forecast

Returns a Location object

get_reception_time(timeformat=’unix’)

Returns the GMT time telling when the forecast was received from the OWM web API

Parameters timeformat (str) – the format for the time value. May be: ‘unix’ (de-fault) for UNIX time ‘iso’ for ISO8601-formatted string in the format YYYY-MM-DDHH:MM:SS+00 ‘date for datetime.datetime object instance

Returns an int or a str

Raises ValueError

get_weathers()Returns a copy of the Weather objects list composing the forecast

Returns a list of Weather objects

set_interval(interval)Sets the time granularity of the forecast

Parameters interval (str) – the time granularity of the forecast, may be “3h” or “daily”

to_JSON()Dumps object fields into a JSON formatted string

Returns the JSON string

to_XML(xml_declaration=True, xmlns=True)Dumps object fields to an XML-formatted string. The ‘xml_declaration’ switch enables printing of aleading standard XML line containing XML version and encoding. The ‘xmlns’ switch enables printingof qualified XMLNS prefixes.

Parameters

• XML_declaration (bool) – if True (default) prints a leading XML declaration line

• xmlns (bool) – if True (default) prints full XMLNS prefixes

Returns an XML-formatted string

class pyowm.webapi25.forecast.ForecastIterator(obj)Bases: object

Iterator over the list of Weather objects encapsulated in a Forecast class instance

Parameters obj (object) – the iterable object

Returns a ForecastIterator instance

26 Chapter 1. pyowm package

Page 31: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

next()Compatibility for Python 2.x, delegates to function: __next__() Returns the next Weather item

Returns the next Weather item

1.1.7.6 pyowm.webapi25.forecaster module

Module containing weather forecast abstraction classes and data structures.

class pyowm.webapi25.forecaster.Forecaster(forecast)Bases: object

A class providing convenience methods for manipulating weather forecast data. The class encapsulates a Fore-cast instance and provides abstractions on the top of it in order to let programmers exploit weather forecast datain a human-friendly fashion.

Parameters forecast (Forecast) – a Forecast instance

Returns a Forecaster instance

get_forecast()Returns the Forecast instance

Returns the Forecast instance

get_weather_at(timeobject)Gives the Weather item in the forecast that is closest in time to the time value conveyed by the parameter

Parameters timeobject (long/int, datetime.datetime or str)) – may be a UNIXtime, a datetime.datetime object or an ISO8601-formatted string in the formatYYYY-MM-DD HH:MM:SS+00

Returns a Weather object

most_cold()Returns the Weather object in the forecast having the lowest min temperature. The temperature is retrievedusing the get_temperature['temp_min'] call; was ‘temp_min’ key missing for every Weatherinstance in the forecast, None would be returned.

Returns a Weather object or None if no item in the forecast is eligible

most_hot()Returns the Weather object in the forecast having the highest max temperature. The temperature is re-trieved using the get_temperature['temp_max'] call; was ‘temp_max’ key missing for everyWeather instance in the forecast, None would be returned.

Returns a Weather object or None if no item in the forecast is eligible

most_humid()Returns the Weather object in the forecast having the highest humidty.

Returns a Weather object or None if no item in the forecast is eligible

most_rainy()Returns the Weather object in the forecast having the highest precipitation volume. The rain amount isretrieved via the get_rain['all'] call; was the ‘all’ key missing for every Weather instance in theforecast,‘‘None‘‘ would be returned.

Returns a Weather object or None if no item in the forecast is eligible

most_snowy()Returns the Weather object in the forecast having the highest snow volume. The snow amount is retrieved

1.1. Subpackages 27

Page 32: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

via the get_snow['all'] call; was the ‘all’ key missing for every Weather instance in the forecast,None would be returned.

Returns a Weather object or None if no item in the forecast is eligible

most_windy()Returns the Weather object in the forecast having the highest wind speed. The snow amount is retrieved viathe get_wind['speed'] call; was the ‘speed’ key missing for every Weather instance in the forecast,None would be returned.

Returns a Weather object or None if no item in the forecast is eligible

when_clear()Returns a sublist of the Weather list in the forecast, containing only items having clear sky as weathercondition.

Returns a list of Weather objects

when_clouds()Returns a sublist of the Weather list in the forecast, containing only items having clouds as weather condi-tion.

Returns a list of Weather objects

when_ends(timeformat=’unix’)Returns the GMT time of the end of the forecast coverage, which is the time of the most recent Weatheritem in the forecast

Parameters timeformat (str) – the format for the time value. May be: ‘unix’ (de-fault) for UNIX time ‘iso’ for ISO8601-formatted string in the format YYYY-MM-DDHH:MM:SS+00 ‘date for datetime.datetime object instance

Returns a long or a str

Raises ValueError when invalid time format values are provided

when_fog()Returns a sublist of the Weather list in the forecast, containing only items having fog as weather condition.

Returns a list of Weather objects

when_hurricane()Returns a sublist of the Weather list in the forecast, containing only items having hurricane as weathercondition.

Returns a list of Weather objects

when_rain()Returns a sublist of the Weather list in the forecast, containing only items having rain as weather condition.

Returns a list of Weather objects

when_snow()Returns a sublist of the Weather list in the forecast, containing only items having snow as weather condi-tion.

Returns a list of Weather objects

when_starts(timeformat=’unix’)Returns the GMT time of the start of the forecast coverage, which is the time of the most ancient Weatheritem in the forecast

28 Chapter 1. pyowm package

Page 33: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

Parameters timeformat (str) – the format for the time value. May be: ‘unix’ (de-fault) for UNIX time ‘iso’ for ISO8601-formatted string in the format YYYY-MM-DDHH:MM:SS+00 ‘date for datetime.datetime object instance

Returns a long or a str

Raises ValueError when invalid time format values are provided

when_storm()Returns a sublist of the Weather list in the forecast, containing only items having storm as weather condi-tion.

Returns a list of Weather objects

when_sun(*args, **kwargs)Returns a sublist of the Weather list in the forecast, containing only items having sun as weather condition.

Returns a list of Weather objects

when_tornado()Returns a sublist of the Weather list in the forecast, containing only items having tornado as weathercondition.

Returns a list of Weather objects

will_be_clear_at(timeobject)Tells if at the specified time the condition is clear sky. The check is performed on the Weather item of theforecast which is closest to the time value conveyed by the parameter

Parameters timeobject (long/int, datetime.datetime or str)) – may be a UNIXtime, a datetime.datetime object or an ISO8601-formatted string in the formatYYYY-MM-DD HH:MM:SS+00

Returns boolean

will_be_cloudy_at(timeobject)Tells if at the specified time the condition is clouds. The check is performed on the Weather item of theforecast which is closest to the time value conveyed by the parameter

Parameters timeobject (long/int, datetime.datetime or str)) – may be a UNIXtime, a datetime.datetime object or an ISO8601-formatted string in the formatYYYY-MM-DD HH:MM:SS+00

Returns boolean

will_be_foggy_at(timeobject)Tells if at the specified time the condition is fog. The check is performed on the Weather item of theforecast which is closest to the time value conveyed by the parameter

Parameters timeobject (long/int, datetime.datetime or str)) – may be a UNIXtime, a datetime.datetime object or an ISO8601-formatted string in the formatYYYY-MM-DD HH:MM:SS+00

Returns boolean

will_be_hurricane_at(timeobject)Tells if at the specified time the condition is hurricane. The check is performed on the Weather item of theforecast which is closest to the time value conveyed by the parameter

Parameters timeobject (long/int, datetime.datetime or str)) – may be a UNIXtime, a datetime.datetime object or an ISO8601-formatted string in the formatYYYY-MM-DD HH:MM:SS+00

Returns boolean

1.1. Subpackages 29

Page 34: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

will_be_rainy_at(timeobject)Tells if at the specified time the condition is rain. The check is performed on the Weather item of theforecast which is closest to the time value conveyed by the parameter

Parameters timeobject (long/int, datetime.datetime or str)) – may be a UNIXtime, a datetime.datetime object or an ISO8601-formatted string in the formatYYYY-MM-DD HH:MM:SS+00

Returns boolean

will_be_snowy_at(timeobject)Tells if at the specified time the condition is snow. The check is performed on the Weather item of theforecast which is closest to the time value conveyed by the parameter

Parameters timeobject (long/int, datetime.datetime or str)) – may be a UNIXtime, a datetime.datetime object or an ISO8601-formatted string in the formatYYYY-MM-DD HH:MM:SS+00

Returns boolean

will_be_stormy_at(timeobject)Tells if at the specified time the condition is storm. The check is performed on the Weather item of theforecast which is closest to the time value conveyed by the parameter

Parameters timeobject (long/int, datetime.datetime or str)) – may be a UNIXtime, a datetime.datetime object or an ISO8601-formatted string in the formatYYYY-MM-DD HH:MM:SS+00

Returns boolean

will_be_sunny_at(*args, **kwargs)Tells if at the specified time the condition is sun. The check is performed on the Weather item of theforecast which is closest to the time value conveyed by the parameter

Parameters timeobject (long/int, datetime.datetime or str)) – may be a UNIXtime, a datetime.datetime object or an ISO8601-formatted string in the formatYYYY-MM-DD HH:MM:SS+00

Returns boolean

will_be_tornado_at(timeobject)Tells if at the specified time the condition is tornado. The check is performed on the Weather item of theforecast which is closest to the time value conveyed by the parameter

Parameters timeobject (long/int, datetime.datetime or str)) – may be a UNIXtime, a datetime.datetime object or an ISO8601-formatted string in the formatYYYY-MM-DD HH:MM:SS+00

Returns boolean

will_have_clear()Tells if into the forecast coverage exist one or more Weather items related to clear sky conditions

Returns boolean

will_have_clouds()Tells if into the forecast coverage exist one or more Weather items related to cloud conditions

Returns boolean

will_have_fog()Tells if into the forecast coverage exist one or more Weather items related to fog conditions

Returns boolean

30 Chapter 1. pyowm package

Page 35: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

will_have_hurricane()Tells if into the forecast coverage exist one or more Weather items related to hurricanes

Returns boolean

will_have_rain()Tells if into the forecast coverage exist one or more Weather items related to rain conditions

Returns boolean

will_have_snow()Tells if into the forecast coverage exist one or more Weather items related to snow conditions

Returns boolean

will_have_storm()Tells if into the forecast coverage exist one or more Weather items related to storms

Returns boolean

will_have_sun(*args, **kwargs)Tells if into the forecast coverage exist one or more Weather items related to sun conditions

Returns boolean

will_have_tornado()Tells if into the forecast coverage exist one or more Weather items related to tornadoes

Returns boolean

1.1.7.7 pyowm.webapi25.forecastparser module

Module containing a concrete implementation for JSONParser abstract class, returning Forecast objects

class pyowm.webapi25.forecastparser.ForecastParserBases: pyowm.abstractions.jsonparser.JSONParser

Concrete JSONParser implementation building a Forecast instance out of raw JSON data coming from OWMweb API responses.

parse_JSON(JSON_string)Parses a Forecast instance out of raw JSON data. Only certain properties of the data are used: if theseproperties are not found or cannot be parsed, an error is issued.

Parameters JSON_string (str) – a raw JSON string

Returns a Forecast instance or None if no data is available

Raises ParseResponseError if it is impossible to find or parse the data needed to build the result,APIResponseError if the JSON string embeds an HTTP status error (this is an OWM webAPI 2.5 bug)

1.1.7.8 pyowm.webapi25.historian module

Module containing weather history abstraction classes and data structures.

class pyowm.webapi25.historian.Historian(station_history)Bases: object

A class providing convenience methods for manipulating meteostation weather history data. The class encap-sulates a StationHistory instance and provides abstractions on the top of it in order to let programmers exploitmeteostation weather history data in a human-friendly fashion

1.1. Subpackages 31

Page 36: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

Parameters station_history (StationHistory) – a StationHistory instance

Returns a Historian instance

average_humidity()Returns the average value in the humidity series

Returns a float

Raises ValueError when the measurement series is empty

average_pressure()Returns the average value in the pressure series

Returns a float

Raises ValueError when the measurement series is empty

average_rain()Returns the average value in the rain series

Returns a float

Raises ValueError when the measurement series is empty

average_temperature(unit=’kelvin’)Returns the average value in the temperature series

Parameters unit (str) – the unit of measure for the temperature values. May be among:‘kelvin’ (default), ‘celsius’ or ‘fahrenheit’

Returns a float

Raises ValueError when invalid values are provided for the unit of measure or the measurementseries is empty

get_station_history()Returns the StationHistory instance

Returns the StationHistory instance

humidity_series()Returns the humidity time series relative to the meteostation, in the form of a list of tuples, each onecontaining the couple timestamp-value

Returns a list of tuples

max_humidity()Returns a tuple containing the max value in the humidity series preceeded by its timestamp

Returns a tuple

Raises ValueError when the measurement series is empty

max_pressure()Returns a tuple containing the max value in the pressure series preceeded by its timestamp

Returns a tuple

Raises ValueError when the measurement series is empty

max_rain()Returns a tuple containing the max value in the rain series preceeded by its timestamp

Returns a tuple

Raises ValueError when the measurement series is empty

32 Chapter 1. pyowm package

Page 37: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

max_temperature(unit=’kelvin’)Returns a tuple containing the max value in the temperature series preceeded by its timestamp

Parameters unit (str) – the unit of measure for the temperature values. May be among:‘kelvin’ (default), ‘celsius’ or ‘fahrenheit’

Returns a tuple

Raises ValueError when invalid values are provided for the unit of measure or the measurementseries is empty

min_humidity()Returns a tuple containing the min value in the humidity series preceeded by its timestamp

Returns a tuple

Raises ValueError when the measurement series is empty

min_pressure()Returns a tuple containing the min value in the pressure series preceeded by its timestamp

Returns a tuple

Raises ValueError when the measurement series is empty

min_rain()Returns a tuple containing the min value in the rain series preceeded by its timestamp

Returns a tuple

Raises ValueError when the measurement series is empty

min_temperature(unit=’kelvin’)Returns a tuple containing the min value in the temperature series preceeded by its timestamp

Parameters unit (str) – the unit of measure for the temperature values. May be among:‘kelvin’ (default), ‘celsius’ or ‘fahrenheit’

Returns a tuple

Raises ValueError when invalid values are provided for the unit of measure or the measurementseries is empty

pressure_series()Returns the atmospheric pressure time series relative to the meteostation, in the form of a list of tuples,each one containing the couple timestamp-value

Returns a list of tuples

rain_series()Returns the precipitation time series relative to the meteostation, in the form of a list of tuples, each onecontaining the couple timestamp-value

Returns a list of tuples

temperature_series(unit=’kelvin’)Returns the temperature time series relative to the meteostation, in the form of a list of tuples, each onecontaining the couple timestamp-value

Parameters unit (str) – the unit of measure for the temperature values. May be among:‘kelvin’ (default), ‘celsius’ or ‘fahrenheit’

Returns a list of tuples

Raises ValueError when invalid values are provided for the unit of measure

1.1. Subpackages 33

Page 38: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

wind_series()Returns the wind speed time series relative to the meteostation, in the form of a list of tuples, each onecontaining the couple timestamp-value

Returns a list of tuples

1.1.7.9 pyowm.webapi25.location module

Module containing location-related classes and data structures.

class pyowm.webapi25.location.Location(name, lon, lat, ID, country=None)Bases: object

A class representing a location in the world. A location is defined through a toponym, a couple of geographiccoordinates such as longitude and latitude and a numeric identifier assigned by the OWM web API that uniquelyspots the location in the world. Optionally, the country specification may be provided.

Further reference about OWM city IDs can be found at: http://bugs.openweathermap.org/projects/api/wiki/Api_2_5_weather#3-By-city-ID

Parameters

• name (Unicode) – the location’s toponym

• lon (int/float) – the location’s longitude, must be between -180.0 and 180.0

• lat (int/float) – the location’s latitude, must be between -90.0 and 90.0

• ID (int) – the location’s OWM city ID

• country (Unicode) – the location’s country (None by default)

Returns a Location instance

Raises ValueError if lon or lat values are provided out of bounds

get_ID()Returns the OWM city ID of the location

Returns the int OWM city ID

get_country()Returns the country of the location

Returns the Unicode country

get_lat()Returns the latitude of the location

Returns the float latitude

get_lon()Returns the longitude of the location

Returns the float longitude

get_name()Returns the toponym of the location

Returns the Unicode toponym

to_JSON()Dumps object fields into a JSON formatted string

Returns the JSON string

34 Chapter 1. pyowm package

Page 39: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

to_XML(xml_declaration=True, xmlns=True)Dumps object fields to an XML-formatted string. The ‘xml_declaration’ switch enables printing of aleading standard XML line containing XML version and encoding. The ‘xmlns’ switch enables printingof qualified XMLNS prefixes.

Parameters

• XML_declaration (bool) – if True (default) prints a leading XML declaration line

• xmlns (bool) – if True (default) prints full XMLNS prefixes

Returns an XML-formatted string

pyowm.webapi25.location.location_from_dictionary(d)Builds a Location object out of a data dictionary. Only certain properties of the dictionary are used: if theseproperties are not found or cannot be read, an error is issued.

Parameters d (dict) – a data dictionary

Returns a Location instance

Raises KeyError if it is impossible to find or read the data needed to build the instance

1.1.7.10 pyowm.webapi25.observation module

Weather observation classes and data structures.

class pyowm.webapi25.observation.Observation(reception_time, location, weather)Bases: object

A class representing the weather which is currently being observed in a certain location in the world. Thelocation is represented by the encapsulated Location object while the observed weather data are held by theencapsulated Weather object.

Parameters

• reception_time (int) – GMT UNIXtime telling when the weather obervation hasbeen received from the OWM web API

• location (Location) – the Location relative to this observation

• weather (Weather) – the Weather relative to this observation

Returns an Observation instance

Raises ValueError when negative values are provided as reception time

get_location()Returns the Location object for this observation

Returns the Location object

get_reception_time(timeformat=’unix’)

Returns the GMT time telling when the observation has been received from the OWM web API

Parameters timeformat (str) – the format for the time value. May be: ‘unix’ (de-fault) for UNIX time ‘iso’ for ISO8601-formatted string in the format YYYY-MM-DDHH:MM:SS+00 ‘date for datetime.datetime object instance

Returns an int or a str

Raises ValueError when negative values are provided

1.1. Subpackages 35

Page 40: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

get_weather()Returns the Weather object for this observation

Returns the Weather object

to_JSON()Dumps object fields into a JSON formatted string

Returns the JSON string

to_XML(xml_declaration=True, xmlns=True)Dumps object fields to an XML-formatted string. The ‘xml_declaration’ switch enables printing of aleading standard XML line containing XML version and encoding. The ‘xmlns’ switch enables printingof qualified XMLNS prefixes.

Parameters

• XML_declaration (bool) – if True (default) prints a leading XML declaration line

• xmlns (bool) – if True (default) prints full XMLNS prefixes

Returns an XML-formatted string

1.1.7.11 pyowm.webapi25.observationlistparser module

Module containing a concrete implementation for JSONParser abstract class, returning lists of Observation objects

class pyowm.webapi25.observationlistparser.ObservationListParserBases: pyowm.abstractions.jsonparser.JSONParser

Concrete JSONParser implementation building a list of Observation instances out of raw JSON data comingfrom OWM web API responses.

parse_JSON(JSON_string)Parses a list of Observation instances out of raw JSON data. Only certain properties of the data are used:if these properties are not found or cannot be parsed, an error is issued.

Parameters JSON_string (str) – a raw JSON string

Returns a list of Observation instances or None if no data is available

Raises ParseResponseError if it is impossible to find or parse the data needed to build the result,APIResponseError if the OWM API returns a HTTP status error (this is an OWM web API2.5 bug)

1.1.7.12 pyowm.webapi25.observationparser module

Module containing a concrete implementation for JSONParser abstract class, returning Observation objects

class pyowm.webapi25.observationparser.ObservationParserBases: pyowm.abstractions.jsonparser.JSONParser

Concrete JSONParser implementation building an Observation instance out of raw JSON data coming fromOWM web API responses.

parse_JSON(JSON_string)Parses an Observation instance out of raw JSON data. Only certain properties of the data are used: if theseproperties are not found or cannot be parsed, an error is issued.

Parameters JSON_string (str) – a raw JSON string

Returns an Observation instance or None if no data is available

36 Chapter 1. pyowm package

Page 41: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

Raises ParseResponseError if it is impossible to find or parse the data needed to build the result,APIResponseError if the JSON string embeds an HTTP status error (this is an OWM webAPI 2.5 bug)

1.1.7.13 pyowm.webapi25.owm25 module

Module containing the PyOWM library main entry point

class pyowm.webapi25.owm25.OWM25(parsers, API_key=None, cache=<pyowm.caches.nullcache.NullCache>,language=’en’, subscription_type=’free’)

Bases: pyowm.abstractions.owm.OWM

OWM_API_VERSION = '2.5'OWM subclass providing methods for each OWM web API 2.5 endpoint. The class is instantiated withjsonparser subclasses, each one parsing the response payload of a specific API endpoint

Parameters

• parsers (dict) – the dictionary containing jsonparser concrete instances to be used asparsers for OWM web API 2.5 responses

• API_key (str) – the OWM web API key (defaults to None)

• cache (an OWMCache concrete instance) – a concrete implementation of class OWM-Cache serving as the cache provider (defaults to a NullCache instance)

• language (str) – the language in which you want text results to be returned. It’s atwo-characters string, eg: “en”, “ru”, “it”. Defaults to: “en”

• subscription_type (str) – the type of OWM web API subscription to be wrapped.Can be ‘free’ (free subscription) or ‘pro’ (paid subscription), Defaults to: ‘free’

Returns an OWM25 instance

city_id_registry()Gives the CityIDRegistry singleton instance that can be used to lookup for city IDs.

Returns a CityIDRegistry instance

coindex_around_coords(lat, lon, start=None, interval=None)Queries the OWM web API for Carbon Monoxide values sampled in the surroundings of the providedgeocoordinates and in the specified time interval. A COIndex object instance is returned, encapsulatinga Location object and the list of CO samples If start is not provided, the latest available CO samples areretrieved If start is provided but interval is not, then interval defaults to the maximum extent, which is:year

Parameters

• lat (int/float) – the location’s latitude, must be between -90.0 and 90.0

• lon (int/float) – the location’s longitude, must be between -180.0 and 180.0

• start (int, datetime.datetime or ISO8601-formatted string) – the object convey-ing the start value of the search time window start (defaults to None). If not provided, thelatest available CO samples value are retrieved

• interval (str among: 'minute', 'hour', 'day', 'month,'year') – the length of the search time window starting at start (defaults to None). Ifnot provided, ‘year’ is used

Returns a COIndex instance or None if data is not available

1.1. Subpackages 37

Page 42: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

Raises ParseResponseException when OWM web API responses’ data cannot be parsed, API-CallException when OWM web API can not be reached, ValueError for wrong input values

daily_forecast(name, limit=None)Queries the OWM web API for daily weather forecast for the specified location (eg: “London,uk”). AForecaster object is returned, containing a Forecast instance covering a global streak of fourteen days bydefault: this instance encapsulates Weather objects, with a time interval of one day one from each other

Parameters

• name (str or unicode) – the location’s toponym

• limit (int or None) – the maximum number of daily Weather items to be retrieved(default is None, which stands for any number of items)

Returns a Forecaster instance or None if forecast data is not available for the specified location

Raises ParseResponseException when OWM web API responses’ data cannot be parsed, API-CallException when OWM web API can not be reached, ValueError if negative values aresupplied for limit

daily_forecast_at_coords(lat, lon, limit=None)Queries the OWM web API for daily weather forecast for the specified geographic coordinate (eg: latitude:51.5073509, longitude: -0.1277583). A Forecaster object is returned, containing a Forecast instancecovering a global streak of fourteen days by default: this instance encapsulates Weather objects, with atime interval of one day one from each other

Parameters

• lat (int/float) – location’s latitude, must be between -90.0 and 90.0

• lon (int/float) – location’s longitude, must be between -180.0 and 180.0

• limit (int or None) – the maximum number of daily Weather items to be retrieved(default is None, which stands for any number of items)

Returns a Forecaster instance or None if forecast data is not available for the specified location

Raises ParseResponseException when OWM web API responses’ data cannot be parsed, API-CallException when OWM web API can not be reached, ValueError if negative values aresupplied for limit

daily_forecast_at_id(id, limit=None)Queries the OWM web API for daily weather forecast for the specified city ID (eg: 5128581). A Forecasterobject is returned, containing a Forecast instance covering a global streak of fourteen days by default: thisinstance encapsulates Weather objects, with a time interval of one day one from each other

Parameters

• id (int) – the location’s city ID

• limit (int or None) – the maximum number of daily Weather items to be retrieved(default is None, which stands for any number of items)

Returns a Forecaster instance or None if forecast data is not available for the specified location

Raises ParseResponseException when OWM web API responses’ data cannot be parsed, API-CallException when OWM web API can not be reached, ValueError if negative values aresupplied for limit

get_API_key()Returns the str OWM API key

Returns a str

38 Chapter 1. pyowm package

Page 43: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

get_API_version(*args, **kwargs)Returns the currently supported OWM web API version

Deprecated since version 3.0.0: Will return a dict of tuples instead of a str

Returns str

get_language()Returns the language in which the OWM web API shall return text results

Returns the language

get_subscription_type()Returns the OWM API subscription type

Returns the subscription type

get_version(*args, **kwargs)Returns the current version of the PyOWM library

Deprecated since version 3.0.0: Will return a tuple instead of a str

Returns str

is_API_online()Returns True if the OWM web API is currently online. A short timeout is used to determine API serviceavailability.

Returns bool

no2index_around_coords(lat, lon, start=None, interval=None)Queries the OWM web API for Nitrogen Dioxide values sampled in the surroundings of the providedgeocoordinates and in the specified time interval. A NO2Index object instance is returned, encapsulating aLocation object and the list of NO2 samples If start is not provided, the latest available NO2 samples areretrieved If start is provided but interval is not, then interval defaults to the maximum extent, which is:year

Parameters

• lat (int/float) – the location’s latitude, must be between -90.0 and 90.0

• lon (int/float) – the location’s longitude, must be between -180.0 and 180.0

• start (int, datetime.datetime or ISO8601-formatted string) – the object convey-ing the start value of the search time window start (defaults to None). If not provided, thelatest available NO2 samples value are retrieved

• interval (str among: 'minute', 'hour', 'day', 'month,'year') – the length of the search time window starting at start (defaults to None). Ifnot provided, ‘year’ is used

Returns a NO2Index instance or None if data is not available

Raises ParseResponseException when OWM web API responses’ data cannot be parsed, API-CallException when OWM web API can not be reached, ValueError for wrong input values

ozone_around_coords(lat, lon, start=None, interval=None)Queries the OWM web API for Ozone (O3) value in Dobson Units sampled in the surroundings of theprovided geocoordinates and in the specified time interval. An Ozone object instance is returned, encap-sulating a Location object and the UV intensity value. If start is not provided, the latest available ozonevalue is retrieved. If start is provided but interval is not, then interval defaults to the maximum extent,which is: year

Parameters

1.1. Subpackages 39

Page 44: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

• lat (int/float) – the location’s latitude, must be between -90.0 and 90.0

• lon (int/float) – the location’s longitude, must be between -180.0 and 180.0

• start (int, datetime.datetime or ISO8601-formatted string) – the object convey-ing the start value of the search time window start (defaults to None). If not provided, thelatest available Ozone value is retrieved

• interval (str among: 'minute', 'hour', 'day', 'month,'year') – the length of the search time window starting at start (defaults to None). Ifnot provided, ‘year’ is used

Returns an Ozone instance or None if data is not available

Raises ParseResponseException when OWM web API responses’ data cannot be parsed, API-CallException when OWM web API can not be reached, ValueError for wrong input values

set_API_key(API_key)Updates the str OWM API key

Parameters API_key (str) – the new str API key

set_language(language)Sets the language in which the OWM web API shall return text results

Parameters language – the new two-characters language (eg: “ru”)

so2index_around_coords(lat, lon, start=None, interval=None)Queries the OWM web API for Sulphur Dioxide values sampled in the surroundings of the providedgeocoordinates and in the specified time interval. A SO2Index object instance is returned, encapsulating aLocation object and the list of SO2 samples If start is not provided, the latest available SO2 samples areretrieved If start is provided but interval is not, then interval defaults to the maximum extent, which is:year

Parameters

• lat (int/float) – the location’s latitude, must be between -90.0 and 90.0

• lon (int/float) – the location’s longitude, must be between -180.0 and 180.0

• start (int, datetime.datetime or ISO8601-formatted string) – the object convey-ing the start value of the search time window start (defaults to None). If not provided, thelatest available SO2 samples value are retrieved

• interval (str among: 'minute', 'hour', 'day', 'month,'year') – the length of the search time window starting at start (defaults to None). Ifnot provided, ‘year’ is used

Returns a SO2Index instance or None if data is not available

Raises ParseResponseException when OWM web API responses’ data cannot be parsed, API-CallException when OWM web API can not be reached, ValueError for wrong input values

station_at_coords(*args, **kwargs)Queries the OWM web API for weather stations nearest to the specified geographic coordinates (eg: lati-tude: 51.5073509, longitude: -0.1277583). A list of Station objects is returned, this instance encapsulatesa last reported Weather object.

Parameters

• lat (int/float) – location’s latitude, must be between -90.0 and 90.0

• lon (int/float) – location’s longitude, must be between -180.0 and 180.0

40 Chapter 1. pyowm package

Page 45: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

• cnt (int or None) – the maximum number of Station items to be retrieved (default isNone, which stands for any number of items)

Returns a list of Station objects or None if station data is not available for the specified location

Raises ParseResponseException when OWM web API responses’ data cannot be parsed, API-CallException when OWM web API can not be reached

station_day_history(station_ID, limit=None)Queries the OWM web API for historic weather data measurements for the specified meteostation (eg:2865), sampled once a day. A Historian object instance is returned, encapsulating a StationHistory objectswhich contains the measurements. The total number of retrieved data points can be limited using theappropriate parameter

Parameters

• station_ID (int) – the numeric ID of the meteostation

• limit (int or None) – the maximum number of data points the result shall contain (de-fault is None, which stands for any number of data points)

Returns a Historian instance or None if data is not available for the specified meteostation

Raises ParseResponseException when OWM web API responses’ data cannot be parsed, API-CallException when OWM web API can not be reached, ValueError if the limit value isnegative

station_hour_history(station_ID, limit=None)Queries the OWM web API for historic weather data measurements for the specified meteostation (eg:2865), sampled once a hour. A Historian object instance is returned, encapsulating a StationHistory objectswhich contains the measurements. The total number of retrieved data points can be limited using theappropriate parameter

Parameters

• station_ID (int) – the numeric ID of the meteostation

• limit (int or None) – the maximum number of data points the result shall contain (de-fault is None, which stands for any number of data points)

Returns a Historian instance or None if data is not available for the specified meteostation

Raises ParseResponseException when OWM web API responses’ data cannot be parsed, API-CallException when OWM web API can not be reached, ValueError if the limit value isnegative

station_tick_history(station_ID, limit=None)Queries the OWM web API for historic weather data measurements for the specified meteostation (eg:2865), sampled once a minute (tick). A StationHistory object instance is returned, encapsulating themeasurements: the total number of data points can be limited using the appropriate parameter

Parameters

• station_ID (int) – the numeric ID of the meteostation

• limit (int or None) – the maximum number of data points the result shall contain (de-fault is None, which stands for any number of data points)

Returns a StationHistory instance or None if data is not available for the specified meteostation

Raises ParseResponseException when OWM web API responses’ data cannot be parsed, API-CallException when OWM web API can not be reached, ValueError if the limit value isnegative

1.1. Subpackages 41

Page 46: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

stations_manager()Gives a StationsManager instance that can be used to read/write meteostations data. :returns: a Stations-Manager instance

three_hours_forecast(name)Queries the OWM web API for three hours weather forecast for the specified location (eg: “London,uk”).A Forecaster object is returned, containing a Forecast instance covering a global streak of five days: thisinstance encapsulates Weather objects, with a time interval of three hours one from each other

Parameters name (str or unicode) – the location’s toponym

Returns a Forecaster instance or None if forecast data is not available for the specified location

Raises ParseResponseException when OWM web API responses’ data cannot be parsed, API-CallException when OWM web API can not be reached

three_hours_forecast_at_coords(lat, lon)Queries the OWM web API for three hours weather forecast for the specified geographic coordinate (eg:latitude: 51.5073509, longitude: -0.1277583). A Forecaster object is returned, containing a Forecastinstance covering a global streak of five days: this instance encapsulates Weather objects, with a timeinterval of three hours one from each other

Parameters

• lat (int/float) – location’s latitude, must be between -90.0 and 90.0

• lon (int/float) – location’s longitude, must be between -180.0 and 180.0

Returns a Forecaster instance or None if forecast data is not available for the specified location

Raises ParseResponseException when OWM web API responses’ data cannot be parsed, API-CallException when OWM web API can not be reached

three_hours_forecast_at_id(id)Queries the OWM web API for three hours weather forecast for the specified city ID (eg: 5128581). AForecaster object is returned, containing a Forecast instance covering a global streak of five days: thisinstance encapsulates Weather objects, with a time interval of three hours one from each other

Parameters id (int) – the location’s city ID

Returns a Forecaster instance or None if forecast data is not available for the specified location

Raises ParseResponseException when OWM web API responses’ data cannot be parsed, API-CallException when OWM web API can not be reached

uvindex_around_coords(lat, lon)Queries the OWM web API for Ultra Violet value sampled in the surroundings of the provided geocoordi-nates and in the specified time interval. A UVIndex object instance is returned, encapsulating a Locationobject and the UV intensity value. If start is not provided, the latest available UVIndex value is retrieved.If start is provided but interval is not, then interval defaults to the maximum extent, which is: year

Parameters

• lat (int/float) – the location’s latitude, must be between -90.0 and 90.0

• lon (int/float) – the location’s longitude, must be between -180.0 and 180.0

Returns a UVIndex instance or None if data is not available

Raises ParseResponseException when OWM web API responses’ data cannot be parsed, API-CallException when OWM web API can not be reached, ValueError for wrong input values

42 Chapter 1. pyowm package

Page 47: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

weather_around_coords(lat, lon, limit=None)Queries the OWM web API for the currently observed weather in all the locations in the proximity of thespecified coordinates.

Parameters

• lat (int/float) – location’s latitude, must be between -90.0 and 90.0

• lon (int/float) – location’s longitude, must be between -180.0 and 180.0

• limit – the maximum number of Observation items in the returned list (default is None,which stands for any number of items)

• limit – int or None

Returns a list of Observation objects or None if no weather data is available

Raises ParseResponseException when OWM web API responses’ data cannot be parsed, API-CallException when OWM web API can not be reached, ValueError when coordinates valuesare out of bounds or negative values are provided for limit

weather_at_coords(lat, lon)Queries the OWM web API for the currently observed weather at the specified geographic (eg: 51.503614,-0.107331).

Parameters

• lat (int/float) – the location’s latitude, must be between -90.0 and 90.0

• lon (int/float) – the location’s longitude, must be between -180.0 and 180.0

Returns an Observation instance or None if no weather data is available

Raises ParseResponseException when OWM web API responses’ data cannot be parsed or API-CallException when OWM web API can not be reached

weather_at_id(id)Queries the OWM web API for the currently observed weather at the specified city ID (eg: 5128581)

Parameters id (int) – the location’s city ID

Returns an Observation instance or None if no weather data is available

Raises ParseResponseException when OWM web API responses’ data cannot be parsed or API-CallException when OWM web API can not be reached

weather_at_ids(ids_list)Queries the OWM web API for the currently observed weathers at the specified city IDs (eg:[5128581,87182])

Parameters ids_list (list of int) – the list of city IDs

Returns a list of Observation instances or an empty list if no weather data is available

Raises ParseResponseException when OWM web API responses’ data cannot be parsed or API-CallException when OWM web API can not be reached

weather_at_place(name)Queries the OWM web API for the currently observed weather at the specified toponym (eg: “London,uk”)

Parameters name (str or unicode) – the location’s toponym

Returns an Observation instance or None if no weather data is available

Raises ParseResponseException when OWM web API responses’ data cannot be parsed or API-CallException when OWM web API can not be reached

1.1. Subpackages 43

Page 48: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

weather_at_places(pattern, searchtype, limit=None)Queries the OWM web API for the currently observed weather in all the locations whose name is matchingthe specified text search parameters. A twofold search can be issued: ‘accurate’ (exact matching) and ‘like’(matches names that are similar to the supplied pattern).

Parameters

• pattern (str) – the string pattern (not a regex) to be searched for the toponym

• searchtype – the search mode to be used, must be ‘accurate’ for an exact matching or‘like’ for a likelihood matching

• limit – the maximum number of Observation items in the returned list (default is None,which stands for any number of items)

• limit – int or None

Type searchtype: str

Returns a list of Observation objects or None if no weather data is available

Raises ParseResponseException when OWM web API responses’ data cannot be parsed, API-CallException when OWM web API can not be reached, ValueError when bad value is sup-plied for the search type or the maximum number of items retrieved

weather_at_station(station_id)Queries the OWM web API for the weather currently observed by a specific meteostation (eg: 29584)

Parameters station_id (int) – the meteostation ID

Returns an Observation instance or None if no weather data is available

Raises ParseResponseException when OWM web API responses’ data cannot be parsed or API-CallException when OWM web API can not be reached

weather_at_stations_in_bbox(lat_top_left, lon_top_left, lat_bottom_right, lon_bottom_right,cluster=False, limit=None)

Queries the OWM web API for the weather currently observed by meteostations inside the bounding boxof latitude/longitude coords.

Parameters

• lat_top_left (int/float) – latitude for top-left of bounding box, must be between-90.0 and 90.0

• lon_top_left (int/float) – longitude for top-left of bounding box must be be-tween -180.0 and 180.0

• lat_bottom_right (int/float) – latitude for bottom-right of bounding box, mustbe between -90.0 and 90.0

• lon_bottom_right (int/float) – longitude for bottom-right of bounding box,must be between -180.0 and 180.0

• cluster (bool) – use server clustering of points

• limit – the maximum number of Observation items in the returned list (default is None,which stands for any number of items)

• limit – int or None

Returns a list of Observation objects or None if no weather data is available

Raises ParseResponseException when OWM web API responses’ data cannot be parsed, API-CallException when OWM web API can not be reached, ValueError when coordinates valuesare out of bounds or negative values are provided for limit

44 Chapter 1. pyowm package

Page 49: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

weather_at_zip_code(zipcode, country)Queries the OWM web API for the currently observed weather at the specified zip code and country code(eg: 2037, au).

Parameters

• zip (string) – the location’s zip or postcode

• country (string) – the location’s country code

Returns an Observation instance or None if no weather data is available

Raises ParseResponseException when OWM web API responses’ data cannot be parsed or API-CallException when OWM web API can not be reached

weather_history_at_coords(lat, lon, start=None, end=None)Queries the OWM web API for weather history for the specified at the specified geographic (eg:51.503614, -0.107331). A list of Weather objects is returned. It is possible to query for weather history ina closed time period, whose boundaries can be passed as optional parameters.

Parameters

• lat (int/float) – the location’s latitude, must be between -90.0 and 90.0

• lon (int/float) – the location’s longitude, must be between -180.0 and 180.0

• start (int, datetime.datetime or ISO8601-formatted string) – the object convey-ing the time value for the start query boundary (defaults to None)

• end (int, datetime.datetime or ISO8601-formatted string) – the object conveyingthe time value for the end query boundary (defaults to None)

Returns a list of Weather instances or None if history data is not available for the specifiedlocation

weather_history_at_id(id, start=None, end=None)Queries the OWM web API for weather history for the specified city ID. A list of Weather objects isreturned. It is possible to query for weather history in a closed time period, whose boundaries can bepassed as optional parameters.

Parameters

• id (int) – the city ID

• start (int, datetime.datetime or ISO8601-formatted string) – the object convey-ing the time value for the start query boundary (defaults to None)

• end (int, datetime.datetime or ISO8601-formatted string) – the object conveyingthe time value for the end query boundary (defaults to None)

Returns a list of Weather instances or None if history data is not available for the specifiedlocation

Raises ParseResponseException when OWM web API responses’ data cannot be parsed, API-CallException when OWM web API can not be reached, ValueError if the time boundariesare not in the correct chronological order, if one of the time boundaries is not None and theother is or if one or both of the time boundaries are after the current time

weather_history_at_place(name, start=None, end=None)Queries the OWM web API for weather history for the specified location (eg: “London,uk”). A list ofWeather objects is returned. It is possible to query for weather history in a closed time period, whoseboundaries can be passed as optional parameters.

Parameters

1.1. Subpackages 45

Page 50: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

• name (str or unicode) – the location’s toponym

• start (int, datetime.datetime or ISO8601-formatted string) – the object convey-ing the time value for the start query boundary (defaults to None)

• end (int, datetime.datetime or ISO8601-formatted string) – the object conveyingthe time value for the end query boundary (defaults to None)

Returns a list of Weather instances or None if history data is not available for the specifiedlocation

Raises ParseResponseException when OWM web API responses’ data cannot be parsed, API-CallException when OWM web API can not be reached, ValueError if the time boundariesare not in the correct chronological order, if one of the time boundaries is not None and theother is or if one or both of the time boundaries are after the current time

1.1.7.14 pyowm.webapi25.station module

Module containing classes and data structures related to meteostation data

class pyowm.webapi25.station.Station(*args, **kwargs)Bases: object

A class representing meteostations which are reporting current weather conditions from geographical coordi-nates.

Parameters

• name (string) – meteostation name

• station_ID (int) – OWM station ID

• station_type (int) – meteostation type

• status (int) – station status

• lat (float) – latitude for station

• lon (float) – longitude for station

• distance (float) – distance of station from lat/lon of search criteria

• last_weather (Weather instance) – last reported weather conditions from station

Returns a Station instance

Raises ValueError if lon or lat values are provided out of bounds or last_weather is not an instanceof Weather or None

get_distance()Returns the distance of the station from the geo coordinates used in search

Returns the float distance from geo coordinates

get_last_weather()Returns the last reported weather conditions reported by the station.

Returns the last Weather instance reported by station

get_lat()Returns the latitude of the location

Returns the float latitude

46 Chapter 1. pyowm package

Page 51: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

get_lon()Returns the longitude of the location

Returns the float longitude

get_name()Returns the name of the station

Returns the Unicode station name

get_station_ID()Returns the OWM station ID

Returns the int OWM station ID

get_station_type()Returns the OWM station type

Returns the int OWM station type

get_status()Returns the OWM station status

Returns the int OWM station status

to_JSON()Dumps object fields into a JSON formatted string

Returns the JSON string

to_XML(xml_declaration=True, xmlns=True)Dumps object fields to an XML-formatted string. The ‘xml_declaration’ switch enables printing of aleading standard XML line containing XML version and encoding. The ‘xmlns’ switch enables printingof qualified XMLNS prefixes.

Parameters

• XML_declaration (bool) – if True (default) prints a leading XML declaration line

• xmlns (bool) – if True (default) prints full XMLNS prefixes

Returns an XML-formatted string

1.1.7.15 pyowm.webapi25.stationhistory module

Module containing classes and datastructures related to meteostation history data

class pyowm.webapi25.stationhistory.StationHistory(station_ID, interval, recep-tion_time, measurements)

Bases: object

A class representing historic weather measurements collected by a meteostation. Three types of historic meteo-station data can be obtained by the OWM web API: ticks (one data chunk per minute) data, hourly and dailydata.

Parameters

• station_ID (int) – the numeric ID of the meteostation

• interval (str) – the time granularity of the meteostation data history

• reception_time (int) – GMT UNIXtime of the data reception from the OWM webAPI

• measurements (dict) – a dictionary containing raw weather measurements

1.1. Subpackages 47

Page 52: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

Returns a StationHistory instance

Raises ValueError when the supplied value for reception time is negative

get_interval()Returns the interval of the meteostation history data

Returns the int interval

get_measurements()Returns the measurements of the meteostation as a dict. The dictionary keys are UNIX timestamps andfor each one the value is a dict containing the keys ‘temperature’,’humidity’,’pressure’,’rain’,’wind’ alongwith their corresponding numeric values. Eg: {1362933983: { "temperature": 266.25,"humidity": 27.3, "pressure": 1010.02, "rain": None, "wind": 4.7},... }

Returns the dict containing the meteostation’s measurements

get_reception_time(timeformat=’unix’)

Returns the GMT time telling when the meteostation history data was received from the OWM webAPI

Parameters timeformat (str) – the format for the time value. May be: ‘unix’ (de-fault) for UNIX time ‘iso’ for ISO8601-formatted string in the format YYYY-MM-DDHH:MM:SS+00 ‘date for datetime.datetime object instance

Returns an int or a str

Raises ValueError

get_station_ID()Returns the ID of the meteostation

Returns the int station ID

set_interval(interval)Sets the interval of the meteostation history data

Parameters interval (string) – the time granularity of the meteostation history data, maybe among “tick”,”hour” and “day”

set_station_ID(station_ID)Sets the numeric ID of the meteostation

Parameters station_ID (int) – the numeric ID of the meteostation

to_JSON()Dumps object fields into a JSON formatted string

Returns the JSON string

to_XML(xml_declaration=True, xmlns=True)Dumps object fields to an XML-formatted string. The ‘xml_declaration’ switch enables printing of aleading standard XML line containing XML version and encoding. The ‘xmlns’ switch enables printingof qualified XMLNS prefixes.

Parameters

• XML_declaration (bool) – if True (default) prints a leading XML declaration line

• xmlns (bool) – if True (default) prints full XMLNS prefixes

Returns an XML-formatted string

48 Chapter 1. pyowm package

Page 53: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

1.1.7.16 pyowm.webapi25.stationhistoryparser module

Module containing a concrete implementation for JSONParser abstract class, returning a StationHistory instance

class pyowm.webapi25.stationhistoryparser.StationHistoryParserBases: pyowm.abstractions.jsonparser.JSONParser

Concrete JSONParser implementation building a StationHistory instance out of raw JSON data coming fromOWM web API responses.

parse_JSON(JSON_string)Parses a StationHistory instance out of raw JSON data. Only certain properties of the data are used: ifthese properties are not found or cannot be parsed, an error is issued.

Parameters JSON_string (str) – a raw JSON string

Returns a StationHistory instance or None if no data is available

Raises ParseResponseError if it is impossible to find or parse the data needed to build the result,APIResponseError if the JSON string embeds an HTTP status error (this is an OWM webAPI 2.5 bug)

1.1.7.17 pyowm.webapi25.stationlistparser module

Module containing a concrete implementation for JSONParser abstract class, returning a list of Station instances

class pyowm.webapi25.stationlistparser.StationListParserBases: pyowm.abstractions.jsonparser.JSONParser

Concrete JSONParser implementation building a list of Station instances out of raw JSON data coming fromOWM web API responses.

parse_JSON(JSON_string)Parses a list of Station instances out of raw JSON data. Only certain properties of the data are used: ifthese properties are not found or cannot be parsed, an error is issued.

Parameters JSON_string (str) – a raw JSON string

Returns a list of Station instances or None if no data is available

Raises ParseResponseError if it is impossible to find or parse the data needed to build the result,APIResponseError if the OWM API returns a HTTP status error (this is an OWM web API2.5 bug)

1.1.7.18 pyowm.webapi25.stationparser module

Module containing a concrete implementation for JSONParser abstract class, returning a Station instance

class pyowm.webapi25.stationparser.StationParserBases: pyowm.abstractions.jsonparser.JSONParser

Concrete JSONParser implementation building a Station instance out of raw JSON data coming from OWMweb API responses.

parse_JSON(JSON_string)Parses a Station instance out of raw JSON data. Only certain properties of the data are used: if theseproperties are not found or cannot be parsed, an error is issued.

Parameters JSON_string (str) – a raw JSON string

Returns a Station instance or None if no data is available

1.1. Subpackages 49

Page 54: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

Raises ParseResponseError if it is impossible to find or parse the data needed to build the result,APIResponseError if the JSON string embeds an HTTP status error (this is an OWM webAPI 2.5 bug)

1.1.7.19 pyowm.webapi25.weather module

Module containing weather data classes and data structures.

class pyowm.webapi25.weather.Weather(reference_time, sunset_time, sunrise_time, clouds, rain,snow, wind, humidity, pressure, temperature, status, de-tailed_status, weather_code, weather_icon_name, visi-bility_distance, dewpoint, humidex, heat_index)

Bases: object

A class encapsulating raw weather data. A reference about OWM weather codes and icons can be found at:http://bugs.openweathermap.org/projects/api/wiki/Weather_Condition_Codes

Parameters

• reference_time (int) – GMT UNIX time of weather measurement

• sunset_time (int or None) – GMT UNIX time of sunset or None on polar days

• sunrise_time (int or None) – GMT UNIX time of sunrise or None on polar nights

• clouds (int) – cloud coverage percentage

• rain (dict) – precipitation info

• snow (dict) – snow info

• wind (dict) – wind info

• humidity (int) – atmospheric humidity percentage

• pressure (dict) – atmospheric pressure info

• temperature (dict) – temperature info

• status (Unicode) – short weather status

• detailed_status (Unicode) – detailed weather status

• weather_code (int) – OWM weather condition code

• weather_icon_name (Unicode) – weather-related icon name

• visibility_distance (float) – visibility distance

• dewpoint (float) – dewpoint

• humidex (float) – Canadian humidex

• heat_index (float) – heat index

Returns a Weather instance

Raises ValueError when negative values are provided

get_clouds()Returns the cloud coverage percentage as an int

Returns the cloud coverage percentage

get_detailed_status()Returns the detailed weather status as a Unicode string

50 Chapter 1. pyowm package

Page 55: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

Returns the detailed weather status

get_dewpoint()Returns the dew point as a float

Returns the dew point

get_heat_index()Returns the heat index as a float

Returns the heat index

get_humidex()Returns the Canadian humidex as a float

Returns the Canadian humidex

get_humidity()Returns the atmospheric humidity as an int

Returns the humidity

get_pressure()Returns a dict containing atmospheric pressure info

Returns a dict containing pressure info

get_rain()Returns a dict containing precipitation info

Returns a dict containing rain info

get_reference_time(timeformat=’unix’)Returns the GMT time telling when the weather was measured

Parameters timeformat (str) – the format for the time value. May be: ‘unix’ (de-fault) for UNIX time ‘iso’ for ISO8601-formatted string in the format YYYY-MM-DDHH:MM:SS+00 ‘date for datetime.datetime object instance

Returns an int or a str

Raises ValueError when negative values are provided

get_snow()Returns a dict containing snow info

Returns a dict containing snow info

get_status()Returns the short weather status as a Unicode string

Returns the short weather status

get_sunrise_time(timeformat=’unix’)Returns the GMT time of sunrise

Parameters timeformat (str) – the format for the time value. May be: ‘unix’ (de-fault) for UNIX time or ‘iso’ for ISO8601-formatted string in the format YYYY-MM-DDHH:MM:SS+00

Returns an int or a str or None

Raises ValueError

get_sunset_time(timeformat=’unix’)Returns the GMT time of sunset

1.1. Subpackages 51

Page 56: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

Parameters timeformat (str) – the format for the time value. May be: ‘unix’ (de-fault) for UNIX time or ‘iso’ for ISO8601-formatted string in the format YYYY-MM-DDHH:MM:SS+00

Returns an int or a str or None

Raises ValueError

get_temperature(unit=’kelvin’)Returns a dict with temperature info

Parameters unit (str) – the unit of measure for the temperature values. May be: ‘kelvin’(default), ‘celsius’ or ‘fahrenheit’

Returns a dict containing temperature values.

Raises ValueError when unknown temperature units are provided

get_visibility_distance()Returns the visibility distance as a float

Returns the visibility distance

get_weather_code()Returns the OWM weather condition code as an int

Returns the OWM weather condition code

get_weather_icon_name()Returns weather-related icon name as a Unicode string.

Returns the icon name.

get_wind(unit=’meters_sec’)Returns a dict containing wind info

Parameters unit (str) – the unit of measure for the wind values. May be: ‘meters_sec’(default) or ‘miles_hour’

Returns a dict containing wind info

to_JSON()Dumps object fields into a JSON formatted string

Returns the JSON string

to_XML(xml_declaration=True, xmlns=True)Dumps object fields to an XML-formatted string. The ‘xml_declaration’ switch enables printing of aleading standard XML line containing XML version and encoding. The ‘xmlns’ switch enables printingof qualified XMLNS prefixes.

Parameters

• XML_declaration (bool) – if True (default) prints a leading XML declaration line

• xmlns (bool) – if True (default) prints full XMLNS prefixes

Returns an XML-formatted string

pyowm.webapi25.weather.weather_from_dictionary(d)Builds a Weather object out of a data dictionary. Only certain properties of the dictionary are used: if theseproperties are not found or cannot be read, an error is issued.

Parameters d (dict) – a data dictionary

Returns a Weather instance

52 Chapter 1. pyowm package

Page 57: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

Raises KeyError if it is impossible to find or read the data needed to build the instance

1.1.7.20 pyowm.webapi25.weathercoderegistry module

Module containing weather code lookup and resolution classes

class pyowm.webapi25.weathercoderegistry.WeatherCodeRegistry(code_ranges_dict)Bases: object

A registry class for looking up weather statuses from weather codes.

Parameters code_ranges_dict (dict) – a dict containing the mapping between weather sta-tuses (eg: “sun”,”clouds”,etc) and weather code ranges

Returns a WeatherCodeRegistry instance

status_for(code)Returns the weather status related to the specified weather status code, if any is stored, None otherwise.

Parameters code (int) – the weather status code whose status is to be looked up

Returns the weather status str or None if the code is not mapped

1.1.7.21 pyowm.webapi25.weatherhistoryparser module

Module containing a concrete implementation for JSONParser abstract class, returning a list of Weather objects

class pyowm.webapi25.weatherhistoryparser.WeatherHistoryParserBases: pyowm.abstractions.jsonparser.JSONParser

Concrete JSONParser implementation building a list of Weather instances out of raw JSON data coming fromOWM web API responses.

parse_JSON(JSON_string)Parses a list of Weather instances out of raw JSON data. Only certain properties of the data are used: ifthese properties are not found or cannot be parsed, an error is issued.

Parameters JSON_string (str) – a raw JSON string

Returns a list of Weather instances or None if no data is available

Raises ParseResponseError if it is impossible to find or parse the data needed to build the result,APIResponseError if the JSON string embeds an HTTP status error (this is an OWM webAPI 2.5 bug)

1.1.7.22 pyowm.webapi25.weatherutils module

Module containing search and filter utilities for Weather objects lists management

pyowm.webapi25.weatherutils.any_status_is(weather_list, status, weather_code_registry)Checks if the weather status code of any of the Weather objects in the provided list corresponds to the detailedstatus indicated. The lookup is performed against the provided WeatherCodeRegistry object.

Parameters

• weathers (list) – a list of Weather objects

• status (str) – a string indicating a detailed weather status

• weather_code_registry (WeatherCodeRegistry) – a WeatherCodeRegistry object

1.1. Subpackages 53

Page 58: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

Returns True if the check is positive, False otherwise

pyowm.webapi25.weatherutils.filter_by_status(weather_list, status,weather_code_registry)

Filters out from the provided list of Weather objects a sublist of items having a status corresponding to theprovided one. The lookup is performed against the provided WeatherCodeRegistry object.

Parameters

• weathers (list) – a list of Weather objects

• status (str) – a string indicating a detailed weather status

• weather_code_registry (WeatherCodeRegistry) – a WeatherCodeRegistry object

Returns True if the check is positive, False otherwise

pyowm.webapi25.weatherutils.find_closest_weather(weathers_list, unixtime)Extracts from the provided list of Weather objects the item which is closest in time to the provided UNIXtime.

Parameters

• weathers_list (list) – a list of Weather objects

• unixtime (int) – a UNIX time

Returns the Weather object which is closest in time or None if the list is empty

pyowm.webapi25.weatherutils.is_in_coverage(unixtime, weathers_list)Checks if the supplied UNIX time is contained into the time range (coverage) defined by the most ancient andmost recent Weather objects in the supplied list

Parameters

• unixtime (int) – the UNIX time to be searched in the time range

• weathers_list (list) – the list of Weather objects to be scanned for global time cov-erage

Returns True if the UNIX time is contained into the time range, False otherwise

pyowm.webapi25.weatherutils.status_is(weather, status, weather_code_registry)Checks if the weather status code of a Weather object corresponds to the detailed status indicated. The lookupis performed against the provided WeatherCodeRegistry object.

Parameters

• weather (Weather) – the Weather object whose status code is to be checked

• status (str) – a string indicating a detailed weather status

• weather_code_registry (WeatherCodeRegistry) – a WeatherCodeRegistry object

Returns True if the check is positive, False otherwise

1.1.7.23 pyowm.webapi25.uvindex module

class pyowm.webapi25.uvindex.UVIndex(reference_time, location, value, reception_time)Bases: object

A class representing the UltraViolet Index observed in a certain location in the world. The location is representedby the encapsulated Location object.

Parameters

54 Chapter 1. pyowm package

Page 59: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

• reference_time (int) – GMT UNIXtime telling when the UV data have been mea-sured

• location (Location) – the Location relative to this UV observation

• value (float) – the observed UV intensity value

• reception_time (int) – GMT UNIXtime telling when the observation has been re-ceived from the OWM web API

Returns an UVIndex instance

Raises ValueError when negative values are provided as reception time or UV intensity value

get_exposure_risk()Returns a string stating the risk of harm from unprotected sun exposure for the average adult on this UVobservation :return: str

get_location()Returns the Location object for this UV observation

Returns the Location object

get_reception_time(timeformat=’unix’)Returns the GMT time telling when the UV has been received from the API

Parameters timeformat (str) – the format for the time value. May be: ‘unix’ (de-fault) for UNIX time ‘iso’ for ISO8601-formatted string in the format YYYY-MM-DDHH:MM:SS+00 ‘date for datetime.datetime object instance

Returns an int or a str

Raises ValueError when negative values are provided

get_reference_time(timeformat=’unix’)

Returns the GMT time telling when the UV has been observed from the OWM web API

Parameters timeformat (str) – the format for the time value. May be: ‘unix’ (de-fault) for UNIX time ‘iso’ for ISO8601-formatted string in the format YYYY-MM-DDHH:MM:SS+00 ‘date for datetime.datetime object instance

Returns an int or a str

Raises ValueError when negative values are provided

get_value()Returns the UV intensity for this observation

Returns float

to_JSON()Dumps object fields into a JSON formatted string

Returns the JSON string

to_XML(xml_declaration=True, xmlns=True)Dumps object fields to an XML-formatted string. The ‘xml_declaration’ switch enables printing of aleading standard XML line containing XML version and encoding. The ‘xmlns’ switch enables printingof qualified XMLNS prefixes.

Parameters

• XML_declaration (bool) – if True (default) prints a leading XML declaration line

1.1. Subpackages 55

Page 60: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

• xmlns (bool) – if True (default) prints full XMLNS prefixes

Returns an XML-formatted string

pyowm.webapi25.uvindex.uv_intensity_to_exposure_risk(uv_intensity)

1.1.7.24 pyowm.webapi25.uvindexparser module

Module containing a concrete implementation for JSONParser abstract class, returning UVIndex objects

class pyowm.webapi25.uvindexparser.UVIndexParserBases: pyowm.abstractions.jsonparser.JSONParser

Concrete JSONParser implementation building an UVIndex instance out of raw JSON data coming from OWMweb API responses.

parse_JSON(JSON_string)Parses an UVIndex instance out of raw JSON data. Only certain properties of the data are used: if theseproperties are not found or cannot be parsed, an error is issued.

Parameters JSON_string (str) – a raw JSON string

Returns an UVIndex instance or None if no data is available

Raises ParseResponseError if it is impossible to find or parse the data needed to build the result,APIResponseError if the JSON string embeds an HTTP status error (this is an OWM webAPI 2.5 bug)

1.1.7.25 pyowm.webapi25.coindex module

Carbon Monoxide classes and data structures.

class pyowm.webapi25.coindex.COIndex(reference_time, location, interval, co_samples, recep-tion_time)

Bases: object

A class representing the Carbon monOxide Index observed in a certain location in the world. The index is madeup of several measurements, each one at a different atmospheric pressure. The location is represented by theencapsulated Location object.

Parameters

• reference_time (int) – GMT UNIXtime telling when the CO data has been measured

• location (Location) – the Location relative to this CO observation

• interval (str) – the time granularity of the CO observation

• co_samples (list of dicts) – the CO samples

• reception_time (int) – GMT UNIXtime telling when the CO observation has beenreceived from the OWM web API

Returns an COIndex instance

Raises ValueError when negative values are provided as reception time, CO samples are not pro-vided in a list

get_co_sample_with_highest_vmr()Returns the CO sample with the highest Volume Mixing Ratio value :return: dict

get_co_sample_with_lowest_vmr()Returns the CO sample with the lowest Volume Mixing Ratio value :return: dict

56 Chapter 1. pyowm package

Page 61: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

get_co_samples()Returns the CO samples for this index

Returns list of dicts

get_interval()Returns the time granularity interval for this CO index measurement

Returns str

get_location()Returns the Location object for this CO index measurement

Returns the Location object

get_reception_time(timeformat=’unix’)Returns the GMT time telling when the CO observation has been received from the OWM web API

Parameters timeformat (str) – the format for the time value. May be: ‘unix’ (de-fault) for UNIX time ‘iso’ for ISO8601-formatted string in the format YYYY-MM-DDHH:MM:SS+00 ‘date for datetime.datetime object instance

Returns an int or a str

Raises ValueError when negative values are provided

get_reference_time(timeformat=’unix’)Returns the GMT time telling when the CO samples have been measured

Parameters timeformat (str) – the format for the time value. May be: ‘unix’ (de-fault) for UNIX time ‘iso’ for ISO8601-formatted string in the format YYYY-MM-DDHH:MM:SS+00 ‘date for datetime.datetime object instance

Returns an int or a str

Raises ValueError when negative values are provided

is_forecast()Tells if the current CO observation refers to the future with respect to the current date :return: bool

to_JSON()Dumps object fields into a JSON formatted string

Returns the JSON string

to_XML(xml_declaration=True, xmlns=True)Dumps object fields to an XML-formatted string. The ‘xml_declaration’ switch enables printing of aleading standard XML line containing XML version and encoding. The ‘xmlns’ switch enables printingof qualified XMLNS prefixes.

Parameters

• XML_declaration (bool) – if True (default) prints a leading XML declaration line

• xmlns (bool) – if True (default) prints full XMLNS prefixes

Returns an XML-formatted string

1.1.7.26 pyowm.webapi25.coindexparser module

class pyowm.webapi25.coindexparser.COIndexParserBases: pyowm.abstractions.jsonparser.JSONParser

1.1. Subpackages 57

Page 62: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

Concrete JSONParser implementation building an COIndex instance out of raw JSON data coming from OWMweb API responses.

parse_JSON(JSON_string)Parses an COIndex instance out of raw JSON data. Only certain properties of the data are used: if theseproperties are not found or cannot be parsed, an error is issued.

Parameters JSON_string (str) – a raw JSON string

Returns an COIndex instance or None if no data is available

Raises ParseResponseError if it is impossible to find or parse the data needed to build the result,APIResponseError if the JSON string embeds an HTTP status error (this is an OWM webAPI 2.5 bug)

1.1.7.27 pyowm.webapi25.ozone module

class pyowm.webapi25.ozone.Ozone(reference_time, location, interval, du_value, reception_time)Bases: object

A class representing the Ozone (O3) data observed in a certain location in the world. The location is representedby the encapsulated Location object.

Parameters

• reference_time (int) – GMT UNIXtime telling when the O3 data have been mea-sured

• location (Location) – the Location relative to this O3 observation

• du_value (float) – the observed O3 Dobson Units value (reference: http://www.theozonehole.com/dobsonunit.htm)

• interval (str) – the time granularity of the O3 observation

• reception_time (int) – GMT UNIXtime telling when the observation has been re-ceived from the OWM web API

Returns an Ozone instance

Raises ValueError when negative values are provided as reception time or du_value

get_du_value()Returns the O3 Dobson Unit of this observation

Returns float

get_interval()Returns the time granularity interval for this O3 observation

Returns str

get_location()Returns the Location object for this O3 observation

Returns the Location object

get_reception_time(timeformat=’unix’)Returns the GMT time telling when the O3 observation has been received from the OWM web API

Parameters timeformat (str) – the format for the time value. May be: ‘unix’ (de-fault) for UNIX time ‘iso’ for ISO8601-formatted string in the format YYYY-MM-DDHH:MM:SS+00 ‘date for datetime.datetime object instance

58 Chapter 1. pyowm package

Page 63: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

Returns an int or a str

Raises ValueError when negative values are provided

get_reference_time(timeformat=’unix’)Returns the GMT time telling when the O3 data have been measured

Parameters timeformat (str) – the format for the time value. May be: ‘unix’ (de-fault) for UNIX time ‘iso’ for ISO8601-formatted string in the format YYYY-MM-DDHH:MM:SS+00 ‘date for datetime.datetime object instance

Returns an int or a str

Raises ValueError when negative values are provided

is_forecast()Tells if the current O3 observation refers to the future with respect to the current date :return: bool

to_JSON()Dumps object fields into a JSON formatted string

Returns the JSON string

to_XML(xml_declaration=True, xmlns=True)Dumps object fields to an XML-formatted string. The ‘xml_declaration’ switch enables printing of aleading standard XML line containing XML version and encoding. The ‘xmlns’ switch enables printingof qualified XMLNS prefixes.

Parameters

• XML_declaration (bool) – if True (default) prints a leading XML declaration line

• xmlns (bool) – if True (default) prints full XMLNS prefixes

Returns an XML-formatted string

1.1.7.28 pyowm.webapi25.ozone_parser module

Module containing a concrete implementation for JSONParser abstract class, returning UVIndex objects

class pyowm.webapi25.ozone_parser.OzoneParserBases: pyowm.abstractions.jsonparser.JSONParser

Concrete JSONParser implementation building an Ozone instance out of raw JSON data coming from OWMweb API responses.

parse_JSON(JSON_string)Parses an Ozone instance out of raw JSON data. Only certain properties of the data are used: if theseproperties are not found or cannot be parsed, an error is issued.

Parameters JSON_string (str) – a raw JSON string

Returns an Ozone instance or None if no data is available

Raises ParseResponseError if it is impossible to find or parse the data needed to build the result,APIResponseError if the JSON string embeds an HTTP status error (this is an OWM webAPI 2.5 bug)

1.1. Subpackages 59

Page 64: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

1.1.7.29 Module contents

1.2 Submodules

1.3 pyowm.constants module

Constants for the PyOWM library

1.4 Module contents

The PyOWM init file

Author: Claudio Sparpaglione, @csparpa <[email protected]>

Platform: platform independent

pyowm.OWM(API_key=’b1b15e88fa797225412429c1c50c122a’, version=’2.5’, config_module=None, lan-guage=None, subscription_type=None)

A parametrized factory method returning a global OWM instance that represents the desired OWM web APIversion (or the currently supported one if no version number is specified)

Parameters

• API_key (str) – the OWM web API key (defaults to a test value)

• version (str) – the OWM web API version. Defaults to None, which means use thelatest web API version

• config_module (str (eg: 'mypackage.mysubpackage.myconfigmodule')) – the Python path of the configuration module you want toprovide for instantiating the library. Defaults to None, which means use the default con-figuration values for the web API version support you are currently requesting. Please beaware that malformed user-defined configuration modules can lead to unwanted behaviour!

• language (str) – the language in which you want text results to be returned. It’s a two-characters string, eg: “en”, “ru”, “it”. Defaults to: None, which means use the defaultlanguage.

• subscription_type (str) – the type of OWM web API subscription to be wrapped.Can be ‘free’ (free subscription) or ‘pro’ (paid subscription), Defaults to: ‘free’

Returns an instance of a proper OWM subclass

Raises ValueError when unsupported OWM API versions are provided

60 Chapter 1. pyowm package

Page 65: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

CHAPTER 2

Indices and tables

• genindex

• modindex

• search

61

Page 66: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

62 Chapter 2. Indices and tables

Page 67: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

Python Module Index

ppyowm, 60pyowm.abstractions, 6pyowm.abstractions.jsonparser, 3pyowm.abstractions.linkedlist, 3pyowm.abstractions.owm, 4pyowm.abstractions.owmcache, 5pyowm.caches, 7pyowm.caches.lrucache, 6pyowm.caches.nullcache, 7pyowm.commons, 11pyowm.commons.airpollution_client, 9pyowm.commons.frontlinkedlist, 7pyowm.commons.uv_client, 11pyowm.commons.weather_client, 9pyowm.constants, 60pyowm.exceptions, 12pyowm.exceptions.api_call_error, 11pyowm.exceptions.api_response_error, 12pyowm.exceptions.not_found_error, 12pyowm.exceptions.parse_response_error,

12pyowm.exceptions.unauthorized_error, 12pyowm.stationsapi30.buffer, 13pyowm.stationsapi30.measurement, 14pyowm.stationsapi30.persistence_backend,

15pyowm.stationsapi30.station, 16pyowm.stationsapi30.station_parser, 17pyowm.stationsapi30.stations_manager,

17pyowm.stationsapi30.xsd, 13pyowm.stationsapi30.xsd.xmlnsconfig, 13pyowm.utils, 24pyowm.utils.temputils, 19pyowm.utils.timeformatutils, 20pyowm.utils.timeutils, 21pyowm.utils.xmlutils, 23pyowm.webapi25, 60

pyowm.webapi25.cityidregistry, 24pyowm.webapi25.cityids, 24pyowm.webapi25.coindex, 56pyowm.webapi25.coindexparser, 57pyowm.webapi25.configuration25, 25pyowm.webapi25.forecast, 25pyowm.webapi25.forecaster, 27pyowm.webapi25.forecastparser, 31pyowm.webapi25.historian, 31pyowm.webapi25.location, 34pyowm.webapi25.observation, 35pyowm.webapi25.observationlistparser,

36pyowm.webapi25.observationparser, 36pyowm.webapi25.owm25, 37pyowm.webapi25.ozone, 58pyowm.webapi25.ozone_parser, 59pyowm.webapi25.station, 46pyowm.webapi25.stationhistory, 47pyowm.webapi25.stationhistoryparser, 49pyowm.webapi25.stationlistparser, 49pyowm.webapi25.stationparser, 49pyowm.webapi25.uvindex, 54pyowm.webapi25.uvindexparser, 56pyowm.webapi25.weather, 50pyowm.webapi25.weathercoderegistry, 53pyowm.webapi25.weatherhistoryparser, 53pyowm.webapi25.weatherutils, 53pyowm.webapi25.xsd, 24pyowm.webapi25.xsd.xmlnsconfig, 24

63

Page 68: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

64 Python Module Index

Page 69: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

Index

Aactualize() (pyowm.webapi25.forecast.Forecast method),

25add() (pyowm.abstractions.linkedlist.LinkedList

method), 4add() (pyowm.commons.frontlinkedlist.FrontLinkedList

method), 8AggregatedMeasurement (class in py-

owm.stationsapi30.measurement), 14AirPollutionHttpClient (class in py-

owm.commons.airpollution_client), 9ALLOWED_AGGREGATION_TIME_FRAMES (py-

owm.stationsapi30.measurement.AggregatedMeasurementattribute), 14

annotate_with_XMLNS() (in module py-owm.utils.xmlutils), 23

any_status_is() (in module py-owm.webapi25.weatherutils), 53

API_SUBSCRIPTION_SUBDOMAINS (py-owm.commons.weather_client.WeatherHttpClientattribute), 9

APICallError, 11APIResponseError, 12append() (pyowm.stationsapi30.buffer.Buffer method), 13append_from_dict() (pyowm.stationsapi30.buffer.Buffer

method), 13append_from_json() (pyowm.stationsapi30.buffer.Buffer

method), 13average_humidity() (py-

owm.webapi25.historian.Historian method),32

average_pressure() (pyowm.webapi25.historian.Historianmethod), 32

average_rain() (pyowm.webapi25.historian.Historianmethod), 32

average_temperature() (py-owm.webapi25.historian.Historian method),32

BBadGatewayError, 11Buffer (class in pyowm.stationsapi30.buffer), 13

Ccall_API() (pyowm.commons.weather_client.WeatherHttpClient

method), 9city_id_registry() (pyowm.webapi25.owm25.OWM25

method), 37CityIDRegistry (class in py-

owm.webapi25.cityidregistry), 24clean() (pyowm.caches.lrucache.LRUCache method), 6COIndex (class in pyowm.webapi25.coindex), 56coindex_around_coords() (py-

owm.webapi25.owm25.OWM25 method),37

COIndexParser (class in py-owm.webapi25.coindexparser), 57

contains() (pyowm.abstractions.linkedlist.LinkedListmethod), 4

contains() (pyowm.commons.frontlinkedlist.FrontLinkedListmethod), 8

count_weathers() (pyowm.webapi25.forecast.Forecastmethod), 25

create_DOM_node_from_dict() (in module py-owm.utils.xmlutils), 23

create_station() (pyowm.stationsapi30.stations_manager.StationsManagermethod), 18

created_at (pyowm.stationsapi30.buffer.Buffer attribute),13

creation_time() (pyowm.stationsapi30.buffer.Buffermethod), 13

creation_time() (pyowm.stationsapi30.measurement.AggregatedMeasurementmethod), 14

creation_time() (pyowm.stationsapi30.measurement.Measurementmethod), 15

creation_time() (pyowm.stationsapi30.station.Stationmethod), 16

65

Page 70: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

Ddaily_forecast() (pyowm.webapi25.owm25.OWM25

method), 38daily_forecast_at_coords() (py-

owm.webapi25.owm25.OWM25 method),38

daily_forecast_at_id() (py-owm.webapi25.owm25.OWM25 method),38

data() (pyowm.commons.frontlinkedlist.LinkedListNodemethod), 8

delete_station() (pyowm.stationsapi30.stations_manager.StationsManagermethod), 18

DOM_node_to_XML() (in module py-owm.utils.xmlutils), 23

dst() (pyowm.utils.timeformatutils.UTC method), 20

Eempty() (pyowm.stationsapi30.buffer.Buffer method), 13

Ffilter_by_status() (in module py-

owm.webapi25.weatherutils), 54find_closest_weather() (in module py-

owm.webapi25.weatherutils), 54first_node() (pyowm.commons.frontlinkedlist.FrontLinkedList

method), 8Forecast (class in pyowm.webapi25.forecast), 25Forecaster (class in pyowm.webapi25.forecaster), 27ForecastIterator (class in pyowm.webapi25.forecast), 26ForecastParser (class in py-

owm.webapi25.forecastparser), 31from_dict() (pyowm.stationsapi30.measurement.Measurement

class method), 15FrontLinkedList (class in py-

owm.commons.frontlinkedlist), 7FrontLinkedListIterator (class in py-

owm.commons.frontlinkedlist), 8

Gget() (pyowm.abstractions.owmcache.OWMCache

method), 5get() (pyowm.caches.lrucache.LRUCache method), 6get() (pyowm.caches.nullcache.NullCache method), 7get() (pyowm.webapi25.forecast.Forecast method), 26get_API_key() (pyowm.abstractions.owm.OWM

method), 4get_API_key() (pyowm.webapi25.owm25.OWM25

method), 38get_API_version() (pyowm.abstractions.owm.OWM

method), 4get_API_version() (pyowm.webapi25.owm25.OWM25

method), 38

get_clouds() (pyowm.webapi25.weather.Weathermethod), 50

get_co_sample_with_highest_vmr() (py-owm.webapi25.coindex.COIndex method),56

get_co_sample_with_lowest_vmr() (py-owm.webapi25.coindex.COIndex method),56

get_co_samples() (pyowm.webapi25.coindex.COIndexmethod), 56

get_coi() (pyowm.commons.airpollution_client.AirPollutionHttpClientmethod), 10

get_country() (pyowm.webapi25.location.Locationmethod), 34

get_detailed_status() (pyowm.webapi25.weather.Weathermethod), 50

get_dewpoint() (pyowm.webapi25.weather.Weathermethod), 51

get_distance() (pyowm.webapi25.station.Stationmethod), 46

get_du_value() (pyowm.webapi25.ozone.Ozone method),58

get_exposure_risk() (py-owm.webapi25.uvindex.UVIndex method),55

get_forecast() (pyowm.webapi25.forecaster.Forecastermethod), 27

get_heat_index() (pyowm.webapi25.weather.Weathermethod), 51

get_humidex() (pyowm.webapi25.weather.Weathermethod), 51

get_humidity() (pyowm.webapi25.weather.Weathermethod), 51

get_ID() (pyowm.webapi25.location.Location method),34

get_interval() (pyowm.webapi25.coindex.COIndexmethod), 57

get_interval() (pyowm.webapi25.forecast.Forecastmethod), 26

get_interval() (pyowm.webapi25.ozone.Ozone method),58

get_interval() (pyowm.webapi25.stationhistory.StationHistorymethod), 48

get_language() (pyowm.webapi25.owm25.OWM25method), 39

get_last_weather() (pyowm.webapi25.station.Stationmethod), 46

get_lat() (pyowm.webapi25.location.Location method),34

get_lat() (pyowm.webapi25.station.Station method), 46get_location() (pyowm.webapi25.coindex.COIndex

method), 57get_location() (pyowm.webapi25.forecast.Forecast

method), 26

66 Index

Page 71: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

get_location() (pyowm.webapi25.observation.Observationmethod), 35

get_location() (pyowm.webapi25.ozone.Ozone method),58

get_location() (pyowm.webapi25.uvindex.UVIndexmethod), 55

get_lon() (pyowm.webapi25.location.Location method),34

get_lon() (pyowm.webapi25.station.Station method), 46get_measurements() (py-

owm.stationsapi30.stations_manager.StationsManagermethod), 18

get_measurements() (py-owm.webapi25.stationhistory.StationHistorymethod), 48

get_name() (pyowm.webapi25.location.Locationmethod), 34

get_name() (pyowm.webapi25.station.Station method),47

get_no2() (pyowm.commons.airpollution_client.AirPollutionHttpClientmethod), 10

get_o3() (pyowm.commons.airpollution_client.AirPollutionHttpClientmethod), 10

get_pressure() (pyowm.webapi25.weather.Weathermethod), 51

get_rain() (pyowm.webapi25.weather.Weather method),51

get_reception_time() (py-owm.webapi25.coindex.COIndex method),57

get_reception_time() (py-owm.webapi25.forecast.Forecast method),26

get_reception_time() (py-owm.webapi25.observation.Observationmethod), 35

get_reception_time() (pyowm.webapi25.ozone.Ozonemethod), 58

get_reception_time() (py-owm.webapi25.stationhistory.StationHistorymethod), 48

get_reception_time() (py-owm.webapi25.uvindex.UVIndex method),55

get_reference_time() (py-owm.webapi25.coindex.COIndex method),57

get_reference_time() (pyowm.webapi25.ozone.Ozonemethod), 59

get_reference_time() (py-owm.webapi25.uvindex.UVIndex method),55

get_reference_time() (pyowm.webapi25.weather.Weathermethod), 51

get_snow() (pyowm.webapi25.weather.Weather method),51

get_so2() (pyowm.commons.airpollution_client.AirPollutionHttpClientmethod), 10

get_station() (pyowm.stationsapi30.stations_manager.StationsManagermethod), 18

get_station_history() (py-owm.webapi25.historian.Historian method),32

get_station_ID() (pyowm.webapi25.station.Stationmethod), 47

get_station_ID() (pyowm.webapi25.stationhistory.StationHistorymethod), 48

get_station_type() (pyowm.webapi25.station.Stationmethod), 47

get_stations() (pyowm.stationsapi30.stations_manager.StationsManagermethod), 18

get_status() (pyowm.webapi25.station.Station method),47

get_status() (pyowm.webapi25.weather.Weather method),51

get_subscription_type() (py-owm.webapi25.owm25.OWM25 method),39

get_sunrise_time() (pyowm.webapi25.weather.Weathermethod), 51

get_sunset_time() (pyowm.webapi25.weather.Weathermethod), 51

get_temperature() (pyowm.webapi25.weather.Weathermethod), 52

get_uvi() (pyowm.commons.uv_client.UltraVioletHttpClientmethod), 11

get_value() (pyowm.webapi25.uvindex.UVIndexmethod), 55

get_version() (pyowm.abstractions.owm.OWM method),4

get_version() (pyowm.webapi25.owm25.OWM25method), 39

get_visibility_distance() (py-owm.webapi25.weather.Weather method),52

get_weather() (pyowm.webapi25.observation.Observationmethod), 35

get_weather_at() (pyowm.webapi25.forecaster.Forecastermethod), 27

get_weather_code() (pyowm.webapi25.weather.Weathermethod), 52

get_weather_icon_name() (py-owm.webapi25.weather.Weather method),52

get_weathers() (pyowm.webapi25.forecast.Forecastmethod), 26

get_wind() (pyowm.webapi25.weather.Weather method),52

Index 67

Page 72: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

HHistorian (class in pyowm.webapi25.historian), 31humidity_series() (pyowm.webapi25.historian.Historian

method), 32

Iid_for() (pyowm.webapi25.cityidregistry.CityIDRegistry

method), 24ids_for() (pyowm.webapi25.cityidregistry.CityIDRegistry

method), 24index_of() (pyowm.abstractions.linkedlist.LinkedList

method), 4index_of() (pyowm.commons.frontlinkedlist.FrontLinkedList

method), 8is_API_online() (pyowm.abstractions.owm.OWM

method), 5is_API_online() (pyowm.webapi25.owm25.OWM25

method), 39is_forecast() (pyowm.webapi25.coindex.COIndex

method), 57is_forecast() (pyowm.webapi25.ozone.Ozone method),

59is_in_coverage() (in module py-

owm.webapi25.weatherutils), 54

JJSONParser (class in pyowm.abstractions.jsonparser), 3JSONPersistenceBackend (class in py-

owm.stationsapi30.persistence_backend),15

Kkelvin_dict_to() (in module pyowm.utils.temputils), 19kelvin_to_celsius() (in module pyowm.utils.temputils),

19kelvin_to_fahrenheit() (in module py-

owm.utils.temputils), 19

Llast_hour() (in module pyowm.utils.timeutils), 21last_month() (in module pyowm.utils.timeutils), 21last_three_hours() (in module pyowm.utils.timeutils), 21last_update_time() (pyowm.stationsapi30.station.Station

method), 16last_week() (in module pyowm.utils.timeutils), 21last_year() (in module pyowm.utils.timeutils), 21LinkedList (class in pyowm.abstractions.linkedlist), 3LinkedListNode (class in py-

owm.commons.frontlinkedlist), 8load_to_buffer() (pyowm.stationsapi30.persistence_backend.JSONPersistenceBackend

method), 16load_to_buffer() (pyowm.stationsapi30.persistence_backend.PersistenceBackend

method), 16

Location (class in pyowm.webapi25.location), 34location_for() (pyowm.webapi25.cityidregistry.CityIDRegistry

method), 25location_from_dictionary() (in module py-

owm.webapi25.location), 35locations_for() (pyowm.webapi25.cityidregistry.CityIDRegistry

method), 25LRUCache (class in pyowm.caches.lrucache), 6

MMATCHINGS (pyowm.webapi25.cityidregistry.CityIDRegistry

attribute), 24max_humidity() (pyowm.webapi25.historian.Historian

method), 32max_pressure() (pyowm.webapi25.historian.Historian

method), 32max_rain() (pyowm.webapi25.historian.Historian

method), 32max_temperature() (py-

owm.webapi25.historian.Historian method),32

Measurement (class in py-owm.stationsapi30.measurement), 14

measurements (pyowm.stationsapi30.buffer.Bufferattribute), 13

metric_wind_dict_to_imperial() (in module py-owm.utils.temputils), 20

min_humidity() (pyowm.webapi25.historian.Historianmethod), 33

min_pressure() (pyowm.webapi25.historian.Historianmethod), 33

min_rain() (pyowm.webapi25.historian.Historianmethod), 33

min_temperature() (pyowm.webapi25.historian.Historianmethod), 33

most_cold() (pyowm.webapi25.forecaster.Forecastermethod), 27

most_hot() (pyowm.webapi25.forecaster.Forecastermethod), 27

most_humid() (pyowm.webapi25.forecaster.Forecastermethod), 27

most_rainy() (pyowm.webapi25.forecaster.Forecastermethod), 27

most_snowy() (pyowm.webapi25.forecaster.Forecastermethod), 27

most_windy() (pyowm.webapi25.forecaster.Forecastermethod), 28

Nnext() (pyowm.commons.frontlinkedlist.FrontLinkedListIterator

method), 8next() (pyowm.commons.frontlinkedlist.LinkedListNode

method), 9

68 Index

Page 73: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

next() (pyowm.webapi25.forecast.ForecastIteratormethod), 26

next_hour() (in module pyowm.utils.timeutils), 22next_month() (in module pyowm.utils.timeutils), 22next_three_hours() (in module pyowm.utils.timeutils), 22next_week() (in module pyowm.utils.timeutils), 22next_year() (in module pyowm.utils.timeutils), 22no2index_around_coords() (py-

owm.webapi25.owm25.OWM25 method),39

NotFoundError, 12now() (in module pyowm.utils.timeutils), 22NullCache (class in pyowm.caches.nullcache), 7

OObservation (class in pyowm.webapi25.observation), 35ObservationListParser (class in py-

owm.webapi25.observationlistparser), 36ObservationParser (class in py-

owm.webapi25.observationparser), 36OWM (class in pyowm.abstractions.owm), 4OWM() (in module pyowm), 60OWM25 (class in pyowm.webapi25.owm25), 37OWM_API_VERSION (py-

owm.webapi25.owm25.OWM25 attribute),37

OWMCache (class in pyowm.abstractions.owmcache), 5OWMError, 12Ozone (class in pyowm.webapi25.ozone), 58ozone_around_coords() (py-

owm.webapi25.owm25.OWM25 method),39

OzoneParser (class in pyowm.webapi25.ozone_parser),59

Pparse_dict() (pyowm.stationsapi30.station_parser.StationParser

method), 17parse_JSON() (pyowm.abstractions.jsonparser.JSONParser

method), 3parse_JSON() (pyowm.stationsapi30.station_parser.StationParser

method), 17parse_JSON() (pyowm.webapi25.coindexparser.COIndexParser

method), 58parse_JSON() (pyowm.webapi25.forecastparser.ForecastParser

method), 31parse_JSON() (pyowm.webapi25.observationlistparser.ObservationListParser

method), 36parse_JSON() (pyowm.webapi25.observationparser.ObservationParser

method), 36parse_JSON() (pyowm.webapi25.ozone_parser.OzoneParser

method), 59parse_JSON() (pyowm.webapi25.stationhistoryparser.StationHistoryParser

method), 49

parse_JSON() (pyowm.webapi25.stationlistparser.StationListParsermethod), 49

parse_JSON() (pyowm.webapi25.stationparser.StationParsermethod), 49

parse_JSON() (pyowm.webapi25.uvindexparser.UVIndexParsermethod), 56

parse_JSON() (pyowm.webapi25.weatherhistoryparser.WeatherHistoryParsermethod), 53

ParseResponseError, 12persist_buffer() (pyowm.stationsapi30.persistence_backend.JSONPersistenceBackend

method), 16persist_buffer() (pyowm.stationsapi30.persistence_backend.PersistenceBackend

method), 16PersistenceBackend (class in py-

owm.stationsapi30.persistence_backend),16

pop() (pyowm.abstractions.linkedlist.LinkedListmethod), 4

pop() (pyowm.commons.frontlinkedlist.FrontLinkedListmethod), 8

pressure_series() (pyowm.webapi25.historian.Historianmethod), 33

pyowm (module), 60pyowm.abstractions (module), 6pyowm.abstractions.jsonparser (module), 3pyowm.abstractions.linkedlist (module), 3pyowm.abstractions.owm (module), 4pyowm.abstractions.owmcache (module), 5pyowm.caches (module), 7pyowm.caches.lrucache (module), 6pyowm.caches.nullcache (module), 7pyowm.commons (module), 11pyowm.commons.airpollution_client (module), 9pyowm.commons.frontlinkedlist (module), 7pyowm.commons.uv_client (module), 11pyowm.commons.weather_client (module), 9pyowm.constants (module), 60pyowm.exceptions (module), 12pyowm.exceptions.api_call_error (module), 11pyowm.exceptions.api_response_error (module), 12pyowm.exceptions.not_found_error (module), 12pyowm.exceptions.parse_response_error (module), 12pyowm.exceptions.unauthorized_error (module), 12pyowm.stationsapi30.buffer (module), 13pyowm.stationsapi30.measurement (module), 14pyowm.stationsapi30.persistence_backend (module), 15pyowm.stationsapi30.station (module), 16pyowm.stationsapi30.station_parser (module), 17pyowm.stationsapi30.stations_manager (module), 17pyowm.stationsapi30.xsd (module), 13pyowm.stationsapi30.xsd.xmlnsconfig (module), 13pyowm.utils (module), 24pyowm.utils.temputils (module), 19pyowm.utils.timeformatutils (module), 20

Index 69

Page 74: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

pyowm.utils.timeutils (module), 21pyowm.utils.xmlutils (module), 23pyowm.webapi25 (module), 19, 60pyowm.webapi25.cityidregistry (module), 24pyowm.webapi25.cityids (module), 24pyowm.webapi25.coindex (module), 56pyowm.webapi25.coindexparser (module), 57pyowm.webapi25.configuration25 (module), 25pyowm.webapi25.forecast (module), 25pyowm.webapi25.forecaster (module), 27pyowm.webapi25.forecastparser (module), 31pyowm.webapi25.historian (module), 31pyowm.webapi25.location (module), 34pyowm.webapi25.observation (module), 35pyowm.webapi25.observationlistparser (module), 36pyowm.webapi25.observationparser (module), 36pyowm.webapi25.owm25 (module), 37pyowm.webapi25.ozone (module), 58pyowm.webapi25.ozone_parser (module), 59pyowm.webapi25.station (module), 46pyowm.webapi25.stationhistory (module), 47pyowm.webapi25.stationhistoryparser (module), 49pyowm.webapi25.stationlistparser (module), 49pyowm.webapi25.stationparser (module), 49pyowm.webapi25.uvindex (module), 54pyowm.webapi25.uvindexparser (module), 56pyowm.webapi25.weather (module), 50pyowm.webapi25.weathercoderegistry (module), 53pyowm.webapi25.weatherhistoryparser (module), 53pyowm.webapi25.weatherutils (module), 53pyowm.webapi25.xsd (module), 24pyowm.webapi25.xsd.xmlnsconfig (module), 24

Rrain_series() (pyowm.webapi25.historian.Historian

method), 33remove() (pyowm.abstractions.linkedlist.LinkedList

method), 4remove() (pyowm.commons.frontlinkedlist.FrontLinkedList

method), 8

Ssend_buffer() (pyowm.stationsapi30.stations_manager.StationsManager

method), 18send_measurement() (py-

owm.stationsapi30.stations_manager.StationsManagermethod), 18

send_measurements() (py-owm.stationsapi30.stations_manager.StationsManagermethod), 19

set() (pyowm.abstractions.owmcache.OWMCachemethod), 5

set() (pyowm.caches.lrucache.LRUCache method), 6set() (pyowm.caches.nullcache.NullCache method), 7

set_API_key() (pyowm.abstractions.owm.OWMmethod), 5

set_API_key() (pyowm.webapi25.owm25.OWM25method), 40

set_interval() (pyowm.webapi25.forecast.Forecastmethod), 26

set_interval() (pyowm.webapi25.stationhistory.StationHistorymethod), 48

set_language() (pyowm.webapi25.owm25.OWM25method), 40

set_station_ID() (pyowm.webapi25.stationhistory.StationHistorymethod), 48

size() (pyowm.abstractions.linkedlist.LinkedListmethod), 4

size() (pyowm.caches.lrucache.LRUCache method), 7size() (pyowm.commons.frontlinkedlist.FrontLinkedList

method), 8so2index_around_coords() (py-

owm.webapi25.owm25.OWM25 method),40

sort_chronologically() (py-owm.stationsapi30.buffer.Buffer method),13

sort_reverse_chronologically() (py-owm.stationsapi30.buffer.Buffer method),13

Station (class in pyowm.stationsapi30.station), 16Station (class in pyowm.webapi25.station), 46station_at_coords() (pyowm.webapi25.owm25.OWM25

method), 40station_day_history() (py-

owm.webapi25.owm25.OWM25 method),41

station_hour_history() (py-owm.webapi25.owm25.OWM25 method),41

station_id (pyowm.stationsapi30.buffer.Buffer attribute),13

station_tick_history() (py-owm.webapi25.owm25.OWM25 method),41

StationHistory (class in pyowm.webapi25.stationhistory),47

StationHistoryParser (class in py-owm.webapi25.stationhistoryparser), 49

StationListParser (class in py-owm.webapi25.stationlistparser), 49

StationParser (class in py-owm.stationsapi30.station_parser), 17

StationParser (class in pyowm.webapi25.stationparser),49

stations_api_version() (py-owm.stationsapi30.stations_manager.StationsManagermethod), 19

70 Index

Page 75: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

stations_manager() (pyowm.webapi25.owm25.OWM25method), 41

StationsManager (class in py-owm.stationsapi30.stations_manager), 17

status_for() (pyowm.webapi25.weathercoderegistry.WeatherCodeRegistrymethod), 53

status_is() (in module pyowm.webapi25.weatherutils), 54

Ttemperature_series() (py-

owm.webapi25.historian.Historian method),33

three_hours_forecast() (py-owm.webapi25.owm25.OWM25 method),42

three_hours_forecast_at_coords() (py-owm.webapi25.owm25.OWM25 method),42

three_hours_forecast_at_id() (py-owm.webapi25.owm25.OWM25 method),42

timeformat() (in module pyowm.utils.timeformatutils), 20to_date() (in module pyowm.utils.timeformatutils), 21to_dict() (pyowm.stationsapi30.measurement.AggregatedMeasurement

method), 14to_dict() (pyowm.stationsapi30.measurement.Measurement

method), 15to_ISO8601() (in module pyowm.utils.timeformatutils),

20to_JSON() (pyowm.stationsapi30.measurement.AggregatedMeasurement

method), 14to_JSON() (pyowm.stationsapi30.measurement.Measurement

method), 15to_JSON() (pyowm.stationsapi30.station.Station

method), 17to_JSON() (pyowm.webapi25.coindex.COIndex

method), 57to_JSON() (pyowm.webapi25.forecast.Forecast method),

26to_JSON() (pyowm.webapi25.location.Location

method), 34to_JSON() (pyowm.webapi25.observation.Observation

method), 36to_JSON() (pyowm.webapi25.ozone.Ozone method), 59to_JSON() (pyowm.webapi25.station.Station method), 47to_JSON() (pyowm.webapi25.stationhistory.StationHistory

method), 48to_JSON() (pyowm.webapi25.uvindex.UVIndex

method), 55to_JSON() (pyowm.webapi25.weather.Weather method),

52to_UNIXtime() (in module pyowm.utils.timeformatutils),

20

to_XML() (pyowm.stationsapi30.station.Station method),17

to_XML() (pyowm.webapi25.coindex.COIndex method),57

to_XML() (pyowm.webapi25.forecast.Forecast method),26

to_XML() (pyowm.webapi25.location.Location method),34

to_XML() (pyowm.webapi25.observation.Observationmethod), 36

to_XML() (pyowm.webapi25.ozone.Ozone method), 59to_XML() (pyowm.webapi25.station.Station method), 47to_XML() (pyowm.webapi25.stationhistory.StationHistory

method), 48to_XML() (pyowm.webapi25.uvindex.UVIndex method),

55to_XML() (pyowm.webapi25.weather.Weather method),

52tomorrow() (in module pyowm.utils.timeutils), 22tzname() (pyowm.utils.timeformatutils.UTC method), 20

UUltraVioletHttpClient (class in py-

owm.commons.uv_client), 11UnauthorizedError, 12update_next() (pyowm.commons.frontlinkedlist.LinkedListNode

method), 9update_station() (pyowm.stationsapi30.stations_manager.StationsManager

method), 19UTC (class in pyowm.utils.timeformatutils), 20utcoffset() (pyowm.utils.timeformatutils.UTC method),

20uv_intensity_to_exposure_risk() (in module py-

owm.webapi25.uvindex), 56UVIndex (class in pyowm.webapi25.uvindex), 54uvindex_around_coords() (py-

owm.webapi25.owm25.OWM25 method),42

UVIndexParser (class in py-owm.webapi25.uvindexparser), 56

WWeather (class in pyowm.webapi25.weather), 50weather_around_coords() (py-

owm.webapi25.owm25.OWM25 method),42

weather_at_coords() (pyowm.webapi25.owm25.OWM25method), 43

weather_at_id() (pyowm.webapi25.owm25.OWM25method), 43

weather_at_ids() (pyowm.webapi25.owm25.OWM25method), 43

weather_at_place() (pyowm.webapi25.owm25.OWM25method), 43

Index 71

Page 76: pyowm Documentation - Read the Docs · pyowm Documentation, Release An abstract class representing a Linked List data structure. Each element in the list should contain data and a

pyowm Documentation, Release

weather_at_places() (pyowm.webapi25.owm25.OWM25method), 43

weather_at_station() (pyowm.webapi25.owm25.OWM25method), 44

weather_at_stations_in_bbox() (py-owm.webapi25.owm25.OWM25 method),44

weather_at_zip_code() (py-owm.webapi25.owm25.OWM25 method),45

weather_from_dictionary() (in module py-owm.webapi25.weather), 52

weather_history_at_coords() (py-owm.webapi25.owm25.OWM25 method),45

weather_history_at_id() (py-owm.webapi25.owm25.OWM25 method),45

weather_history_at_place() (py-owm.webapi25.owm25.OWM25 method),45

WeatherCodeRegistry (class in py-owm.webapi25.weathercoderegistry), 53

WeatherHistoryParser (class in py-owm.webapi25.weatherhistoryparser), 53

WeatherHttpClient (class in py-owm.commons.weather_client), 9

when_clear() (pyowm.webapi25.forecaster.Forecastermethod), 28

when_clouds() (pyowm.webapi25.forecaster.Forecastermethod), 28

when_ends() (pyowm.webapi25.forecaster.Forecastermethod), 28

when_fog() (pyowm.webapi25.forecaster.Forecastermethod), 28

when_hurricane() (pyowm.webapi25.forecaster.Forecastermethod), 28

when_rain() (pyowm.webapi25.forecaster.Forecastermethod), 28

when_snow() (pyowm.webapi25.forecaster.Forecastermethod), 28

when_starts() (pyowm.webapi25.forecaster.Forecastermethod), 28

when_storm() (pyowm.webapi25.forecaster.Forecastermethod), 29

when_sun() (pyowm.webapi25.forecaster.Forecastermethod), 29

when_tornado() (pyowm.webapi25.forecaster.Forecastermethod), 29

will_be_clear_at() (pyowm.webapi25.forecaster.Forecastermethod), 29

will_be_cloudy_at() (py-owm.webapi25.forecaster.Forecaster method),29

will_be_foggy_at() (py-owm.webapi25.forecaster.Forecaster method),29

will_be_hurricane_at() (py-owm.webapi25.forecaster.Forecaster method),29

will_be_rainy_at() (py-owm.webapi25.forecaster.Forecaster method),29

will_be_snowy_at() (py-owm.webapi25.forecaster.Forecaster method),30

will_be_stormy_at() (py-owm.webapi25.forecaster.Forecaster method),30

will_be_sunny_at() (py-owm.webapi25.forecaster.Forecaster method),30

will_be_tornado_at() (py-owm.webapi25.forecaster.Forecaster method),30

will_have_clear() (pyowm.webapi25.forecaster.Forecastermethod), 30

will_have_clouds() (py-owm.webapi25.forecaster.Forecaster method),30

will_have_fog() (pyowm.webapi25.forecaster.Forecastermethod), 30

will_have_hurricane() (py-owm.webapi25.forecaster.Forecaster method),30

will_have_rain() (pyowm.webapi25.forecaster.Forecastermethod), 31

will_have_snow() (pyowm.webapi25.forecaster.Forecastermethod), 31

will_have_storm() (pyowm.webapi25.forecaster.Forecastermethod), 31

will_have_sun() (pyowm.webapi25.forecaster.Forecastermethod), 31

will_have_tornado() (py-owm.webapi25.forecaster.Forecaster method),31

wind_series() (pyowm.webapi25.historian.Historianmethod), 33

Yyesterday() (in module pyowm.utils.timeutils), 23

72 Index