2020-05-14 22:04:13 +02:00
|
|
|
import time
|
2020-05-15 14:16:32 +02:00
|
|
|
import math
|
2020-05-14 22:04:13 +02:00
|
|
|
import swisseph as swe
|
|
|
|
|
import drawSvg as svg
|
|
|
|
|
from openlocationcode import openlocationcode as olc
|
|
|
|
|
|
2020-05-15 14:16:32 +02:00
|
|
|
def planetaryMoment(lat, lon, epoch): # calculate planetary ephemeris + ascendant according to location and timestamp
|
|
|
|
|
|
2020-05-14 22:04:13 +02:00
|
|
|
planets = [0,1,2,3,4,5,6]
|
|
|
|
|
tmp = time.gmtime(epoch) # convert epoch to time
|
|
|
|
|
hours = tmp.tm_hour + tmp.tm_min / 60 + tmp.tm_sec / 3600 # convert hh:mm:ss to decimal hours
|
|
|
|
|
jd = swe.julday(tmp.tm_year,tmp.tm_mon,tmp.tm_mday,hours,1) # convert to Julian day
|
|
|
|
|
te = jd + swe.deltat(jd) # add deltaT
|
2020-05-15 14:16:32 +02:00
|
|
|
|
2020-05-14 22:04:13 +02:00
|
|
|
# get ecliptic planet locations
|
|
|
|
|
for i in range(len(planets)):
|
|
|
|
|
planets[i] = swe.calc(te, i)
|
2020-05-15 14:16:32 +02:00
|
|
|
|
2020-05-14 22:04:13 +02:00
|
|
|
# clean up
|
|
|
|
|
for i in range(len(planets)):
|
|
|
|
|
planets[i] = planets[i][0][0]
|
2020-05-15 14:16:32 +02:00
|
|
|
|
2020-05-14 22:04:13 +02:00
|
|
|
cusps = swe.houses_ex(jd, lat, lon, b'P',0) # get ecliptic ascendant degree
|
|
|
|
|
planets.insert(0, cusps[0][0])
|
2020-05-15 14:16:32 +02:00
|
|
|
|
2020-05-14 22:04:13 +02:00
|
|
|
return planets
|
|
|
|
|
|
2020-05-15 14:16:32 +02:00
|
|
|
def locationSigil(plusCode, planets, canvas): # draw arcs depending on planetary positions at the moment in time
|
|
|
|
|
|
|
|
|
|
colors = ['violet', 'yellow', 'white', 'orange', 'green', 'red', 'royalblue', 'indigo'] # black inner circle for ascendant and planetary colors
|
|
|
|
|
|
2020-05-14 22:04:13 +02:00
|
|
|
# draw rings for ascendant + planets and keep a small gap at the ecliptic degrees they are in
|
|
|
|
|
for i in range(len(planets)):
|
|
|
|
|
circleColor = colors[i]
|
2020-05-15 14:16:32 +02:00
|
|
|
# circleColor = 'grey'
|
2020-05-14 22:04:13 +02:00
|
|
|
degree = planets[i]
|
2020-05-15 14:16:32 +02:00
|
|
|
startArc = degree + 90 # 0° is at the 12 o'clock position
|
|
|
|
|
endArc = degree - 110 + 90
|
2020-05-14 22:04:13 +02:00
|
|
|
radius = 180 + i * 10
|
2020-05-15 14:16:32 +02:00
|
|
|
canvas.append(svg.ArcLine(0, 0, radius, startArc, endArc, stroke=circleColor, stroke_width=7, fill='none'))
|
|
|
|
|
|
2020-05-14 22:04:13 +02:00
|
|
|
codeList = list(plusCode.replace('+', '')) # remove the + in the string
|
2020-05-15 14:16:32 +02:00
|
|
|
|
|
|
|
|
#draw global area sigil
|
|
|
|
|
arrow2 = svg.Marker(-0.5, -0.5, 0.5, 0.5, scale=5, orient='auto') # define line to terminate the sigil
|
|
|
|
|
arrow2.append(svg.Line(-0., -0.5, 0., 0.5, stroke_width=0.2, stroke='red'))
|
|
|
|
|
dot2 = svg.Marker(-0.5, -0.5, 0.5, 0.5, scale=5, orient='auto') # define circle to start the sigil
|
|
|
|
|
dot2.append(svg.Circle(0.0, 0.0, 0.4, stroke_width=0.2, stroke='red'))
|
|
|
|
|
# set up sigil path
|
|
|
|
|
p = svg.Path(stroke_width=7, stroke='red', fill='none', marker_start=dot2, marker_end=arrow2)
|
|
|
|
|
# draw sigil
|
|
|
|
|
drawGlobalSigil(codeList, p, 4)
|
|
|
|
|
canvas.append(p)
|
|
|
|
|
|
|
|
|
|
del codeList[0:4] # delete area code from list
|
|
|
|
|
|
|
|
|
|
#draw local fractal sigil
|
|
|
|
|
arrow = svg.Marker(-0.5, -0.5, 0.5, 0.5, scale=5, orient='auto') # define line to terminate the sigil
|
|
|
|
|
arrow.append(svg.Line(-0., -0.5, 0., 0.5, stroke_width=0.2, stroke='white'))
|
|
|
|
|
dot = svg.Marker(-0.5, -0.5, 0.5, 0.5, scale=5, orient='auto') # define circle to start the sigil
|
|
|
|
|
dot.append(svg.Circle(0.0, 0.0, 0.4, stroke_width=0.2, stroke='white'))
|
|
|
|
|
# set up sigil path
|
|
|
|
|
p = svg.Path(stroke_width=7, stroke='white', fill='none', marker_start=dot, marker_end=arrow)
|
|
|
|
|
# draw sigil
|
|
|
|
|
drawLocalSigil(codeList, p, 5)
|
|
|
|
|
canvas.append(p)
|
|
|
|
|
|
|
|
|
|
def drawLocalSigil(points, p, length): # draw sigil based on OLC magic square
|
2020-05-14 22:04:13 +02:00
|
|
|
grid = {
|
|
|
|
|
'R' : [-103, 112], 'V' : [-35, 112], 'W' : [35, 112], 'X' : [103, 112], # | R | V | W | X |
|
|
|
|
|
'J' : [-103, 56], 'M' : [-35, 56], 'P' : [35, 56], 'Q' : [103, 56], # | J | M | P | Q |
|
|
|
|
|
'C' : [-103, 0], 'F' : [-35, 0], 'G' : [35, 0], 'H' : [103, 0], # | C | F | G | H |
|
|
|
|
|
'6' : [-103, -56], '7' : [-35, -56], '8' : [35, -56], '9' : [103, -56], # | 6 | 7 | 8 | 9 |
|
|
|
|
|
'2' : [-103, -112], '3' : [-35, -112], '4' : [35, -112], '5' : [103, -112] # | 2 | 3 | 4 | 5 |
|
|
|
|
|
}
|
|
|
|
|
# get the starting point
|
2020-05-15 14:16:32 +02:00
|
|
|
originX = grid[points[0]][0]
|
|
|
|
|
originY = grid[points[0]][1]
|
2020-05-14 22:04:13 +02:00
|
|
|
p.M(originX, originY)
|
2020-05-15 14:16:32 +02:00
|
|
|
del points[0] # delete starting point from list
|
|
|
|
|
for c in range(length):
|
|
|
|
|
x = grid[points[c]][0] - originX # abs. to rel. coords
|
|
|
|
|
y = grid[points[c]][1] - originY # abs. to rel. coords
|
2020-05-14 22:04:13 +02:00
|
|
|
p.l(x, y) # draw
|
2020-05-15 14:16:32 +02:00
|
|
|
originX = grid[points[c]][0]
|
|
|
|
|
originY = grid[points[c]][1]
|
|
|
|
|
|
|
|
|
|
def drawGlobalSigil(points, p, length): # draw sigil based on concentric circle positions
|
2020-05-14 22:04:13 +02:00
|
|
|
|
2020-05-15 14:16:32 +02:00
|
|
|
decoder = ['2', '3', '4', '5', '6', '7', '8', '9', 'C', 'F', 'G', 'H', 'J', 'M', 'P', 'Q', 'R', 'V', 'W', 'X']
|
2020-05-14 22:04:13 +02:00
|
|
|
|
2020-05-15 14:16:32 +02:00
|
|
|
for c in range(length):
|
|
|
|
|
index = decoder.index(points[c])
|
|
|
|
|
|
|
|
|
|
# find coordinates on circle every 18° (360° / 20 digits)
|
|
|
|
|
radius = 150 - c * 20
|
|
|
|
|
angle = 18 * index
|
|
|
|
|
x = radius * math.cos(angle)
|
|
|
|
|
y = radius * math.sin(angle)
|
|
|
|
|
|
|
|
|
|
if c == 0:
|
|
|
|
|
p.M(x,y) # starting point
|
|
|
|
|
originX = x
|
|
|
|
|
originY = y
|
|
|
|
|
else:
|
|
|
|
|
p.l(x - originX, y - originY) # draw
|
|
|
|
|
originX = x
|
|
|
|
|
originY = y
|
|
|
|
|
|
2020-05-14 22:04:13 +02:00
|
|
|
def main():
|
2020-05-15 14:16:32 +02:00
|
|
|
|
|
|
|
|
lat = 37.223187
|
|
|
|
|
lon = 38.922438
|
2020-05-14 22:04:13 +02:00
|
|
|
epoch = time.time() # now
|
2020-05-15 14:16:32 +02:00
|
|
|
|
|
|
|
|
# calculate OLC and ephemeris
|
|
|
|
|
plusCode = olc.encode(lat,lon,10) # generate Open Location Code aka. plus code from coordinates
|
2020-05-14 22:04:13 +02:00
|
|
|
planets = planetaryMoment(lat, lon, epoch) # generate planetary ephemeris
|
2020-05-15 14:16:32 +02:00
|
|
|
|
|
|
|
|
# set up SVG canvas
|
|
|
|
|
d = svg.Drawing(600, 600, origin='center', displayInline=False) # define canvas
|
|
|
|
|
d.append(svg.Circle(0, 0, 260, fill='black', stroke_width=0))
|
|
|
|
|
|
|
|
|
|
# draw sigil
|
|
|
|
|
locationSigil(plusCode, planets, d) # draw sigil SVG
|
|
|
|
|
|
|
|
|
|
# save sigil to SVG file
|
|
|
|
|
fileName = '%s-%s.svg' % (plusCode, epoch)
|
|
|
|
|
fileName = 'test.svg'
|
|
|
|
|
d.saveSvg(fileName)
|
2020-05-14 22:04:13 +02:00
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|