Mercurial > hg > horiscopes
comparison V4/synastry.py @ 23:11d4e438045e
make version 5
author | DaveM |
---|---|
date | Mon, 09 Apr 2018 15:07:21 +0100 |
parents | a5b8e2b91d8f |
children |
comparison
equal
deleted
inserted
replaced
22:a5b8e2b91d8f | 23:11d4e438045e |
---|---|
9 | 9 |
10 class compatibility: | 10 class compatibility: |
11 def __init__(self): | 11 def __init__(self): |
12 self.rules = [] | 12 self.rules = [] |
13 self.uniqueID = 0 | 13 self.uniqueID = 0 |
14 print 'Warning, need to fix [Vertex, Ascendant House, None Location] issues' | 14 print 'Warning, need to fix [Vertex, Ascendant House, South Node, IC/MC and None Location] issues' |
15 | 15 |
16 def addRule(self,planetTuple,aspectList,score): | 16 def addRule(self,planetTuple,aspectList,score): |
17 rule = compatibilityRule(self.uniqueID,planetTuple,aspectList,score) | 17 rule = compatibilityRule(self.uniqueID,planetTuple,aspectList,score) |
18 self.rules.append(rule) | 18 self.rules.append(rule) |
19 self.uniqueID += 1 | 19 self.uniqueID += 1 |
34 return text | 34 return text |
35 | 35 |
36 def parseCompatRules(self,filename): | 36 def parseCompatRules(self,filename): |
37 comList = self.readFile(filename) | 37 comList = self.readFile(filename) |
38 for com in comList: | 38 for com in comList: |
39 # print com | |
40 planetTuple = None | |
41 aspectList = None | |
42 score = None | |
39 c = com.split(',') | 43 c = com.split(',') |
40 if len(c) == 4: | 44 if len(c) == 4: |
41 if len(c[1]) > 1: | 45 if len(c[1]) > 1: |
42 aspectList = [] | 46 aspectList = [] |
43 planetTuple = tuple(sorted((c[0].lower(),c[2].lower()))) | 47 planetTuple = tuple((c[0].lower(),c[2].lower())) |
44 score = int(c[3]) | 48 score = int(c[3]) |
45 for subset in c[1].split(' '): | 49 for subset in c[1].lower().split(' '): |
46 aspectList.append(subset) | 50 aspectList.append(subset) |
47 elif len(c[1]) == 0 : | 51 elif len(c[1]) == 0 : |
48 if 'house' not in c[2]: | 52 if 'house' not in c[2]: |
49 print 'some error where rule is not house' | 53 print 'some error where rule is not house' |
50 planetTuple = (c[0].lower(),'house') | 54 planetTuple = (c[0].lower(),'house') |
51 houseNo = re.findall('\d+', c[2]) | 55 houseNo = re.findall('\d+', c[2]) |
52 if len(houseNo) != 1: | 56 if len(houseNo) != 1: |
53 print 'multiple house numbers found - ERROR' | 57 print 'multiple house numbers found - ERROR' |
54 aspectList = int(houseNo[0]) | 58 aspectList = int(houseNo[0]) |
55 score = int(c[3]) | 59 score = int(c[3]) |
56 self.addRule(planetTuple,aspectList,score) | 60 self.addRule(planetTuple,aspectList,score) |
57 | 61 |
58 def calcCompatibility(self, horiscope): | 62 def calcCompatibility(self, horiscope): |
59 score = 0 | 63 score = 0 |
60 for r in self.rules: | 64 for r in sorted(self.rules): |
61 if 'vertex' in r.planet: | 65 if 'vertex' in r.planet: |
62 # print 'ERROR - catch Vertex issue' | 66 # print 'ERROR - catch Vertex issue' |
63 pass | 67 pass |
68 elif 'southnode' in r.planet: | |
69 # print 'ERROR - catch South Node issue' | |
70 pass | |
71 # elif 'ic/mc' in r.planet: | |
72 # # print 'ERROR - catch IC/MC issue' | |
73 # pass | |
64 elif r.planet[1] == 'house' and r.planet[0] == 'asc': | 74 elif r.planet[1] == 'house' and r.planet[0] == 'asc': |
65 # print 'ERROR - catch Ascendant House issue' | 75 # print 'ERROR - catch Ascendant House issue' |
66 pass | 76 pass |
67 elif horiscope.planets[r.planet[0]].angleA is None: | 77 elif horiscope.planets[r.planet[0]].angleA is None: |
68 # print 'Error - None Location' | 78 # print 'Error - None Location' |
69 return None | 79 return None |
70 elif r.planet[1] == 'house': | 80 elif r.planet[1] == 'house': |
71 if horiscope.isInHouse(r.planet[0],r.aspect): | 81 if horiscope.isInHouse(r.planet[0],r.aspect): |
72 score += r.score | 82 score += r.score |
73 else: | 83 print r.planet[0] +' '+ r.planet[1] +' '+ str(aspect)+' '+str(r.score) |
74 # print 'query standard synastry' | 84 # print r.planet,r.aspect,r.score,score |
85 elif r.planet[0] == r.planet[1]: | |
75 aspect,variance = horiscope.calcAspect(r.planet[0],r.planet[1]) | 86 aspect,variance = horiscope.calcAspect(r.planet[0],r.planet[1]) |
76 if aspect is not None: | 87 if aspect is not None: |
77 if aspect in r.aspect: | 88 if aspect in r.aspect: |
78 score += r.score | 89 score += r.score |
90 print r.planet[0]+' '+aspect +' '+ r.planet[1] +' '+ str(r.score) | |
91 # print r.planet,r.aspect,aspect,r.score,score | |
92 else: | |
93 # print 'query standard synastry' | |
94 for order in [0,1]: | |
95 # print order,not order | |
96 # print r.planet[order],r.planet[not order] | |
97 aspect,variance = horiscope.calcAspect(r.planet[order],r.planet[not order]) | |
98 if aspect is not None: | |
99 # print aspect | |
100 # currentR = r | |
101 # pdb.set_trace() | |
102 if aspect in r.aspect: | |
103 score += r.score | |
104 print r.planet[0] +' '+ aspect +' '+ r.planet[1] +' '+ str(r.score) | |
105 # print r.planet,r.aspect,aspect,r.score,score | |
106 # else: | |
107 # print r.planet,r.aspect,aspect,0,score | |
108 print score | |
79 return score | 109 return score |
80 | 110 |
81 | 111 |
82 | 112 |
83 | 113 |
249 self.angleA = random.random()*360 | 279 self.angleA = random.random()*360 |
250 self.angleB = random.random()*360 | 280 self.angleB = random.random()*360 |
251 | 281 |
252 | 282 |
253 class planetPositions: | 283 class planetPositions: |
254 aspectDict = {'conjunction':0,'semi-square':45,'sextile':60,'square':90,'trine':120,'opposite':180} | 284 aspectDict = {'conjunction':0,'semi-square':45,'sextile':60,'square':90,'trine':120,'opposition':180} |
255 # zodiacAngle = {'aries':0,'taurus':30,'gemini':60,'cancer':90,'leo':120,'virgo':150,'libra':180,'scorpio':210,'sagittarius':240,'capricorn':270,'aquarius':300,'pisces':330} | 285 # zodiacAngle = {'aries':0,'taurus':30,'gemini':60,'cancer':90,'leo':120,'virgo':150,'libra':180,'scorpio':210,'sagittarius':240,'capricorn':270,'aquarius':300,'pisces':330} |
256 # Taken from https://en.wikipedia.org/wiki/Astrological_sign, with reference from https://en.wikipedia.org/wiki/Astrological_symbols#Signs_of_the_zodiac | 286 # Taken from https://en.wikipedia.org/wiki/Astrological_sign, with reference from https://en.wikipedia.org/wiki/Astrological_symbols#Signs_of_the_zodiac |
257 planetNames = ['sun','moon','mercury','venus','mars','jupiter','saturn','uranus','neptune','pluto','node','lilith','chiron','asc','ic','dsc','mc','asc/mc','sun/moon'] | 287 planetNames = ['sun','moon','mercury','venus','mars','jupiter','saturn','uranus','neptune','pluto','node','lilith','chiron','asc','ic','dsc','mc','asc/mc','sun/moon'] |
258 def __init__(self): | 288 def __init__(self): |
259 self.planets = {} | 289 self.planets = {} |