commit d6c87ee60f579c2d96956d47cfd9f6b022876260 Author: Alexander Rossmanith Date: Fri Aug 7 20:38:53 2026 +0530 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0dd47c3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +*.py[codz] +__pycache__/ +.mypy_cache/ +.pytest_cache/ +.ruff_cache/ +.pdm-python diff --git a/astrology/main.py b/astrology/main.py new file mode 100644 index 0000000..09553fe --- /dev/null +++ b/astrology/main.py @@ -0,0 +1,87 @@ +import swisseph as swe +import json +from datetime import datetime + +# Set the path to the Swiss Ephemeris data files +swe.set_ephe_path('ephe') + +# Set the Ayanamsha to N.C. Lahiri +swe.set_sid_mode(swe.SIDM_LAHIRI) + +# Get user input +name = input("Enter name: ") +dob = input("Enter date of birth (YYYY-MM-DD): ") +tob = input("Enter time of birth (HH:MM:SS): ") +place_of_birth = input("Enter place of birth: ") +latitude = float(input("Enter latitude: ")) +longitude = float(input("Enter longitude: ")) + +# Parse the date and time of birth +year, month, day = map(int, dob.split('-')) +hour, minute, second = map(int, tob.split(':')) + +# Calculate Julian Day +jd = swe.julday(year, month, day, hour + minute/60 + second/3600) + +print(type(jd), type(latitude), type(longitude)) + +# Calculate the Ascendant using Equal house system +#asc = swe.houses(jd, latitude, longitude, b'E')[0][0] + +# Calculate the Rasi (Zodiac sign) +#rasi = int((asc % 360) / 30) + +# Calculate planetary positions and houses +planets = ['Sun', 'Moon', 'Mercury', 'Venus', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'Pluto'] +planet_positions = {} +planet_houses = {} +for i, planet in enumerate(planets): + xx, ret = swe.calc_ut(jd, i, swe.FLG_SPEED) # Include velocities in the output + planet_positions[planet] = xx[0] # Longitude of the planet + # planet_houses[planet] = swe.house_pos(asc, latitude, 'E', xx[0], xx[1]) # House of the planet + +# Calculate sunrise and sunset +next_sunrise = swe.rise_trans(jd, swe.SUN, geopos=(longitude, latitude, 0), rsmi=swe.CALC_RISE)[1][0] +next_sunset = swe.rise_trans(jd, swe.SUN, geopos=(longitude, latitude, 0), rsmi=swe.CALC_SET)[1][0] + +print(type(next_sunrise), type(next_sunset)) + +next_sunrise_ = swe.revjul(next_sunrise) +next_sunset_= swe.revjul(next_sunset) + +# Convert sunrise and sunset times to date-time format +next_sunrise = datetime.fromtimestamp(swe.revjul(next_sunrise)).strftime('%Y-%m-%d %H:%M:%S') +next_sunset = datetime.fromtimestamp(swe.revjul(next_sunset)).strftime('%Y-%m-%d %H:%M:%S') + +# Calculate Tithi (Lunar day) +moon_long = swe.calc_ut(jd, swe.MOON)[0][0] +sun_long = swe.calc_ut(jd, swe.SUN)[0][0] +tithi = int((moon_long - sun_long) % 360 / 12) + 1 + +# Calculate Vara (Day of the week) +vara = int((jd + 1) % 7) +vara_names = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] + +# Create a dictionary to store the results +data = { + "name": name, + "date_of_birth": dob, + "time_of_birth": tob, + "place_of_birth": place_of_birth, + "latitude": latitude, + "longitude": longitude, + # "ascendant": asc, + # "rasi": rasi, + "planet_positions": planet_positions, + # "planet_houses": planet_houses, + "next_sunrise": next_sunrise, + "next_sunset": next_sunset, + "tithi": tithi, + "vara": vara_names[vara] +} + +# Convert the dictionary to a JSON string +json_data = json.dumps(data, indent=4) + +# Print the JSON string +print(json_data) \ No newline at end of file diff --git a/pdm.lock b/pdm.lock new file mode 100644 index 0000000..a35f180 --- /dev/null +++ b/pdm.lock @@ -0,0 +1,21 @@ +# This file is @generated by PDM. +# It is not intended for manual editing. + +[metadata] +groups = ["default"] +strategy = ["inherit_metadata"] +lock_version = "4.5.0" +content_hash = "sha256:34872997215e064c4204e726fe8f6d1b8423ab70a2c3e5106702027467c51ef7" + +[[metadata.targets]] +requires_python = "==3.14.*" + +[[package]] +name = "pyswisseph" +version = "2.10.3.2" +requires_python = ">=3.5" +summary = "Python extension to the Swiss Ephemeris" +groups = ["default"] +files = [ + {file = "pyswisseph-2.10.3.2.tar.gz", hash = "sha256:c54c305e83dbd5d2b71e58d8a69d8ee41de24c4d3328ce09e2af860a3537624d"}, +] diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..3f739b6 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,15 @@ +[project] +name = "astrology" +version = "0.1.0" +description = "Default template for PDM package" +authors = [ + {name = "Alexander Rossmanith",email = "dev@alexander-rossmanith.de"}, +] +dependencies = ["pyswisseph>=2.10.3.2"] +requires-python = "==3.14.*" +readme = "README.md" +license = {text = "MIT"} + + +[tool.pdm] +distribution = false