示例#1
0
def years_diff(y1, m1, d1, h1, y2, m2, d2, h2):
    swe.set_ephe_path(ephe_path)
    jd1 = swe.julday(y1, m1, d1, h1)
    jd2 = swe.julday(y2, m2, d2, h2)
    jd = jd1 + swe._years_diff(jd1, jd2)
    #jd = jd1 + ( (jd2-jd1) / 365.248193724 )
    y, mth, d, h, m, s = swe._revjul(jd, swe.GREG_CAL)
    return datetime.datetime(y, mth, d, h, m, s)
示例#2
0
def years_diff(y1, m1, d1, h1 , y2, m2, d2, h2):
		swe.set_ephe_path(ephe_path)
		jd1 = swe.julday(y1,m1,d1,h1)
		jd2 = swe.julday(y2,m2,d2,h2)
		jd = jd1 + swe._years_diff(jd1, jd2)
		#jd = jd1 + ( (jd2-jd1) / 365.248193724 )
		y, mth, d, h, m, s = swe._revjul(jd, swe.GREG_CAL)
		return datetime.datetime(y,mth,d,h,m,s)
示例#3
0
def get_star_longitude(star, jd):
    """ Calculate star longitude based on sefstars.txt.
  
  :param star: Example: Spica. 
  :param jd: 
  :return: 
  """
    from jyotisha.panchaanga.temporal import data
    import os
    swe.set_ephe_path(os.path.dirname(data.__file__))
    (long, lat, _, _, _, _) = swe.fixstar_ut(star, jd)[0]
    return long
示例#4
0
 def _setup_swisseph(self):
     """Prepare swisseph for calculations."""
     f = self._filter
     # ephemeris type
     if f._ephe_type == 'swiss':
         swe.set_ephe_path(f._ephe_path)
     elif f._ephe_type == 'jpl':
         swe.set_jpl_file(f._ephe_path)
     # sidereal mode
     if f._sid_mode > -1:
         swe.set_sid_mode(f._sid_mode, f._sid_t0, f._sid_ayan_t0)
     # situation
     if f._xcentric == 'topo':
         swe.set_topo(float(self._longitude), float(self._latitude),
             self._altitude)
示例#5
0
def check_input(input_json):
    try:
        if 'SWISSEPH_PATH' in os.environ:
            ephe_path = os.environ['SWISSEPH_PATH']
        else:
            raise ValueError("SWISSEPH_PATH must be set....")

        if os.path.isdir(ephe_path):
            swe.set_ephe_path(ephe_path)
        else:
            raise ValueError("Error, swiss ephemeris was not found")

        check_json(input_json)

        return input_json
    except Exception as e:
        raise ValueError(str(e))
示例#6
0
文件: swe.py 项目: ruthenium/flatlib
def setPath(path):
    """ Sets the path for the swe files. """
    swisseph.set_ephe_path(path)
示例#7
0
    def __init__(self,
                 year,
                 month,
                 day,
                 hour,
                 geolon,
                 geolat,
                 altitude,
                 planets,
                 zodiac,
                 openastrocfg,
                 houses_override=None):
        #ephemeris path (default "/usr/share/swisseph:/usr/local/share/swisseph")
        swe.set_ephe_path(ephe_path)

        #basic location
        self.jul_day_UT = swe.julday(year, month, day, hour)
        self.geo_loc = swe.set_topo(geolon, geolat, altitude)

        #output variables
        self.planets_sign = list(range(len(planets)))
        self.planets_degree = list(range(len(planets)))
        self.planets_degree_ut = list(range(len(planets)))
        self.planets_info_string = list(range(len(planets)))
        self.planets_retrograde = list(range(len(planets)))

        #iflag
        """
		#define SEFLG_JPLEPH         1L     // use JPL ephemeris
		#define SEFLG_SWIEPH         2L     // use SWISSEPH ephemeris, default
		#define SEFLG_MOSEPH         4L     // use Moshier ephemeris
		#define SEFLG_HELCTR         8L     // return heliocentric position
		#define SEFLG_TRUEPOS        16L     // return true positions, not apparent
		#define SEFLG_J2000          32L     // no precession, i.e. give J2000 equinox
		#define SEFLG_NONUT          64L     // no nutation, i.e. mean equinox of date
		#define SEFLG_SPEED3         128L     // speed from 3 positions (do not use it, SEFLG_SPEED is // faster and preciser.)
		#define SEFLG_SPEED          256L     // high precision speed (analyt. comp.)
		#define SEFLG_NOGDEFL        512L     // turn off gravitational deflection
		#define SEFLG_NOABERR        1024L     // turn off 'annual' aberration of light
		#define SEFLG_EQUATORIAL     2048L     // equatorial positions are wanted
		#define SEFLG_XYZ            4096L     // cartesian, not polar, coordinates
		#define SEFLG_RADIANS        8192L     // coordinates in radians, not degrees
		#define SEFLG_BARYCTR        16384L     // barycentric positions
		#define SEFLG_TOPOCTR      (32*1024L)     // topocentric positions
		#define SEFLG_SIDEREAL     (64*1024L)     // sidereal positions
		"""
        #check for apparent geocentric (default), true geocentric, topocentric or heliocentric
        iflag = swe.FLG_SWIEPH + swe.FLG_SPEED
        if (openastrocfg['postype'] == "truegeo"):
            iflag += swe.FLG_TRUEPOS
        elif (openastrocfg['postype'] == "topo"):
            iflag += swe.FLG_TOPOCTR
        elif (openastrocfg['postype'] == "helio"):
            iflag += swe.FLG_HELCTR

        #sidereal
        if (openastrocfg['zodiactype'] == "sidereal"):
            iflag += swe.FLG_SIDEREAL
            mode = "SIDM_" + openastrocfg['siderealmode']
            swe.set_sid_mode(getattr(swe, mode))

        #compute a planet (longitude,latitude,distance,long.speed,lat.speed,speed)
        for i in range(23):
            ret_flag = swe.calc_ut(self.jul_day_UT, i, iflag)
            for x in range(len(zodiac)):
                deg_low = float(x * 30)
                deg_high = float((x + 1) * 30)
                if ret_flag[0] >= deg_low:
                    if ret_flag[0] <= deg_high:
                        self.planets_sign[i] = x
                        self.planets_degree[i] = ret_flag[0] - deg_low
                        self.planets_degree_ut[i] = ret_flag[0]
                        #if latitude speed is negative, there is retrograde
                        if ret_flag[3] < 0:
                            self.planets_retrograde[i] = True
                        else:
                            self.planets_retrograde[i] = False

        #available house systems:
        """
		hsys= 		‘P’     Placidus
				‘K’     Koch
				‘O’     Porphyrius
				‘R’     Regiomontanus
				‘C’     Campanus
				‘A’ or ‘E’     Equal (cusp 1 is Ascendant)
				‘V’     Vehlow equal (Asc. in middle of house 1)
				‘X’     axial rotation system
				‘H’     azimuthal or horizontal system
				‘T’     Polich/Page (“topocentric” system)
				‘B’     Alcabitus
				‘G’     Gauquelin sectors
				‘M’     Morinus
		"""
        #houses calculation (hsys=P for Placidus)
        #check for polar circle latitude < -66 > 66
        if houses_override:
            self.jul_day_UT = swe.julday(houses_override[0],
                                         houses_override[1],
                                         houses_override[2],
                                         houses_override[3])

        if geolat > 66.0:
            geolat = 66.0
            print("polar circle override for houses, using 66 degrees")
        elif geolat < -66.0:
            geolat = -66.0
            print("polar circle override for houses, using -66 degrees")

        #sidereal houses
        if (openastrocfg['zodiactype'] == "sidereal"):
            sh = swe.houses_ex(self.jul_day_UT, geolat, geolon,
                               openastrocfg['houses_system'].encode("ascii"),
                               swe.FLG_SIDEREAL)
        else:
            sh = swe.houses(self.jul_day_UT, geolat, geolon,
                            openastrocfg['houses_system'].encode("ascii"))

        self.houses_degree_ut = list(sh[0])

        #arabic parts
        sun, moon, asc = self.planets_degree_ut[0], self.planets_degree_ut[
            1], self.houses_degree_ut[0]
        dsc, venus = self.houses_degree_ut[6], self.planets_degree_ut[3]

        #offset
        offset = moon - sun

        #if planet degrees is greater than 360 substract 360 or below 0 add 360
        for i in range(len(self.houses_degree_ut)):
            #add offset
            #self.houses_degree_ut[i] += offset

            if self.houses_degree_ut[i] > 360.0:
                self.houses_degree_ut[i] = self.houses_degree_ut[i] - 360.0
            elif self.houses_degree_ut[i] < 0.0:
                self.houses_degree_ut[i] = self.houses_degree_ut[i] + 360.0

        self.houses_degree = list(range(len(self.houses_degree_ut)))
        self.houses_sign = list(range(len(self.houses_degree_ut)))
        for i in range(12):
            for x in range(len(zodiac)):
                deg_low = float(x * 30)
                deg_high = float((x + 1) * 30)
                if self.houses_degree_ut[i] >= deg_low:
                    if self.houses_degree_ut[i] <= deg_high:
                        self.houses_sign[i] = x
                        self.houses_degree[
                            i] = self.houses_degree_ut[i] - deg_low

        #mean apogee
        bm = self.planets_degree_ut[12]
        #mean north node
        mn = self.planets_degree_ut[10]
        #perigee lunaire moyen
        pl = self.planets_degree_ut[22]
        #perigee solaire moyen
        #define SE_NODBIT_MEAN          1
        #define SE_NODBIT_OSCU          2
        #define SE_NODBIT_OSCU_BAR     4
        #define SE_NODBIT_FOPOINT     256
        #Return: 4 tuples of 6 float (asc, des, per, aph)
        ps = swe.nod_aps_ut(self.jul_day_UT, 0, swe.NODBIT_MEAN, iflag)
        pl = swe.nod_aps_ut(self.jul_day_UT, 1, swe.NODBIT_MEAN, iflag)
        ps = ps[2][0]
        pl = pl[2][0]
        #print mn
        #print sun
        #print ps
        #print moon
        #print pl

        c = 1.517 * math.sin(2 * math.radians(sun - mn))
        c += -0.163 * math.sin(math.radians(sun - ps))
        c += -0.128 * math.sin(2 * math.radians(moon - sun))
        c += 0.120 * math.sin(2 * math.radians(moon - mn))
        c += 0.107 * math.sin(2 * math.radians(pl - mn))
        c += 0.063 * math.sin(math.radians(3 * sun - ps - 2 * mn))
        c += 0.040 * math.sin(math.radians(moon + pl - 2 * sun))
        c += -0.040 * math.sin(math.radians(moon + pl - 2 * mn))
        c += 0.027 * math.sin(math.radians(moon - pl))
        c += -0.027 * math.sin(math.radians(sun + ps - 2 * mn))
        c += 0.015 * math.sin(2 * math.radians(sun - pl))
        c += -0.013 * math.sin(math.radians(moon + 2 * mn - pl - 2 * sun))
        c += -0.013 * math.sin(math.radians(moon - 2 * mn - pl + 2 * sun))
        c += -0.007 * math.sin(math.radians(2 * moon + pl - 3 * sun))
        c += 0.005 * math.sin(math.radians(3 * moon - pl - 2 * mn))
        c += -0.005 * math.sin(math.radians(3 * moon - pl - 2 * sun))
        #print c

        sbm = sun - bm
        if sbm < 0: sbm += 360
        if sbm > 180.0: sbm -= 180
        print("sun %s black moon %s sun-bm %s=%s" % (sun, bm, sun - bm, sbm))

        q = 12.333
        if sbm < 60.0:
            print('sbm<60')
            c = q * math.sin(1.5 * math.radians(sbm))
        elif sbm > 120.0:
            print('sbm>120')
            c = q * math.cos(1.5 * math.radians(sbm))
        else:
            print('sbm 60-120')
            c = -q * math.cos(3.0 * math.radians(sbm))

        true_lilith = c

        def true_lilith_calc(sun, lilith):
            deg = sun - lilith
            q = 12.333
            if deg < 0.0: deg += 360.0
            if deg > 180.0: deg -= 180.0

            if deg < 60.0:
                return q * math.sin(1.5 * math.radians(deg)
                                    ) - 1.892 * math.sin(3 * math.radians(deg))
            elif deg > 120.0:
                return q * math.cos(1.5 * math.radians(deg)
                                    ) + 1.892 * math.sin(3 * math.radians(deg))
            elif deg < 100.0:
                return -q * math.cos(
                    3.0 * math.radians(deg)) + 0.821 * math.cos(
                        4.5 * math.radians(deg))
            else:
                return -q * math.cos(3.0 * math.radians(deg))

        def true_lilith_calc2(sun, lilith):
            deg = sun - lilith
            q = 12.333
            if deg < 0.0: deg += 360.0
            if deg > 180.0: deg -= 180.0

            if deg < 60.0: return q * math.sin(1.5 * math.radians(deg))
            elif deg > 120.0: return q * math.cos(1.5 * math.radians(deg))
            else: return -q * math.cos(3.0 * math.radians(deg))

        true_lilith = true_lilith_calc2(sun, bm)
        #print c
        """
		if sbm < 60.0:
			print 'sbm 0-60'
			c=  q * math.sin(1.5*math.radians(sbm)) - 0.0917
		elif sbm >= 60.0 and sbm < 120.0:
			print 'sbm 60-120'
			c= -q * math.cos(3*math.radians(sbm)) - 0.0917
		elif sbm >= 120.0 and sbm < 240.0:
			print 'sbm 120-240'
			c= q * math.cos(1.5*math.radians(sbm)) - 0.0917
		elif sbm >= 240.0 and sbm < 300.0:
			print 'sbm 240-300'
			c= q * math.cos(3*math.radians(sbm)) - 0.0917
		else:
			print 'sbm 300-360'
			c= -q * math.sin(1.5*math.radians(sbm)) - 0.0917
		"""
        c += -0.117 * math.sin(math.radians(sun - ps))
        #print c

        #c+= x * -0.163 * math.sin(math.radians(sun-ps))
        #c+= x * -0.128 * math.sin(2*math.radians(moon-sun))
        #c+= x * 0.120 * math.sin(2*math.radians(moon-bm))
        #c+= x * 0.107 * math.sin(2*math.radians(pl-bm))
        #c+= x * 0.063 * math.sin(math.radians(3*sun-ps-2*bm))
        #c+= x * 0.040 * math.sin(math.radians(moon+pl-2*sun))
        #c+= x * -0.040 * math.sin(math.radians(moon+pl-2*bm))
        #c+= x * 0.027 * math.sin(math.radians(moon-pl))
        #c+= x * -0.027 * math.sin(math.radians(sun+ps-2*bm))
        #c+= x * 0.015 * math.sin(2*math.radians(sun-pl))
        #c+= x * -0.013 * math.sin(math.radians(moon+2*bm-pl-2*sun))
        #c+= x * -0.013 * math.sin(math.radians(moon-2*bm-pl+2*sun))
        #c+= x * -0.007 * math.sin(math.radians(2*moon+pl-3*sun))
        #c+= x * 0.005 * math.sin(math.radians(3*moon-pl-2*bm))
        #c+= x * -0.005 * math.sin(math.radians(3*moon-pl-2*sun))

        #compute additional points and angles
        #list index 23 is asc, 24 is Mc, 25 is Dsc, 26 is Ic
        self.planets_degree_ut[23] = self.houses_degree_ut[0]
        self.planets_degree_ut[24] = self.houses_degree_ut[9]
        self.planets_degree_ut[25] = self.houses_degree_ut[6]
        self.planets_degree_ut[26] = self.houses_degree_ut[3]

        #list index 27 is day pars
        self.planets_degree_ut[27] = asc + (moon - sun)
        #list index 28 is night pars
        self.planets_degree_ut[28] = asc + (sun - moon)
        #list index 29 is South Node
        self.planets_degree_ut[29] = self.planets_degree_ut[10] - 180.0
        #list index 30 is marriage pars
        self.planets_degree_ut[30] = (asc + dsc) - venus
        #list index 31 is black sun
        self.planets_degree_ut[31] = swe.nod_aps_ut(self.jul_day_UT, 0,
                                                    swe.NODBIT_MEAN,
                                                    swe.FLG_SWIEPH)[3][0]
        #list index 32 is vulcanus
        self.planets_degree_ut[32] = 31.1 + (self.jul_day_UT -
                                             2425246.5) * 0.00150579
        #list index 33 is persephone
        self.planets_degree_ut[33] = 240.0 + (self.jul_day_UT -
                                              2425246.5) * 0.002737829
        #list index 34 is true lilith (own calculation)
        self.planets_degree_ut[34] = self.planets_degree_ut[12] + true_lilith
        #swiss ephemeris version of true lilith
        #self.planets_degree_ut[34] = swe.nod_aps_ut(self.jul_day_UT,1,swe.NODBIT_OSCU,swe.FLG_SWIEPH)[3][0]

        #adjust list index 32 and 33
        for i in range(23, 35):
            while (self.planets_degree_ut[i] < 0):
                self.planets_degree_ut[i] += 360.0
            while (self.planets_degree_ut[i] > 360.0):
                self.planets_degree_ut[i] -= 360.0

            #get zodiac sign
            for x in range(12):
                deg_low = float(x * 30.0)
                deg_high = float((x + 1.0) * 30.0)
                if self.planets_degree_ut[i] >= deg_low:
                    if self.planets_degree_ut[i] <= deg_high:
                        self.planets_sign[i] = x
                        self.planets_degree[
                            i] = self.planets_degree_ut[i] - deg_low
                        self.planets_retrograde[i] = False

        #lunar phase, anti-clockwise degrees between sun and moon
        ddeg = moon - sun
        if ddeg < 0: ddeg += 360.0
        step = 360.0 / 28.0
        print(moon, sun, ddeg)
        for x in range(28):
            low = x * step
            high = (x + 1) * step
            if ddeg >= low and ddeg < high: mphase = x + 1
        sunstep = [
            0, 30, 40, 50, 60, 70, 80, 90, 120, 130, 140, 150, 160, 170, 180,
            210, 220, 230, 240, 250, 260, 270, 300, 310, 320, 330, 340, 350
        ]
        for x in range(len(sunstep)):
            low = sunstep[x]
            if x is 27: high = 360
            else: high = sunstep[x + 1]
            if ddeg >= low and ddeg < high: sphase = x + 1
        self.lunar_phase = {
            "degrees": ddeg,
            "moon_phase": mphase,
            "sun_phase": sphase
        }

        #close swiss ephemeris
        swe.close()
示例#8
0
import swisseph as swe
import collections
from Swiss_eph_constants import *

swe.set_ephe_path('/usr/share/ephe')  #set path to ephemeris files


class Chart(object):
    def __init__(self):
        self.data = []

    def Setup_eph(self, lat, long, side=1):

        swe.set_topo(lat, long)
        swe.set_sid_mode(side)

    def decdeg2dms(self, dd):
        is_positive = dd >= 0
        dd = abs(dd)
        minutes, seconds = divmod(dd * 3600, 60)
        degrees, minutes = divmod(minutes, 60)
        degrees = degrees if is_positive else -degrees
        return (degrees, minutes, seconds)

    def prnt(self, var):

        return (str(var[0]) + 'º ' + str(var[1]) + "' " +
                str(round(var[2], 2)) + '"')

    def getHouse(self, PlanetLocDict, HouseDict, planet):
示例#9
0
import swisseph as swe
import time
from datetime import datetime, timedelta

from my_ephe_path import EPHE_PATH

swe.set_ephe_path(EPHE_PATH) #set the filepath to your Swiss Ephemeris download
swe.set_sid_mode(swe.SIDM_LAHIRI) #uses Hindu-Lahiri ayanamsa for sidereal zodiac

SIGNKEY=('Aries', #0
		'Taurus', #1
		'Gemini', #2
		'Cancer', #3
		'Leo', #4
		'Virgo', #5
		'Libra', #6
		'Scorpio', #7
		'Sagittarius', #8
		'Capricorn', #9
		'Aquarius', #10
		'Pisces') #11

SIGNCUSPS=tuple(30*x for x in range(12)) #degree value of all sign cusps from 0 = 0 deg Aries to 330 = 0 deg Pisces

PLANETKEY=('Sun', #0
		'Moon', #1
		'Mercury', #2
		'Venus', #3
		'Mars', #4
		'Jupiter', #5
		'Saturn') #6
示例#10
0
    name = str(get['name'].value)
    city = str(get['city'].value)
    newcity = str(get['newcity'].value)
    lat = float(get['lat'].value)
    lon = float(get['lon'].value)
    newlat = float(get['newlat'].value)
    newlon = float(get['newlon'].value)
    year = int(get['year'].value)
    newyear = int(get['newyear'].value)
    month = int(get['month'].value)
    day = int(get['day'].value)
    time = float(get['time'].value)
    hsys = str(get['hsys'].value)
    display = str(get['display'].value)

    swe.set_ephe_path('ephe')

    # Thanks to openastro.org for this algorythm

    solaryearsecs = 31556925.51  # 365 days, 5 hours, 48 minutes, 45.51 seconds
    #print("localToSolar: from %s to %s" %(year,newyear))
    h, m, s = decHour(time)
    dt_original = datetime.datetime(year, month, day, h, m, s)
    dt_new = datetime.datetime(newyear, month, day, h, m, s)
    result1 = swe.calc_ut(swe.julday(year, month, day, time), 0)
    #print("localToSolar: first sun %s" % (result1[0]) )
    result2 = swe.calc_ut(swe.julday(newyear, month, day, time), 0)
    #print("localToSolar: second sun %s" % (result2[0]) )
    sundiff = result1[0] - result2[0]
    #print("localToSolar: sundiff %s" %(sundiff))
    sundelta = (sundiff / 360.0) * solaryearsecs
示例#11
0
# Rarely used, pprint is imported only upon such request for output.
# It also substitutes swe.get_planet_name - can be handy on occasion.

if "out" in re and re["out"] == "pprint":
  from pprint import pprint


if __name__ == "__main__":

    # This is a minimal e[phemeris].
    e = {"0": {}, "1": {}, "2": {}, "3": [], "4": []}

    # The data files, which may not be in the
    # [sin repo](https://github.com/astrolet/sin) /
    # [gravity pakage](http://search.npmjs.org/#/gravity).
    swe.set_ephe_path(re["data"])

    # Is using the Gregorian calendar flag correct?
    # If calendar type is conditional, is it easier to determine here (with the help of swe)?
    t = swe.utc_to_jd(re["ut"][0],
                      re["ut"][1],
                      re["ut"][2],
                      re["ut"][3],
                      re["ut"][4],
                      re["ut"][5],
                      re["ut"][6])
    # <!---
    # e["jd-ut1"] = swe.jdut1_to_utc(t[1], 1)
    # --->
    #
    # Ask for what is precious:
示例#12
0
文件: defs.py 项目: vitoroa/cerridwen
import os
import swisseph as sweph


### FILES AND DIRECTORIES
_ROOT = os.path.abspath(os.path.dirname(__file__))
sweph_dir = os.path.join(_ROOT, '../sweph')
dbfile = os.path.join(_ROOT, 'events.db')

sweph.set_ephe_path(sweph_dir)


### APPROXIMATOR TWEAKS
debug_event_approximation = False

maximum_error = 2e-6 # our guaranteed maximum error
max_data_points = 100000


### ASPECTS
# TODO there are quite a few minor aspects that aren't included yet.
dexter_aspects = [
        (30, 'semi-sextile'),
        (45, 'semi-square'),
        (60, 'sextile'),
        (72, 'quintile'),
        (120, 'trine'),
        (144, 'bi-quintile'),
        (150, 'quincunx')
]
示例#13
0
from datetime import datetime, timedelta
from collections import OrderedDict
from math import ceil

import networkx as nx
import swisseph
swisseph.set_ephe_path('/usr/share/libswe/ephe/')

DELTA = 0.0004

from IPython import embed


def diff(a1, a2):
    angle_diff = ((a1 - a2 + 180 + 360) % 360) - 180
    return angle_diff


def binary_search(function, target, lo=0, hi=None, delta=DELTA):
    val = None
    i = 0

    while lo < hi:

        mid = lo + (hi - lo) / 2
        dif = diff(function(mid), target)
        i += 1
        #print(i,lo,hi,dif,delta)
        if dif < 0:
            lo = mid
        else:
示例#14
0
#!/usr/bin/python3.6
# -*- coding: utf-8 -*-

import os
import swisseph as swe
import tkinter as tk
from math import cos, sin, radians

swe.set_ephe_path(os.path.join(os.getcwd(), "Eph"))

root = tk.Tk()
root.title("")
root.configure(bg="white")
root.resizable(width=False, height=False)


def source_path(relative_path):
    import sys
    base_path = getattr(sys, '_MEIPASS',
                        os.path.dirname(os.path.abspath(__file__)))
    return os.path.join(base_path, relative_path)


if os.name == "nt":
    root.iconbitmap(source_path("TkSwissEph.ico"))

canvas = None
toplevel = None


def create_toplevel():
示例#15
0
#!/usr/bin/env python
__author__ = 'naren'
import swisseph as swe
import datetime
import math
import birthchart
from astro import constants

swe.set_ephe_path('astro/data/ephemeris/')


def date_convert(jul_number):
    temp = swe.revjul(jul_number)
    year = temp[0]
    month = temp[1]
    day = temp[2]
    min_temp, hour = math.modf(temp[3])
    sec_temp, min = math.modf(min_temp * 60)
    sub_sec, sec = math.modf(sec_temp * 60)
    return datetime.datetime(year, month, day, int(hour), int(min), int(sec))


def solar(time_zone, year, month, day, location_latitude, location_longitude):
    solaar = {}
    now = swe.julday(year, month, day)
    for i in range(1):
        res_global = swe.sol_eclipse_when_glob(now)
        #print 'global', res_global
        t_start = res_global[1][0]
        lat_long = swe.sol_eclipse_where(t_start)
        #print 'where', lat_long
示例#16
0
#!/usr/bin/env python
__author__ = 'naren'
import swisseph as swe
import datetime
import math
import birthchart
from astro import constants

swe.set_ephe_path('../ephemeris/')


def date_convert(jul_number):
    temp = swe.revjul(jul_number)
    year = temp[0]
    month = temp[1]
    day = temp[2]
    min_temp, hour = math.modf(temp[3])
    sec_temp, min = math.modf(min_temp * 60)
    sub_sec, sec = math.modf(sec_temp * 60)
    return datetime.datetime(year, month, day, int(hour), int(min), int(sec))


# ###lunar eclipses
print 'When next Lunar Eclipse'
print '------------------------'
now = swe.julday(2016, 3, 23)
time_zone = 0  # we have to look up time zone from lat/long
res = swe.lun_eclipse_when(now)
res_how = swe.lun_eclipse_how(res[1][0], 139.7, 35.68)
print res
print res_how
示例#17
0
import swisseph as sweph
from cerridwen import jd_now


sweph.set_ephe_path("/home/sky/cerridwen/sweph/")

signs = ['Aries','Taurus','Gemini','Cancer','Leo','Virgo',
         'Libra','Scorpio','Sagittarius','Capricorn','Aquarius','Pisces'];

ranges = [['28 Gem', '10 Can'], ['22 Leo', '28 Leo']]

def sign_abbrev_to_idx(sa):
    abbrevs = [s[0:3] for s in signs]
    for i, abbrev in enumerate(abbrevs):
        if abbrev == sa:
            return i

assert(sign_abbrev_to_idx('Gem')==2)


def absrange(relrange):
    start, end = relrange
    deg, sign = start.split(' ')
    start_abs = int(deg) + sign_abbrev_to_idx(sign)*30
    deg, sign = end.split(' ')
    end_abs = int(deg) + sign_abbrev_to_idx(sign)*30
    return [start_abs, end_abs]


ranges = list(map(absrange, ranges))
示例#18
0
def getinfo(lat=0.0,
            lon=0.0,
            year=1970,
            month=1,
            day=1,
            time=0.0,
            hsys='E',
            display=range(23)):

    swe.set_ephe_path('ephe')

    julday = swe.julday(year, month, day, time)
    geo = swe.set_topo(lon, lat, 0)
    houses, ascmc = swe.houses(julday, lat, lon, hsys)

    for body in range(25):
        if str(body) in display:
            if body == 23:
                result = swe.calc_ut(julday, 10)
                degree_ut = sanitize(result[0] + 180)
                retrograde = bool(result[3] > 0)
            elif body == 24:
                result = swe.calc_ut(julday, 11)
                degree_ut = sanitize(result[0] + 180)
                retrograde = bool(result[3] > 0)
            else:
                result = swe.calc_ut(julday, body)
                degree_ut = result[0]
                retrograde = bool(result[3] < 0)
            for sign in range(12):
                deg_low = float(sign * 30)
                deg_high = float((sign + 1) * 30)
                if (degree_ut >= deg_low and degree_ut <= deg_high):
                    cibody = {
                        "id": body,
                        "name": bnames[body],
                        "sign": sign,
                        "sign_name": snames[sign],
                        "degree": degree_ut - deg_low,
                        "degree_ut": degree_ut,
                        "retrograde": retrograde
                    }
                    cibodies.append(cibody)

    for index, degree_ut in enumerate(houses):
        for sign in range(12):
            deg_low = float(sign * 30)
            deg_high = float((sign + 1) * 30)
            if (degree_ut >= deg_low and degree_ut <= deg_high):
                cihouse = {
                    "id": index + 1,
                    "number": hnames[index],
                    "name": "House",
                    "sign": sign,
                    "sign_name": snames[sign],
                    "degree": degree_ut - deg_low,
                    "degree_ut": degree_ut
                }
                cihouses.append(cihouse)

    for index, degree_ut in enumerate(ascmc):
        for sign in range(12):
            deg_low = float(sign * 30)
            deg_high = float((sign + 1) * 30)
            if (degree_ut >= deg_low and degree_ut <= deg_high):
                ciascmc = {
                    "id": index + 1,
                    "name": anames[index],
                    "sign": sign,
                    "sign_name": snames[sign],
                    "degree": degree_ut - deg_low,
                    "degree_ut": degree_ut
                }
                ciascmcs.append(ciascmc)

    for body1 in cibodies:
        deg1 = body1["degree_ut"] - ciascmcs[0]["degree_ut"] + 180
        for body2 in cibodies:
            deg2 = body2["degree_ut"] - ciascmcs[0]["degree_ut"] + 180
            test_aspect(body1, body2, deg1, deg2, 180, 10, "Opposition")
            test_aspect(body1, body2, deg1, deg2, 150, 2, "Quincunx")
            test_aspect(body1, body2, deg1, deg2, 120, 8, "Trine")
            test_aspect(body1, body2, deg1, deg2, 90, 6, "Square")
            test_aspect(body1, body2, deg1, deg2, 60, 4, "Sextile")
            test_aspect(body1, body2, deg1, deg2, 30, 1, "Semi-sextile")
            test_aspect(body1, body2, deg1, deg2, 0, 10, "Conjunction")

    swe.close()

    cibodies.sort(cmp_bodies)

    old_deg = -1000.
    dist = 0
    for body in cibodies:
        deg = body["degree_ut"] - ciascmcs[0]["degree_ut"] + 180
        dist = dist + 1 if math.fabs(old_deg - deg) < 5 else 0
        body["dist"] = dist
        old_deg = deg

    ciresults = {
        "bodies": cibodies,
        "houses": cihouses,
        "ascmcs": ciascmcs,
        "aspects": ciaspects,
    }

    return ciresults
示例#19
0
#!/usr/bin/env python
__author__ = 'naren'
import numpy as np
import birthchart
import datetime
import pandas as pd
import swisseph as swe
from astro import constants
import numpy as np
import time

swe.set_ephe_path('astro/data/ephemeris/')  # path to ephemeris files

start_time = datetime.datetime.utcnow()
print 'date is: ', start_time
#print start_time.tzinfo
birth_date = start_time
time_birth_hour = start_time.hour  # 24 hour format
time_birth_min = start_time.minute  # 24 hour format
bt_zone = float(0)  # Positive for East of London
city_latitude = float(28.66666667)  # Positive for north of Equator
city_longitude = float(77.21666667)  # positive for East of London
is_birth_time = False
x, y = np.array(birthchart.ephemeris_calc(0.,birth_date, time_birth_hour, time_birth_min))
# x, y = np.array(birthchart.natal_chart_calc(bt_zone, birth_offset, birth_date, time_birth_hour, time_birth_min,
# birth_latitude, birth_longitude, is_birth_time, house_type))
signs = birthchart.natal_planet_signs(x)
#print signs
for i in range(len(x)):
    planet_deg = int(x[i])
    p_min = x[i] - planet_deg
示例#20
0
文件: swe.py 项目: xAlstrat/flatlib
def setPath(path):
    """ Sets the path for the swe files. """
    swisseph.set_ephe_path(path)
示例#21
0
#!/usr/bin/env python
__author__ = 'naren'
import swisseph as swe
import datetime
import math
import birthchart
from astro import constants

swe.set_ephe_path('astro/data/ephemeris/')


def date_convert(jul_number):
    temp = swe.revjul(jul_number)
    year = temp[0]
    month = temp[1]
    day = temp[2]
    min_temp, hour = math.modf(temp[3])
    sec_temp, min = math.modf(min_temp * 60)
    sub_sec, sec = math.modf(sec_temp * 60)
    return datetime.datetime(year, month, day, int(hour), int(min), int(sec))


print 'Next Solar Eclipse global'
print '------------------------'
now = swe.julday(2017, 8, 1)
time_zone = -0  # we have to look up time zone from lat/long

for i in range(1):
    res_global = swe.sol_eclipse_when_glob(now)
    print 'global', res_global
    t_start = res_global[1][0]
示例#22
0
# -*- coding: utf-8 -*-
import os
import sys
import math
from datetime import datetime
from utils import dechourjoin

import swisseph as swe
from settings import SWE_DATAFILE_PATH
swe.set_ephe_path(SWE_DATAFILE_PATH)

bnames = ["sun", "moon", "mercury", "venus", "mars", "jupiter", "saturn",\
          "uranus", "neptune", "pluto", "mean node"]
#swisseph 中 星体代码
bnames_se = {"sun":0, "moon":1, "mercury":2, "venus":3, "mars":4, "jupiter":5, \
          "saturn":6, "uranus":7, "neptune":8, "pluto":9, "mean node":10}
anames = ["Asc", "Mc"]
#十二星座
snames = ["aries", "taurus", "gemini", "cancer", "leo", "virgo", "libra", 
"scorpio", "sagittarius", "capricorn", "aquarius", "pisces"]

DEFAULT_DATE = datetime(1990, 3, 30, 18, 15, 0)

class swissephData:

    def __init__(self):
        self.cibodies  = []
        self.cihouses  = []
        self.ciascmcs  = []
        self.ciresults = {}
    
示例#23
0
文件: ci.py 项目: DarkSide666/AstroWS
def getinfo(lat=0.0, lon=0.0, year=1970, month=1, day=1, time=0.0, hsys='E', display=range(23)):

	swe.set_ephe_path('ephe')

	julday = swe.julday(year, month, day, time)
	geo = swe.set_topo(lon, lat, 0)
	houses, ascmc = swe.houses(julday, lat, lon, hsys)
	
	for body in range(25):
		if str(body) in display:
			if body == 23:
				result = swe.calc_ut(julday, 10)
				degree_ut = sanitize(result[0] + 180);
				retrograde = bool(result[3] > 0)
			elif body == 24:
				result = swe.calc_ut(julday, 11)
				degree_ut = sanitize(result[0] + 180);
				retrograde = bool(result[3] > 0)		
			else:
				result = swe.calc_ut(julday, body)
				degree_ut = result[0];
				retrograde = bool(result[3] < 0)			
			for sign in range(12):
				deg_low =  float(sign * 30)
				deg_high = float((sign + 1) * 30)
				if (degree_ut >= deg_low and degree_ut <= deg_high):
					cibody = { "id"         : body,
						       "name"       : bnames[body],
						       "sign"       : sign,
						       "sign_name"  : snames[sign],
						       "degree"     : degree_ut - deg_low,
						       "degree_ut"  : degree_ut,
						       "retrograde" : retrograde }
					cibodies.append(cibody)

	for index, degree_ut in enumerate(houses):
		for sign in range(12):
			deg_low =  float(sign * 30)
			deg_high = float((sign + 1) * 30)
			if (degree_ut >= deg_low and degree_ut <= deg_high):
				cihouse = { "id"         : index + 1,
				            "number"     : hnames[index],
				            "name"       : "House",
				            "sign"       : sign,
				            "sign_name"  : snames[sign],
				            "degree"     : degree_ut - deg_low,
				            "degree_ut"  : degree_ut }
				cihouses.append(cihouse)
	
	for index, degree_ut in enumerate(ascmc):
		for sign in range(12):
			deg_low =  float(sign * 30)
			deg_high = float((sign + 1) * 30)
			if (degree_ut >= deg_low and degree_ut <= deg_high):
				ciascmc = { "id"         : index + 1,
				            "name"       : anames[index],
				            "sign"       : sign,
				            "sign_name"  : snames[sign],
				            "degree"     : degree_ut - deg_low,
				            "degree_ut"  : degree_ut }
				ciascmcs.append(ciascmc)
	
	for body1 in cibodies:
		deg1 = body1["degree_ut"] - ciascmcs[0]["degree_ut"] + 180
		for body2 in cibodies:
			deg2 = body2["degree_ut"] - ciascmcs[0]["degree_ut"] + 180
			test_aspect(body1, body2, deg1, deg2, 180, 10, "Opposition")
			test_aspect(body1, body2, deg1, deg2, 150,  2, "Quincunx")
			test_aspect(body1, body2, deg1, deg2, 120,  8, "Trine")
			test_aspect(body1, body2, deg1, deg2,  90,  6, "Square")
			test_aspect(body1, body2, deg1, deg2,  60,  4, "Sextile")
			test_aspect(body1, body2, deg1, deg2,  30,  1, "Semi-sextile")
			test_aspect(body1, body2, deg1, deg2,   0, 10, "Conjunction")

	swe.close()
	
	cibodies.sort(cmp_bodies)

	old_deg = -1000.
	dist = 0
	for body in cibodies:
		deg = body["degree_ut"] - ciascmcs[0]["degree_ut"] + 180
		dist = dist + 1 if math.fabs(old_deg - deg) < 5 else 0
		body["dist"] = dist
		old_deg = deg
	
	ciresults = {
		"bodies"  : cibodies,
		"houses"  : cihouses,
		"ascmcs"  : ciascmcs,
		"aspects" : ciaspects,
		}

	return ciresults
示例#24
0
# Rarely used, pprint is imported only upon such request for output.
# It also substitutes swe.get_planet_name - can be handy on occasion.

if "out" in re and re["out"] == "pprint":
    from pprint import pprint


if __name__ == "__main__":

    # This is a minimal e[phemeris].
    e = {"0": {}, "1": {}, "2": {}, "3": [], "4": []}

    # The data files, which may not be in the
    # [sin repo](https://github.com/astrolet/sin) /
    # [gravity pakage](http://search.npmjs.org/#/gravity).
    swe.set_ephe_path(re["data"])

    # Is using the Gregorian calendar flag correct?
    # If calendar type is conditional, is it easier to determine here (with the help of swe)?
    t = swe.utc_to_jd(re["ut"][0], re["ut"][1], re["ut"][2], re["ut"][3], re["ut"][4], re["ut"][5], re["ut"][6])
    # <!---
    # e["jd-ut1"] = swe.jdut1_to_utc(t[1], 1)
    # --->
    #
    # Ask for what is precious:
    #
    # 1. majors (the main things / points for astrology)
    # 2. minors (other objects - e.g. some "minor planets")
    # 3. angles (ascmc) = 8 of 10 doubles (unused 8 & 9)
    # 4. houses (cusps) = 12 of 13 doubles (unused zero)
    #
示例#25
0
import csv
import math
import sys
from pathlib import Path
from random import random, shuffle
from typing import Tuple, List, Dict, Optional

import numpy as np
import swisseph as swe

import roc_sd
from roc_estimates import ROC_SD

DAYS_IN_YEAR = (swe.julday(2300, 1, 1) - swe.julday(1900, 1, 1)) / 400

swe.set_ephe_path("/home/dmc/astrolog/astephem")

SUN = 0
MERCURY = 2
VENUS = 3
"""
For each "planet" we're going to consider, we record its index in SwissEph, its full name, a unique two-letter
identifier, and its orbital period in years. (Astrologers use the term "planet" to include not only true astronomical
planets but all bodies of interest in the solar system, including the Sun, Moon, asteroids and other things too small
to be planets).
"""
PLANET_DATA = [
    (0, "Sun", "Su", 1.0),
    (1, "Moon", "Mo", 0.074),
    (2, "Mercury", "Me", 0.241),
    (3, "Venus", "Ve", 0.699),
示例#26
0
#!/usr/bin/env python
__author__ = 'naren'
import swisseph as swe
import datetime
import math
import birthchart
from astro import constants

swe.set_ephe_path('../ephemeris/')


def date_convert(jul_number):
    temp = swe.revjul(jul_number)
    year = temp[0]
    month = temp[1]
    day = temp[2]
    min_temp, hour = math.modf(temp[3])
    sec_temp, min = math.modf(min_temp * 60)
    sub_sec, sec = math.modf(sec_temp * 60)
    return datetime.datetime(year, month, day, int(hour), int(min), int(sec))


def lunar(time_zone, year, month, day, location_latitude, location_longitude):
    # ###lunar eclipses
    lunar_eclipse = {}
    now = swe.julday(year, month, day)
    res = swe.lun_eclipse_when(now)
    res_how = swe.lun_eclipse_how(res[1][0], 139.7, 35.68)
    #print res
    #print res_how
    eclip_time = swe.revjul(res[1][0])  # utc
示例#27
0
from dateutil.parser import parse
import pytz
import geocoder
import swisseph as swe
swe.set_ephe_path('/usr/share/libswe/ephe/')

from django.utils.translation import ugettext_lazy as _
from django.utils.translation import pgettext_lazy
from django.db import models
from timezone_field import TimeZoneField
from tzwhere.tzwhere import tzwhere
from users.models import UserProfile

tzwhere = tzwhere()

class Event(models.Model):
    user = models.ForeignKey(UserProfile, related_name='events', null=True, verbose_name=_('User'))
    name = models.CharField(max_length=256, verbose_name=_('Name'))
    date = models.DateTimeField(verbose_name=_('Date'))
    city = models.CharField(max_length=256, verbose_name=_('City'))

    location = models.ForeignKey('Location', related_name='events', null=True, verbose_name=_('Location'))
    ephemeris = models.OneToOneField('Ephemeris', related_name='event', verbose_name=_('Events'))
    houses = models.OneToOneField('Houses', related_name='event', verbose_name=_('Houses'))

    class Meta:
        verbose_name = _('event')
        verbose_name_plural = _('events')

    def __unicode__(self):
        return self.name
示例#28
0
import swisseph as sweph
from cerridwen import jd_now

sweph.set_ephe_path("/home/sky/cerridwen/sweph/")

signs = [
    'Aries', 'Taurus', 'Gemini', 'Cancer', 'Leo', 'Virgo', 'Libra', 'Scorpio',
    'Sagittarius', 'Capricorn', 'Aquarius', 'Pisces'
]

ranges = [['28 Gem', '10 Can'], ['22 Leo', '28 Leo']]


def sign_abbrev_to_idx(sa):
    abbrevs = [s[0:3] for s in signs]
    for i, abbrev in enumerate(abbrevs):
        if abbrev == sa:
            return i


assert (sign_abbrev_to_idx('Gem') == 2)


def absrange(relrange):
    start, end = relrange
    deg, sign = start.split(' ')
    start_abs = int(deg) + sign_abbrev_to_idx(sign) * 30
    deg, sign = end.split(' ')
    end_abs = int(deg) + sign_abbrev_to_idx(sign) * 30
    return [start_abs, end_abs]
示例#29
0
	name    = str  (get['name'].value)
	city    = str  (get['city'].value)
	newcity = str  (get['newcity'].value)
	lat     = float(get['lat'].value)
	lon     = float(get['lon'].value)
	newlat  = float(get['newlat'].value)
	newlon  = float(get['newlon'].value)
	year    = int  (get['year'].value)
	newyear = int  (get['newyear'].value)
	month   = int  (get['month'].value)
	day     = int  (get['day'].value)
	time    = float(get['time'].value)
	hsys    = str  (get['hsys'].value)
	display = str  (get['display'].value)

	swe.set_ephe_path('ephe')
	
	# Thanks to openastro.org for this algorythm

	solaryearsecs = 31556925.51 # 365 days, 5 hours, 48 minutes, 45.51 seconds
	#print("localToSolar: from %s to %s" %(year,newyear))
	h,m,s = decHour(time)
	dt_original = datetime.datetime(year,month,day,h,m,s)
	dt_new = datetime.datetime(newyear,month,day,h,m,s)
	result1 = swe.calc_ut(swe.julday(year,month,day,time), 0)
	#print("localToSolar: first sun %s" % (result1[0]) )
	result2 = swe.calc_ut(swe.julday(newyear,month,day,time), 0)
	#print("localToSolar: second sun %s" % (result2[0]) )
	sundiff = result1[0] - result2[0]
	#print("localToSolar: sundiff %s" %(sundiff))
	sundelta = ( sundiff / 360.0 ) * solaryearsecs
示例#30
0
import planet_rise_times
import ip2location_lookup
import ephemeris_today
import moon_phases
import eclipse_solar
import eclipses_lunar

#############################################################################################################################
############################################### Common ######################################################################

con = sqlite3.connect('city', check_same_thread=False)
curr = con.cursor()
application = Flask(__name__, static_url_path='/astro/static')
api = Api(application)

swe.set_ephe_path('astro/data/ephemeris/')  # path to ephemeris files
f = urllib2.urlopen('http://jsonip.com/')
json_string = f.read()
f.close()
ip_add = json.loads(json_string)
ip_addrs = ip_add['ip']#'2607:f1c0:83c:7000:0:0:43:963d'
tt = ''
if (re.match('^[0-9]{0,3}.[0-9]{0,3}.[0-9]{0,3}.[0-9]{0,3}$', ip_addrs)):
    tt = 1
    location_latitude, location_longitude, TimezoneID, region, city, country, timezone  = ip2location_lookup.ipv42loc(ip_addrs)
    
else:
    tt = 0
    location_latitude, location_longitude, TimezoneID, region, city, country, timezone  = ip2location_lookup.ipv62loc(ip_addrs)
#print 'latitude is', location_latitude
#print 'Longitude is', location_longitude
示例#31
0
    hora) + ':' + str(min) + '"'

horaLocal = horaLocal - datetime.timedelta(hours=int(gmt))
#horaLocal = horaLocal - datetime.timedelta(minutes=int(30))
#print(horaLocal)

#Luego de aplicar el GMT
dia = horaLocal.strftime('%d')
mes = int(horaLocal.strftime('%m'))
anio = horaLocal.strftime('%Y')
hora = horaLocal.strftime('%H')
min = horaLocal.strftime('%M')

#print('Tiempo: ' + dia + '/' + mes + '/' + anio + ' ' + hora + ':' + min)

swe.set_ephe_path('/usr/share/libswe/ephe')

d = datetime.datetime(int(anio), int(mes), int(dia), int(hora), int(min))
jd1 = jdutil.datetime_to_jd(d)

np = [('Sol', 0), ('Luna', 1), ('Mercurio', 2), ('Venus', 3), ('Marte', 4),
      ('Júpiter', 5), ('Saturno', 6), ('Urano', 7), ('Neptuno', 8),
      ('Plutón', 9), ('Nodo Norte', 11), ('Nodo Sur', 10), ('Quirón', 15),
      ('Selena', 57), ('Lilith', 12)]

#La oblicuidad de calcula con ipl = SE_ECL_NUT = -1 en SWE pero en swisseph ECL_NUT = -1
posObli = swe.calc(jd1, -1, flag=swe.FLG_SWIEPH + swe.FLG_SPEED)
oblicuidad = posObli[0][0]
#pos=swe.calc_ut(jd1, np[4][1], flag=swe.FLG_SWIEPH+swe.FLG_SPEED)
#pos=swe.calc_ut(jd1, np[4][1], flag=swe.FLG_SWIEPH)
pos = swe.calc_ut(jd1, np[2][1], flag=swe.FLG_SPEED)
示例#32
0
data_book = {'Sheet1': []}
##pyexcel.save_as(array=data, dest_file_name=output_file)
#sheet = pyexcel.Sheet(data)
other_book = pyexcel.Book(data_book)
other_book.save_as(output_file)

input_file = u"xls_wordlist.xls"
empty_row = ["NA", "NA", "NA", "NA", "NA", "NA", "NA", "NA", "NA"]
i = -1
row_to_add = []
for value in empty_row:
    i += 1
    row_to_add.append(empty_row[i])

ephe_path = '/usr/share/libswe/:/usr/local/share/libswe/'
swe.set_ephe_path(ephe_path)
gregflag = 1
geolon = 0.34  #bordeaux
geolat = 44.50  #bordeaux

#Ce serait bien de faire une liste du top 10 des occurences contenant le moins de lettres
# implement limit to psalms


def Read_cell(
    x=1,
    y=1
):  #this procedure uses an xls file and pyexcel the other should be harmonized
    print "reading cell", x, y, "from", input_file
    global input_file
示例#33
0
        #name = chrt.planets.planets[j].name
        #riseset = chrt.riseset.planetRiseSet(j)
        out.append("%.2f\t%.2f\t%.3f\t%.2f\t" % (lon, lat, decl, speed))

    for asteroid in chrt.asteroids.asteroids:
        lon = asteroid.data[planets.Planet.LONG]
        lat = asteroid.data[planets.Planet.LAT]
        speed = asteroid.data[planets.Planet.SPLON]
        decl = asteroid.dataEqu[planets.Planet.DECLEQU]
        out.append("%.2f\t%.2f\t%.3f\t%.2f\t" % (lon, lat, decl, speed))

    sys.stdout.write(''.join(out))


opts = options.Options()
swisseph.set_ephe_path('../SWEP/Ephem')
# instance of place, time and chart generation
# Based on Greenwich place and UTC time.
place = chart.Place(None, 51, 29, 24, True, 0, 0, 0, True, 0)
time = chart.event.DateTime(2020, 8, 20, 0, 0, 0, False, 0, 0, True, 0, 0,
                            False, place)
chrt = chart.Chart("Daily Chart", False, time, place, 0, "", opts)

print("Date\tHour\t" \
    "SULON\tSULAT\tSUDEC\tSUSP\t" \
    "MOLON\tMOLAT\tMODEC\tMOSP\t" \
    "MELON\tMELAT\tMEDEC\tMESP\t" \
    "VELON\tVELAT\tVEDEC\tVESP\t" \
    "MALON\tMALAT\tMADEC\tMASP\t" \
    "JULON\tJULAT\tJUDEC\tJUSP\t" \
    "SALON\tSALAT\tSADEC\tSASP\t" \
示例#34
0
	def __init__(self,year,month,day,hour,geolon,geolat,altitude,planets,zodiac,openastrocfg,houses_override=None):
		#ephemeris path (default "/usr/share/swisseph:/usr/local/share/swisseph")
		swe.set_ephe_path(ephe_path)
		
		#basic location		
		self.jul_day_UT=swe.julday(year,month,day,hour)
		self.geo_loc = swe.set_topo(geolon,geolat,altitude)

		#output variables
		self.planets_sign = range(len(planets))
		self.planets_degree = range(len(planets))
		self.planets_degree_ut = range(len(planets))
		self.planets_info_string = range(len(planets))
		self.planets_retrograde = range(len(planets))
		
		#iflag
		"""
		#define SEFLG_JPLEPH         1L     // use JPL ephemeris
		#define SEFLG_SWIEPH         2L     // use SWISSEPH ephemeris, default
		#define SEFLG_MOSEPH         4L     // use Moshier ephemeris
		#define SEFLG_HELCTR         8L     // return heliocentric position
		#define SEFLG_TRUEPOS        16L     // return true positions, not apparent
		#define SEFLG_J2000          32L     // no precession, i.e. give J2000 equinox
		#define SEFLG_NONUT          64L     // no nutation, i.e. mean equinox of date
		#define SEFLG_SPEED3         128L     // speed from 3 positions (do not use it, SEFLG_SPEED is // faster and preciser.)
		#define SEFLG_SPEED          256L     // high precision speed (analyt. comp.)
		#define SEFLG_NOGDEFL        512L     // turn off gravitational deflection
		#define SEFLG_NOABERR        1024L     // turn off 'annual' aberration of light
		#define SEFLG_EQUATORIAL     2048L     // equatorial positions are wanted
		#define SEFLG_XYZ            4096L     // cartesian, not polar, coordinates
		#define SEFLG_RADIANS        8192L     // coordinates in radians, not degrees
		#define SEFLG_BARYCTR        16384L     // barycentric positions
		#define SEFLG_TOPOCTR      (32*1024L)     // topocentric positions
		#define SEFLG_SIDEREAL     (64*1024L)     // sidereal positions 		
		"""
		#check for apparent geocentric (default), true geocentric, topocentric or heliocentric
		iflag=swe.FLG_SWIEPH+swe.FLG_SPEED
		if(openastrocfg['postype']=="truegeo"):
			iflag += swe.FLG_TRUEPOS
		elif(openastrocfg['postype']=="topo"):
			iflag += swe.FLG_TOPOCTR
		elif(openastrocfg['postype']=="helio"):
			iflag += swe.FLG_HELCTR

		#sidereal
		if(openastrocfg['zodiactype']=="sidereal"):
			iflag += swe.FLG_SIDEREAL
			mode="SIDM_"+openastrocfg['siderealmode']
			swe.set_sid_mode(getattr(swe,mode.encode("ascii")))

		#compute a planet (longitude,latitude,distance,long.speed,lat.speed,speed)
		for i in range(23):
			ret_flag = swe.calc_ut(self.jul_day_UT,i,iflag)
			for x in range(len(zodiac)):
				deg_low=float(x*30)
				deg_high=float((x+1)*30)
				if ret_flag[0] >= deg_low:
					if ret_flag[0] <= deg_high:
						self.planets_sign[i]=x
						self.planets_degree[i] = ret_flag[0] - deg_low
						self.planets_degree_ut[i] = ret_flag[0]
						#if latitude speed is negative, there is retrograde
						if ret_flag[3] < 0:						
							self.planets_retrograde[i] = True
						else:
							self.planets_retrograde[i] = False

							
		#available house systems:
		"""
		hsys= ‘P’     Placidus
				‘K’     Koch
				‘O’     Porphyrius
				‘R’     Regiomontanus
				‘C’     Campanus
				‘A’ or ‘E’     Equal (cusp 1 is Ascendant)
				‘V’     Vehlow equal (Asc. in middle of house 1)
				‘X’     axial rotation system
				‘H’     azimuthal or horizontal system
				‘T’     Polich/Page (“topocentric” system)
				‘B’     Alcabitus
				‘G’     Gauquelin sectors
				‘M’     Morinus
		"""
		#houses calculation (hsys=P for Placidus)
		#check for polar circle latitude < -66 > 66
		if houses_override:
			self.jul_day_UT = swe.julday(houses_override[0],houses_override[1],houses_override[2],houses_override[3])
			
		if geolat > 66.0:
			geolat = 66.0
			print "polar circle override for houses, using 66 degrees"
		elif geolat < -66.0:
			geolat = -66.0
			print "polar circle override for houses, using -66 degrees"
		#sidereal houses
		if(openastrocfg['zodiactype']=="sidereal"):
			sh = swe.houses_ex(self.jul_day_UT,geolat,geolon,openastrocfg['houses_system'].encode("ascii"),swe.FLG_SIDEREAL)
		else:
			sh = swe.houses(self.jul_day_UT,geolat,geolon,openastrocfg['houses_system'].encode("ascii"))
		self.houses_degree_ut = list(sh[0])
		self.houses_degree = range(len(self.houses_degree_ut))
		self.houses_sign = range(len(self.houses_degree_ut))
		for i in range(12):
			for x in range(len(zodiac)):
				deg_low=float(x*30)
				deg_high=float((x+1)*30)
				if self.houses_degree_ut[i] >= deg_low:
					if self.houses_degree_ut[i] <= deg_high:
						self.houses_sign[i]=x
						self.houses_degree[i] = self.houses_degree_ut[i] - deg_low
		



		#compute additional points and angles
		#list index 23 is asc, 24 is Mc, 25 is Dsc, 26 is Ic
		self.planets_degree_ut[23] = self.houses_degree_ut[0]
		self.planets_degree_ut[24] = self.houses_degree_ut[9]
		self.planets_degree_ut[25] = self.houses_degree_ut[6]
		self.planets_degree_ut[26] = self.houses_degree_ut[3]	
		#arabic parts
		sun,moon,asc = self.planets_degree_ut[0],self.planets_degree_ut[1],self.planets_degree_ut[23]
		dsc,venus = self.planets_degree_ut[25],self.planets_degree_ut[3]			
		#list index 27 is day pars
		self.planets_degree_ut[27] = asc + (moon - sun)
		#list index 28 is night pars
		self.planets_degree_ut[28] = asc + (sun - moon)
		#list index 29 is South Node
		self.planets_degree_ut[29] = self.planets_degree_ut[10] - 180.0
		#list index 30 is marriage pars
		self.planets_degree_ut[30] = (asc+dsc)-venus
		#if planet degrees is greater than 360 substract 360 or below 0 add 360
		for i in range(23,31):
			if self.planets_degree_ut[i] > 360.0:
				self.planets_degree_ut[i] = self.planets_degree_ut[i] - 360.0
			elif self.planets_degree_ut[i] < 0.0:
				self.planets_degree_ut[i] = self.planets_degree_ut[i] + 360.0
			#get zodiac sign
			for x in range(12):
				deg_low=float(x*30.0)
				deg_high=float((x+1.0)*30.0)
				if self.planets_degree_ut[i] >= deg_low:
					if self.planets_degree_ut[i] <= deg_high:
						self.planets_sign[i]=x
						self.planets_degree[i] = self.planets_degree_ut[i] - deg_low
						self.planets_retrograde[i] = False

		
		
		#close swiss ephemeris
		swe.close()