Files
Jyotisha/scripts/cmd_narayana_dasha.py
T
732642856 e2aa76a786 v6.0.20: Narayana Dasha (Rishi Dasha) implementation
Narayana Dasha is Parashara's rashi-based dasha system, complementary to
Vimshottari (nakshatra-based). Algorithm: start from Lagna, each sign's
dasha years = count from the sign to its lord's sign (zodiacal order).

Implementation:
- scripts/narayana_dasha.py: core calculation module
  - calc_narayana_mahadasha(): 12-sign sequence from Lagna
  - calc_narayana_antardasha(): sub-periods within each MD
  - get_current_narayana_dasha(): locate current period by age
- scripts/cmd_narayana_dasha.py: CLI subcommand
- jyotish_engine.py: Step 4.13 in full-reading + narayana-dasha subparser

Verified with Leo Asc chart: total cycle 88 years, current Sagittarius MD
(31-38 yrs, 5H/creativity) complements Vimshottari Saturn MD.

Files: +2 new (narayana_dasha.py, cmd_narayana_dasha.py), +4 modified
2026-06-04 11:08:05 +08:00

85 lines
3.0 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 DashaRishi 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 DashaRishi 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', {}).get('sign_idx', 0)
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,
)
# 格式化输出
lines = [
"╔══════════════════════════════════════════╗",
"║ Narayana DashaRishi Dasha",
"╚══════════════════════════════════════════╝",
"",
f"Lagna: {result['lagna_sign']}{result['lagna_sign_idx']}",
f"总周期: {result['total_cycle_years']}",
"",
"── 大运序列 ──",
]
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']}")
lines.append("")
for line in result.get('interpretation', []):
lines.append(f" {line}")
return "\n".join(lines)