Files
Jyotisha/jyotish_vedic/__init__.py
T
Jesse_ChenandClaude Opus 5.5 147ebc1789 feat(consult): prompt and Skill read from the evidence card (Skill 6.9.17)
The natal system prompt now says: the card in claim_cards is the chart
evidence for this answer, quote it as given, look up one further section of
this calculation with read-consultation-evidence before writing, and read
evidence_card.backstage as a confidence cap. The "use every executed layer"
and must_use_layers sentences are replaced; local_layers paths now point at
the card. SKILL.md 关联技法完整调取 / 0.0.1 and router 0.7 state that the
full result stays in receipts, the 本轮技法 panel and reports while web chat
answers from the card; computing the full spectrum is unchanged. Skill and
package version 6.9.16 -> 6.9.17 (tests/run_all.py 三栏).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017eEAG8HD3mm8gsKXgk8uU8
2026-09-27 02:54:11 +08:00

167 lines
6.3 KiB
Python

"""
Jyotish Vedic Astrology — Comprehensive calculation engine
A Python package for Vedic (Jyotish) astrology calculations:
- D1-D60 divisional charts (Varga)
- Vimshottari Dasha (planetary periods)
- Shadbala (six-fold planetary strength)
- Ashtakavarga (eight-fold bindus)
- Yoga detection (planetary combinations)
- Nakshatra analysis
- Transit calculations
- Full-reading synthesis
License: MIT
"""
import sys
import os
# Add scripts dir to path so all engine modules are importable
_pkg_dir = os.path.dirname(os.path.abspath(__file__))
_repo_root = os.path.dirname(_pkg_dir)
_scripts_dir = os.path.join(_repo_root, "scripts")
if _scripts_dir not in sys.path:
sys.path.insert(0, _scripts_dir)
__version__ = "6.9.17"
__all__ = [
"calculate_chart",
"calculate_dasha",
"calculate_shadbala",
"calculate_ashtakavarga",
"calculate_varga",
"calculate_yogas",
"full_reading",
]
# Lazy imports — only load when called
def _import_engine():
"""Import jyotish_engine module (lazy to avoid heavy init)."""
import jyotish_engine
return jyotish_engine
def _birth_second_args(second):
return ["--second", str(second)] if int(second or 0) else []
def calculate_chart(year, month, day, hour, minute, lat, lon, tz, node_mode="mean", second=0):
"""Calculate D1 Rashi chart."""
import json
import subprocess
engine = os.path.join(_scripts_dir, "jyotish_engine.py")
cmd = [
sys.executable, engine, "chart",
"--year", str(year), "--month", str(month), "--day", str(day),
"--hour", str(hour), "--minute", str(minute),
*_birth_second_args(second),
"--lat", str(lat), "--lon", str(lon), "--tz", str(tz),
"--node-mode", node_mode,
]
result = subprocess.run(cmd, capture_output=True, text=True, timeout=120)
return json.loads(result.stdout) if result.returncode == 0 else {"error": result.stderr}
def calculate_dasha(year, month, day, hour, minute, lat, lon, tz, years=10, node_mode="mean", second=0):
"""Calculate Vimshottari Dasha timeline."""
import json
import subprocess
engine = os.path.join(_scripts_dir, "jyotish_engine.py")
cmd = [
sys.executable, engine, "dasha",
"--year", str(year), "--month", str(month), "--day", str(day),
"--hour", str(hour), "--minute", str(minute),
*_birth_second_args(second),
"--lat", str(lat), "--lon", str(lon), "--tz", str(tz),
"--years", str(years), "--node-mode", node_mode,
]
result = subprocess.run(cmd, capture_output=True, text=True, timeout=120)
return json.loads(result.stdout) if result.returncode == 0 else {"error": result.stderr}
def calculate_shadbala(year, month, day, hour, minute, lat, lon, tz, node_mode="mean", second=0):
"""Calculate Shadbala (six-fold strength)."""
import json
import subprocess
engine = os.path.join(_scripts_dir, "jyotish_engine.py")
cmd = [
sys.executable, engine, "shadbala",
"--year", str(year), "--month", str(month), "--day", str(day),
"--hour", str(hour), "--minute", str(minute),
*_birth_second_args(second),
"--lat", str(lat), "--lon", str(lon), "--tz", str(tz),
"--node-mode", node_mode,
]
result = subprocess.run(cmd, capture_output=True, text=True, timeout=120)
return json.loads(result.stdout) if result.returncode == 0 else {"error": result.stderr}
def calculate_ashtakavarga(year, month, day, hour, minute, lat, lon, tz, node_mode="mean", second=0):
"""Calculate Ashtakavarga matrix."""
import json
import subprocess
engine = os.path.join(_scripts_dir, "jyotish_engine.py")
cmd = [
sys.executable, engine, "ashtakavarga",
"--year", str(year), "--month", str(month), "--day", str(day),
"--hour", str(hour), "--minute", str(minute),
*_birth_second_args(second),
"--lat", str(lat), "--lon", str(lon), "--tz", str(tz),
"--node-mode", node_mode,
]
result = subprocess.run(cmd, capture_output=True, text=True, timeout=120)
return json.loads(result.stdout) if result.returncode == 0 else {"error": result.stderr}
def calculate_varga(year, month, day, hour, minute, lat, lon, tz, varga="D9", node_mode="mean", second=0):
"""Calculate a specific Varga (D9, D10, etc.)."""
import json
import subprocess
engine = os.path.join(_scripts_dir, "jyotish_engine.py")
cmd = [
sys.executable, engine, "varga",
"--year", str(year), "--month", str(month), "--day", str(day),
"--hour", str(hour), "--minute", str(minute),
*_birth_second_args(second),
"--lat", str(lat), "--lon", str(lon), "--tz", str(tz),
"--varga", varga, "--node-mode", node_mode,
]
result = subprocess.run(cmd, capture_output=True, text=True, timeout=120)
return json.loads(result.stdout) if result.returncode == 0 else {"error": result.stderr}
def calculate_yogas(year, month, day, hour, minute, lat, lon, tz, node_mode="mean", second=0):
"""Detect Yogas in the birth chart."""
import json
import subprocess
engine = os.path.join(_scripts_dir, "jyotish_engine.py")
cmd = [
sys.executable, engine, "yoga",
"--year", str(year), "--month", str(month), "--day", str(day),
"--hour", str(hour), "--minute", str(minute),
*_birth_second_args(second),
"--lat", str(lat), "--lon", str(lon), "--tz", str(tz),
"--node-mode", node_mode,
]
result = subprocess.run(cmd, capture_output=True, text=True, timeout=120)
return json.loads(result.stdout) if result.returncode == 0 else {"error": result.stderr}
def full_reading(year, month, day, hour, minute, lat, lon, tz, age, transit_date, node_mode="mean", second=0):
"""Run the complete full-reading pipeline."""
import json
import subprocess
engine = os.path.join(_scripts_dir, "jyotish_engine.py")
cmd = [
sys.executable, engine, "full-reading",
"--year", str(year), "--month", str(month), "--day", str(day),
"--hour", str(hour), "--minute", str(minute),
*_birth_second_args(second),
"--lat", str(lat), "--lon", str(lon), "--tz", str(tz),
"--age", str(age), "--transit-date", transit_date,
"--node-mode", node_mode,
]
result = subprocess.run(cmd, capture_output=True, text=True, timeout=300)
return json.loads(result.stdout) if result.returncode == 0 else {"error": result.stderr}