How to use the ephem.city 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 domogik / domogik / src / domogik / common / cron.py View on Github external
for p in params :
                                locP[p.key] = p.value
                            locCoord = {'lat' : float(locP['lat']), 'lng' : float(locP['lng'])}
#                        else :
#                            print(u"No location find in : {0}".format(line))
                    if locCoord :
                        self._observer = ephem.Observer()
                        self._observer.lat = locCoord['lat'] /180.*math.pi
                        self._observer.lon = locCoord['lng'] /180.*math.pi
#                        print(u"Observer created : {0}".format(locCoord))
#                        print(self._observer)
                        tzName = tzfinder.timezone_at(lng=locCoord['lng'], lat=locCoord['lat']) # returns timezone of GPS point
                        self.timeZone = pytz.timezone(tzName)
#                        print(self.timeZone)
                    else : # Default Bruxel use
                        self._observer = ephem.city('Brussels')
        # store the original input
        self.orig_line = line

        # parse the input
        if not self._special:
            for key, value in SUBSTITUTIONS.items():
                if line.startswith(key):
                    line = line.replace(key, value)
                    break

            fields = line.split(' ')
            if len(fields) >= 6:
                if re.match( r'^(?:\*$)|(^\d{4}$)|(^\d{4}(([,-]?\d{4})|(/?\d))+$)', fields[5]) is not None :
                    # this a years field
                    fields = line.split(None, 6)
                else :
github akkana / scripts / oppretro / oppretro_ephem.py View on Github external
def lookup_observer(city):
        try:
            return ephem.city(city)
        except KeyError:
            try:
                return cities.lookup(city)
            except ValueError:
                raise RuntimeError("I don't know where %s is, sorry" % city)
github Stellarium / stellarium-web-engine / tools / compute-ephemeris.py View on Github external
def compute_asteroid(name, data, t, precision_radec=15, precision_azalt=120):
    R2D = 180. / pi;
    o = ephem.city('Atlanta')
    o.date = t
    target = ephem.EllipticalBody()
    target._inc = data['i']
    target._Om = data['Node']
    target._om = data['Peri']
    target._a = data['a']
    target._M = data['M']
    target._epoch_M = data['Epoch'] - 2415020.0
    target._e = data['e']
    target._epoch = '2000'
    target.compute(o)
    # Pyephem use Dublin JD, ephemeride uses Modified JD!
    mjd = o.date + 15020 - 0.5
    return dict(
        name = name,
        utc = mjd,
github akkana / scripts / analemma.py View on Github external
def observer_for_city(city):
    try:
        return ephem.city(city)
    except KeyError:
        pass

    try:
        return cities.lookup(city)
    except ValueError:
        pass

    # Add some cities pyephem doesn't know:
    if city == 'San Jose':     # San Jose, CA at Houge Park
        observer = ephem.Observer()
        observer.name = "San Jose"
        observer.lon = '-121:56.8'
        observer.lat = '37:15.55'
        observer.elevation = 100
        return observer
github akkana / scripts / rise_set_az.py View on Github external
def observer_for_city(city):
    try:
        return ephem.city(city)
    except KeyError:
        pass

    try:
        return cities.lookup(city)
    except ValueError:
        pass

    # Add some cities pyephem doesn't know:
    if city == 'San Jose':     # San Jose, CA at Houge Park
        observer = ephem.Observer()
        observer.name = "San Jose"
        observer.lon = '-121:56.8'
        observer.lat = '37:15.55'
        observer.elevation = 100
        return observer
github ifermon / garagePi / garage_shared.py View on Github external
def sunrise():
    utc_datetime = ephem.city('New York').next_rising(
            ephem.Sun()).datetime()
    utc_datetime = utc_datetime.replace(tzinfo=tz.gettz('UTC'))
    return utc_datetime.astimezone(my_tz())
github ifermon / garagePi / garage_shared.py View on Github external
def sunset():
    utc_datetime = ephem.city('New York').next_setting(
            ephem.Sun()).datetime()
    utc_datetime = utc_datetime.replace(tzinfo=tz.gettz('UTC'))
    return utc_datetime.astimezone(my_tz())