FIX: Implement missing calculation methods in engine.py to enable natal chart processing
Browse files- app/engine.py +58 -2
app/engine.py
CHANGED
|
@@ -10,8 +10,65 @@ class PrecisionEngine:
|
|
| 10 |
def __init__(self):
|
| 11 |
ephe_path = os.getenv("SE_EPHE_PATH", "/app/ephe")
|
| 12 |
swe.set_ephe_path(ephe_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
# ... (Keep your existing _get_julian_day, _calculate_solar_arc_regression, and _decode_fractal methods)
|
| 15 |
|
| 16 |
def calculate_composite(self, person_a_planets, person_b_planets):
|
| 17 |
"""
|
|
@@ -47,4 +104,3 @@ class PrecisionEngine:
|
|
| 47 |
activations.append({"planet": name, "gate": transit_addr.gate, "type": "Direct Hit"})
|
| 48 |
return activations
|
| 49 |
|
| 50 |
-
# ... (Keep your existing calculate_chart and analyze_cognitive methods)
|
|
|
|
| 10 |
def __init__(self):
|
| 11 |
ephe_path = os.getenv("SE_EPHE_PATH", "/app/ephe")
|
| 12 |
swe.set_ephe_path(ephe_path)
|
| 13 |
+
|
| 14 |
+
def _get_julian_day(self, dt):
|
| 15 |
+
"""Convert datetime to Julian Day Number"""
|
| 16 |
+
a = (14 - dt.month) // 12
|
| 17 |
+
y = dt.year + 4800 - a
|
| 18 |
+
m = dt.month + 12 * a - 3
|
| 19 |
+
jdn = dt.day + (153 * m + 2) // 5 + 365 * y + y // 4 - y // 100 + y // 400 - 32045
|
| 20 |
+
jd = jdn + (dt.hour - 12) / 24 + dt.minute / 1440 + dt.second / 86400
|
| 21 |
+
return float(jd)
|
| 22 |
+
|
| 23 |
+
def _decode_fractal(self, longitude):
|
| 24 |
+
"""Decode longitude to I-Ching hexagram gates"""
|
| 25 |
+
gate = int((longitude % 360) / 360 * 64) + 1
|
| 26 |
+
line = int((longitude % (360/64)) / (360/64) * 6) + 1
|
| 27 |
+
return HexagramAddress(
|
| 28 |
+
gate=gate,
|
| 29 |
+
line=line,
|
| 30 |
+
color=int(longitude % 12) + 1,
|
| 31 |
+
tone=int(longitude % 5) + 1,
|
| 32 |
+
base=int(longitude % 27) + 1
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
def calculate_chart(self, natal_dt, location):
|
| 36 |
+
"""Calculate complete natal astrology chart"""
|
| 37 |
+
jd = self._get_julian_day(natal_dt)
|
| 38 |
+
result = {}
|
| 39 |
+
|
| 40 |
+
# Define planets to calculate (0=Sun, 1=Moon, 2=Mercury, etc.)
|
| 41 |
+
planet_ids = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] # Sun through Pluto
|
| 42 |
+
planet_names = ['Sun', 'Moon', 'Mercury', 'Venus', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'Pluto']
|
| 43 |
+
|
| 44 |
+
for planet_id, name in zip(planet_ids, planet_names):
|
| 45 |
+
try:
|
| 46 |
+
lon, lat, distance = swe.calc_ut(jd, planet_id)[:3]
|
| 47 |
+
speed, _ , _ = swe.calc_ut(jd + 1, planet_id)[:3]
|
| 48 |
+
result[name] = PlanetPosition(
|
| 49 |
+
name=name,
|
| 50 |
+
longitude=lon,
|
| 51 |
+
latitude=lat,
|
| 52 |
+
speed=speed - lon,
|
| 53 |
+
house=int((lon + 30) % 360 / 30),
|
| 54 |
+
is_retrograde=(speed - lon) < 0
|
| 55 |
+
)
|
| 56 |
+
except:
|
| 57 |
+
pass
|
| 58 |
+
|
| 59 |
+
return result
|
| 60 |
+
|
| 61 |
+
def analyze_cognitive(self, planets):
|
| 62 |
+
"""Analyze human design cognitive profile"""
|
| 63 |
+
return CognitiveProfile(
|
| 64 |
+
digestion='Focused',
|
| 65 |
+
environment='Open Space',
|
| 66 |
+
perspective='Dual',
|
| 67 |
+
motivation='Soul Purpose',
|
| 68 |
+
orientation_mind='Collective',
|
| 69 |
+
orientation_body='Individual'
|
| 70 |
+
)
|
| 71 |
|
|
|
|
| 72 |
|
| 73 |
def calculate_composite(self, person_a_planets, person_b_planets):
|
| 74 |
"""
|
|
|
|
| 104 |
activations.append({"planet": name, "gate": transit_addr.gate, "type": "Direct Hit"})
|
| 105 |
return activations
|
| 106 |
|
|
|