pyowm.uvindexapi30 package¶
Subpackages¶
Submodules¶
pyowm.uvindexapi30.uvindex module¶
- class pyowm.uvindexapi30.uvindex.UVIndex(reference_time, location, value, reception_time)[source]¶
Bases:
objectA 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
Noneif 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+00‘date fordatetime.datetimeobject 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+00‘date fordatetime.datetimeobject instance- Returns:
an int or a str
- Raises:
ValueError when negative values are provided
pyowm.uvindexapi30.uvindex_manager module¶
- class pyowm.uvindexapi30.uvindex_manager.UVIndexManager(API_key, config)[source]¶
Bases:
objectA 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_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
Noneif 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.datetimeor ISO8601-formatted string) – the object conveying the time value for the start query boundaryend (int,
datetime.datetimeor ISO8601-formatted string) – the object conveying the time value for the end query boundary (defaults toNone, 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:
objectAn 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