Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,8 @@ from PIL import Image
|
|
8 |
from geopy.geocoders import Nominatim
|
9 |
from timezonefinder import TimezoneFinder
|
10 |
import pytz
|
|
|
|
|
11 |
|
12 |
# Russian translations for planets
|
13 |
planet_ru = {
|
@@ -74,33 +76,32 @@ def lon_to_sign(lon):
|
|
74 |
return f"{signs[sign_index]} {degrees}°{minutes}'"
|
75 |
|
76 |
def PLadder_ZSizes(utc_dt, lat, lon):
|
77 |
-
"""Calculate Planetary Ladder and Zone Sizes."""
|
78 |
if not 1900 <= utc_dt.year <= 2050:
|
79 |
return {"error": "Date out of range (1900–2050)."}
|
80 |
|
81 |
-
#
|
82 |
-
|
83 |
-
earth = planets['earth']
|
84 |
|
85 |
-
#
|
86 |
planet_objects = {
|
87 |
-
'Sun':
|
88 |
-
'Venus':
|
89 |
-
'Jupiter':
|
90 |
}
|
91 |
|
92 |
-
#
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
# Calculate geocentric ecliptic longitudes for each planet
|
97 |
longitudes = {}
|
98 |
-
for planet,
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
|
105 |
# Sort planets by their ecliptic longitude
|
106 |
sorted_planets = sorted(longitudes.items(), key=lambda x: x[1])
|
|
|
8 |
from geopy.geocoders import Nominatim
|
9 |
from timezonefinder import TimezoneFinder
|
10 |
import pytz
|
11 |
+
import swisseph as swe
|
12 |
+
|
13 |
|
14 |
# Russian translations for planets
|
15 |
planet_ru = {
|
|
|
76 |
return f"{signs[sign_index]} {degrees}°{minutes}'"
|
77 |
|
78 |
def PLadder_ZSizes(utc_dt, lat, lon):
|
79 |
+
"""Calculate Planetary Ladder and Zone Sizes using Swiss Ephemeris."""
|
80 |
if not 1900 <= utc_dt.year <= 2050:
|
81 |
return {"error": "Date out of range (1900–2050)."}
|
82 |
|
83 |
+
# Initialize Swiss Ephemeris
|
84 |
+
swe.set_ephe_path(None) # Use default ephemeris path
|
|
|
85 |
|
86 |
+
# Map planet names to Swiss Ephemeris constants
|
87 |
planet_objects = {
|
88 |
+
'Sun': swe.SUN, 'Moon': swe.MOON, 'Mercury': swe.MERCURY,
|
89 |
+
'Venus': swe.VENUS, 'Mars': swe.MARS,
|
90 |
+
'Jupiter': swe.JUPITER, 'Saturn': swe.SATURN
|
91 |
}
|
92 |
|
93 |
+
# Convert datetime to Julian Day
|
94 |
+
jd = swe.julday(utc_dt.year, utc_dt.month, utc_dt.day,
|
95 |
+
utc_dt.hour + utc_dt.minute/60 + utc_dt.second/3600)
|
96 |
+
|
97 |
# Calculate geocentric ecliptic longitudes for each planet
|
98 |
longitudes = {}
|
99 |
+
for planet, planet_id in planet_objects.items():
|
100 |
+
# Calculate position (geocentric, apparent, with light-time correction)
|
101 |
+
flags = swe.FLG_SWIEPH | swe.FLG_SPEED
|
102 |
+
xx, _ = swe.calc_ut(jd, planet_id, flags)
|
103 |
+
lon = xx[0] # ecliptic longitude in degrees
|
104 |
+
longitudes[planet] = lon % 360 # ensure 0-360 range
|
105 |
|
106 |
# Sort planets by their ecliptic longitude
|
107 |
sorted_planets = sorted(longitudes.items(), key=lambda x: x[1])
|