import time import swisseph as swe import drawSvg as svg from openlocationcode import openlocationcode as olc def planetaryMoment(lat, lon, epoch): 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 # get ecliptic planet locations for i in range(len(planets)): planets[i] = swe.calc(te, i) # clean up for i in range(len(planets)): planets[i] = planets[i][0][0] cusps = swe.houses_ex(jd, lat, lon, b'P',0) # get ecliptic ascendant degree planets.insert(0, cusps[0][0]) return planets def locationSigil(lat, lon, planets): # draw arcs depending on planetary positions at the moment in time colors = ['black', 'yellow', 'grey', 'orange', 'green', 'red', 'blue', 'black'] # black inner circle for ascendant and planetary colors d = svg.Drawing(600, 600, origin='center', displayInline=False) # define canvas # 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] degree = planets[i] startArc = degree + 1 + 90 # 0° is at the 12 o'clock position endArc = degree - 1 + 90 radius = 180 + i * 10 d.append(svg.ArcLine(0, 0, radius, startArc, endArc, stroke=circleColor, stroke_width=5, fill='none')) # draw sigil based on location plusCode = olc.encode(lat,lon,10) # generate Open Location Code aka. plus code from coordinates codeList = list(plusCode.replace('+', '')) # remove the + in the string # grid for 2dimensional representation of the plus code letters 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 | } #draw area code as red polygon p = svg.Path(stroke_width=5, stroke='red', fill='red') # get the starting point originX = grid[codeList[0]][0] originY = grid[codeList[0]][1] p.M(originX, originY) del codeList[0] # delete starting point from list # for all remaining points draw from point to point for c in range(3): x = grid[codeList[c]][0] - originX # absolute to relative coords y = grid[codeList[c]][1] - originY # abs. to rel. coords p.l(x, y) # draw originX = grid[codeList[c]][0] originY = grid[codeList[c]][1] p.Z() # close the lines to starting point d.append(p) del codeList[0:3] # delete area code from list #draw address arrow = svg.Marker(-0.1, -0.5, 0.9, 0.5, scale=4, orient='auto') # define arrow to terminate the sigil arrow.append(svg.Line(-0.5, 0.3, 0.1, 0.3, stroke_width=2, stroke='black')) p = svg.Path(stroke_width=5, stroke='black', fill='none', marker_end=arrow) # get the starting point originX = ogx = grid[codeList[0]][0] originY = ogy = grid[codeList[0]][1] p.M(originX, originY) del codeList[0] # delete starting point from list for c in range(len(codeList)): x = grid[codeList[c]][0] - originX # abs. to rel. coords y = grid[codeList[c]][1] - originY # abs. to rel. coords p.l(x, y) # draw originX = grid[codeList[c]][0] originY = grid[codeList[c]][1] d.append(p) d.append(svg.Circle(ogx, ogy, 10, fill='white', stroke_width=5, stroke='black')) # draw circle to beginning fileName = '%s.svg' % (plusCode) d.saveSvg(fileName) def main(): lat = 55.753687 lon = 37.619938 epoch = time.time() # now planets = planetaryMoment(lat, lon, epoch) # generate planetary ephemeris locationSigil(lat,lon, planets) # draw sigil SVG if __name__ == "__main__": main()