fix(varga): source D5/D6/D8/D11 from PVR 6.2 (BUG-1260, upstream f32472b5)

This commit is contained in:
jesse-ux
2026-10-07 16:39:01 +08:00
parent 5cc8e50458
commit db68e90816
5 changed files with 91 additions and 41 deletions
+16 -32
View File
@@ -159,6 +159,14 @@ class DivisionalChartsCalculator:
Returns:
分盘中的黄道度数(0-360)
"""
# D5/D6/D8/D11 share the sourced PVR mapping in varga.calc_varga.
if division in (5, 6, 8, 11):
try:
from varga import calc_varga
except ImportError:
from scripts.varga import calc_varga
point = calc_varga(degree, division)
return point['sign_idx'] * 30 + point['degree_in_sign']
# 获取星座索引和星座内度数
sign_index = int(degree // 30)
sign_degree = degree % 30
@@ -445,44 +453,20 @@ class DivisionalChartsCalculator:
return self._calculate_d12(d12_sign, d12_deg)
def _calculate_d5(self, sign_index: int, sign_degree: float) -> float:
"""D5 Panchamsa - 名声/权力分盘"""
part = int(sign_degree // 6)
if sign_index in self.ODD_SIGNS:
varga_sign = (sign_index + part) % 12
else:
varga_sign = (sign_index + 8 + part) % 12
varga_degree = (sign_degree % 6) * 5
return varga_sign * 30 + varga_degree
"""PVR 6.2.5 mapping shared with varga.calc_varga."""
return self._calculate_varga_position(sign_index * 30 + sign_degree, 5)
def _calculate_d6(self, sign_index: int, sign_degree: float) -> float:
"""D6 Shashthamsa - 健康/敌人分盘"""
part = int(sign_degree // 5)
if sign_index in self.ODD_SIGNS:
varga_sign = (sign_index + part) % 12
else:
varga_sign = (sign_index + 6 + part) % 12
varga_degree = (sign_degree % 5) * 6
return varga_sign * 30 + varga_degree
"""PVR 6.2.6 mapping shared with varga.calc_varga."""
return self._calculate_varga_position(sign_index * 30 + sign_degree, 6)
def _calculate_d8(self, sign_index: int, sign_degree: float) -> float:
"""D8 Ashtamsa - 突发事件分盘"""
part = int(sign_degree // 3.75)
if sign_index in self.ODD_SIGNS:
varga_sign = (sign_index + part) % 12
else:
varga_sign = (sign_index + 8 + part) % 12
varga_degree = (sign_degree % 3.75) * 8
return varga_sign * 30 + varga_degree
"""PVR 6.2.8 mapping shared with varga.calc_varga."""
return self._calculate_varga_position(sign_index * 30 + sign_degree, 8)
def _calculate_d11(self, sign_index: int, sign_degree: float) -> float:
"""D11 Rudramsa - 破坏/转化分盘"""
part = int(sign_degree // (30/11))
if sign_index in self.ODD_SIGNS:
varga_sign = (sign_index + part) % 12
else:
varga_sign = (sign_index + 8 + part) % 12
varga_degree = (sign_degree % (30/11)) * 11
return varga_sign * 30 + varga_degree
"""PVR 6.2.11 mapping shared with varga.calc_varga."""
return self._calculate_varga_position(sign_index * 30 + sign_degree, 11)
def _calculate_generic_varga(self, sign_index: int, sign_degree: float, division: int) -> float:
"""通用分盘算法(适用于其他分盘)"""
+10 -5
View File
@@ -69,10 +69,11 @@ def varga_map(si, pi, div):
if div==2: return (4 if o else 3) if pi==0 else (3 if o else 4)
if div==3: return (si+pi*4)%12 # Drekkana: same → +4 → +8, no odd/even distinction
if div==4: return (si+pi*3)%12
if div==5: return (si+pi)%12 if o else (si+8+pi)%12
if div==6: return (si+pi)%12 if o else (si+6+pi)%12
# PVR Integrated Approach 6.2.5 / 6.2.6 / 6.2.8. D8 start is movable Aries, fixed Sagittarius, dual Leo.
if div==5: return ((0,10,8,2,6) if o else (1,5,11,9,7))[pi]
if div==6: return ((0 if o else 6)+pi)%12
if div==7: return (si+pi)%12 if o else (si+6+pi)%12
if div==8: return (si+pi)%12 if o else (si+8+pi)%12
if div==8: return ((0,8,4)[si%3]+pi)%12
if div==9:
# BPHS Navamsa: movable=same, fixed=9th from sign (+8), dual=5th from sign (+4)
if si%3==0: start=si
@@ -80,7 +81,7 @@ def varga_map(si, pi, div):
else: start=(si+4)%12
return (start+pi)%12
if div==10: return (si+pi)%12 if o else (si+8+pi)%12 # D10: even signs count from 9th inclusively => +8 offset
if div==11: return (si+pi)%12 if o else (si+8+pi)%12 # D11 Rudramsa: mirror extended calculator
if div==11: return (-si+pi)%12 # PVR Integrated Approach 6.2.11: anti-zodiacal seed from Aries, then zodiacal parts
if div==12: return (si+pi)%12
if div==16: return ((0 if o else 4)+pi)%12 # D16: movable=+0, fixed=+4; dual needs separate (2026-05-03 fix: was +1)
if div==20: return ((0 if o else 8)+pi)%12
@@ -323,7 +324,11 @@ def calc_all_vargas(planet_lons, asc_lon, divisions=None, mode='classical_local'
)
vd={'_meta':{'div':div,'name':m.get('name',''),'cn':m.get('cn',''),
'area':m.get('area',''),'part_size':30.0/div,
'mapping_status': mapping_status}}
'mapping_status': mapping_status,
'mapping_source': (
'PVR Integrated Approach sections 6.2.5-6.2.11; D8 movable Aries, fixed Sagittarius, dual Leo'
if div in (5, 6, 8, 11) else mapping_status
)}}
vd['Ascendant']=normalize_varga_ascendant(calc_varga(asc_lon,div,mode=mode))
for pn,lon in planet_lons.items():
vd[pn]=calc_varga(lon,div,mode=mode)