aurorawatchuk¶
Python interface to the AuroraWatch UK status API.
-
class
aurorawatchuk.Activity(expires, thresholds, updated, activity_values, messages)¶ An
Activityobject holds the current and recent AuroraWatch UK activity values.-
all¶ All activity values. Type
listofActivityValueobjects.
-
latest¶ The latest activity value available. Type
ActivityValue.
-
messages¶ A list of currently active messages. May be empty.
-
thresholds¶ The lower thresholds, in nanotesla (nT), for each activity level. Type
collections.OrderedDict.
-
updated¶ The time status was last updated. Type
datetime.datetime.
-
-
class
aurorawatchuk.ActivityValue(level, datetime, value)¶ A single AuroraWatch UK activity value.
Parameters: - level (str) – The status level.
- datetime (datetime.datetime) – The start time of the period for which the activity value applies. Activity values are computed hourly.
- value (float) – The activity value, in units of nanotesla (nT).
Returns: An object holding an AuroraWatch UK activity value and its related information.
Return type: -
datetime¶ The start time of the period for which the activity value applies. Type
datetime.datetime.Activity values are computed hourly.
-
class
aurorawatchuk.AuroraWatchUK(base_url='http://aurorawatch-api.lancs.ac.uk/0.2/', lang='en', raise_=True, unknown_status_color='#777777')¶ Object from which the current and recent AuroraWatch UK status, activity and descriptions can be obtained.
When the object is constructed
base_urlmay be used to adjust the base URL of the AuroraWatch UK API, for instance to select between HTTP and HTTPS transport. The language used for descriptions, messages etc. can be adjusted with thelangparameter; onlylang='en'is supported at present.By default exceptions are raised when the status, activity or descriptions cannot be fetched from AuroraWatch UK. In some limited cases unknown values can be returned instead of exceptions (primarily when such information may be included in formatted strings). Call the constructor with
raise_=Falseto avoid exceptions, note the trailing underscore to avoid collision with theraisekeyword. When the status is unknown the value retrieved fromstatus_colorreturned can be set with theunknown_status_colorkeyword.-
activity¶ The current activity object. Type
Activity.If the current activity cannot be obtained accessing this property will generate an exception, regardless of the constructor parameter
raise_.
-
descriptions¶ Descriptions and meanings used in the AuroraWatch UK API. Type
collections.OrderedDict.If the current activity cannot be obtained accessing this property will generate an exception, regardless of the constructor parameter
raise_.
-
status¶ Retrieves the current status object. Type
Status.If the current status cannot be obtained accessing this property will generate an exception, regardless of the constructor parameter
raise_.
-
status_color¶ Retrieves the current status color as a RGB string. Type
str.If the
AuroraWatchUKobject was created withraise_=Truethen accessing this property will generate an exception if the current status cannot be obtained. However if it was created withraise_=Falsethenunknown_status_colorwill be returned if the current status cannot be determined.
-
status_description¶ Retrieves the description for the current alert status. Type
str.If the
AuroraWatchUKobject was created withraise_=Truethen accessing this property will generate an exception if the current description cannot be obtained. However if it was created withraise_=Falsethen'Unknown'will be returned.Status descriptions are not terminated with a full stop.
-
status_level¶ Retrieves the current status level. Type
str.- If the
AuroraWatchUKobject was created withraise=Truethen accessing this property will - generate an exception if the current status cannot be obtained. However if it was created with
raise_=Falsethen the status level will be returned as unknown if the current status cannot be determined.
- If the
-
status_meaning¶ The meaning of the current alert status. Type
str.If the
AuroraWatchUKobject was created withraise_=Truethen accessing this property will generate an exception if the current description cannot be obtained. However if it was created withraise_=Falsethen'Unknown.'will be returned.The status meanings are terminated with a full stop.
-
-
class
aurorawatchuk.Status(expires, level, updated, messages)¶ AuroraWatch UK object.
Parameters: - base_url (str.) – Base URL of the AuroraWatch UK API
- lang (str) – Language to use for descriptions, messages etc. lang must be provided by the API.
- raise (bool) – Raise exceptions on errors (note the trailing underscore to avoid collision with the keyword raise).
- unknown_color (str) – RGB color value for when status cannot be determined.
Returns: An object from which the current AuroraWatch UK status, activity and descriptions can be obtained.
Return type: -
messages¶ A list of currently active messages. May be empty.
-
updated¶ The time status was last updated. Type
datetime.datetime.