def indexInfo(self, index): """ Returns information about a specific planetary time. """ entry = self.table[index] info = { # Default is diurnal 'mode': 'Day', 'ruler': self.dayRuler(), 'dayRuler': self.dayRuler(), 'nightRuler': self.nightRuler(), 'hourRuler': entry[2], 'hourNumber': index + 1, 'tableIndex': index, 'start': Datetime.fromJD(entry[0], self.date.utcoffset), 'end': Datetime.fromJD(entry[1], self.date.utcoffset) } if index >= 12: # Set information as nocturnal info.update({ 'mode': 'Night', 'ruler': info['nightRuler'], 'hourNumber': index + 1 - 12 }) return info
def calculate_chart(date, time='17:00', utcoffset='+00:00', lat='55n45', lon='37e36'): """Calculates astrological chart based on a person's birth date, time and location. Using flatlib library. Args: bdate (str): with format `2015/03/13` time (str): with format `17:00` utcoffset (str): UTC Offset with format `+00:00` lat (str): latitude of birth location lon (str): longtitude of birth location Returns: chart (flatlib.chart.Chart): chart object with astrological information such as plantes positions and so on. """ # create flatlib.datetime object date = Datetime(date, time, utcoffset) # create flatlib.geopos object location = GeoPos('55n45', '37e36') # calculate chart chart = Chart(date, location, IDs=flatlib.const.LIST_OBJECTS) return chart
def prevLunarEclipse(date): """ Returns the Datetime of the maximum phase of the previous global lunar eclipse. """ eclipse = swe.lunarEclipseGlobal(date.jd, backward=True) return Datetime.fromJD(eclipse['maximum'], date.utcoffset)
def nextLunarEclipse(date): """ Returns the Datetime of the maximum phase of the next global lunar eclipse. """ eclipse = swe.lunarEclipseGlobal(date.jd, backward=False) return Datetime.fromJD(eclipse['maximum'], date.utcoffset)
def get_datastring(publish_date_text): publish_date = Datetime(publish_date_text, '00:00', '+00:00') list_obj = [publish_date_text] for obj in const.LIST_OBJECTS_TRADITIONAL: calculator = Chart(publish_date, pos).objects list_obj.append(kdfm.sign_dict[calculator.get(obj).sign]) list_obj.append(calculator.get(obj).lon) list_obj.append(calculator.get(obj).lat) return list_obj
def get_angle_on_day(self, o, day): global date, pos, chart, obj date = Datetime(day.strftime("%Y/%m/%d"), '00:00', '+00:00') pos = GeoPos(0, 0) chart = Chart(date, pos) obj = chart.get(o) if obj.sign != self.sign: return None return obj.signlon
def runAstroScript(dateString, timeString, location1String, location2String): # Here you call the functions you need to and parse the data into whatever format you need it in (maybe a dict) """Running flatlib script""" date = Datetime(dateString, timeString, '+00:00') pos = GeoPos(location1String, location2String) chart = Chart(date, pos, IDs=const.LIST_OBJECTS) # chart = Chart(date, pos, hsys=const.HOUSES_PLACIDUS) asc = chart.get(const.ASC) chart_dict = {} for obj in chart.objects: chart_dict.update({obj.id: obj.sign}) chart_dict.update({asc.id: asc.sign}) return ('{0}'.format(chart_dict))
def test_may_27_1991_in_cincinatti_at_07_15(self): date = Datetime('1991/05/27', '07:15', '-4:00') pos = GeoPos(39.1031, -84.5120) chart = Chart(date, pos) expected = { const.SUN: const.GEMINI, const.MOON: const.SCORPIO, const.MERCURY: const.TAURUS, const.VENUS: const.CANCER, const.MARS: const.LEO, const.ASC: const.GEMINI, } self._check_chart(chart, expected)
def test_july_30_1989_in_dallas_at_00_05(self): date = Datetime('1989/07/30', '00:05', '-05:00') pos = GeoPos(30.2643, -97.7139) chart = Chart(date, pos) expected = { const.SUN: const.LEO, const.MOON: const.CANCER, const.MERCURY: const.LEO, const.VENUS: const.VIRGO, const.MARS: const.LEO, const.ASC: const.ARIES, } self._check_chart(chart, expected)
def advancedview(): if flask.request.method == "POST": num = flask.request.form.get('choiceit') town = flask.request.form.get('town') country = flask.request.form.get('country') # print('num is:', num) if len(num) > 6: yy, mm, dd = num[:4], num[5:7], num[8:10] tiden = yy + '/' + mm + '/' + dd date = Datetime(tiden, '17:00', '+00:00') geo_coordinates = get_geo_cords(town, country) if not geo_coordinates: return flask.render_template("advanced.html", countries=countries, error="Could not find the city") g0, g1 = float(geo_coordinates[0]), float( geo_coordinates[1].replace('</span>', '')) pos = GeoPos(g0, g1) chart = Chart(date, pos, IDs=const.LIST_OBJECTS) sun = chart.getObject(const.SUN) # print("Your sun sign is: ",sun.sign) #zodiac sign # print("Your zodiac is explained as: ", explain_zodiac(sun.sign)) # print("Your sun movement is: ",sun.movement()) # print("Your sun element is: ",sun.element()) # print("Explained element:", explain_element(sun.element())) # print("Your sun faction is: ",sun.faction()) #print(chart.__dict__) #house is different depending on chart # for merp in const.LIST_HOUSES: # print(merp, 'sign is',chart.getHouse(merp).sign,'The condition is:',chart.getHouse(merp).condition()) # print("This is the",explain_house(merp).get("translated"), " the lating motto for it is '",explain_house(merp).get("Latin motto"),"' It's basicly means: ",explain_house(merp).get('explain')) ##print("Your sun element is: ",chart.getObject(const.SUN).figures()) moon = chart.get(const.MOON) # print("Your moon is in:", moon.sign) # print("Your moon movement is: ",moon.movement()) # print("Your moon element is: ",moon.element()) # print("Explained element:", explain_element(moon.element())) # print("Your moon faction is: ",moon.faction()) # print("Your moon phase:", chart.getMoonPhase()) return flask.render_template("advanced.html", moon=moon, sun=sun, const=const, explain_house=explain_house, chart=chart, explain_zodiac=explain_zodiac, explain_element=explain_element) return flask.render_template("advanced.html", countries=countries)
async def cmd_sun(message): l = message.content.split(' ') try: date = parse(l[1]) datetime = Datetime(date.strftime('%Y/%m/%d')) pos = GeoPos('00n00', '0w00') chart = Chart(datetime, pos) sun = str(chart.getObject(SUN)).split(' ')[1] await send_text( client, message.channel, "If you were born on %s, then you're a %s!" % (date.strftime('%B %d, %Y'), sun)) except Exception as e: logger.info(e) await send_text(client, message.channel, "Invalid date string")
def next_moon_ingress(chart): """ Calculates datetime of the next Moon ingress """ # Define the sign angles angles = [30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360] # Initate local variables # The next sign angle from the current moon position angle = 0.0 # Distance between the current Moon position and the next sign dist = 0.0 # Intiate iteration counter for statistical purposes i = 0 # Load the current Moon position moon_lon = swe.sweObjectLon(const.MOON, chart.date.jd) # Find the next sign angle for ang in angles: if moon_lon < ang: angle = ang dist = ang - moon_lon break # Evalute a mean time in days before the next Moon ingress jd = dist / const.MEAN_MOTION_MOON # Add the 'jd' into the the current Moon position jd = jd + chart.date.jd # Run the loop for calculating the ingress time while abs(dist) > MAX_ERROR: # Get Moon longtitude moon_lon = swe.sweObjectLon(const.MOON, jd) # Correct value of the moon's longtitude if ingress # to Aries if angle == 360 and moon_lon >= 0.0 and moon_lon < 30.0: moon_lon = moon_lon + 360.0 # Calcualte distance dist = angle - moon_lon # Calculate position differential jd = jd + dist / const.MEAN_MOTION_MOON i += 1 return {'Date': Datetime.fromJD(jd, '+00:00'), 'Iter': i}
def hgaresult(): if request.method == 'POST': result = request.form print(result) datelong = result['year']+"/"+result['month']+"/"+result['day'] hour = result['hour'] if result['ampm']=="PM": hour+=12 time = hour+":"+result['minute'] lat = result['latdegree']+result['lataxis']+result['latminute'] lon = result['londegree']+result['lonaxis']+result['lonminute'] DATE = Datetime(datelong, time, '+00:00') POS = GeoPos(lat, lon) aspects = Aspects(DATE,POS) zodiac = makeZodiac() signs = [[aspects.syzygy['sign'],str(aspects.syzygy['degree'])],[aspects.moon['sign'],str(aspects.moon['degree'])],[aspects.sun['sign'],str(aspects.sun['degree'])]] hebrew = makeName(zodiac, signs, 'hebrew') hebrewreverse = makeName(zodiac, signs, 'hebrewreverse') return render_template("hga.html",output=[hebrew,hebrewreverse])
def __init__(self, person): self.planets = {} self.houses = {} self.person = person self.date = Datetime(person.birth_date_str(), person.birth_time_str(), person.birth_utc_offset) self.pos = GeoPos(person.birth_lat, person.birth_lon) self.chart = Chart(self.date, self.pos, IDs=const.LIST_OBJECTS, hsys=const.HOUSES_PLACIDUS) for body in LIST_PLANETS: self.planets[body] = NatalPlanet(self.chart, body) for house in const.LIST_HOUSES: self.houses[house] = NatalHouse(self.chart, house)
def set_astrology_info(self): d = Datetime( f'{self.moon.datetime.year}/{self.moon.datetime.month}/{self.moon.datetime.day}', f'{self.moon.datetime.hour}:00', '+00:00') pos = GeoPos( '38n32', '8w54') #todo use a different location? this was in the docs self.chart = Chart(d, pos) self.moon_astrology_info = self.chart.get(const.MOON) self.moon_sign = self.moon_astrology_info.sign self.astrology_ascii_dict = astrology_dict["signs"][self.moon_sign] self.astrology_sign_random_emoji = choice( astrology_dict["signs"][self.moon_sign]["related"]) self.astrology_element_random_emoji = choice( astrology_dict["elements"][self.astrology_ascii_dict["element"]]) # get aspects of chart dyn = ChartDynamics(self.chart) self.aspects = dyn.validAspects(const.MOON, const.MAJOR_ASPECTS)
def in_day(year, month, day, hour, minute): """ Função retorna data thelemica de um dia e horário especifico :param year: Ano :param month: Mês :param day: Dia :param hour: Hora :param minute: Minuto :return: a data thelemica dos dados passados """ ev_in_day_weekday = date(year, month, day).weekday() ev_in_day_date = str(date(year, month, day).strftime('%Y/%m/%d')) ev_in_day_time = f'{hour}:{minute}' ev_in_day_na_year = int(year) - 1904 # New Aeon "generation" of 22 years ciclo_i = ev_in_day_na_year // 22 # // Years in the current cycle ciclo_ii = int(year) - 1904 - (ciclo_i * 22) # New Aeon year na_year = numerals[ciclo_ii].upper() + ':' + numerals[ciclo_i] na_date = Datetime(ev_in_day_date, ev_in_day_time, '-03:00') pos = GeoPos('23s39', '46w32') chart = Chart(na_date, pos) sun = chart.getObject(const.SUN) solis = str(sun).split(' ') solis_sign = solis[1] solis_arc = solis[2].split(':')[0].replace('+', '') moon = chart.get(const.MOON) luna = str(moon).split(' ') luna_sign = luna[1] luna_arc = luna[2].split(':')[0].replace('+', '') return (f'☉ in {solis_arc}º {signs[solis_sign]} ' f'☽ in {luna_arc}º {signs[luna_sign]} ' f'Dies {dies[ev_in_day_weekday]} ' f'Anno {na_year} æræ novæ')
def now(): """ Função não recebe parametros :return: a data thelemica atual """ # Era Vulgar Year ev_year = int(date.today().strftime('%Y')) # Whole Years since March Equinox 1904 ev_years_total = ev_year - 1904 # New Aeon "generation" of 22 years ciclo_i = ev_years_total // 22 # // Years in the current cycle ciclo_ii = ev_year - 1904 - (ciclo_i * 22) # New Aeon year na_year = numerals[ciclo_ii].upper() + ':' + numerals[ciclo_i] ev_weekday = date.today().weekday() ev_today = str(date.today().strftime('%Y/%m/%d')) ev_time = str(time.strftime('%H:%M')) na_date = Datetime(ev_today, ev_time, '-03:00') pos = GeoPos('23s39', '46w32') chart = Chart(na_date, pos) sun = chart.getObject(const.SUN) solis = str(sun).split(' ') solis_sign = solis[1] solis_arc = solis[2].split(':')[0].replace('+', '') moon = chart.get(const.MOON) luna = str(moon).split(' ') luna_sign = luna[1] luna_arc = luna[2].split(':')[0].replace('+', '') return (f'☉ in {solis_arc}º {signs[solis_sign]} ' f'☽ in {luna_arc}º {signs[luna_sign]} ' f'Dies {dies[ev_weekday]} ' f'Anno {na_year} æræ novæ')
async def cmd_chart(message): global TZWHERE_INST, GEOLOCATOR l = message.content.split(' ') date = parse(l[1]) time = parse(l[2]) pos = 3 if l[3].lower() == 'am': pos += 1 if l[3].lower() == 'pm': pos += 1 time.replace(hour=time.hour + 12) place = ' '.join(l[pos:]) location = GEOLOCATOR.geocode(place, addressdetails=True) timezone_str = TZWHERE_INST.tzNameAt(location.latitude, location.longitude) timezone = pytz.timezone(timezone_str) offset = str(timezone.utcoffset(date).total_seconds() / 60 / 60).replace( '.', ':') datetime = Datetime(date.strftime('%Y/%m/%d'), time.strftime('%H:%M'), offset) pos = GeoPos(location.latitude, location.longitude) chart = Chart(datetime, pos) response = ["%s, your chart is:" % (message.author.mention)] for const in LIST_OBJECTS: try: response += [ ' %s: %s' % (const, str(chart.getObject(const).sign)) ] except: pass try: url, img = get_chart_image(date, time, location, message) response += [url] response += [img] except Exception as e: logger.critical(e) response += ["Couldn't generate your image :/"] logger.info("Sending message: %s" % '\n'.join(response)) await send_text(client, message.channel, '\n'.join(response))
def get_calendar(start, end): dates = pd.date_range(start=start, end=end) calendar = [] for d in dates: date = Datetime(d.strftime("%Y/%m/%d"), '12:00', '+00:00') pos = GeoPos('51n23', '0w18') chart = Chart(date, pos) moon = chart.getObject(flc.MOON) sun = chart.getObject(flc.SUN) mercury = chart.getObject(flc.MERCURY) venus = chart.getObject(flc.VENUS) mars = chart.getObject(flc.MARS) calendar.append({ 'date': d, 'moon_lon': int(moon.lon), 'sun_lon': int(sun.lon), 'mercury_lon': int(mercury.lon), 'venus_lon': int(venus.lon), 'mars_lon': int(mars.lon) }) calendar = pd.DataFrame(calendar) return calendar
def lastSunrise(date, pos): """ Returns the date of the last sunrise. """ jd = eph.lastSunrise(date.jd, pos.lat, pos.lon) return Datetime.fromJD(jd, date.utcoffset)
def prevSolarReturn(date, lon): """ Returns the previous date when sun is at longitude 'lon'. """ jd = eph.prevSolarReturn(date.jd, lon) return Datetime.fromJD(jd, date.utcoffset)
def nextSolarReturn(date, lon): """ Returns the next date when sun is at longitude 'lon'. """ jd = eph.nextSolarReturn(date.jd, lon) return Datetime.fromJD(jd, date.utcoffset)
# chart = Chart(date, pos) # sun = chart.get(const.SUN) # print(sun) start_time = pd.to_datetime('1949/10/01') end_time = pd.to_datetime('2030/01/01') days = (end_time - start_time).days pos = GeoPos('30n42', '111e17') # Yichang from pandas.tseries.offsets import Day time_collection = [] saturn_collection = [] for timeslice in range(days): if timeslice % 7 == 0: current_day = start_time + Day(timeslice) date_string = current_day.date().strftime('%Y/%m/%d') date = Datetime(date_string, '00:00', '+08:00') chart = Chart(date, pos) if const.CAPRICORN ==chart.objects.content['Saturn'].sign \ or const.AQUARIUS ==chart.objects.content['Saturn'].sign \ or const.LIBRA==chart.objects.content['Saturn'].sign: saturn_status = 5 else: saturn_status = 0 time_collection.append(date_string) saturn_collection.append(saturn_status) print(date_string, chart.objects.content['Saturn'].sign) saturn_collection = np.array(saturn_collection) x_label = np.arange(len(saturn_collection)) # X label use time need test print('eof')
def nextSunset(date, pos): """ Returns the date of the next sunset. """ jd = eph.nextSunset(date.jd, pos.lat, pos.lon) return Datetime.fromJD(jd, date.utcoffset)
""" Author: João Ventura <*****@*****.**> This recipe shows sample code for computing the temperament protocol. """ from flatlib import const from flatlib.chart import Chart from flatlib.datetime import Datetime from flatlib.geopos import GeoPos from flatlib.protocols import behavior # Build a chart for a date and location date = Datetime('2015/03/13', '17:00', '+00:00') pos = GeoPos('38n32', '8w54') chart = Chart(date, pos) # Behavior factors = behavior.compute(chart) for factor in factors: print(factor)
import datetime import time from flatlib.datetime import Datetime from flatlib.geopos import GeoPos from flatlib.chart import Chart from flatlib import const from flatlib import aspects # Build a chart for a date and location data = datetime.datetime.utcnow() d = data.strftime('%Y/%m/%d') h = data.strftime('%H:%M:%S') date = Datetime(d, h) pos = GeoPos('38n43', '9w8') chart = Chart(date, pos) # Retrieve the Sun and Moon sun = chart.get(const.SUN) moon = chart.get(const.MOON) venus = chart.get(const.VENUS) # Get the aspect aspect1 = aspects.getAspect(sun, moon, const.MAJOR_ASPECTS) aspect2 = aspects.getAspect(sun, venus, const.ALL_ASPECTS) print(aspect1) print(aspect2xsc)
from MagicChart import MagicChart, ELEMENTS from flatlib.datetime import Datetime from flatlib.geopos import GeoPos from datetime import datetime, timedelta MOST = GeoPos('50n50', '13e64') ROZTOKY = GeoPos('50n17', '14e38') dNow = datetime.now() elmStarted = False elmStartD = dNow for d in (dNow + timedelta(minutes=1 * i) for i in range(60*24*60)): date = Datetime(d.__format__('%y/%m/%d'), d.__format__('%H:%M'), '+2:00') pos = GeoPos('50n50', '13e64') chart = MagicChart(date, ROZTOKY) for elm in ELEMENTS: if chart.canElement(elm): if not elmStarted: elmStarted = True elmStartD = d elmStart = elm else: if elmStarted and elm == elmStart: print('{:<10} {:02d}.{:02d}.{:04d} {:02d}:{:02d}-{:02d}:{:02d} ({:<3} min.)'.format( elm, elmStartD.day, elmStartD.month, elmStartD.year, elmStartD.hour, elmStartD.minute, d.hour, d.minute, (d - elmStartD).seconds//60
def nextStation(ID, date): """ Returns the aproximate date of the next station. """ jd = eph.nextStation(ID, date.jd) return Datetime.fromJD(jd, date.utcoffset)
This recipe shows sample code for handling solar returns. """ from flatlib import const from flatlib.chart import Chart from flatlib.datetime import Datetime from flatlib.geopos import GeoPos from flatlib.predictives import returns # Build a chart for a date and location date = Datetime('2013/06/13', '17:00', '+01:00') pos = GeoPos('38n32', '8w54') chart = Chart(date, pos) # Get the next solar return Chart given a date today = Datetime('2015/04/06', '10:40', '+01:00') srChart = returns.nextSolarReturn(chart, today) # Print the date and Asc asc = srChart.get(const.ASC) print(asc) # <Asc Taurus +26:25:47> print(srChart.date) # <2015/06/14 04:38:37 01:00:00> # Solar return of the year srChart = chart.solarReturn(2015) print(asc) # <Asc Taurus +26:25:47>
years = [elem[0] for elem in hdiff] hours = [elem[1] for elem in hdiff] plt.plot(years, hours) plt.ylabel('Hour distance') plt.xlabel('Year') plt.title(title) plt.axhline(y=-24, c='red') plt.show() # Set the birth date and time date = [1983, 3, 21] time = ['+', 0, 0, 0] # Get the sun position at birth dt = Datetime(date, time) pos = GeoPos('38n32', '8w54') sun = ephem.getObject(const.SUN, dt, pos) # Collect hour differences for the following 100 years hdiff = [] span = 100 for year in range(date[0], date[0] + 1 + span): # Get solar return of the year dt = Datetime('%s/01/01' % year, '00:00') sr = ephem.nextSolarReturn(dt, sun.lon) # Create anniversary date for the year date[0] = year an = Datetime(date, time)