a4f8620a71
## 新增模块 (16个) ### P0 精度修复 - ashtakavarga: calc_prastara_av() + calc_sodhita_av() - kakshya.py: Kakshya评分系统 (8区间×3.75°) - shadbala.py: Sputa Drishti + Yuddha Bala ### P1 核心升级 - bhava_bala.py: 宫位三元力量 (jyotishganit MIT) - pancha_mahapurusha.py: PMC完整检测含4层失效条件 - sade_sati.py: Sade Sati+Kantaka Shani - sudarshana_chakra.py: 三参考点盘+收敛分析 - tajika.py: Sahams 7→36 + Tajika Yogas 10种 - birth_time_rectifier.py: 生时矫正 ### P2 覆盖扩展 - kp_system.py: KP Sublord+ABCD Significator (diliprk/VedicAstro MIT) - synastry.py: 16因子合盘36分制 (dashaflow MIT) - muhurtha_election.py: 6活动选举 (dashaflow MIT) - career_analysis.py: 结构化事业引擎 - relationship_analysis.py: 结构化感情引擎 - conditional_dashas.py: Dwisaptati+Shattrimsa+Dwadashottari - divisional_charts_extended: D81/D108/D144 - remedies.py: 5类补救系统 ## 修改文件 jaimini/dasha_calculator/shadbala/SKILL.md/COVERAGE_AUDIT等12个 ## 开源复用: 4个MIT项目
115 lines
4.9 KiB
Python
115 lines
4.9 KiB
Python
from typing import Optional
|
|
from pydantic import BaseModel
|
|
from fastapi import FastAPI
|
|
from concurrent.futures import ThreadPoolExecutor
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from vedicastro import VedicAstro, horary_chart, utils
|
|
|
|
app = FastAPI()
|
|
|
|
class ChartInput(BaseModel):
|
|
year: int
|
|
month: int
|
|
day: int
|
|
hour: int
|
|
minute: int
|
|
second: int
|
|
utc: str
|
|
latitude: float
|
|
longitude: float
|
|
ayanamsa: str = "Lahiri"
|
|
house_system: str = "Equal"
|
|
return_style: Optional[str] = None
|
|
|
|
class HoraryChartInput(BaseModel):
|
|
horary_number: int
|
|
year: int
|
|
month: int
|
|
day: int
|
|
hour: int
|
|
minute: int
|
|
second: int
|
|
utc: str
|
|
latitude: float
|
|
longitude: float
|
|
ayanamsa: str = "Krishnamurti"
|
|
house_system: str = "Placidus"
|
|
return_style: Optional[str] = None
|
|
|
|
# Add CORS middleware
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"], # Allows all origins
|
|
allow_credentials=True,
|
|
allow_methods=["*"], # Allows all methods
|
|
allow_headers=["*"], # Allows all headers
|
|
)
|
|
|
|
@app.get("/")
|
|
async def read_root():
|
|
return {"message": "Welcome to VedicAstro FastAPI Service!",
|
|
"info": "Visit http://127.0.0.1:8088/docs to test the API functions"}
|
|
|
|
|
|
@app.post("/get_all_horoscope_data")
|
|
async def get_chart_data(input: ChartInput):
|
|
"""
|
|
Generates all data for a given time and location, based on the selected ayanamsa & house system
|
|
"""
|
|
horoscope = VedicAstro.VedicHoroscopeData(input.year, input.month, input.day,
|
|
input.hour, input.minute, input.second,
|
|
input.latitude, input.longitude,
|
|
input.utc,
|
|
input.ayanamsa, input.house_system)
|
|
chart = horoscope.generate_chart()
|
|
|
|
planets_data = horoscope.get_planets_data_from_chart(chart)
|
|
houses_data = horoscope.get_houses_data_from_chart(chart)
|
|
planet_significators = horoscope.get_planet_wise_significators(planets_data, houses_data)
|
|
planetary_aspects = horoscope.get_planetary_aspects(chart)
|
|
house_significators = horoscope.get_house_wise_significators(planets_data, houses_data)
|
|
vimshottari_dasa_table = horoscope.compute_vimshottari_dasa(chart)
|
|
consolidated_chart_data = horoscope.get_consolidated_chart_data(planets_data=planets_data,
|
|
houses_data=houses_data,
|
|
return_style = input.return_style)
|
|
|
|
return {
|
|
"planets_data": [planet._asdict() for planet in planets_data],
|
|
"houses_data": [house._asdict() for house in houses_data],
|
|
"planet_significators": planet_significators,
|
|
"planetary_aspects": planetary_aspects,
|
|
"house_significators": house_significators,
|
|
"vimshottari_dasa_table": vimshottari_dasa_table,
|
|
"consolidated_chart_data": consolidated_chart_data
|
|
}
|
|
|
|
@app.post("/get_all_horary_data")
|
|
async def get_horary_data(input: HoraryChartInput):
|
|
"""
|
|
Generates all data for a given horary number, time and location as per KP Astrology system
|
|
"""
|
|
matched_time, vhd_hora_houses_chart, houses_data = horary_chart.find_exact_ascendant_time(input.year, input.month, input.day, input.utc, input.latitude, input.longitude, input.horary_number, input.ayanamsa)
|
|
vhd_hora = VedicAstro.VedicHoroscopeData(input.year, input.month, input.day,
|
|
input.hour, input.minute, input.second,
|
|
input.utc, input.latitude, input.longitude,
|
|
input.ayanamsa, input.house_system)
|
|
|
|
vhd_hora_planets_chart = vhd_hora.generate_chart()
|
|
planets_data = vhd_hora.get_planets_data_from_chart(vhd_hora_planets_chart, vhd_hora_houses_chart)
|
|
planet_significators = vhd_hora.get_planet_wise_significators(planets_data, houses_data)
|
|
planetary_aspects = vhd_hora.get_planetary_aspects(vhd_hora_planets_chart)
|
|
house_significators = vhd_hora.get_house_wise_significators(planets_data, houses_data)
|
|
vimshottari_dasa_table = vhd_hora.compute_vimshottari_dasa(vhd_hora_planets_chart)
|
|
consolidated_chart_data = vhd_hora.get_consolidated_chart_data(planets_data=planets_data,
|
|
houses_data=houses_data,
|
|
return_style = input.return_style)
|
|
|
|
return {
|
|
"planets_data": [planet._asdict() for planet in planets_data],
|
|
"houses_data": [house._asdict() for house in houses_data],
|
|
"planet_significators": planet_significators,
|
|
"planetary_aspects": planetary_aspects,
|
|
"house_significators": house_significators,
|
|
"vimshottari_dasa_table": vimshottari_dasa_table,
|
|
"consolidated_chart_data": consolidated_chart_data
|
|
} |