def gregtuple(year): if year < 1: yy = year - 1 else: yy = year return ephem.next_vernal_equinox(str(yy)).tuple()
def events_until(limit): initial_date = ephem.Date(datetime.now()) events = {} now = initial_date while ephem.localtime(now) <= limit: now = ephem.next_full_moon(now) events[now] = "🌕" now = initial_date while ephem.localtime(now) <= limit: now = ephem.next_new_moon(now) events[now] = "🌑" now = initial_date while ephem.localtime(now) <= limit: now = ephem.next_vernal_equinox(now) events[now] = "spring equinox" now = initial_date while ephem.localtime(now) <= limit: now = ephem.next_autumnal_equinox(now) events[now] = "fall equinox" now = initial_date while ephem.localtime(now) <= limit: now = ephem.next_winter_solstice(now) events[now] = "winter solstice" now = initial_date while ephem.localtime(now) <= limit: now = ephem.next_summer_solstice(now) events[now] = "summer solstice" return events
def getStart(self, year): start = ephem.date(str(year) + '/1/1') start = ephem.next_vernal_equinox(start) start = ephem.previous_new_moon(start) self.location.date = start moon.compute(self.location) start = self.location.next_rising(moon) return start
def vernal_equinox(year, offset=None, observance=None): dt = datetime(year, 1, 1) dt = ephem.next_vernal_equinox(dt).datetime().replace(hour=0, minute=0, second=0, microsecond=0) if offset != None: dt = dt + timedelta(offset) return dt if observance == None else observance(dt)
def gregtuple(year): # if year < 1: # yy = year - 1 # else: # yy = year yy = year tup = list(ephem.next_vernal_equinox(str(yy)).tuple()) # tup[0] = year return tuple(tup)
def EquinoxSolsticeJD(year, angle): if 0 <= angle < 90: date = ephem.next_vernal_equinox(year) elif 90 <= angle < 180: date = ephem.next_summer_solstice(year) elif 180 <= angle < 270: date = ephem.next_autumn_equinox(year) else: date = ephem.next_winter_solstice(year) JD = ephem.julian_date(date) return JD
def springleap(year, do_print=False): # The type of modulo we use depends on the interval this # year falls in. for yearbin in [1059, 4298, 5305, 5466, 6457, 6804, 50000]: if year < yearbin: break # print("yearbin =", yearbin) # extract the appropriate offset and moduli to use for the appropriate # year bin. mods = {1059:(18,260,33), # repeat cycles of 3*33 + 29 4298:(1777,1440,491,33), # 2 cycles of 14*33+29 plus 1 cycle of 13*33+29 5305:(4298,1007,260,33), # 3 cycles of 7*33 + 29 plus 1 cycle of 6*33 + 29: 5466:(5305,161,33), # 4*33 + 29 6457:(5466,128,33), # 7 cycles of 3*33 + 29 6804:(6457,95,33), # 2*33 + 29 50000:(6804,62,33)}[yearbin] # 33 + 29 # print("mods =", mods) z, rectleap = diffmod(year, *mods) y = year while (y < 0): y += 400 c = y // 100 tradleap = False if y % 100 == 0: if y % 400 == 0: tradleap = True elif y % 4 == 0: tradleap = True if do_print: if year <= 0: yyy = year - 1 else: yyy = year print(year, tradleap, rectleap, y % 4, z, ephem.next_vernal_equinox(str(yyy))) return (tradleap, rectleap)
def springleap(year, do_print=False): # The type of modulo we use depends on the interval this # year falls in. for yearbin in [1059, 4298, 5305, 5466, 6457, 6804, 50000]: if year < yearbin: break # print("yearbin =", yearbin) # extract the appropriate offset and moduli to use for the appropriate # year bin. mods = { 1059: (18, 260, 33), # repeat cycles of 3*33 + 29 4298: (1777, 1440, 491, 33), # 2 cycles of 14*33+29 plus 1 cycle of 13*33+29 5305: (4298, 1007, 260, 33), # 3 cycles of 7*33 + 29 plus 1 cycle of 6*33 + 29: 5466: (5305, 161, 33), # 4*33 + 29 6457: (5466, 128, 33), # 7 cycles of 3*33 + 29 6804: (6457, 95, 33), # 2*33 + 29 50000: (6804, 62, 33) }[yearbin] # 33 + 29 # print("mods =", mods) z, rectleap = diffmod(year, *mods) y = year while (y < 0): y += 400 c = y // 100 tradleap = False if y % 100 == 0: if y % 400 == 0: tradleap = True elif y % 4 == 0: tradleap = True if do_print: if year <= 0: yyy = year - 1 else: yyy = year print(year, tradleap, rectleap, y % 4, z, ephem.next_vernal_equinox(str(yyy))) return (tradleap, rectleap)
def sol(jotape_bot, last_chat_id): # Brasilia bsb = ephem.Observer() bsb.lat, bsb.lon = '-15.6982196', '-48.1082429' bsb.horizon = '-6' # Civil twilight -6 graus em relação ao centro do sol bsb.date = datetime.datetime.utcnow() nascer = bsb.next_rising(ephem.Sun()).datetime().replace(tzinfo=pytz.utc) zenite = bsb.next_transit(ephem.Sun()).datetime().replace(tzinfo=pytz.utc) por = bsb.next_setting(ephem.Sun()).datetime().replace(tzinfo=pytz.utc) unascer = bsb.previous_rising( ephem.Sun()).datetime().replace(tzinfo=pytz.utc) uzenite = bsb.previous_transit( ephem.Sun()).datetime().replace(tzinfo=pytz.utc) upor = bsb.previous_setting( ephem.Sun()).datetime().replace(tzinfo=pytz.utc) jotape_bot.send_message( last_chat_id, "Último\nNascer do Sol: %s\n Zênite: %s\n Pôr-do-sol: %s\n---\nPróximo\nNascer do Sol: %s\n Zênite: %s\n Pôr-do-sol: %s\n" % (unascer.astimezone(pytz.timezone('America/Sao_Paulo')), uzenite.astimezone(pytz.timezone('America/Sao_Paulo')), upor.astimezone(pytz.timezone('America/Sao_Paulo')), nascer.astimezone(pytz.timezone('America/Sao_Paulo')), zenite.astimezone(pytz.timezone('America/Sao_Paulo')), por.astimezone(pytz.timezone('America/Sao_Paulo')))) dts = [ ('Outono', ephem.next_vernal_equinox( datetime.datetime.utcnow()).datetime().replace(tzinfo=pytz.utc)), ('Inverno', ephem.next_summer_solstice( datetime.datetime.utcnow()).datetime().replace(tzinfo=pytz.utc)), ('Verão', ephem.next_winter_solstice( datetime.datetime.utcnow()).datetime().replace(tzinfo=pytz.utc)), ('Primavera', ephem.next_autumnal_equinox( datetime.datetime.utcnow()).datetime().replace(tzinfo=pytz.utc)) ] lista = sorted(dts, key=lambda x: x[1]) s = "" for d in lista: s = s + ("%s - %s\n" % (d[0], d[1].astimezone(pytz.timezone('America/Sao_Paulo')))) jotape_bot.send_message(last_chat_id, s)
def seasonPhase(date): season = "" nss = ephem.next_summer_solstice(date).datetime() nae = ephem.next_autumnal_equinox(date).datetime() nws = ephem.next_winter_solstice(date).datetime() nve = ephem.next_vernal_equinox(date).datetime() if nss > nae: season = "Summer" if nae > nws: season = "Autumn" if nws > nve: season = "Winter" if nve > nss: season = "Spring" if date == nss.replace(hour=0, minute=0, second=0, microsecond=0): season = "Summer Solstice %s" % nss.strftime('%Y.%m.%d %H:%M:%S') if date == nae.replace(hour=0, minute=0, second=0, microsecond=0): season = "Autumnal equinox %s" % nae.strftime('%Y.%m.%d %H:%M:%S') if date == nws.replace(hour=0, minute=0, second=0, microsecond=0): season = "Winter solstice %s" % nws.strftime('%Y.%m.%d %H:%M:%S') if date == nve.replace(hour=0, minute=0, second=0, microsecond=0): season = "Vernal equinox %s" % nve.strftime('%Y.%m.%d %H:%M:%S') return season
def next_ve_nm( date, accuracy = 1, dow = None ): "get next vernal equinox when the same as a new moon when on a wednesday" if type(date) is enoch.Date: e = date else: e = enoch.Date ( date ) ve = e.djd nm = 0 found = False while not found: ve = ephem.next_vernal_equinox ( ve ) nm = ephem.next_new_moon ( math.floor(ve)) df = math.fabs(ve-nm) if df < accuracy: e.set ( nm ) if dow is not None: if e.dayofweek == dow: found = True else: found = True return {"ve":ve,"enoch":e}
def get_moon_year(date, ignoreTime=True): pve = ephem.previous_vernal_equinox(date) nve = ephem.next_vernal_equinox(pve) fnm = pnm = ephem.next_new_moon(math.floor(pve)) # check if date is still in previous lunar year if date < fnm: nve = pve pve = ephem.previous_vernal_equinox(nve) fnm = pnm = ephem.next_new_moon(math.floor(pve)) #print str(date) + " : " + str(pve) + " : " + str(nve) nm = pve moonyear = [] while nm < nve: nm = ephem.next_new_moon(pnm) if ignoreTime: moonyear += [math.floor(nm) - math.floor(pnm)] else: moonyear += [round(nm - pnm)] pnm = nm return (moonyear, fnm, nm)
def get_moon_year(date,ignoreTime = True ): pve = ephem.previous_vernal_equinox(date) nve = ephem.next_vernal_equinox(pve) fnm = pnm = ephem.next_new_moon(math.floor(pve)) # check if date is still in previous lunar year if date < fnm: nve = pve pve = ephem.previous_vernal_equinox(nve) fnm = pnm = ephem.next_new_moon(math.floor(pve)) #print str(date) + " : " + str(pve) + " : " + str(nve) nm = pve moonyear = [] while nm < nve: nm = ephem.next_new_moon(pnm) if ignoreTime: moonyear += [ math.floor(nm)-math.floor(pnm) ] else: moonyear += [ round(nm-pnm) ] pnm = nm return (moonyear,fnm,nm)
# -*- coding: utf-8 -*- """ Created on Sat Jun 13 14:02:04 2020 https://rhodesmill.org/pyephem/quick.html#equinoxes-solstices @author: PC """ import ephem d1 = ephem.next_equinox('2000') print(d1) d2 = ephem.next_solstice(d1) print(d2) t = d2 - d1 print("Spring lasted %.1f days" % t) print(ephem.previous_solstice('2000')) print(ephem.next_solstice('2000')) print(ephem.previous_equinox('2000')) print(ephem.next_equinox('2000')) print(ephem.previous_vernal_equinox('2000')) print(ephem.next_vernal_equinox('2000'))
#!/usr/local/bin/python import sys import ephem sun = ephem.Sun() golgotha = ephem.Observer() golgotha.lat = 31.7811323 golgotha.lon = 35.2296886 golgotha.elevation = 2484 import enoch ve = ephem.next_vernal_equinox( '-5500' ) golgotha.date = int(ve) sr = golgotha.next_rising(sun) print ve print sr #sys.exit() for priest in enoch.Priests: print "priest: " + priest daysofweek=('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday') home = ephem.Observer() home.lat = 38.162881 home.lon = -122.266138 home.elevation = 46 d = "2000"
#!/usr/bin/env python import ephem from pprint import pprint try: range = xrange input = raw_input from itertools import izip as zip except NameError: pass mytups = [] for yr in range(1,4001): tup = ephem.next_vernal_equinox(str(yr)).tuple() if tup[3] == 0: tup2 = ephem.next_vernal_equinox(str(yr+4)).tuple() if tup2[3] != 0: mytups.append(tup) yrs = [tup[0] for tup in mytups] diffs = [(b,(b-a),tup[1:]) for a, b, tup in zip(yrs[:-1], yrs[1:], mytups[1:])] pprint(diffs)
if attribute == 1: print(Yin) elif attribute == 0: print(Yang) else: print('Error!') print(Num_of_Dun(3,0)) import datetime import dateutil.parser import ephem import time years = time.strftime('%Y',time.localtime(time.time())) xz = ephem.next_summer_solstice(years) dz = ephem.next_winter_solstice(years) cf = ephem.next_vernal_equinox(years) qf = ephem.next_autumnal_equinox(years) xz = str(xz) dz = str(dz) cf = str(cf) qf = str(qf) print('Now(UTC+8) ' + time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))) print('Summer_solstice GMT=' + xz) print('Winter_solstice GMT=' + dz) print('Vernal_equinox GMT=' + cf) print('Autumnal_equinox GMT=' + qf) def getDateTime(s): d = dateutil.parser.parse(s) return d print(getDateTime(xz) + datetime.timedelta(hours = 8)) print(getDateTime(dz) + datetime.timedelta(hours = 8))
#!/usr/local/bin/python import sys import ephem sun = ephem.Sun() golgotha = ephem.Observer() golgotha.lat = 31.7811323 golgotha.lon = 35.2296886 golgotha.elevation = 2484 import enoch ve = ephem.next_vernal_equinox('-5500') golgotha.date = int(ve) sr = golgotha.next_rising(sun) print ve print sr #sys.exit() for priest in enoch.Priests: print "priest: " + priest daysofweek = ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday') home = ephem.Observer() home.lat = 38.162881 home.lon = -122.266138 home.elevation = 46 d = "2000"