lib.orb

class lib.orb.Orb(orb, lon, lat, elev=False, neverup_delta=1e-05)[Quellcode]

Bases: object

Save an observers location and the name of a celestial body for future use

The Methods internally use PyEphem for computation

An Observer instance allows to compute the positions of celestial bodies as seen from a particular position on the Earth’s surface. Following attributes can be set after creation (used defaults are given):

date - the moment the Observer is created lat - zero degrees latitude lon - zero degrees longitude elevation - 0 meters above sea level horizon - 0 degrees epoch - J2000 temp - 15 degrees Celsius pressure - 1010 mBar

All calculations by ephem will be based on utc time. Changelog of pypehem: > Version 4.1.1 (2021 November 27) > When you provide PyEphem with a Python datetime that has a time zone attached, > PyEphem now detects the time zone and converts the date and time to UTC automatically.

To prevent side effects by this behaviour every datetime object given to any function in class Orb will be converted to utc. In case the given datetime is - naive (no timezone attached) –> the current timezone of SmartHomeNG will be used and the datetime will be converted to utc - has a timezone other than utc –> dt will be converted to utc - has utc timezone –> dt will not be changed and has always an offset of 0:00

TODO: It can be that datetime conversion from and to utc is ambigous: Imagine October 27th, in 2024, at 2:30 in the night. dt = datetime(2024, 10, 27, 2, 30, tzinfo=berlin) This is ambigous because it could well be summertime having still utc+2 hours or wintertime with utc+1 hours This ambiguity is not handled right now

aware_datetime_to_utc(aware_dt)[Quellcode]
get_observer_and_orb()[Quellcode]

Return a tuple of an instance of an observer with location information and a celestial body Both returned objects are uniquely created to prevent errors in computation

See also this thread at Stackoverflow dated back to 2015 where the creator of pyephem writes:

> Second answer: As long as each thread has its own Moon and Observer objects,

it should be able to do its own computations without ruining those of any other threads.

Rückgabe:

tuple of observer and celestial body

midnight(doff=0, moff=0, dt=None)[Quellcode]

Calculate the time of next antitransit starting with dt. If dt is None the the time of this function call will be used

Parameter:
  • doff (float, optional) – degrees offset, defaults to 0

  • moff (float, optional) – minutes offset, defaults to 0

  • dt (datetime, optional) – datetime object to start calculation with, defaults to None

Rückgabe:

datetime of next antitransit

Rückgabetyp:

datetime

noon(doff=0, moff=0, dt=None)[Quellcode]

calculate the time of next transit starting with dt. If dt is None the the time of this function call will be used

Parameter:
  • doff (float, optional) – degrees offset, defaults to 0

  • moff (float, optional) – minutes offset, defaults to 0

  • dt (datetime, optional) – datetime object to start calculation with, defaults to None

Rückgabe:

datetime of next transit

Rückgabetyp:

datetime

pos(offset=None, degree=False, dt=None)[Quellcode]

Calculates the position of either sun or moon :type offset: :param offset: given in minutes, shifts the time of calculation by some minutes back or forth :type degree: :param degree: if True: return the position of either sun or moon from the observer as degrees, otherwise as radians :type dt: :param dt: time for which the position needs to be calculated :return: a tuple with azimuth and elevation

rise(doff=0, moff=0, center=True, dt=None)[Quellcode]

Computes the rise of either sun or moon :type doff: :param doff: degrees offset for the observers horizon :type moff: :param moff: minutes offset from time of rise (either before or after) :type center: :param center: if True then the centerpoint of either sun or moon will be considered to make the transit otherwise the upper limb will be considered :type dt: :param dt: start time for the search for a rise, if not given the current time will be used :return: datetime of next rising in utc timezone

set(doff=0, moff=0, center=True, dt=None)[Quellcode]

Computes the setting of either sun or moon :type doff: :param doff: degrees offset for the observers horizon :type moff: :param moff: minutes offset from time of setting (either before or after) :type center: :param center: if True then the centerpoint of either sun or moon will be considered to make the transit otherwise the upper limb will be considered :type dt: :param dt: start time for the search for a setting, if not given the current time will be used :return: datetime of next setting in utc timezone

unaware_datetime_to_utc(naive_dt)[Quellcode]
utc_to_local(utc_dt)[Quellcode]