Spaces:
Sleeping
Sleeping
Update astro_core.py
Browse files- astro_core.py +20 -7
astro_core.py
CHANGED
|
@@ -10,14 +10,22 @@ from typing import Dict, Any
|
|
| 10 |
from flatlib.datetime import Datetime
|
| 11 |
from flatlib.geopos import GeoPos
|
| 12 |
from flatlib.chart import Chart
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
class ChartCalculator:
|
| 16 |
"""Handles astrological calculations"""
|
| 17 |
|
| 18 |
def __init__(self):
|
| 19 |
-
self.planets = [
|
| 20 |
-
|
|
|
|
|
|
|
| 21 |
|
| 22 |
def _get_house_number(self, lon: float, chart: Chart) -> int:
|
| 23 |
"""
|
|
@@ -44,6 +52,13 @@ class ChartCalculator:
|
|
| 44 |
"""Normalize longitude to 0-360 range"""
|
| 45 |
return lon % 360
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
def calculate_birth_chart(self,
|
| 48 |
birth_datetime: datetime,
|
| 49 |
latitude: float,
|
|
@@ -75,8 +90,7 @@ class ChartCalculator:
|
|
| 75 |
lon = self._normalize_longitude(obj.lon)
|
| 76 |
|
| 77 |
# Get sign
|
| 78 |
-
|
| 79 |
-
sign = LIST_SIGNS[sign_num]
|
| 80 |
|
| 81 |
# Get house
|
| 82 |
house = self._get_house_number(lon, chart)
|
|
@@ -101,9 +115,8 @@ class ChartCalculator:
|
|
| 101 |
house = chart.houses.get(i)
|
| 102 |
if house:
|
| 103 |
lon = self._normalize_longitude(house.lon)
|
| 104 |
-
sign_num = int(lon / 30)
|
| 105 |
houses[f'House_{i}'] = {
|
| 106 |
-
'sign':
|
| 107 |
'degrees': lon
|
| 108 |
}
|
| 109 |
except Exception as e:
|
|
|
|
| 10 |
from flatlib.datetime import Datetime
|
| 11 |
from flatlib.geopos import GeoPos
|
| 12 |
from flatlib.chart import Chart
|
| 13 |
+
|
| 14 |
+
# Define our own constants
|
| 15 |
+
ZODIAC_SIGNS = [
|
| 16 |
+
'Aries', 'Taurus', 'Gemini', 'Cancer',
|
| 17 |
+
'Leo', 'Virgo', 'Libra', 'Scorpio',
|
| 18 |
+
'Sagittarius', 'Capricorn', 'Aquarius', 'Pisces'
|
| 19 |
+
]
|
| 20 |
|
| 21 |
class ChartCalculator:
|
| 22 |
"""Handles astrological calculations"""
|
| 23 |
|
| 24 |
def __init__(self):
|
| 25 |
+
self.planets = [
|
| 26 |
+
'Sun', 'Moon', 'Mercury', 'Venus', 'Mars',
|
| 27 |
+
'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'Pluto'
|
| 28 |
+
]
|
| 29 |
|
| 30 |
def _get_house_number(self, lon: float, chart: Chart) -> int:
|
| 31 |
"""
|
|
|
|
| 52 |
"""Normalize longitude to 0-360 range"""
|
| 53 |
return lon % 360
|
| 54 |
|
| 55 |
+
def _get_zodiac_sign(self, longitude: float) -> str:
|
| 56 |
+
"""
|
| 57 |
+
Get zodiac sign from longitude
|
| 58 |
+
"""
|
| 59 |
+
sign_num = int(self._normalize_longitude(longitude) / 30)
|
| 60 |
+
return ZODIAC_SIGNS[sign_num]
|
| 61 |
+
|
| 62 |
def calculate_birth_chart(self,
|
| 63 |
birth_datetime: datetime,
|
| 64 |
latitude: float,
|
|
|
|
| 90 |
lon = self._normalize_longitude(obj.lon)
|
| 91 |
|
| 92 |
# Get sign
|
| 93 |
+
sign = self._get_zodiac_sign(lon)
|
|
|
|
| 94 |
|
| 95 |
# Get house
|
| 96 |
house = self._get_house_number(lon, chart)
|
|
|
|
| 115 |
house = chart.houses.get(i)
|
| 116 |
if house:
|
| 117 |
lon = self._normalize_longitude(house.lon)
|
|
|
|
| 118 |
houses[f'House_{i}'] = {
|
| 119 |
+
'sign': self._get_zodiac_sign(lon),
|
| 120 |
'degrees': lon
|
| 121 |
}
|
| 122 |
except Exception as e:
|