Ashtottari 在适用时把出生前已经走过的部分算进时间线。 Co-Authored-By: Grok (agent loop)
47 lines
1.5 KiB
Python
47 lines
1.5 KiB
Python
"""Shared dasha arithmetic used by the conditional-dasha modules.
|
|
|
|
This module must not import the API server or PyJHora. PyJHora stays a test
|
|
oracle only.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
NAKSHATRA_SPAN = 360.0 / 27.0
|
|
|
|
# Insertion order is the Vimshottari sequence. Callers compare items() before
|
|
# replacing a local table, and rely on this order staying stable.
|
|
VIMSHOTTARI_YEARS = {
|
|
"Ketu": 7,
|
|
"Venus": 20,
|
|
"Sun": 6,
|
|
"Moon": 10,
|
|
"Mars": 7,
|
|
"Rahu": 18,
|
|
"Jupiter": 16,
|
|
"Saturn": 19,
|
|
"Mercury": 17,
|
|
}
|
|
VIMSHOTTARI_ORDER = list(VIMSHOTTARI_YEARS.keys())
|
|
|
|
|
|
def nakshatra_seeded_birth_balance(
|
|
moon_longitude: float,
|
|
*,
|
|
anchor_index: int,
|
|
sequence: tuple | list,
|
|
) -> tuple[str, float, int]:
|
|
"""Birth lord and remaining years for a nakshatra-seeded conditional dasha.
|
|
|
|
The arithmetic matches the six copied helpers: offset from the anchor
|
|
nakshatra, lord = sequence[offset % length], balance = years * (1 - fraction
|
|
already elapsed inside the nakshatra). Operation order is fixed so the
|
|
float matches the previous per-module copies.
|
|
"""
|
|
moon = float(moon_longitude) % 360.0
|
|
nakshatra_index = int(moon // NAKSHATRA_SPAN)
|
|
offset = (nakshatra_index - int(anchor_index)) % 27
|
|
lord, full_years = sequence[offset % len(sequence)]
|
|
fraction_elapsed = (moon % NAKSHATRA_SPAN) / NAKSHATRA_SPAN
|
|
remaining_years = full_years * (1.0 - fraction_elapsed)
|
|
return lord, remaining_years, nakshatra_index
|