cryogenic22 commited on
Commit
3944ead
·
verified ·
1 Parent(s): 14146bb

Update astro_core.py

Browse files
Files changed (1) hide show
  1. astro_core.py +2 -17
astro_core.py CHANGED
@@ -18,7 +18,6 @@ class ChartCalculator:
18
  """Handles astrological calculations"""
19
 
20
  def __init__(self):
21
- # List of planets, including modern ones like Uranus, Neptune, and Pluto
22
  self.planets = [
23
  'Sun', 'Moon', 'Mercury', 'Venus', 'Mars',
24
  'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'Pluto'
@@ -43,28 +42,19 @@ class ChartCalculator:
43
  Returns a dictionary of planetary positions and house cusps
44
  """
45
  try:
46
- # Handle timezone
47
  tz = zoneinfo.ZoneInfo(timezone)
48
  birth_datetime = birth_datetime.replace(tzinfo=tz)
49
  utc_offset = int(birth_datetime.utcoffset().total_seconds() / 3600)
50
 
51
- # Adjust to UTC
52
  adjusted_datetime = birth_datetime - timedelta(hours=utc_offset)
53
  date_str = adjusted_datetime.strftime('%Y/%m/%d')
54
  time_str = adjusted_datetime.strftime('%H:%M')
55
 
56
- # Debugging: Log inputs to the chart
57
- print(f"Date: {date_str}, Time: {time_str}, UTC Offset: {utc_offset}")
58
- print(f"Geo Position - Latitude: {latitude}, Longitude: {longitude}")
59
-
60
- # Create flatlib datetime and position
61
  date = Datetime(date_str, time_str, utc_offset)
62
  pos = GeoPos(latitude, longitude)
63
 
64
- # Generate the chart
65
  chart = Chart(date, pos)
66
 
67
- # Extract planetary positions
68
  positions = {}
69
  for planet in self.planets:
70
  try:
@@ -84,7 +74,6 @@ class ChartCalculator:
84
  'error': f"Error calculating {planet}: {str(e)}"
85
  }
86
 
87
- # Extract house cusps
88
  houses = {}
89
  for i in range(1, 13):
90
  try:
@@ -123,26 +112,22 @@ class ChartCalculator:
123
  ax.set_theta_zero_location("S")
124
  ax.set_theta_direction(-1)
125
 
126
- # Draw zodiac signs
127
- zodiac_angles = np.linspace(0, 2 * np.pi, 13) # 12 zodiac signs
128
  for i, sign in enumerate(ZODIAC_SIGNS):
129
  angle = zodiac_angles[i]
130
  ax.text(angle, 1.05, sign, ha='center', va='center', fontsize=10)
131
 
132
- # Draw houses
133
- house_angles = np.linspace(0, 2 * np.pi, 13) # 12 houses
134
  for i in range(1, 13):
135
  angle = house_angles[i - 1]
136
  ax.text(angle, 0.8, f"H{i}", ha='center', va='center', fontsize=10)
137
 
138
- # Plot planets
139
  for planet, data in chart_data['planets'].items():
140
  if 'error' not in data:
141
  degrees = data['degrees']
142
  angle = np.deg2rad(degrees)
143
  ax.plot([angle], [0.5], marker='o', label=planet, markersize=10)
144
 
145
- # Draw the chart
146
  ax.legend(loc='upper right', bbox_to_anchor=(1.3, 1))
147
  plt.title("Astrology Chart", va='bottom', fontsize=15)
148
  plt.show()
 
18
  """Handles astrological calculations"""
19
 
20
  def __init__(self):
 
21
  self.planets = [
22
  'Sun', 'Moon', 'Mercury', 'Venus', 'Mars',
23
  'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'Pluto'
 
42
  Returns a dictionary of planetary positions and house cusps
43
  """
44
  try:
 
45
  tz = zoneinfo.ZoneInfo(timezone)
46
  birth_datetime = birth_datetime.replace(tzinfo=tz)
47
  utc_offset = int(birth_datetime.utcoffset().total_seconds() / 3600)
48
 
 
49
  adjusted_datetime = birth_datetime - timedelta(hours=utc_offset)
50
  date_str = adjusted_datetime.strftime('%Y/%m/%d')
51
  time_str = adjusted_datetime.strftime('%H:%M')
52
 
 
 
 
 
 
53
  date = Datetime(date_str, time_str, utc_offset)
54
  pos = GeoPos(latitude, longitude)
55
 
 
56
  chart = Chart(date, pos)
57
 
 
58
  positions = {}
59
  for planet in self.planets:
60
  try:
 
74
  'error': f"Error calculating {planet}: {str(e)}"
75
  }
76
 
 
77
  houses = {}
78
  for i in range(1, 13):
79
  try:
 
112
  ax.set_theta_zero_location("S")
113
  ax.set_theta_direction(-1)
114
 
115
+ zodiac_angles = np.linspace(0, 2 * np.pi, 13)
 
116
  for i, sign in enumerate(ZODIAC_SIGNS):
117
  angle = zodiac_angles[i]
118
  ax.text(angle, 1.05, sign, ha='center', va='center', fontsize=10)
119
 
120
+ house_angles = np.linspace(0, 2 * np.pi, 13)
 
121
  for i in range(1, 13):
122
  angle = house_angles[i - 1]
123
  ax.text(angle, 0.8, f"H{i}", ha='center', va='center', fontsize=10)
124
 
 
125
  for planet, data in chart_data['planets'].items():
126
  if 'error' not in data:
127
  degrees = data['degrees']
128
  angle = np.deg2rad(degrees)
129
  ax.plot([angle], [0.5], marker='o', label=planet, markersize=10)
130
 
 
131
  ax.legend(loc='upper right', bbox_to_anchor=(1.3, 1))
132
  plt.title("Astrology Chart", va='bottom', fontsize=15)
133
  plt.show()