57 lines
2.3 KiB
Python
57 lines
2.3 KiB
Python
"""Badhaka raw facts for D1. PRODUCT computation, pending astrologer review (BUG-1853).
|
|
|
|
Her engine (yinduzhanxing 8aaf6099) has no natal Badhaka module, so this lives
|
|
in a product file, announced in references/product_runtime_contract.md. It only
|
|
reads positions the engine already computed and the Badhaka house rule from
|
|
``yoga_engine.badhaka_house``; it follows references/badhaka-obstacle-planet-guide.md §二
|
|
(identical to her copy) and gives positions, no interpretation.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from yoga_engine import badhaka_house
|
|
|
|
SOURCE = "references/badhaka-obstacle-planet-guide.md §二"
|
|
STATUS = "product_computation_pending_astrologer_review"
|
|
PROFILE = "badhaka_modality_v1"
|
|
PROFILE_RULE = "动 → 11、固 → 9、双 → 7,按 badhaka-obstacle-planet-guide.md §二"
|
|
SIGNS = ("Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio",
|
|
"Sagittarius", "Capricorn", "Aquarius", "Pisces")
|
|
LORDS = ("Mars", "Venus", "Mercury", "Moon", "Sun", "Mercury", "Venus", "Mars",
|
|
"Jupiter", "Saturn", "Saturn", "Jupiter")
|
|
MODALITY = {11: "movable", 9: "fixed", 7: "dual"}
|
|
|
|
|
|
def badhaka_facts(asc_sign: Any, planets: dict[str, dict]) -> dict[str, Any] | None:
|
|
"""Return the obstructing house and its lord's placement separately.
|
|
|
|
``planets`` maps a planet name to its D1 record (``sign``, ``house``, optional ``dignity``).
|
|
Returns None when the ascendant sign is unknown.
|
|
"""
|
|
if asc_sign not in SIGNS:
|
|
return None
|
|
house = badhaka_house(asc_sign)
|
|
if house is None:
|
|
return None
|
|
sign = SIGNS[(SIGNS.index(asc_sign) + house - 1) % 12]
|
|
lord = LORDS[SIGNS.index(sign)]
|
|
lord_data = planets.get(lord) if isinstance(planets.get(lord), dict) else {}
|
|
occupants = sorted(name for name, row in planets.items() if isinstance(row, dict) and row.get("sign") == sign)
|
|
return {
|
|
"ascendant_sign": asc_sign,
|
|
"ascendant_modality": MODALITY[house],
|
|
"badhaka_sthana": {"house": house, "sign": sign, "occupants": occupants},
|
|
"badhakesh": {
|
|
"planet": lord,
|
|
"sign": lord_data.get("sign"),
|
|
"house": lord_data.get("house"),
|
|
"dignity": lord_data.get("dignity"),
|
|
},
|
|
"source": SOURCE,
|
|
"status": STATUS,
|
|
"profile": PROFILE,
|
|
"profile_rule": PROFILE_RULE,
|
|
}
|