fix: expose wealth varga and solar return evidence
This commit is contained in:
@@ -4722,6 +4722,17 @@ def cmd_full_reading(args):
|
||||
}
|
||||
if d1_data:
|
||||
varga_result["D1_Rashi"] = d1_data
|
||||
if "D11_Rudramsa" not in varga_result:
|
||||
try:
|
||||
from divisional_charts_extended import DivisionalChartsCalculator, VargaType
|
||||
dc_calc_for_d11 = DivisionalChartsCalculator()
|
||||
varga_result["D11_Rudramsa"] = dc_calc_for_d11._calculate_single_varga(
|
||||
VargaType.D11,
|
||||
planet_lons,
|
||||
asc_deg,
|
||||
)
|
||||
except Exception as d11_error:
|
||||
varga_result["D11_Rudramsa"] = {"error": str(d11_error)}
|
||||
report['modules']['varga_full'] = varga_result
|
||||
|
||||
# v6.1.7: Re-run Yoga with D9/D60 context after varga-full is available.
|
||||
|
||||
+24
-4
@@ -29,6 +29,11 @@ try:
|
||||
except ImportError:
|
||||
HAS_SWE = False
|
||||
|
||||
|
||||
def _gregorian_calendar_flag() -> int:
|
||||
"""Return the Gregorian calendar flag across swisseph builds."""
|
||||
return int(getattr(swe, 'GREG_FLAG', 1)) if HAS_SWE else 1
|
||||
|
||||
# ── 常量 ──────────────────────────────────────────────────────────
|
||||
SIGNS = ['Aries','Taurus','Gemini','Cancer','Leo','Virgo',
|
||||
'Libra','Scorpio','Sagittarius','Capricorn','Aquarius','Pisces']
|
||||
@@ -74,8 +79,22 @@ def _jd_to_datetime(jd_ut: float) -> datetime:
|
||||
# 使用 swisseph 的辅助函数,或手动转换
|
||||
if HAS_SWE:
|
||||
# swe.revjul 返回 (year, month, day, hour, minute, second)
|
||||
y, m, d, h, mn, s = swe.revjul(jd_ut, swe.GREG_FLAG)
|
||||
return datetime(y, m, d, h, int(mn), int(s))
|
||||
rev = swe.revjul(jd_ut, _gregorian_calendar_flag())
|
||||
if len(rev) == 4:
|
||||
y, m, d, hour_decimal = rev
|
||||
h = int(hour_decimal)
|
||||
minute_decimal = (hour_decimal - h) * 60.0
|
||||
mn = int(minute_decimal)
|
||||
s = int(round((minute_decimal - mn) * 60.0))
|
||||
if s >= 60:
|
||||
s -= 60
|
||||
mn += 1
|
||||
if mn >= 60:
|
||||
mn -= 60
|
||||
h += 1
|
||||
else:
|
||||
y, m, d, h, mn, s = rev
|
||||
return datetime(y, m, d, int(h), int(mn), int(s))
|
||||
else:
|
||||
# 近似:JD 2440587.5 = 1970-01-01 00:00:00 UT
|
||||
jd_unix = jd_ut - 2440587.5
|
||||
@@ -88,7 +107,7 @@ def _datetime_to_jd_ut(dt: datetime) -> float:
|
||||
if HAS_SWE:
|
||||
return swe.julday(dt.year, dt.month, dt.day,
|
||||
dt.hour + dt.minute/60.0 + dt.second/3600.0,
|
||||
swe.GREG_FLAG)
|
||||
_gregorian_calendar_flag())
|
||||
else:
|
||||
# 近似
|
||||
unix_sec = int((dt - datetime(1970, 1, 1)).total_seconds())
|
||||
@@ -315,7 +334,8 @@ def calc_solar_return_chart(
|
||||
if birth_chart is None:
|
||||
return {'error': '出生盘计算失败(swisseph问题)'}
|
||||
|
||||
birth_sun_lon = birth_chart.get('planets', {}).get('Sun', {}).get('degree', 0)
|
||||
sun_data = birth_chart.get('planets', {}).get('Sun', {})
|
||||
birth_sun_lon = sun_data.get('degree_raw', sun_data.get('degree', 0))
|
||||
birth_jd_ut = birth_jd
|
||||
|
||||
# Step 2: 计算太阳返照精确时刻
|
||||
|
||||
@@ -724,6 +724,21 @@ def test_varga_full_cli_divisions_supports_high_vargas() -> None:
|
||||
assert result["D144_Dwadasamsa-Dwadasamsa"]["planets"]["Moon"]["house"] in range(1, 13)
|
||||
|
||||
|
||||
def test_full_reading_exposes_d11_for_wealth_strict_workflow() -> None:
|
||||
result = run_engine(
|
||||
"full-reading",
|
||||
*BASE_BIRTH_ARGS,
|
||||
"--today",
|
||||
"2026-07-01",
|
||||
"--target-year",
|
||||
"2026",
|
||||
)
|
||||
|
||||
varga_full = result["modules"]["varga_full"]
|
||||
assert "D11_Rudramsa" in varga_full
|
||||
assert varga_full["D11_Rudramsa"]["planets"]["Moon"]["house"] in range(1, 13)
|
||||
|
||||
|
||||
def test_muhurta_cli_scan_days_outputs_panchanga_without_tuple_crash() -> None:
|
||||
output = run_engine_text(
|
||||
"muhurta",
|
||||
|
||||
@@ -19,6 +19,7 @@ from cmd_muhurta import _get_sun_moon_lons
|
||||
from jyotish_engine import _apply_ayanamsa
|
||||
from muhurta import _swisseph_sun_moon_lon
|
||||
from solar_return import _get_sun_lon_jd
|
||||
from solar_return import _datetime_to_jd_ut, _jd_to_datetime
|
||||
from transit_trigger import _datetime_to_jd, _get_planet_lon_swe
|
||||
|
||||
|
||||
@@ -65,6 +66,19 @@ def test_solar_return_sun_helper_defaults_to_lahiri_after_global_raman_switch():
|
||||
assert _angular_diff(actual, expected_lahiri) < 1e-9
|
||||
|
||||
|
||||
def test_solar_return_julian_datetime_helpers_work_without_greg_flag_constant():
|
||||
dt = datetime(2026, 4, 17, 6, 30, 0)
|
||||
|
||||
jd = _datetime_to_jd_ut(dt)
|
||||
roundtrip = _jd_to_datetime(jd)
|
||||
|
||||
assert roundtrip.year == 2026
|
||||
assert roundtrip.month == 4
|
||||
assert roundtrip.day == 17
|
||||
assert roundtrip.hour == 6
|
||||
assert roundtrip.minute == 30
|
||||
|
||||
|
||||
def test_muhurta_sun_moon_helper_defaults_to_lahiri_after_global_raman_switch():
|
||||
jd = swe.julday(2026, 6, 25, 4.0)
|
||||
expected_sun = _sidereal_lon(jd, swe.SUN, swe.SIDM_LAHIRI)
|
||||
|
||||
Reference in New Issue
Block a user