How to use the ephem.localtime 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 LASER-WOLF / OnboardComputerSystem / .OnboardComputerSystem / OnboardComputerSystem.py View on Github external
#Format distance travelled
        distformat='{0:.1f}'.format((float(dist)+float(diststart)) * 0.000539956803)
        distformatfull='{0} NM'.format(distformat)
        #Format uptime
        uptimemin, uptimesec = divmod(uptime, 60)
        uptimehour, uptimemin = divmod(uptimemin, 60)
        uptimeday, uptimehour = divmod(uptimehour, 24)
        uptimeformatfull="%02d DAYS - %02d HOURS - %02d MINUTES" % (uptimeday, uptimehour, uptimemin)
        #Calculate sunset/sunrise
        if (gpsfix==1 and astronomy_update==1):
          eph_observer=ephem.Observer()
          eph_observer.lat=str(gpslatdeg)
          eph_observer.long=str(gpslondeg)
          eph_sun=ephem.Sun()
          eph_sun.compute()
          sunrise=ephem.localtime(eph_observer.next_rising(eph_sun))
          sunset=ephem.localtime(eph_observer.next_setting(eph_sun))
          sunriseformat=sunrise.strftime('%H:%M')
          sunsetformat=sunset.strftime('%H:%M')
          astronomy_update_lock.acquire()
          astronomy_update=0
          astronomy_update_lock.release()
        if start_output_lcd==0:
          start_output_lcd=1
        if start_output_conky==0:
          start_output_conky=1
        if start_output_data==0:
          start_output_data=1
        if start_alarm_system==0:
          start_alarm_system=1
        if start_update_databases==0:
          start_update_databases=1
github akkana / scripts / conjunctions.py View on Github external
def datestr(d):
    # The date may be wrong because of time zones. Convert to our timezone.
    lt = ephem.localtime(d)
    # return lt.strftime("%m/%d/%Y")
    return lt.strftime("%Y-%m-%d")
github domogik / domogik / src / domogik / xpl / lib / dawndusk.py View on Github external
def getNextFullMoonDawn(self):
        """
        Return the date and time of the next dawn and dusk of the next fullmoon
        @return : the next dawn daytime
        """
        self.mycity.date = self._getNextFullMoon()
        dawn = ephem.localtime(self.mycity.next_rising(ephem.Moon(), use_center=True))
        dusk = ephem.localtime(self.mycity.next_setting(ephem.Moon(), use_center=True))
        if dawn>dusk:
            dawn=ephem.localtime(self.mycity.previous_rising(ephem.Moon(), use_center=True))
        return dawn
github akkana / scripts / conjunctions.py View on Github external
def friendlydate(d):
    lt = ephem.localtime(d)
    return lt.strftime("%b %d")
github home-assistant / home-assistant / homeassistant / observer / WeatherWatcher.py View on Github external
def next_sun_setting(self, observer=None):
        """ Returns a datetime object that points at the next sun setting. """

        if observer is None:
            observer = self._get_observer()

        return ephem.localtime(observer.next_setting(self.sun))
github hazrmard / SatTrack / build / lib / sattrack / sattrack.py View on Github external
def tolocal(utc):       # takes ephem date object and returns localtime string
    return parser.parse(str(ephem.localtime(utc))).strftime('%Y-%m-%d %H:%M:%S')
github domogik / domogik / src / domogik_packages / xpl / lib / earth.py View on Github external
def get_next_dusk(self, mycity, delay, args = None) :
        """
        Return the date and time of the dusk

        @param city: the city wher calculate the event.
        @param delay: the delay (in seconds) to the event.
        @param args: an optional argument.
        @returns: the next dusk daytime or None

        """
        if abs(delay) >= 86400:
            return None
        today = datetime.datetime.today() - datetime.timedelta(seconds=delay+30)
        mycity.date = today
        dusk = ephem.localtime(mycity.next_setting(ephem.Sun(), use_center = True))
        return dusk + datetime.timedelta(seconds=delay)
github domogik / domogik / src / domogik / xpl / lib / dawndusk.py View on Github external
def getNextFullMoonDawn(self):
        """
        Return the date and time of the next dawn and dusk of the next fullmoon
        @return : the next dawn daytime
        """
        self.mycity.date = self._getNextFullMoon()
        dawn = ephem.localtime(self.mycity.next_rising(ephem.Moon(), use_center=True))
        dusk = ephem.localtime(self.mycity.next_setting(ephem.Moon(), use_center=True))
        if dawn>dusk:
            dawn=ephem.localtime(self.mycity.previous_rising(ephem.Moon(), use_center=True))
        return dawn