fix(dasha): measure nakshatra index and progress on one grid

Upstream 3c2dad95, 8643bc9a, and the lon_to_nakshatra part of 9e04f0db. Exact star starts were split across int-division and modulo, so 16 of 27 openings reported a zero balance and skipped the mahadasha. Off-boundary longitudes keep the old modulo. BUG-1381.

Co-Authored-By: Grok (agent loop)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
jesse-ux
2026-10-18 16:15:48 +08:00
co-authored by Grok (agent loop) Cursor
parent 68762ccec5
commit d11ee6f0dd
5 changed files with 138 additions and 29 deletions
+12 -6
View File
@@ -68,12 +68,18 @@ def fuzzy_match_nakshatra(name):
return None
def lon_to_nakshatra(moon_lon):
"""月亮黄经(0-360)→ Nakshatra + Pada"""
nak_span = 360 / 27
pada_span = nak_span / 4
idx = int(moon_lon / nak_span)
progress = (moon_lon % nak_span) / nak_span
pada = int((moon_lon % nak_span) / pada_span) + 1
"""月亮黄经(0-360)→ Nakshatra + Pada。序号与进度来自同一把尺子。"""
try:
from nakshatra_advanced import nakshatra_index_and_progress
except ImportError:
from scripts.nakshatra_advanced import nakshatra_index_and_progress
idx, progress = nakshatra_index_and_progress(moon_lon)
if progress == 0.0:
pada = 1
else:
nak_span = 360 / 27
pada_span = nak_span / 4
pada = int((float(moon_lon) % nak_span) / pada_span) + 1
return NAKSHATRA_LIST[idx], progress, pada
def build_dasha_timeline(birth_date_str, nak_info, nak_progress):