Files
Jyotisha/scripts/cmd_narayana_dasha.py
T
Jesse_ChenandClaude Opus 5.5 9eb22f6363 feat(narayana): label the product Narayana as the legacy algorithm (T4, BUG-1215)
Round-4 ruling Q4 / product decision A: scoring and the consultation and
report time axes keep the old Narayana (from the Lagna, always zodiacal) until
the Rath trial is decided; every user-visible Narayana now says so.
narayana_legacy_label adds profile=legacy_reference_only and the note (zh/en)
at the consumers (consultation modules, full reading Step 4.13, CLI), not in
the frozen narayana_dasha.py (ERR-110/115). The card's timing.narayana carries
'algorithm'; the projection allowlist passes algorithm_note; the reference
report's Narayana section and the dasha-family table show '算法:…' (English
twin in the phrase table). The unused narayana-dasha --variant-profile flag,
the one place offering a Chara Dasha author's profile for Narayana, is removed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N4f2nya58RoRu4yEmJgRGE
2026-10-03 16:42:15 +08:00

102 lines
3.9 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Narayana Dasha 子命令
Jyotish Vedic Astrology Skill — v6.0.20
"""
import json
def cmd_narayana_dasha(args, chart_data):
"""
narayana-dasha 子命令:计算并报告 Narayana Dasha(Rishi Dasha)。
用法:
python jyotish_engine.py narayana-dasha --year REDACTED_YEAR --month 4 --day 17 \\
--hour 14 --minute 45 --lat 36.47 --lon 114.2 --tz 8 --age 33
"""
if chart_data is None:
return "\n".join([
"╔══════════════════════════════════════════╗",
"║ Narayana Dasha(Rishi Dasha) ║",
"╚══════════════════════════════════════════╝",
"",
"错误:图表数据未生成(swisseph 可能未安装)。",
"Narayana Dasha 需要完整的行星经度数据。",
])
from narayana_dasha import narayana_dasha_full_report
planet_lons = {}
for pn, pd in chart_data.get('planets', {}).items():
if isinstance(pd, dict) and 'degree' in pd:
planet_lons[pn] = pd['degree']
asc_idx = chart_data.get('ascendant_index')
if asc_idx is None:
asc_info = chart_data.get('ascendant', {}) if isinstance(chart_data, dict) else {}
asc_idx = asc_info.get('sign_idx', 0)
if asc_idx == 0 and isinstance(asc_info, dict):
# compute_chart_data 输出 ascendant.sign,但不一定输出 sign_idx;兼容旧结构
sign_name = asc_info.get('sign')
signs = ['Aries', 'Taurus', 'Gemini', 'Cancer', 'Leo', 'Virgo',
'Libra', 'Scorpio', 'Sagittarius', 'Capricorn', 'Aquarius', 'Pisces']
if sign_name in signs:
asc_idx = signs.index(sign_name)
if isinstance(asc_idx, str):
asc_idx = int(asc_idx)
current_age = float(getattr(args, 'age', 0) or 0)
birth_year = getattr(args, 'year', 0) or 0
result = narayana_dasha_full_report(
lagna_sign_idx=asc_idx,
planet_lons=planet_lons,
current_age=current_age,
birth_year=birth_year,
)
from narayana_legacy_label import label_legacy_narayana # BUG-1215
label_legacy_narayana(result)
# 格式化输出
lines = [
"╔══════════════════════════════════════════╗",
"║ Narayana Dasha(Rishi Dasha) ║",
"╚══════════════════════════════════════════╝",
"",
f"Lagna: {result['lagna_sign']}({result['lagna_sign_idx']})",
f"总周期: {result['total_cycle_years']} 年",
f"算法: {result['algorithm_note']}",
"",
"── 大运序列 ──",
]
for p in result['mahadasha_sequence']:
lines.append(
f" {p['sign']:>12s} ({p['lord']:>7s} in {p['lord_in_sign']:>12s}): "
f"{p['years']:2d}年 [{p['start_age']:5.1f}→{p['end_age']:5.1f}]"
)
curr = result.get('current_dasha', {})
md = curr.get('md')
if md:
lines.append("")
lines.append(f"── 当前大运(age={current_age:.1f})──")
lines.append(f" Mahadasha: {md['sign']}({md['lord']}){md['years']}年")
lines.append(f" 剩余: {curr.get('remaining_years', 0):.1f}年")
ad = curr.get('ad')
if ad:
lines.append(f" Antardasha: {ad['sign']}({ad['lord']}){ad['years']}年")
pd = curr.get('pd')
if pd:
lines.append(f" Pratyantardasha: {pd['sign']}({pd['lord']}){pd['years']}年")
lines.append("")
for line in result.get('interpretation', []):
lines.append(f" {line}")
return "\n".join(lines)