cryogenic22 commited on
Commit
4c8413a
·
verified ·
1 Parent(s): d5b1f72

Update astro_core.py

Browse files
Files changed (1) hide show
  1. astro_core.py +19 -8
astro_core.py CHANGED
@@ -18,6 +18,7 @@ class ChartCalculator:
18
  """Handles astrological calculations"""
19
 
20
  def __init__(self):
 
21
  self.planets = [
22
  'Sun', 'Moon', 'Mercury', 'Venus', 'Mars',
23
  'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'Pluto'
@@ -62,12 +63,21 @@ class ChartCalculator:
62
  # Extract planetary positions
63
  positions = {}
64
  for planet in self.planets:
65
- obj = chart.get(planet)
66
- if obj:
67
- lon = self._normalize_longitude(obj.lon)
 
 
 
 
 
 
 
 
 
 
68
  positions[planet] = {
69
- 'sign': self._get_zodiac_sign(lon),
70
- 'degrees': lon
71
  }
72
 
73
  # Extract house cusps
@@ -113,9 +123,10 @@ class ChartCalculator:
113
 
114
  # Plot planets
115
  for planet, data in chart_data['planets'].items():
116
- degrees = data['degrees']
117
- angle = np.deg2rad(degrees)
118
- ax.plot([angle], [0.5], marker='o', label=planet, markersize=10)
 
119
 
120
  # Draw the chart
121
  ax.legend(loc='upper right', bbox_to_anchor=(1.3, 1))
 
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'
 
63
  # Extract planetary positions
64
  positions = {}
65
  for planet in self.planets:
66
+ try:
67
+ obj = chart.get(planet)
68
+ if obj:
69
+ lon = self._normalize_longitude(obj.lon)
70
+ positions[planet] = {
71
+ 'sign': self._get_zodiac_sign(lon),
72
+ 'degrees': lon
73
+ }
74
+ else:
75
+ positions[planet] = {
76
+ 'error': f"{planet} not supported by the astrological library"
77
+ }
78
+ except KeyError:
79
  positions[planet] = {
80
+ 'error': f"{planet} not supported or unavailable"
 
81
  }
82
 
83
  # Extract house cusps
 
123
 
124
  # Plot planets
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
  # Draw the chart
132
  ax.legend(loc='upper right', bbox_to_anchor=(1.3, 1))