pyowm.uvindexapi30 package

Subpackages

Submodules

pyowm.uvindexapi30.uvindex module

class pyowm.uvindexapi30.uvindex.UVIndex(reference_time, location, value, reception_time)[source]

Bases: object

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

Parameters:
  • reference_time (int) – GMT UNIXtime telling when the UV data have been measured

  • 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 received from the OWM Weather API

Returns:

an UVIndex instance

Raises:

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

classmethod from_dict(the_dict)[source]

Parses an UVIndex instance 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:

the_dict (dict) – the input dict

Returns:

an UVIndex instance or None if no data is available

Raises:

ParseAPIResponseError if it is impossible to find or parse the data needed to build the result, APIResponseError if the input dict embeds an HTTP status error

get_exposure_risk()[source]

Returns a string stating the risk of harm from unprotected sun exposure for the average adult on this UV observation :return: str

reception_time(timeformat='unix')[source]

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’ (default) for UNIX time ‘iso’ for ISO8601-formatted string in the format YYYY-MM-DD HH:MM:SS+00date for datetime.datetime object instance

Returns:

an int or a str

Raises:

ValueError when negative values are provided

reference_time(timeformat='unix')[source]
Returns the GMT time telling when the UV has been observed

from the OWM Weather API

Parameters:

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

Returns:

an int or a str

Raises:

ValueError when negative values are provided

to_dict()[source]

Dumps object to a dictionary

Returns:

a dict

pyowm.uvindexapi30.uvindex.uv_intensity_to_exposure_risk(uv_intensity)[source]

pyowm.uvindexapi30.uvindex_manager module

class pyowm.uvindexapi30.uvindex_manager.UVIndexManager(API_key, config)[source]

Bases: object

A manager objects that provides a full interface to OWM UV Index API.

Parameters:
  • API_key (str) – the OWM UV Index API key

  • config (dict) – the configuration dictionary

Returns:

a UVIndexManager instance

Raises:

AssertionError when no API Key is provided

uvindex_api_version()[source]
uvindex_around_coords(lat, lon)[source]

Queries for Ultra Violet value sampled in the surroundings of the provided geocoordinates and in the specified time interval. A UVIndex object instance is returned, encapsulating a Location object and the UV intensity value.

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 UV Index API responses’ data cannot be parsed, APICallException when OWM UV Index API can not be reached, ValueError for wrong input values

uvindex_forecast_around_coords(lat, lon)[source]

Queries for forecast Ultra Violet values in the next 8 days in the surroundings of the provided geocoordinates.

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 list of UVIndex instances or empty list if data is not available

Raises:

ParseResponseException when OWM UV Index API responses’ data cannot be parsed, APICallException when OWM UV Index API can not be reached, ValueError for wrong input values

uvindex_history_around_coords(lat, lon, start, end=None)[source]

Queries for UV index historical values in the surroundings of the provided geocoordinates and in the specified time frame. If the end of the time frame is not provided, that is intended to be the current datetime.

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 conveying the time value for the start query boundary

  • end (int, datetime.datetime or ISO8601-formatted string) – the object conveying the time value for the end query boundary (defaults to None, in which case the current datetime will be used)

Returns:

a list of UVIndex instances or empty list if data is not available

Raises:

ParseResponseException when OWM UV Index API responses’ data cannot be parsed, APICallException when OWM UV Index API can not be reached, ValueError for wrong input values

pyowm.uvindexapi30.uv_client module

class pyowm.uvindexapi30.uv_client.UltraVioletHttpClient(API_key, httpclient)[source]

Bases: object

An HTTP client class for the OWM UV web API, which is a subset of the overall OWM API.

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

  • httpclient (an httpclient.HttpClient instance) – an httpclient.HttpClient instance that will be used to send requests to the OWM Air Pollution web API.

get_uvi(params_dict)[source]

Invokes the UV Index endpoint

Parameters:

params_dict – dict of parameters

Returns:

a string containing raw JSON data

Raises:

ValueError, APIRequestError

get_uvi_forecast(params_dict)[source]

Invokes the UV Index Forecast endpoint

Parameters:

params_dict – dict of parameters

Returns:

a string containing raw JSON data

Raises:

ValueError, APIRequestError

get_uvi_history(params_dict)[source]

Invokes the UV Index History endpoint

Parameters:

params_dict – dict of parameters

Returns:

a string containing raw JSON data

Raises:

ValueError, APIRequestError

pyowm.uvindexapi30.uris module

Module contents