0% found this document useful (0 votes)
251 views2 pages

SwissephemDLL Py

Python code (just basic code) for swiss ephemeris for western astrology. For vedic and other astrology, Ayanamsa need to be subtracted as following code: ############################################################ serr = ffi.new("char[22]", "Error in calculation") daya = ffi.new("double*") lib.swe_set_sid_mode(1, 0, 0) aflag = lib.swe_get_ayanamsa_ex(jul_day_UT, iflag, daya, serr) AYANAMSA = daya[0] ###########################################################

Uploaded by

surjansh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
251 views2 pages

SwissephemDLL Py

Python code (just basic code) for swiss ephemeris for western astrology. For vedic and other astrology, Ayanamsa need to be subtracted as following code: ############################################################ serr = ffi.new("char[22]", "Error in calculation") daya = ffi.new("double*") lib.swe_set_sid_mode(1, 0, 0) aflag = lib.swe_get_ayanamsa_ex(jul_day_UT, iflag, daya, serr) AYANAMSA = daya[0] ###########################################################

Uploaded by

surjansh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

# -*- coding: utf-8 -*-

# you need to have 'semo_18.se1' and 'sepl_18.se1' in 'C:\sweph\ephe\' and


'swedll32.dll' at the path mentioned in line 40
import cffi
import os
import datetime as dt
import math

SE_SUN = 0
SE_MOON = 1
SE_MERCURY = 2
SE_VENUS = 3
SE_MARS = 4
SE_JUPITER = 5
SE_SATURN = 6
SE_URANUS = 7
SE_NEPTUNE = 8
SE_PLUTO = 9
SE_MEAN_NODE = 10
SE_TRUE_NODE = 11
SE_GREG_CAL = 1 # for Gregorian calender

longitude = 74.23 # +ve is for EAST

date_place = '2017-02-21'
time_place = ' 15:30:00' # Time in IST
Date_Time = dt.datetime.strptime( date_place + time_place, '%Y-%m-%d %H:%M:%S' )
DAY = float((Date_Time - dt.datetime.strptime('1550-01-01', '%Y-%m-%d') +
dt.timedelta(days=1)).days + 2287184.50) # since 1550-01-01 is day-1
DAY = DAY - (longitude/360.0)

ffi = cffi.FFI()
ffi.cdef("""
double swe_julday(int year, int month, int day, double hour, int gregflag);
int swe_calc ( double tjd, int ipl, int iflag, double* xx, char* serr);
void swe_get_planet_name(int ipl,char* spnam);
double swe_sidtime(double tjdut);
int swe_get_ayanamsa_ex(double tjd_et, int iflag, double *daya, char *serr);
void swe_set_sid_mode(int sid_mode, double t0, double ayan_t0);
void swe_close(void);
int* swe_houses(double tjd_ut, double geolat, double geolon, int hsys, double
*cusp, double *ascmc);
char * swe_house_name(int hsys);
""")#
lib =
ffi.dlopen("C:\\Users\\surjansh\\Desktop\\Ephem\\sweph\\sweph\\bin\\swedll32.dll")

longitude = 82.5
latitude = 23.5
iflag = 2
xx = ffi.new("double[6]", [0, 0, 0, 0, 0, 0])
serr = ffi.new("char[7]", "Error")
jul_day_UT = lib.swe_julday(2017, 8, 30, 10.0, SE_GREG_CAL);
rflag = lib.swe_calc(jul_day_UT,0,iflag,xx,serr) # 0 for sun, 1 for moon, ... etc
as mentioned in line 4-15
##############################################
spnam = ffi.new( "char[]",3) # or "char[3]"
lib.swe_get_planet_name(0, spnam) # 0 for sun, 1 for moon, ... etc as mentioned in
line 4-15
print spnam[0]+spnam[1]+spnam[2]
##############################################
print xx[0], jul_day_UT

daya = ffi.new("double*")
lib.swe_set_sid_mode(1, 0, 0)
print lib.swe_get_ayanamsa_ex(jul_day_UT, iflag, daya, serr)
print daya[0]

################ sidereal time ##############

#eps_true = ffi.new("double",0.0)
#hsys = ffi.new("char","P") #"PKRCE"
cusp = ffi.new("double[13]")
ascmc = ffi.new("double[10]")
lib.swe_houses(jul_day_UT, latitude, longitude, ord('P'), cusp, ascmc);
print ascmc[0] # ASC (Ascendent) for the day

lib.swe_close()

You might also like