aurorawatchuk

Python interface to the AuroraWatch UK status API.

class aurorawatchuk.Activity(expires, thresholds, updated, activity_values, messages)

An Activity object holds the current and recent AuroraWatch UK activity values.

all

All activity values. Type list of ActivityValue objects.

expires

The expiry time, as seconds since epoch. Type float.

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:

ActivityValue

datetime

The start time of the period for which the activity value applies. Type datetime.datetime.

Activity values are computed hourly.

level

The status level. Type str.

value

The activity value, in units of nanotesla (nT). Type float.

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_url may 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 the lang parameter; only lang='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_=False to avoid exceptions, note the trailing underscore to avoid collision with the raise keyword. When the status is unknown the value retrieved from status_color returned can be set with the unknown_status_color keyword.

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_.

lang

Retrieves the selected language for messages, descriptions etc. from the API Type str.

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 AuroraWatchUK object was created with raise_=True then accessing this property will generate an exception if the current status cannot be obtained. However if it was created with raise_=False then unknown_status_color will be returned if the current status cannot be determined.

status_description

Retrieves the description for the current alert status. Type str.

If the AuroraWatchUK object was created with raise_=True then accessing this property will generate an exception if the current description cannot be obtained. However if it was created with raise_=False then 'Unknown' will be returned.

Status descriptions are not terminated with a full stop.

status_level

Retrieves the current status level. Type str.

If the AuroraWatchUK object was created with raise=True then accessing this property will
generate an exception if the current status cannot be obtained. However if it was created with raise_=False then the status level will be returned as unknown if the current status cannot be determined.
status_meaning

The meaning of the current alert status. Type str.

If the AuroraWatchUK object was created with raise_=True then accessing this property will generate an exception if the current description cannot be obtained. However if it was created with raise_=False then '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:

AuroraWatchUK

expires

Retrieves the expiry time, as seconds since epoch. Type float.

level

The status level. Type str.

messages

A list of currently active messages. May be empty.

updated

The time status was last updated. Type datetime.datetime.

Indices and tables