Local

class knut.services.local.Local(location=None, uid='local', latitude=0, longitude=0, elevation=0)

Provide local data like sunrise and sunset times.

This service represent a location with it’s sunrise and sunset time, as well as whether the sun is currently up or not. A daemon task is run to update the is_daylight attribute and push a on_change() notification to listening objects.

Calculate the location data for the location based on the latitude, longitude and elevation. The latitude and longitude are in degree and the elevation in metres.

elevation = None

The elevation of the location in meters.

is_daylight = None

Whether it is day or not.

latitude = None

The latitude of the location in degree [-90, 90]

local()

Return the Local object as dictionary.

The dictionary has the keys 'isDaylight', 'location', 'sunrise', 'sunset' and 'id'. For example:

{
    'isDaylight': True,
    'location': 'Hamburg',
    'sunrise': 1589513114.5880833,
    'sunset': 1589483203.418921,
    'id': 'myLocation'
}
location = None

The name of the location.

longitude = None

The longitude of the location in degree [-180, 180]

observer = None

The astroplan.Observer for this location.

sunrise = None

The time when the sun rises in seconds since the epoch January 1, 1970, 00:00:00 (UTC).

sunset = None

The time when the sun sets in seconds since the epoch January 1, 1970, 00:00:00 (UTC).

uid = None

The identifier of the location service.

update_observer()

Update the observer and sunset time.

After changing any of the longitude, latitude or elevation, the observer should be updated using this method. This also updates the sunset time.