Files
Jyotisha/scripts/pindayu_raman.py
ClaudeandClaude Opus 5.5 ac9be6f88c feat(techniques): port the astrologer upstream skill's missing techniques
Port from yinduzhanxing 5fb8379c (MIT): Naisargika, Kaala, Karaka, Tara,
Lagnamsaka, Yogardha, Mandooka, Paryaaya and Padanadhamsa dashas;
Sarvatobhadra, Kota and Kalanala chakras; Nakshatra Latta; Pachakadi;
Raman Amsayu and Pindayu. Producers and their upstream tests are copied;
scripts/upstream_technique_layers.py feeds them our natal and transit
positions and attaches chart.consultation_native_layers.upstream_techniques.

- dasha_registry: kaala and padanadhamsa keys (35 -> 37); the nine ported
  dashas are served by compute_dasha or fail closed with upstream's reason.
- technique_registry.json: 16 partial entries; README badges follow.
- Evidence lookup section `upstream_techniques` in the consultation tool.
- Boundaries: Kalanala carries no PyJHora (AGPL) grid coordinates;
  Padanadhamsa/Lagnamsaka run on our Narayana engine (no Rath Table 12,
  PVR co-lord variants or second cycle). PyJHora observers and the Amsayu
  worked-example scaffold live in scripts/research (root .py budget).
- PyJHora black-box cross-checks: Naisargika (lords/years) and Kaala
  (seed segment and fraction within 5e-4) on a public chart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbBXoyn7Hj3LCW3BUs5bZ8
2026-11-07 14:44:37 +08:00

154 lines
9.3 KiB
Python

"""Raman Pindayu contributions; explicit Aiyar full-ecliptic Krurodaya profile.
Original arithmetic from Raman Vol2 pp97-104. Aiyar Brihat Jataka VII notes
specify the full-ecliptic Navamsa fraction for the total-sum reduction variant.
No BPHS occupant-only reduction, strength inference or Dasha date generation.
"""
from __future__ import annotations
import argparse
import copy
from fractions import Fraction
import json
from pathlib import Path
if __package__:
from .raman_aayu_rules import PLANETS, HARANA_FLAGS, term, nature, validate_conditions, apply_haranas, unresolved_strength_selections, strength_candidate_report
from .pindayurdaya import PINDAYU_EXALTATION_YEARS, PINDAYU_DEEP_EXALTATION_DEGREES, calculate_arc_of_longevity
else:
from raman_aayu_rules import PLANETS, HARANA_FLAGS, term, nature, validate_conditions, apply_haranas, unresolved_strength_selections, strength_candidate_report
from pindayurdaya import PINDAYU_EXALTATION_YEARS, PINDAYU_DEEP_EXALTATION_DEGREES, calculate_arc_of_longevity
PROFILE = "pindayu_raman_aiyar_total_krurodaya_v1"
KRURA_PROFILE = "aiyar_full_ecliptic_total"
SOURCES = ["Raman, How to Judge a Horoscope Vol2, printed97-104 / PDF104-111",
"https://chestofbooks.com/new-age/astrology/Brihat-Jataka/On-Ayurdayaor-The-Determination-Of-The-Length-Of-Life-Part-2.html"]
def _krurodaya(longitudes, conditions, houses, benefic_aspects):
occupants = houses.get(1, [])
candidates = [p for p in occupants if nature(p, conditions[p]) == "malefic"]
evidence = {"profile": KRURA_PROFILE, "occupants": occupants,
"malefics": candidates, "deduct_fraction": None}
if not candidates:
return {**evidence, "status": "not_applicable", "deduct_fraction": "0",
"reason": "no_malefic_in_supplied_lagna_bhava"}
lagna = longitudes["Lagna"]
if any(longitudes[p] // 1800 != lagna // 1800 for p in occupants):
return {**evidence, "status": "blocked", "reason": "cross_sign_bhava1_nearest_rule_not_selected"}
distances = {p: abs(longitudes[p] - lagna) for p in occupants}
nearest = [p for p in occupants if distances[p] == min(distances.values())]
evidence.update(distance_arcminutes=distances, nearest=nearest)
if len(nearest) != 1:
return {**evidence, "status": "blocked", "reason": "equal_nearest_lagna_occupants_need_tie_rule"}
selected = nearest[0]
if selected not in candidates:
return {**evidence, "status": "not_applicable", "deduct_fraction": "0",
"reason": "nearest_occupant_is_benefic_in_this_profile"}
if selected not in benefic_aspects:
return {**evidence, "status": "blocked", "reason": f"benefic_aspects.{selected} required"}
# Full ecliptic Navamsas /108 = longitude arcminutes /21600.
# Aiyar VII example Aquarius0:90/108 deducted from98.5, leaving16y5m.
fraction = Fraction(lagna, 21600) / (2 if benefic_aspects[selected] else 1)
return {**evidence, "status": "executed", "selected": selected,
"benefic_aspect": benefic_aspects[selected],
"lagna_navamsas_from_aries": str(Fraction(lagna, 200)),
"deduct_fraction": str(fraction)}
def calculate_pindayu_raman(*, longitude_minutes: dict, conditions: dict,
condition_profile: str, krurodaya_profile: str,
strongest_by_bhava: dict | None = None,
benefic_aspects: dict | None = None) -> dict:
if krurodaya_profile != KRURA_PROFILE:
raise ValueError(f"krurodaya_profile must explicitly be {KRURA_PROFILE}")
houses, selectors = validate_conditions(longitude_minutes, conditions, condition_profile,
strongest_by_bhava, HARANA_FLAGS)
aspects = {} if benefic_aspects is None else benefic_aspects
if not isinstance(aspects, dict) or any(p not in PLANETS or type(v) is not bool for p, v in aspects.items()):
raise ValueError("benefic_aspects must map planet names to explicit booleans")
rows, blockers = [], []
subtotal = Fraction(0)
for p in PLANETS:
degree, minute = divmod(longitude_minutes[p], 60)
arc_degree, arc_minute = calculate_arc_of_longevity(degree, minute, PINDAYU_DEEP_EXALTATION_DEGREES[p])
arc = arc_degree * 60 + arc_minute
base = Fraction(arc, 21600) * int(PINDAYU_EXALTATION_YEARS[p])
adjusted, trace, reason = apply_haranas(p, base, conditions[p], houses, selectors)
row = {"body": p, "arc_minutes": arc, "base": term(base), "trace": trace,
"status": "blocked" if reason else "executed",
"adjusted_before_krurodaya": None if reason else term(adjusted)}
if reason:
row["reason"] = reason
if reason not in blockers:
blockers.append(reason)
else:
subtotal += adjusted
rows.append(row)
complete_planets = not blockers
krura = _krurodaya(longitude_minutes, conditions, houses, aspects)
if krura["status"] == "blocked":
blockers.append(krura["reason"])
# Raman Chart33 uses only the nine Navamsas in the occupied sign, not
# Amsayu modulo12 progress and not BPHS stronger-lord Rasi/Navamsa choice.
lagna = Fraction(longitude_minutes["Lagna"] % 1800, 200)
after = subtotal * (1 - Fraction(krura["deduct_fraction"])) if not blockers else None
krura["deduction"] = term(subtotal - after) if after is not None else None
return {"profile_id": PROFILE, "tradition_profile": "raman_pindayu_with_aiyar_total_krurodaya",
"status": "blocked" if blockers else "executed", "evidence_status": "parameter_sensitive",
"sources": SOURCES[:], "condition_profile": condition_profile,
"supplied_conditions": copy.deepcopy(conditions), "strongest_by_bhava": dict(selectors),
"benefic_aspects": dict(aspects), "contributions": rows,
"planet_subtotal": term(subtotal) if complete_planets else None,
"krurodaya": krura, "planet_total_after_krurodaya": term(after) if after is not None else None,
"lagna_contribution": {"rule": "within_sign_navamsa_progress", **term(lagna)},
"total": term(after + lagna) if after is not None else None, "blockers": blockers,
"limits": ["Explicit Raman+Aiyar composition, not universal Pindayu or BPHS occupant-only reduction",
"Supplied bhava/retrogression/inimical/combustion/benefic-aspect conditions; no automatic strength",
"Krurodaya uses nearest of all same-sign Bhava1 occupants; ties/cross-sign cases retain blockers",
"Exact rational years, half-up360-day display only; source printed day discrepancies retained",
"No native Dasha sequence, start, birth balance, MD/AD/PD dates or longevity outcome",
"No customer routing or global closure"]}
def build_pindayu_raman_report(**request):
raw = calculate_pindayu_raman(**request)
lines = ["# Raman Pindayu contributions", "", f"Profile: {PROFILE}", "",
f"Status: {raw['status']}; parameter_sensitive", "",
"| Planet | Base years | After three deductions | State |", "|---|---:|---:|---|"]
for row in raw["contributions"]:
adjusted = row["adjusted_before_krurodaya"]
lines.append(f"| {row['body']} | {row['base']['years_exact']} | {adjusted['years_exact'] if adjusted else '—'} | {row['status']} |")
lines.extend(["", f"Krurodaya: {raw['krurodaya']['status']}; fraction={raw['krurodaya']['deduct_fraction']}",
"Lagna contribution: " + raw["lagna_contribution"]["years_exact"],
"Nominal total: " + (raw["total"]["years_exact"] if raw["total"] else "blocked"), ""])
lines.extend("- " + x for x in raw["blockers"] + raw["limits"])
lines.extend(["", "## Full calculation trace", "", "```json", json.dumps(raw, ensure_ascii=False, indent=2), "```", ""])
return {"status": raw["status"], "profile_id": PROFILE,
"evidence_appendix": [{"pindayu_contributions": raw}],
"exports": {"markdown": "\n".join(lines), "ai_evidence_bundle": copy.deepcopy(raw)}}
def build_pindayu_strength_candidates_report(**request):
baseline = calculate_pindayu_raman(**request)
unresolved, selections = unresolved_strength_selections(baseline['supplied_conditions'], baseline['strongest_by_bhava'])
branches = [dict(branch_key=f'pindayu:strength:{i}', strongest_by_bhava=selection,
result=calculate_pindayu_raman(**dict(request, strongest_by_bhava=selection)))
for i,selection in enumerate(selections)]
return strength_candidate_report(baseline, branches, unresolved, 'Raman Pindayu')
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--request", required=True)
parser.add_argument("--format", choices=("json", "markdown"), default="json")
parser.add_argument('--all-strength-candidates', action='store_true')
args = parser.parse_args()
producer = build_pindayu_strength_candidates_report if args.all_strength_candidates else build_pindayu_raman_report
result = producer(**json.loads(Path(args.request).read_text(encoding="utf-8")))
print(result["exports"]["markdown"] if args.format == "markdown" else json.dumps(result, ensure_ascii=False, indent=2))
if __name__ == "__main__":
main()