Skip to content

API Reference: Ayanamsa Module

AyanamsaSystem Type

AyanamsaSystem = Literal['lahiri', 'raman', 'kali', 'krishnamurti_new', 'krishnamurti_old', 'fagan_bradley', 'janma', 'true', 'madhava', 'vishnu', 'yukteshwar', 'suryasiddhanta', 'aryabhatta', 'ushashasi', 'true_citra', 'true_revati', 'true_pusya'] module-attribute

Functions

ayanamsa

Ayanamsa calculation functions for Vedic astrology.

This module provides functions to calculate various ayanamsa (precession correction) values used in Vedic astrology, including: - Lahiri, Raman, Krishnamurti, Fagan-Bradley ayanamsas - Traditional systems: Kali, Janma, Yukteshwar, Suryasiddhanta, Aryabhatta - Star-based systems: True Citra, True Revati, True Pusya - Other systems: Madhava, Vishnu, Ushashasi, and True ayanamsa

Each function calculates the ayanamsa for a given date using a quadratic formula based on Julian centuries from the J2000.0 epoch.

get_ayanamsa(date, system)

Calculate the ayanamsa for a given date and system.

Parameters:

Name Type Description Default
date datetime

The date for which to calculate the ayanamsa.

required
system AyanamsaSystem

The ayanamsa system to use.

required

Returns:

Name Type Description
float float

The calculated ayanamsa in degrees.

Source code in ndastro_engine/ayanamsa.py
def get_ayanamsa(
    date: datetime.datetime,
    system: AyanamsaSystem,
) -> float:
    """Calculate the ayanamsa for a given date and system.

    Args:
        date (datetime): The date for which to calculate the ayanamsa.
        system (AyanamsaSystem): The ayanamsa system to use.

    Returns:
        float: The calculated ayanamsa in degrees.

    """
    ayanamsa_systems = {
        "lahiri": _get_lahiri_ayanamsa,
        "raman": _get_raman_ayanamsa,
        "kali": _get_kali_ayanamsa,
        "krishnamurti_new": _get_krishnamurti_new_ayanamsa,
        "krishnamurti_old": _get_krishnamurti_old_ayanamsa,
        "fagan_bradley": _get_fagan_bradley_ayanamsa,
        "janma": _get_janma_ayanamsa,
        "true": _get_true_ayanamsa,
        "madhava": _get_madhava_ayanamsa,
        "vishnu": _get_vishnu_ayanamsa,
        "yukteshwar": _get_yukteshwar_ayanamsa,
        "suryasiddhanta": _get_suryasiddhanta_ayanamsa,
        "aryabhatta": _get_aryabhatta_ayanamsa,
        "ushashasi": _get_ushashasi_ayanamsa,
        "true_citra": _get_true_citra_ayanamsa,
        "true_revati": _get_true_revati_ayanamsa,
        "true_pusya": _get_true_pusya_ayanamsa,
    }

    if system not in ayanamsa_systems:
        error_message = f"Unknown ayanamsa system: {system}"
        raise ValueError(error_message)

    return ayanamsa_systems[system](date)