Skip to main content

Library to compute astronomical bodies positions and planetary aspects between them

Project description

Ketu

PyPI version Python Versions License: MIT

🇫🇷 Vous préférez le français ? Consultez README.md

Ketu is a lightweight Python library for computing the positions of astronomical bodies (Sun, Moon, planets, and the mean Node a.k.a. Rahu) and generating calendars driven by astrological aspects.

This library was originally designed to generate biodynamic calendars and time series based on astrological aspects. It can be used as a basis for building astrology software.

Terminal screen

✨ Features

  • 🌍 Planetary positions for 13 bodies (Sun, Moon, Mercury, Venus, Mars, Jupiter, Saturn, Uranus, Neptune, Pluto, Rahu/Mean Node, True North Node, Lilith)
  • Detection of the 7 major aspects (Conjunction, Semi-sextile, Sextile, Square, Trine, Quincunx, Opposition)
  • 🔄 Retrogradation detection and planet motion helpers
  • 🕐 Time system conversions (UTC, Julian Day)
  • 🎯 Orb system based on Abu Ma'shar (787-886) and Al-Biruni (973-1050)
  • 🖥️ Interactive CLI for a non-programmatic workflow
  • 📊 Python API that fits into your own tooling

📦 Installation

From PyPI (recommended)

pip install ketu

From source

git clone https://github.com/alkimya/ketu.git
cd ketu
pip install -e .

🚀 Quick Start

Interactive mode (CLI)

Run the command below and answer the prompts:

ketu

You will be asked for:

  • A date (ISO format: 2020-12-21)
  • A time (ISO format: 19:20)
  • A timezone (for example Europe/Paris)

The program prints:

  • Positions of every celestial body with zodiac signs
  • All inter-planet aspects with their orbs

Programmatic usage

from datetime import datetime
from zoneinfo import ZoneInfo
import ketu

# Define a datetime
dtime = datetime(2020, 12, 21, 19, 20, tzinfo=ZoneInfo("Europe/Paris"))
jday = ketu.utc_to_julian(dtime)

# Display planetary positions
ketu.print_positions(jday)

# Display aspects
ketu.print_aspects(jday)

Additional examples

Compute a planet position

from datetime import datetime
from zoneinfo import ZoneInfo
import ketu

dtime = datetime(2024, 10, 26, 12, 0, tzinfo=ZoneInfo("UTC"))
jday = ketu.utc_to_julian(dtime)

sun_long = ketu.long(jday, 0)
print(f"Sun longitude: {sun_long:.2f}°")

sign, deg, mins, secs = ketu.body_sign(sun_long)
print(f"Position: {ketu.signs[sign]} {deg}°{mins}'{secs}\"")

Check whether a planet is retrograde

import ketu

# Mars (body id = 4)
if ketu.is_retrograde(jday, 4):
    print("Mars is retrograde")
else:
    print("Mars is direct")

Calculate all aspects for a given day

import ketu

aspects_data = ketu.calculate_aspects(jday)

for aspect in aspects_data:
    body1, body2, i_asp, orb = aspect
    print(f"{ketu.body_name(body1)} - {ketu.body_name(body2)}: "
          f"{ketu.aspects['name'][i_asp].decode()} (orb: {orb:.2f}°)")

📚 Documentation

The full documentation is hosted on Read the Docs (French by default, English via the language toggle).

Included sections:

  • Installation: detailed setup instructions
  • Quickstart: guided tour of the basics
  • Concepts: astrological and astronomical background
  • API Reference: all functions documented
  • Examples: advanced usage patterns

🛠️ Requirements

  • Python 3.10 or higher
  • numpy ≥ 1.20.0 — numerical routines and arrays
  • pyswisseph ≥ 2.10.0 — Swiss Ephemeris bindings

The dependency on pyswisseph is scheduled for removal in a future release, replaced by pure NumPy implementation.

📋 Supported bodies

Body ID Orb Average speed (°/day)
Sun 0 12° 0.986
Moon 1 12° 13.176
Mercury 2 1.383
Venus 3 10° 1.200
Mars 4 0.524
Jupiter 5 10° 0.083
Saturn 6 10° 0.034
Uranus 7 0.012
Neptune 8 0.007
Pluto 9 0.004
Rahu (Mean Node) 10 -0.013
True North Node 11 -0.013
Lilith (Black Moon) 12 -0.113

🎯 Supported aspects

Aspect Angle Orb coefficient
Conjunction 1
Semi-sextile 30° 1/6
Sextile 60° 1/3
Square 90° 1/2
Trine 120° 2/3
Quincunx 150° 5/6
Opposition 180° 1

🗺️ Roadmap

  • Removal of dependency on pyswisseph
  • Pure numpy implementation of planetary calculations
  • Search for exact aspects between two dates
  • Generation of aspect calendars
  • API for progressions and directions
  • Support for more celestial bodies (asteroids, etc.)

🤝 Contribution

Contributions are welcome! Feel free to:

  • Open an issue to report a bug or suggest a feature
  • Submit a pull request
  • Improve the documentation

See CONTRIBUTING.md for more details.

📄 License

This project is licensed under MIT. See the LICENSE file for more details.

📧 Contact

Loc Cosnier - @alkimya

Project: https://github.com/alkimya/ketu

Translated with DeepL.com (free version)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ketu-0.2.0.tar.gz (111.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ketu-0.2.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file ketu-0.2.0.tar.gz.

File metadata

  • Download URL: ketu-0.2.0.tar.gz
  • Upload date:
  • Size: 111.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for ketu-0.2.0.tar.gz
Algorithm Hash digest
SHA256 49ee1d79e62a02d35713955b39a32ccfcb81d1f099309ccf9883c586076ca6c4
MD5 be8d18a72d9b1e9472618483e892bb02
BLAKE2b-256 c607593b3d1f8d48e5cc32a1162af676885c3d457a2484dc0b21c0298dea1088

See more details on using hashes here.

File details

Details for the file ketu-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: ketu-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for ketu-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f2a6847c8feffeefc6b4e7fbab907450084732e907943258743f3606acb99d57
MD5 4788d0a77168ebfdbfb3d29603e34a4c
BLAKE2b-256 26bb502e29074e75e429aa9ec06114c8889e1e4ad592062cab74f3fc786f54f6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page