How to use the ephem.next_equinox function in ephem

To help you get started, we’ve selected a few ephem examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github akkana / scripts / analemma.py View on Github external
def draw_equinox(start, whicheq, offsets):
            equinox = ephem.next_equinox(start)
            self.observer.date = self.gmt_for_time_on_date(equinox, (12, 0, 0))
            self.sun.compute(self.observer)
            x, y = self.project(self.sun.az, self.sun.alt)
            print("%s equinox: %s" % (whicheq, str(self.observer.date)))
            self.draw_dot(x, y, self.special_dot_size)

            if labels:
                x1 = x + offsets[0] * 20
                self.draw_line(x, y, x1, y)
                eqstr = "%s equinox\n%s" % (whicheq, str(equinox).split(' ')[0])
                self.draw_string(eqstr, x1, y, offsets)
github home-assistant / home-assistant / homeassistant / components / season / sensor.py View on Github external
def get_season(date, hemisphere, season_tracking_type):
    """Calculate the current season."""

    if hemisphere == "equator":
        return None

    if season_tracking_type == TYPE_ASTRONOMICAL:
        spring_start = ephem.next_equinox(str(date.year)).datetime()
        summer_start = ephem.next_solstice(str(date.year)).datetime()
        autumn_start = ephem.next_equinox(spring_start).datetime()
        winter_start = ephem.next_solstice(summer_start).datetime()
    else:
        spring_start = datetime(2017, 3, 1).replace(year=date.year)
        summer_start = spring_start.replace(month=6)
        autumn_start = spring_start.replace(month=9)
        winter_start = spring_start.replace(month=12)

    if spring_start <= date < summer_start:
        season = STATE_SPRING
    elif summer_start <= date < autumn_start:
        season = STATE_SUMMER
    elif autumn_start <= date < winter_start:
        season = STATE_AUTUMN
    elif winter_start <= date or spring_start > date:
        season = STATE_WINTER
github akkana / scripts / skyalignments.py View on Github external
def find_alignments(observer, waypoints, year, allpoints=False):
    """Find all the alignments with solstice/equinox sun/moon rise/set.
       Returns a dict: { 'vernal equinox': { 'moon': { 'rise': 94.17... } } }
       of azimuth angles in decimal degrees
    """
    azimuths = {}

    # start_date = ephem.Date('%d/1/1' % year)
    start_date = ephem.Date((year, 1, 1))
    # date= ephem.date((-59000,1,1))

    observer.date = ephem.next_equinox(start_date)
    azimuths['vernal equinox'] = find_azimuths(observer)

    observer.date = ephem.next_solstice(observer.date)
    azimuths['summer solstice'] = find_azimuths(observer)

    observer.date = ephem.next_equinox(observer.date)
    azimuths['autumnal equinox'] = find_azimuths(observer)

    observer.date = ephem.next_solstice(observer.date)
    azimuths['winter solstice'] = find_azimuths(observer)

    # pprint(azimuths)

    # How many degrees is close enough?
    DEGREESLOP = 2.
github home-assistant / home-assistant / homeassistant / components / season / sensor.py View on Github external
def get_season(date, hemisphere, season_tracking_type):
    """Calculate the current season."""

    if hemisphere == "equator":
        return None

    if season_tracking_type == TYPE_ASTRONOMICAL:
        spring_start = ephem.next_equinox(str(date.year)).datetime()
        summer_start = ephem.next_solstice(str(date.year)).datetime()
        autumn_start = ephem.next_equinox(spring_start).datetime()
        winter_start = ephem.next_solstice(summer_start).datetime()
    else:
        spring_start = datetime(2017, 3, 1).replace(year=date.year)
        summer_start = spring_start.replace(month=6)
        autumn_start = spring_start.replace(month=9)
        winter_start = spring_start.replace(month=12)

    if spring_start <= date < summer_start:
        season = STATE_SPRING
    elif summer_start <= date < autumn_start:
        season = STATE_SUMMER
    elif autumn_start <= date < winter_start:
        season = STATE_AUTUMN
    elif winter_start <= date or spring_start > date:
github akkana / scripts / skyalignments.py View on Github external
Returns a dict: { 'vernal equinox': { 'moon': { 'rise': 94.17... } } }
       of azimuth angles in decimal degrees
    """
    azimuths = {}

    # start_date = ephem.Date('%d/1/1' % year)
    start_date = ephem.Date((year, 1, 1))
    # date= ephem.date((-59000,1,1))

    observer.date = ephem.next_equinox(start_date)
    azimuths['vernal equinox'] = find_azimuths(observer)

    observer.date = ephem.next_solstice(observer.date)
    azimuths['summer solstice'] = find_azimuths(observer)

    observer.date = ephem.next_equinox(observer.date)
    azimuths['autumnal equinox'] = find_azimuths(observer)

    observer.date = ephem.next_solstice(observer.date)
    azimuths['winter solstice'] = find_azimuths(observer)

    # pprint(azimuths)

    # How many degrees is close enough?
    DEGREESLOP = 2.

    # If allpoints is set, check angles among all pairs of points.
    # Otherwise, only check angles from observer to other points.
    if allpoints:
        print("Looking for alignments among all points")
        observer_points = waypoints
    else:
github domogik / domogik / src / domogik / common / cron.py View on Github external
"""
        Returns next ephemeris date the given time.
        The date tuple should be in the local time.
        return date tupple
        """
        cpm = None;
        if self.string_tab == '@fullmoon':
            cpm = ephem.next_full_moon(date_tuple)
        elif self.string_tab == '@newmoon':
            cpm = ephem.next_new_moon(date_tuple)
        elif self.string_tab == '@firstquarter':
            cpm = ephem.next_first_quarter_moon(date_tuple)
        elif self.string_tab == '@lastquarter':
            cpm = ephem.next_last_quarter_moon(date_tuple)
        elif self.string_tab == '@equinox':
            cpm = ephem.next_equinox(date_tuple)
        elif self.string_tab == '@solstice':
            cpm = ephem.next_solstice(date_tuple)
        elif self.string_tab in ['@dawn', '@dusk']:
            bobs = ephem.Sun()
            date = "{0}/{1}/{2} 00:00".format(date_tuple[0], date_tuple[1], date_tuple[2])
            self._observer.date = date
#            print date
            if self.string_tab == '@dawn':
                cpm = self._observer.next_rising(bobs, start=date)
            else:
                cpm = self._observer.next_setting(bobs, start=date)
        if cpm:
            d = ephem.Date(cpm.tuple())
#            print(u"Timezone : {0}".format(self.timeZone))
#            print(u"Date UTC : {0}".format(d))
#            print(u"Date Local : {0}".format(ephem.localtime(d)))