def get_angam_float(jd, arc_len, w):
    lmoon = (swisseph.calc_ut(jd, swisseph.MOON)[0] -
             swisseph.get_ayanamsa(jd)) % 360
    lsun = (swisseph.calc_ut(jd, swisseph.SUN)[0] -
            swisseph.get_ayanamsa(jd)) % 360
    ldiff = (lmoon * w[0] + lsun * w[1]) % 360
    return (ldiff / arc_len)
def get_last_dhanur_transit (jd_start,latitude,longitude):
  swisseph.set_sid_mode(swisseph.SIDM_LAHIRI) #Force Lahiri Ayanamsha
  for d in range(-25,0):
    jd = jd_start + d
    [y,m,d,t] = swisseph.revjul(jd)
  
    jd_sunrise=swisseph.rise_trans(jd_start=jd,body=swisseph.SUN,lon=longitude,
      lat=latitude,rsmi=swisseph.CALC_RISE|swisseph.BIT_DISC_CENTER)[1][0]
    jd_sunrise_tmrw=swisseph.rise_trans(jd_start=jd+1,body=swisseph.SUN,
      lon=longitude,lat=latitude,rsmi=swisseph.CALC_RISE|swisseph.BIT_DISC_CENTER)[1][0]
    jd_sunset =swisseph.rise_trans(jd_start=jd,body=swisseph.SUN,lon=longitude,
      lat=latitude,rsmi=swisseph.CALC_SET|swisseph.BIT_DISC_CENTER)[1][0]
  
    longitude_sun=swisseph.calc_ut(jd_sunrise,swisseph.SUN)[0]-swisseph.get_ayanamsa(jd_sunrise)
    longitude_sun_set=swisseph.calc_ut(jd_sunset,swisseph.SUN)[0]-swisseph.get_ayanamsa(jd_sunset)
    sun_month_rise = int(1+math.floor(((longitude_sun)%360)/30.0))
    sun_month = int(1+math.floor(((longitude_sun_set)%360)/30.0))
    longitude_sun_tmrw=swisseph.calc_ut(jd_sunrise+1,swisseph.SUN)[0]-swisseph.get_ayanamsa(jd_sunrise+1)
    sun_month_tmrw = int(1+math.floor(((longitude_sun_tmrw)%360)/30.0))

    if sun_month_rise!=sun_month_tmrw:
      if sun_month!=sun_month_tmrw:
        return jd+1
      else:
        return jd
Example #3
0
    def __init__(self, tjd_ut, aId, flag):
        self.aId = aId

        self.data = swisseph.calc_ut(tjd_ut, aId, flag)[0]
        self.dataEqu = swisseph.calc_ut(tjd_ut, aId,
                                        flag + astrology.SEFLG_EQUATORIAL)[0]
        self.name = swisseph.get_planet_name(aId)
Example #4
0
def lunar_return(date, month, year, data, refinements=2): #data contains the angle, date is for a reasonable baseline
	day = datetime_to_julian(date)
	progress, cycles = math.modf((day/LUNAR_MONTH_DAYS))

	cycles = cycles+(year-date.year)*LMONTH_IN_SYEAR
	cycles = cycles+(month-date.month)*LMONTH_TO_MONTH

	day = (cycles)*LUNAR_MONTH_DAYS

	for i in range(refinements):
		angle = swisseph.calc_ut(day, swisseph.MOON)[0]
		day = day+(data-angle)/360*LUNAR_MONTH_DAYS

	for i in range(refinements):
		angle = swisseph.calc_ut(day, swisseph.MOON)[0]
		sec = ((data-angle)/LUNAR_DEGREE_SECOND)/SECS_TO_DAYS
		day = day+sec

	for i in range(refinements):
		angle = swisseph.calc_ut(day, swisseph.MOON)[0]
		msec = ((data-angle)/LUNAR_DEGREE_MS)/(SECS_TO_DAYS*1000)
		day = day+msec

	for i in range(refinements):
		angle = swisseph.calc_ut(day, swisseph.MOON)[0]
		nsec = ((data-angle)/LUNAR_DEGREE_NS)/(SECS_TO_DAYS*1000000)
		day = day+nsec

	return revjul_to_datetime(swisseph.revjul(day))
Example #5
0
def get_moon_sun_diff(day):
    degree1 = swisseph.calc_ut(day, swisseph.MOON)[0]
    degree2 = swisseph.calc_ut(day, swisseph.SUN)[0]
    swisseph.close()
    # we need some imprecision due to some oddities involving new and full moons
    diff = round(degree2 - degree1)
    return diff
Example #6
0
def lunar_return(date, month, year, data, refinements=2):  # data contains the angle, date is for a reasonable baseline
    day = datetime_to_julian(date)
    progress, cycles = math.modf((day / LUNAR_MONTH_DAYS))

    cycles = cycles + (year - date.year) * LMONTH_IN_SYEAR
    cycles = cycles + (month - date.month) * LMONTH_TO_MONTH

    day = (cycles) * LUNAR_MONTH_DAYS

    for i in range(refinements):
        angle = swisseph.calc_ut(day, swisseph.MOON)[0]
        day = day + (data - angle) / 360 * LUNAR_MONTH_DAYS

    for i in range(refinements):
        angle = swisseph.calc_ut(day, swisseph.MOON)[0]
        sec = ((data - angle) / LUNAR_DEGREE_SECOND) / SECS_TO_DAYS
        day = day + sec

    for i in range(refinements):
        angle = swisseph.calc_ut(day, swisseph.MOON)[0]
        msec = ((data - angle) / LUNAR_DEGREE_MS) / (SECS_TO_DAYS * 1000)
        day = day + msec

    for i in range(refinements):
        angle = swisseph.calc_ut(day, swisseph.MOON)[0]
        nsec = ((data - angle) / LUNAR_DEGREE_NS) / (SECS_TO_DAYS * 1000000)
        day = day + nsec

    return revjul_to_datetime(swisseph.revjul(day))
Example #7
0
def get_moon_sun_diff(day):
	degree1 = swisseph.calc_ut(day, swisseph.MOON)[0]
	degree2 = swisseph.calc_ut(day, swisseph.SUN)[0]
	swisseph.close()
	#we need some imprecision due to some oddities involving new and full moons
	diff = round(degree2-degree1)
	return diff
Example #8
0
	def __init__(self, tjd_ut, pId, flag, lat = None, ascmc2 = None, raequasc = None, ecl = None, equ = None, nolat = False, obl = 0.0):
		self.pId = pId

		self.speculums = None

		if (ecl == None):
			self.data = swisseph.calc_ut(tjd_ut, pId, flag)
			self.dataEqu = swisseph.calc_ut(tjd_ut, pId, flag+astrology.SEFLG_EQUATORIAL)

			# data[0] : longitude
			# data[1] : latitude
			# data[2] : distance
			# data[3] : speed in long
			# data[4] : speed in lat
			# data[5] : speed in dist

			# if rflag < 0:
			#	print 'Error: %s' % serr

			self.name = swisseph.get_planet_name(pId)
		else:
			self.data = tuple(ecl)
			self.dataEqu = tuple(equ)
			self.name = 'DescNode'

		if nolat:
			self.data = (self.data[Planet.LONG], 0.0, self.data[Planet.DIST], self.data[Planet.SPLON], self.data[Planet.SPLAT], self.data[Planet.SPDIST])
			ra, decl, dist = swisseph.cotrans(self.data[Planet.LONG], 0.0, 1.0, -obl)
			self.dataEqu = (ra, decl, self.dataEqu[Planet.DISTEQU], self.dataEqu[Planet.SPRAEQU], self.dataEqu[Planet.SPDECLEQU], self.dataEqu[Planet.SPDISTEQU])

		if lat != None:
			#placspec.py and regiospec should be used instead, remove these!
			self.speculums = []
			self.computePlacidianSpeculum(lat, ascmc2)
			self.computeRegiomontanSpeculum(lat, ascmc2, raequasc)
Example #9
0
def get_angam_float(jd,
                    angam_type,
                    offset=0,
                    ayanamsha_id=swe.SIDM_LAHIRI,
                    debug=False):
    """Returns the angam

      Args:
        float jd: The Julian Day at which the angam is to be computed
        angam_type: One of the pre-defined constants in the panchangam
        class, such as TITHI, NAKSHATRAM, YOGA, KARANAM or SOLAR_MONTH

      Returns:
        float angam

      Examples:
        >>> get_angam_float(2444961.7125,NAKSHATRAM)
        15.967801358055189
    """
    swe.set_sid_mode(ayanamsha_id)
    w_moon = angam_type['w_moon']
    w_sun = angam_type['w_sun']
    arc_len = angam_type['arc_len']

    lcalc = 0  # computing weighted longitudes
    if debug:
        logging.debug('## get_angam_float(): jd=%f', jd)
        logging.debug("Ayanamsha: %f", swe.get_ayanamsa(jd))

    #  Get the lunar longitude, starting at the ayanaamsha point in the ecliptic.
    if w_moon != 0:
        lmoon = (swe.calc_ut(jd, swe.MOON)[0] - swe.get_ayanamsa(jd)) % 360
        if (debug):
            logging.debug("Moon longitude: %f", swe.calc_ut(jd, swe.MOON)[0])
            logging.debug('## get_angam_float(): lmoon=%f', lmoon)
        lcalc += w_moon * lmoon

    #  Get the solar longitude, starting at the ayanaamsha point in the ecliptic.
    if w_sun != 0:
        lsun = (swe.calc_ut(jd, swe.SUN)[0] - swe.get_ayanamsa(jd)) % 360
        if (debug):
            logging.debug('## get_angam_float(): lsun=%f', lsun)
        lcalc += w_sun * lsun

    if debug:
        logging.debug('## get_angam_float(): lcalc=%f', lcalc)

    lcalc = lcalc % 360

    if debug:
        logging.debug('## get_angam_float(): lcalc %% 360=%f', lcalc)
        logging.debug("offset: %f", offset)
        logging.debug(offset + int(360.0 / arc_len))

    if offset + int(360.0 / arc_len) == 0 and lcalc < arc_len:
        # Angam 1 -- needs different treatment, because of 'discontinuity'
        return (lcalc / arc_len)
    else:
        return (lcalc / arc_len) + offset
Example #10
0
 def compute_solar_month(self):
   if not hasattr(self, "jd_sunrise") or self.jd_sunrise is None:
     self.compute_sun_moon_transitions()
   swe.set_sid_mode(self.ayanamsha_id)
   self.longitude_sun_sunrise = swe.calc_ut(self.jd_sunrise, swe.SUN)[0] - swe.get_ayanamsa(self.jd_sunrise)
   self.longitude_sun_sunset = swe.calc_ut(self.jd_sunset, swe.SUN)[0] - swe.get_ayanamsa(self.jd_sunset)
   
   # Each solar month has 30 days. So, divide the longitude by 30 to get the solar month.
   self.solar_month_sunset = int(1 + floor((self.longitude_sun_sunset % 360) / 30.0))
   self.solar_month_sunrise = int(1 + floor(((self.longitude_sun_sunrise) % 360) / 30.0))
Example #11
0
def part_of_fortune_rudhyar(cht):
	"""Calculate part of fortune (Rudhyar).
	
	:type cht: Chart
	"""
	flag = cht._filter.get_calcflag()
	sun = swe.calc_ut(cht.julday, swe.SUN, flag)
	moon = swe.calc_ut(cht.julday, swe.MOON, flag)
	pos = swe.degnorm(
		cht._houses.get_positions('Asc')._longitude + (
			swe.difdegn(moon[0], sun[0])))
	return (pos, 0, 0, 0, 0, 0)
Example #12
0
def part_of_fortune_rudhyar(cht):
    """Calculate part of fortune (Rudhyar).
	
	:type cht: Chart
	"""
    flag = cht._filter.get_calcflag()
    sun = swe.calc_ut(cht.julday, swe.SUN, flag)
    moon = swe.calc_ut(cht.julday, swe.MOON, flag)
    pos = swe.degnorm(
        cht._houses.get_positions('Asc')._longitude +
        (swe.difdegn(moon[0], sun[0])))
    return (pos, 0, 0, 0, 0, 0)
Example #13
0
def solar_return(date, year, data, refinements=2): #data contains the angule, date is for a reasonable baseline
	day = datetime_to_julian(date)+(SOLAR_YEAR_DAYS*(year-date.year))

	for i in range(refinements):
		angle = swisseph.calc_ut(day, swisseph.SUN)[0]
		sec = ((data-angle)/SOLAR_DEGREE_SECOND)/SECS_TO_DAYS
		day = day+sec
	for i in range(refinements):
		angle = swisseph.calc_ut(day, swisseph.SUN)[0]
		msec = ((data-angle)/SOLAR_DEGREE_MS)/(SECS_TO_DAYS*1000)

	return revjul_to_datetime(swisseph.revjul(day+msec))
Example #14
0
 def calculate_chart(self):
     julday = self.julday()
     self.sun = swe.calc_ut(julday, 0)[0]
     self.moon = swe.calc_ut(julday, 1)[0]
     self.mercury = swe.calc_ut(julday, 2)[0]
     self.venus = swe.calc_ut(julday, 3)[0]
     self.mars = swe.calc_ut(julday, 4)[0]
     self.jupiter = swe.calc_ut(julday, 5)[0]
     self.saturn = swe.calc_ut(julday, 6)[0]
     self.uranus = swe.calc_ut(julday, 7)[0]
     self.neptune = swe.calc_ut(julday, 8)[0]
     self.pluto = swe.calc_ut(julday, 9)[0]
        def _swisseph(t, ipl):
            t = t[0]
            jd = swe.julday(t.year,t.month,t.day,t.hour+t.minute/60)
            rslt = swe.calc_ut(jd, ipl , swe.FLG_EQUATORIAL | swe.FLG_SWIEPH | swe.FLG_SPEED)
        
            if ipl == 1: #Moon
                rm = swe.calc_ut(jd, ipl , swe.FLG_EQUATORIAL | swe.FLG_SWIEPH | swe.FLG_SPEED |swe.FLG_TRUEPOS | swe.FLG_RADIANS)
                sinhp = EARTH_RADIUS / rm[2] / AUNIT
                moondist=asin(sinhp) / DEGTORAD *3600
                return rslt[0], rslt[1], moondist

            return rslt[0], rslt[1], rslt[2]
Example #16
0
def solar_return(date, year, data, refinements=2):  # data contains the angule, date is for a reasonable baseline
    day = datetime_to_julian(date) + (SOLAR_YEAR_DAYS * (year - date.year))

    for i in range(refinements):
        angle = swisseph.calc_ut(day, swisseph.SUN)[0]
        sec = ((data - angle) / SOLAR_DEGREE_SECOND) / SECS_TO_DAYS
        day = day + sec
    for i in range(refinements):
        angle = swisseph.calc_ut(day, swisseph.SUN)[0]
        msec = ((data - angle) / SOLAR_DEGREE_MS) / (SECS_TO_DAYS * 1000)

    return revjul_to_datetime(swisseph.revjul(day + msec))
Example #17
0
def updatePandC(date, observer, houses, entries):
	day = datetime_to_julian(date)
	obliquity = swisseph.calc_ut(day, swisseph.ECL_NUT)[0]
	cusps, asmc = swisseph.houses(day, observer.lat, observer.lng)
	fill_houses(date, observer, houses=houses, data=cusps)
	for i in range(10):
		calcs = swisseph.calc_ut(day, i)
		hom = swisseph.house_pos(asmc[2], observer.lat, obliquity, calcs[0], objlat=calcs[1])
		if i == swisseph.SUN or i == swisseph.MOON:
			retrograde = 'Not Applicable'
		else:
			retrograde = str(calcs[3] < 0)
		entries[i].retrograde = retrograde
		entries[i].m.longitude = calcs[0]
		entries[i].m.latitude = calcs[1]
		entries[i].m.progress = hom % 1.0
		entries[i].m.house_info = houses[int(hom-1)]
	if len(entries) > 10: #add node entries
		calcs = swisseph.calc_ut(day, swisseph.TRUE_NODE)
		hom = swisseph.house_pos(asmc[2], observer.lat, obliquity, calcs[0], objlat=calcs[1])
		retrograde = "Always"

		entries[10].retrograde = retrograde
		entries[10].m.longitude = calcs[0]
		entries[10].m.latitude = calcs[1]
		entries[10].m.progress = hom%1.0
		entries[10].m.house_info = houses[int(hom-1)]

		#do some trickery to display the South Node
		reverse = swisseph.degnorm(calcs[0]-180.0)
		revhouse = (int(hom)+6)%12
		#revprogress = 1-hom%1.0
		revprogress = hom%1.0
		entries[11].retrograde = retrograde
		entries[11].m.longitude = reverse
		entries[11].m.latitude = calcs[1]
		entries[11].m.progress = revprogress
		entries[11].m.house_info = houses[int(revhouse-1)]
	if len(entries) > 12:
		ascendant = asmc[0]
		descendant = cusps[6]
		mc = asmc[1]
		ic = cusps[3]
		retrograde = 'Not a Planet'

		entries[12].m.longitude = ascendant
		entries[13].m.longitude = descendant
		entries[14].m.longitude = mc
		entries[15].m.longitude = ic

	swisseph.close()
Example #18
0
def updatePandC(date, observer, houses, entries):
    day = datetime_to_julian(date)
    obliquity = swisseph.calc_ut(day, swisseph.ECL_NUT)[0]
    cusps, asmc = swisseph.houses(day, observer.lat, observer.lng)
    fill_houses(date, observer, houses=houses, data=cusps)
    for i in range(10):
        calcs = swisseph.calc_ut(day, i)
        hom = swisseph.house_pos(asmc[2], observer.lat, obliquity, calcs[0], objlat=calcs[1])
        if i == swisseph.SUN or i == swisseph.MOON:
            retrograde = "Not Applicable"
        else:
            retrograde = str(calcs[3] < 0)
        entries[i].retrograde = retrograde
        entries[i].m.longitude = calcs[0]
        entries[i].m.latitude = calcs[1]
        entries[i].m.progress = hom % 1.0
        entries[i].m.house_info = houses[int(hom - 1)]
    if len(entries) > 10:  # add node entries
        calcs = swisseph.calc_ut(day, swisseph.TRUE_NODE)
        hom = swisseph.house_pos(asmc[2], observer.lat, obliquity, calcs[0], objlat=calcs[1])
        retrograde = "Always"

        entries[10].retrograde = retrograde
        entries[10].m.longitude = calcs[0]
        entries[10].m.latitude = calcs[1]
        entries[10].m.progress = hom % 1.0
        entries[10].m.house_info = houses[int(hom - 1)]

        # do some trickery to display the South Node
        reverse = swisseph.degnorm(calcs[0] - 180.0)
        revhouse = (int(hom) + 6) % 12
        # revprogress = 1-hom%1.0
        revprogress = hom % 1.0
        entries[11].retrograde = retrograde
        entries[11].m.longitude = reverse
        entries[11].m.latitude = calcs[1]
        entries[11].m.progress = revprogress
        entries[11].m.house_info = houses[int(revhouse - 1)]
    if len(entries) > 12:
        ascendant = asmc[0]
        descendant = cusps[6]
        mc = asmc[1]
        ic = cusps[3]
        retrograde = "Not a Planet"

        entries[12].m.longitude = ascendant
        entries[13].m.longitude = descendant
        entries[14].m.longitude = mc
        entries[15].m.longitude = ic

    swisseph.close()
Example #19
0
def get_angam_float(jd, angam_type, offset=0, debug=False):
    """Returns the angam

      Args:
        float jd: The Julian Day at which the angam is to be computed
        angam_type: One of the pre-defined constants in the panchangam
            class, such as TITHI, NAKSHATRAM, YOGAM, KARANAM or
            SOLAR_MONTH

      Returns:
        float angam

      Examples:
        >>> get_angam_float(2444961.7125,NAKSHATRAM)
        15.967801358055189
    """
    swe.set_sid_mode(swe.SIDM_LAHIRI)  # Force Lahiri Ayanamsha
    w_moon = angam_type['w_moon']
    w_sun = angam_type['w_sun']
    arc_len = angam_type['arc_len']

    lcalc = 0  # computing weighted longitudes
    if debug:
        print('## get_angam_float(): jd=', jd)

    if w_moon != 0:
        lmoon = (swe.calc_ut(jd, swe.MOON)[0] - swe.get_ayanamsa(jd)) % 360
        if (debug):
            print('## get_angam_float(): lmoon=', lmoon)
        lcalc += w_moon * lmoon

    if w_sun != 0:
        lsun = (swe.calc_ut(jd, swe.SUN)[0] - swe.get_ayanamsa(jd)) % 360
        if (debug):
            print('## get_angam_float(): lsun=', lsun)
        lcalc += w_sun * lsun

    if debug:
        print('## get_angam_float(): lcalc=', lcalc)

    lcalc = lcalc % 360

    if debug:
        print('## get_angam_float(): lcalc%360=', lcalc)
        print("offset: ", offset)
        print(offset + int(360.0 / arc_len))
    if offset + int(360.0 / arc_len) == 0 and lcalc + offset >= 0:
        return (lcalc / arc_len)
    else:
        return (lcalc / arc_len) + offset
Example #20
0
        def _swisseph(t, ipl):
            t = t[0]
            jd = swe.julday(t.year, t.month, t.day, t.hour + t.minute / 60)
            rslt = swe.calc_ut(
                jd, ipl, swe.FLG_EQUATORIAL | swe.FLG_SWIEPH | swe.FLG_SPEED)

            if ipl == 1:  #Moon
                rm = swe.calc_ut(
                    jd, ipl, swe.FLG_EQUATORIAL | swe.FLG_SWIEPH
                    | swe.FLG_SPEED | swe.FLG_TRUEPOS | swe.FLG_RADIANS)
                sinhp = EARTH_RADIUS / rm[2] / AUNIT
                moondist = asin(sinhp) / DEGTORAD * 3600
                return rslt[0], rslt[1], moondist

            return rslt[0], rslt[1], rslt[2]
Example #21
0
def natal_chart_calc(t_zone, b_offset, b_date, t_birth_hour, t_birth_min,
                     b_latitude, b_longitude, is_time, h_type):
    date_year_birth = int(b_date.strftime("%Y"))
    date_month_birth = int(b_date.strftime("%m"))
    date_day_birth = int(b_date.strftime("%d"))
    # print 'naren', date_year_birth, date_month_birth, date_day_birth, t_birth_hour, t_birth_min, t_zone, b_offset,\
    # (t_birth_hour + (t_birth_min / 60.)) - (t_zone + b_offset)
    now_julian = swe.julday(date_year_birth, date_month_birth, date_day_birth,
                            (t_birth_hour +
                             (t_birth_min / 60.)) - (t_zone + b_offset))
    # print now_julian
    l_birthchart = len(constants.BIRTH_PLANETS)
    bchart_pos = np.zeros(l_birthchart + 2)
    bchart_speed = np.zeros(l_birthchart)
    for i in range(l_birthchart):
        pos_p = swe.calc_ut(now_julian, constants.BIRTH_PLANETS[i])
        bchart_pos[i] = pos_p[0]
        bchart_speed[i] = pos_p[3]

    if is_time:
        house_array = (swe.houses(now_julian, b_latitude, b_longitude, h_type))
        bchart_pos[i + 1] = house_array[1][0]
        bchart_pos[i + 2] = house_array[1][1]
    else:
        bchart_pos[i + 1] = 0
        bchart_pos[i + 2] = 0
    return bchart_pos, bchart_speed
Example #22
0
def calculate_planets(input_data, intermediate, output, config):
    output['planets'] = {}
    output['planets']['planets_sign_name'] = [0] * 23
    output['planets']['planets_degree'] = [0] * 23
    output['planets']['planets_degree_ut'] = [0] * 23
    output['planets']['planets_retrograde'] = [0] * 23

    for i in range(NUM_PLANETS):
        ret_flag = swe.calc_ut(intermediate['jul_day_UT'], i,
                               intermediate['iflag'])
        for x in range(len(config['zodiac'])):
            deg_low = float(x * 30)
            deg_high = float((x + 1) * 30)
            if ret_flag[0] >= deg_low:
                if ret_flag[0] <= deg_high:
                    output['planets']['planets_sign_name'][
                        i] = config['planet_name_short'][i] + ":" + config[
                            'zodiac'][x] + ":" + str(x)
                    output['planets']['planets_degree'][
                        i] = ret_flag[0] - deg_low
                    output['planets']['planets_degree_ut'][i] = ret_flag[0]
                    if ret_flag[3] < 0:
                        output['planets']['planets_retrograde'][i] = True
                    else:
                        output['planets']['planets_retrograde'][i] = False
    return output
Example #23
0
    def CalcPlanets(self, HouseDict):
        # print("HouseposList", HousePosList)

        print("")

        print("PLANET POSITIONS FOR NATAL CHART")

        print("")

        PlanetLocDict = collections.OrderedDict()
        PlanetZodiacDict = collections.OrderedDict()

        for i in Planet_List_loop:
            planet_pos = swe.calc_ut(Bday_accurate[1], i,
                                     FLG_SIDEREAL + FLG_SWIEPH)

            PlanetLocDict[Planet_List[i]] = planet_pos[0]
            PlanetZodiacDict[Planet_List[i]] = Zodiac_sign[int(planet_pos[0] /
                                                               30)]

            # print("Planet Dict", PlanetLocDict)

            print(
                Planet_List[i], "(" + Planet_Element[Planet_List[i]] + ")",
                " in House", HouseDict[self.getHouse(PlanetLocDict, HouseDict,
                                                     Planet_List[i])],
                " in Lagna ", Zodiac_sign[int(planet_pos[0] / 30)], "(" +
                Lagna_Element[Zodiac_sign[int(planet_pos[0] / 30)]] + ")")
Example #24
0
def natal_chart_calc(t_zone, b_offset, b_date, t_birth_hour, t_birth_min, b_latitude, b_longitude, is_time, h_type):
    date_year_birth = int(b_date.strftime("%Y"))
    date_month_birth = int(b_date.strftime("%m"))
    date_day_birth = int(b_date.strftime("%d"))
    # print 'naren', date_year_birth, date_month_birth, date_day_birth, t_birth_hour, t_birth_min, t_zone, b_offset,\
    # (t_birth_hour + (t_birth_min / 60.)) - (t_zone + b_offset)
    now_julian = swe.julday(date_year_birth, date_month_birth, date_day_birth,
                            (t_birth_hour + (t_birth_min / 60.)) - (t_zone + b_offset))
    # print now_julian
    l_birthchart = len(constants.BIRTH_PLANETS)
    bchart_pos = np.zeros(l_birthchart + 2)
    bchart_speed = np.zeros(l_birthchart)
    for i in range(l_birthchart):
        pos_p = swe.calc_ut(now_julian, constants.BIRTH_PLANETS[i])
        bchart_pos[i] = pos_p[0]
        bchart_speed[i] = pos_p[3]

    if is_time:
        house_array = (swe.houses(now_julian, b_latitude, b_longitude, h_type))
        bchart_pos[i + 1] = house_array[1][0]
        bchart_pos[i + 2] = house_array[1][1]
    else:
        bchart_pos[i + 1] = 0
        bchart_pos[i + 2] = 0
    return bchart_pos, bchart_speed
Example #25
0
 def calc_planets(self):
     planets = OrderedDict()
     for i in range(swe.NPLANETS):
         planets[PLANET_CODES[i]] = BodyPos(
             i, PLANET_CODES[i], PLANET_NAMES[i],
             *swe.calc_ut(self.datetime_julday, i)).toDict()
     return planets
Example #26
0
    def __init__(self, datetime_utc, latitude=None, longitude=None):
        self.datetime_utc = datetime_utc
        self.datetime_julday = self.calc_julday(self.datetime_utc)
        self.latitude = latitude
        self.longitude = longitude

        self.houses = None
        self.ascmc = None
        self.armc = None
        self.asc = None
        if self.latitude and self.longitude:
            self.houses, self.ascmc = self.calc_houses()
            self.asc = self.houses[1]
            self.mc = self.houses[10]

        if self.ascmc:
            self.armc = self.ascmc.armc
            self.asc = self.ascmc.ascendant
            self.mc = self.ascmc.mc
            self.vertex = self.ascmc.vertex


        self.ecl_nut = swe.calc_ut(self.datetime_julday, swe.ECL_NUT)[0]
        
        if self.latitude:
            self.planets = self.calc_planets_houses()
        else:
            self.planets = self.calc_planets()
        

        self.aspects = self.calc_aspects(self.planets)
        self.categories = self.generate_categories()
Example #27
0
def get_last_dhanur_transit(jd_start, latitude, longitude):
    swisseph.set_sid_mode(swisseph.SIDM_LAHIRI)  #Force Lahiri Ayanamsha
    for d in range(-25, 0):
        jd = jd_start + d
        [y, m, d, t] = swisseph.revjul(jd)

        jd_rise = swisseph.rise_trans(jd_start=jd,
                                      body=swisseph.SUN,
                                      lon=longitude,
                                      lat=latitude,
                                      rsmi=swisseph.CALC_RISE
                                      | swisseph.BIT_DISC_CENTER)[1][0]
        jd_rise_tmrw = swisseph.rise_trans(jd_start=jd + 1,
                                           body=swisseph.SUN,
                                           lon=longitude,
                                           lat=latitude,
                                           rsmi=swisseph.CALC_RISE
                                           | swisseph.BIT_DISC_CENTER)[1][0]
        jd_set = swisseph.rise_trans(jd_start=jd,
                                     body=swisseph.SUN,
                                     lon=longitude,
                                     lat=latitude,
                                     rsmi=swisseph.CALC_SET
                                     | swisseph.BIT_DISC_CENTER)[1][0]

        longitude_sun = swisseph.calc_ut(
            jd_rise, swisseph.SUN)[0] - swisseph.get_ayanamsa(jd_rise)
        longitude_sun_set = swisseph.calc_ut(
            jd_set, swisseph.SUN)[0] - swisseph.get_ayanamsa(jd_set)
        sun_month_rise = masa_names[int(1 + math.floor((
            (longitude_sun) % 360) / 30.0))]
        sun_month = masa_names[int(1 + math.floor((
            (longitude_sun_set) % 360) / 30.0))]
        longitude_sun_tmrw = swisseph.calc_ut(
            jd_rise + 1, swisseph.SUN)[0] - swisseph.get_ayanamsa(jd_rise + 1)
        sun_month_tmrw = masa_names[int(1 + math.floor((
            (longitude_sun_tmrw) % 360) / 30.0))]

        #print '%f:%d-%d-%d: rise=%s, set=%s, tmrw=%s' %(jd,y,m,d,sun_month_rise,sun_month,sun_month_tmrw)

        if sun_month_rise != sun_month_tmrw:
            if sun_month != sun_month_tmrw:
                return jd + 1
            else:
                return jd
Example #28
0
    def _calc_ecl_nut(self):
        """Calculate obliquity and nutation.

        Result is an unmodified swe.calc_ut tuple.

        """
        ##self._setup_swisseph()
        ##print self.julday
        self._ecl_nut = swe.calc_ut(self.julday, swe.ECL_NUT)
Example #29
0
def sweObject(obj, jd):
    """ Returns an object from the Ephemeris. """
    sweObj = SWE_OBJECTS[obj]
    sweList = swisseph.calc_ut(jd, sweObj)
    return {
        'id': obj,
        'lon': sweList[0],
        'lat': sweList[1],
        'lonspeed': sweList[3],
        'latspeed': sweList[4]
    }
Example #30
0
    def calc_planets(self):
        planets = AttrDict()
        for i in range(10):
            angle = swisseph.calc_ut(self.birth_julian, i)[0]
            planets[swisseph.get_planet_name(i).lower()] = angle

            if i == 0:  # Add earth
                angle = swisseph.calc_ut(self.birth_julian, AstroChart.SUN)[0]
                angle = self.get_opposite_angle(angle)
                planets[swisseph.get_planet_name(
                    AstroChart.EARTH).lower()] = angle
            elif i == 1:  # Add nodes
                angle = swisseph.calc_ut(self.birth_julian,
                                         AstroChart.TRUE_NODE)[0]
                planets['north node'] = angle
                planets['south node'] = self.get_opposite_angle(angle)

        for name, angle in planets.items():
            setattr(self, name, angle)
        return planets
Example #31
0
def sweObject(obj, jd):
    """ Returns an object from the Ephemeris. """
    sweObj = SWE_OBJECTS[obj]
    sweList = swisseph.calc_ut(jd, sweObj)
    return {
        'id': obj,
        'lon': sweList[0],
        'lat': sweList[1],
        'lonspeed': sweList[3],
        'latspeed': sweList[4]
    }
Example #32
0
def check_bodies_in_any_range(bodies, ranges):
    for id in bodies:
        try:
            long = sweph.calc_ut(jd_now(), id, sweph.FLG_SWIEPH)[0]
        except sweph.Error as e:
            print("id %d doesn't exist: %s" % (id, e))
            next
        for range in ranges:
            if long > range[0] and long < range[1]:
                sign_idx = int(long / 30)
                deg = long - sign_idx*30
                print("%d %s: %d %s" % (id-sweph.AST_OFFSET, sweph.get_planet_name(id), deg, signs[sign_idx]))
Example #33
0
def calc_chart(date):
    year = date.year
    month = date.month
    day = date.day
    hour = date.hour + date.minute/60
    julday = swe.julday(year, month, day, hour)
    dic = {}
    for planet_index in range(10):
        n = planets[planet_index]
        d = swe.calc_ut(julday, planet_index)[0]
        s = calc_sign(d)
        dic[n.lower()] = d
    return dic
Example #34
0
	def calc_ut(self, jd, flag, chart=None):
		"""Return calculations results.
		
		Houses cusps are calculated in block (see chartcalc).
		Parts require that you pass the chart object.
		
		:type jd: numeric
		:type flag: int
		:type chart: ChartCalc
		:raise ValueError: invalid planet (houses)
		"""
		if self._family == 4:
			raise ValueError('Cannot calculate houses.')
		# "inverted objects". Should invert latitude too??
		elif self._num == -2: # ketu (mean)
			r = swe.calc_ut(jd, 10, flag)
			return (swe.degnorm(r[0]-180),
				r[1], r[2], r[3], r[4], r[5])
		elif self._num == -3: # ketu (true)
			r = swe.calc_ut(jd, 11, flag)
			return (swe.degnorm(r[0]-180),
				r[1], r[2], r[3], r[4], r[5])
		elif self._num == -4: # priapus (mean)
			r = swe.calc_ut(jd, 12, flag)
			return (swe.degnorm(r[0]-180),
				r[1], r[2], r[3], r[4], r[5])
		elif self._num == -5: # priapus (true)
			r = swe.calc_ut(jd, 13, flag)
			return (swe.degnorm(r[0]-180),
				r[1], r[2], r[3], r[4], r[5])
		# planets, asteroids, etc
		elif self._family in (0, 1, 3):
			return swe.calc_ut(jd, self._num, flag)
		# fixed stars
		elif self._family == 2:
			return swe.fixstar_ut(self._name, jd, flag)
		# parts
		elif self._family == 5:
			return oroboros.core.parts.calc_ut(self._name, chart)
Example #35
0
 def get_longitude(self, jd, ayanaamsha_id=None):
     """
 
 :param jd: 
 :param ayanaamsha_id: 
 Default value of ayanaamsha_id here is deliberately None.
 :return: 
 """
     if ayanaamsha_id is not None:
         from jyotisha.panchaanga.temporal.zodiac import Ayanamsha
         return (self.get_longitude(jd=jd) -
                 Ayanamsha.singleton(ayanaamsha_id).get_offset(jd)) % 360
     else:
         return swe.calc_ut(jd, self._get_swisseph_id())[0][0]
Example #36
0
def check_bodies_in_any_range(bodies, ranges):
    for id in bodies:
        try:
            long = sweph.calc_ut(jd_now(), id, sweph.FLG_SWIEPH)[0]
        except sweph.Error as e:
            print("id %d doesn't exist: %s" % (id, e))
            next
        for range in ranges:
            if long > range[0] and long < range[1]:
                sign_idx = int(long / 30)
                deg = long - sign_idx * 30
                print("%d %s: %d %s" %
                      (id - sweph.AST_OFFSET, sweph.get_planet_name(id), deg,
                       signs[sign_idx]))
Example #37
0
def ephemeris_calc(t_zone, b_date, t_birth_hour, t_birth_min):
    date_year_birth = int(b_date.strftime("%Y"))
    date_month_birth = int(b_date.strftime("%m"))
    date_day_birth = int(b_date.strftime("%d"))
    now_julian = swe.julday(date_year_birth, date_month_birth, date_day_birth,
                            (t_birth_hour + (t_birth_min / 60.)) - t_zone)
    len_ephemeris = len(constants.EPHEMERIS_PLANETS)
    ephemeris_pos = np.zeros(len_ephemeris)
    ephemeris_speed = np.zeros(len_ephemeris)
    for i in range(len_ephemeris):
        pos_p = swe.calc_ut(now_julian, constants.EPHEMERIS_PLANETS[i])
        ephemeris_pos[i] = pos_p[0]
        ephemeris_speed[i] = pos_p[3]

    return ephemeris_pos, ephemeris_speed
Example #38
0
def ephemeris_calc(t_zone, b_date, t_birth_hour, t_birth_min):
    date_year_birth = int(b_date.strftime("%Y"))
    date_month_birth = int(b_date.strftime("%m"))
    date_day_birth = int(b_date.strftime("%d"))
    now_julian = swe.julday(date_year_birth, date_month_birth, date_day_birth,
                            (t_birth_hour + (t_birth_min / 60.)) - t_zone)
    len_ephemeris = len(constants.EPHEMERIS_PLANETS)
    ephemeris_pos = np.zeros(len_ephemeris)
    ephemeris_speed = np.zeros(len_ephemeris)
    for i in range(len_ephemeris):
        pos_p = swe.calc_ut(now_julian, constants.EPHEMERIS_PLANETS[i])
        ephemeris_pos[i] = pos_p[0]
        ephemeris_speed[i] = pos_p[3]

    return ephemeris_pos, ephemeris_speed
Example #39
0
    def calc_planets(self):
        planets = AttrDict()

        for i in range(NPLANETS):
            body_pos = BodyPos(i, self.armc, self.latitude, self.ecl_nut, *swe.calc_ut(self.datetime_julday, i))
            planets[body_pos.code] = body_pos

        sun_moon_midpoint = midpoint(planets['sun'].x,  planets['moon'].x)
        planets['sun-moon-midpoint'] = BodyPos('sun-moon-midpoint', None, None, None, sun_moon_midpoint)


        self.planets_dict = OrderedDict()
        for k in planets:
            self.planets_dict[k] = planets[k].toDict()
        return planets
Example #40
0
def get_nirayana_sun_lon(jd, offset=0, debug=False):
    """Returns the nirayana longitude of the sun

      Args:
        float jd: The Julian Day at which the angam is to be computed

      Returns:
        float longitude

      Examples:
    """
    lsun = (swe.calc_ut(jd, swe.SUN)[0]) % 360

    if debug:
        print('## get_angam_float(): lsun (nirayana) =', lsun)

    return lsun + offset
Example #41
0
def get_planet_lon(jd, planet, offset=0, ayanamsha_id=swe.SIDM_LAHIRI):
    """Returns the longitude of the given planet e.g. swe.JUPITER

      Args:
        float jd: The Julian Day at which the longitude is to be computed
        int planet  - e.g. swe.SUN, swe.JUPITER, ...

      Returns:
        float longitude

      Examples:
      >>> get_planet_lon(2458008.58, swe.JUPITER)
      180.00174875784376
    """
    swe.set_sid_mode(ayanamsha_id)
    lon = (swe.calc_ut(jd, planet)[0] - swe.get_ayanamsa(jd)) % 360
    return lon + offset
Example #42
0
def get_nirayana_sun_lon(jd, offset=0, debug=False):
    """Returns the nirayana longitude of the sun

      Args:
        float jd: The Julian Day at which the angam is to be computed

      Returns:
        float longitude

      Examples:
    """
    lsun = (swe.calc_ut(jd, swe.SUN)[0]) % 360

    if debug:
        print('## get_angam_float(): lsun (nirayana) =', lsun)

    if offset + 360 == 0 and lsun < 30:
        # Angam 1 -- needs different treatment, because of 'discontinuity'
        return lsun
    else:
        return lsun + offset
Example #43
0
def loc_of_planet(planet, start, end, freq='1D', scale=1, fit360=False):
    """Calculate the locations of planet within a time span.

        parameters:

        planet: the planet variable in swisseph
        start, end: the time span
        freq: the calculation freq
        scale: mulitply the planet location

        return a pandas Series with planet location

    """

    results = []
    drange = pd.date_range(start, end, freq=freq, tz='utc')

    for date in drange:
        year   = date.year
        month  = date.month
        day    = date.day
        hour   = date.hour
        minute = date.minute
        second = date.second

        jd = swe.utc_to_jd(year, month, day, hour, minute, second, 1)
        ut = jd[1]

        loc = swe.calc_ut(ut, planet)

        results.append(loc[0]*scale)

    res = pd.Series(results, drange, name=swe.get_planet_name(planet))

    if scale > 1 and fit360:
        return res.apply(_fit360)

    return res
Example #44
0
def calc_planets():
    Planet = namedtuple('Planet', ['name', 'angle', 'sign'])
    planet_names = ['Sol', 'Lua', 'Mercurio', 'Venus', 'Marte', 'Jupiter','Saturno', 'Urano', 'Netuno' ,'Plutao']
    signs = ['Aries', 'Touro', 'Gemeos', 'Cancer', 'Leao', 'Virgem', 'Libra', 'Escorpiao', 'Sagitario', 'Capricornio', 'Aquario', 'Peixes']
    d = datetime.utcnow()
    t = list(d.timetuple()[:5])
    t[3] += t[4]/60.0
    t = t[:4]
    j = swe.julday(*t)
    result = {}
    result['date'] = d
    planets = []
    for i in range(10):
        a = swe.calc_ut(j,i)[0]
        s = signs[int(a/30)]
        
        d = {}
        d['index'] = i
        d['name'] = planet_names[i]
        d['angle'] = a
        d['sign'] = s
        planets.append(d)
    result['planets'] = planets
    return jsonify(result=result)
Example #45
0
#!/usr/bin/python
# Print approx. hours until next Moon sign
# (needs PySwissEph)
# 2014-07-08

import datetime
import swisseph as s

n = datetime.datetime.utcnow()

j = s.julday(n.year, n.month, n.day, n.hour + n.minute / 60.)
j2 = j

ra = (s.calc_ut(j, s.MOON))[0]
next_ra = 30.*(1+(ra//30.))
diff = 100

for it in range(15):
	ra = (s.calc_ut(j2, s.MOON))[0]
	if next_ra == 360 and ra < 25:
		h = -ra
	else:
		h = next_ra - ra
	diff = 27.321582/360. * h
	if abs(diff*24*60*60) < 1:
		break
	j2 += diff

h = 24 * (j2-j)

def plur(x):
Example #46
0
File: qa.py Project: musalisa/se


### CARTA Z #################################
#print( "\nCuspidi dei segni")
grado_z = 180 - AOHOR
cx = 350
cy = 350
z1 = 200
z2 = 300
#for i in range(0, 360, 30):
	##print (grado_z+i, math.cos(math.radians(grado_z+i))*80, math.sin(math.radians(grado_z+i))*80,math.cos(math.radians(grado_z+i))*100, math.sin(math.radians(grado_z+i))*100);
	#print ( "{ x1:", (math.cos(math.radians(grado_z+i)) * z1) + cx, ",")
	#print ( "  y1:", (math.sin(math.radians(grado_z+i)) * -z1) + cy, ",")
	#print ( "  x2:", (math.cos(math.radians(grado_z+i)) * z2) + cx, ",")
	#print ( "  y2:", (math.sin(math.radians(grado_z+i)) * -z2) + cy, "\n},")

#print(swe_houses)
print( "\nPIANETI - Eclittiche ed equatoriali")
for p in range( 0,7 ):
	print( "\n" + swe.get_planet_name( p ))
	print("lamda %.4f beta %4f" %  (swe.calc_ut( jut, p, swe.FLG_SPEED )[0],swe.calc_ut( jut, p, swe.FLG_SPEED )[1] ))
	print("alfa %.4f delta %4f" %  (swe.calc_ut( jut, p, swe.FLG_EQUATORIAL )[0],swe.calc_ut( jut, p, swe.FLG_EQUATORIAL )[1] ))


#print(swe.houses_ex(jut, top_lat, top_long, b'P'))
#        Calculate houses cusps (UT).
#       
#        Args: float julday, float lat, float lon, char hsys='P'
#        Return: 2 tuples of 12 and 8 float (cusps, ascmc) (except Gauquelin)
Example #47
0
 def declination(self, jd=None):
     if jd is None: jd = self.jd
     flags = sweph.FLG_SWIEPH + sweph.FLG_EQUATORIAL
     dec = sweph.calc_ut(jd, self.id, flags)[1]
     return dec
Example #48
0
    # 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)
    #

    for o in [{"what": "1", "offset": 0}, {"what": "2", "offset": 10000}]:
        iterate = re["stuff"][int(o["what"])]
        if iterate:
            for w in iterate:
                result = swe.calc_ut(t[1], (w + o["offset"]))
                output = {}
                for out in re["stuff"][0]:
                    output[out] = result[out]
                e[o["what"]][w] = output
        else:
            del e[o["what"]]

    # The angles & houses are possible only if given geo location.
    # For that, the latitude and longitude must set - to float, or
    # be able to convert to float (e.g. from string or perhaps int).
    if "geo" in re and "lat" in re["geo"] and "lon" in re["geo"] and re["geo"]["lat"] and re["geo"]["lon"]:
        e["4"], e["3"] = swe.houses(t[1], float(re["geo"]["lat"]), float(re["geo"]["lon"]), str(re["houses"] or "W"))
        # The Whole Sign default wasn't asked for.
        # None (null) or false means no houses wanted.
        if re["houses"]:
Example #49
0
 def distance(self, jd=None):
     if jd is None: jd = self.jd
     distance = sweph.calc_ut(jd, self.id, sweph.FLG_SWIEPH)[2]
     return distance
Example #50
0
def calc_position(d, planet_index):
    j = julday(d)
    return swe.calc_ut(j, planet_index)[0]
Example #51
0
 def speed(self, jd=None):
     if jd is None: jd = self.jd
     speed = sweph.calc_ut(jd, self.id)[3]
     return speed
Example #52
0
 def _swe_calc(self, datetime_utc):
     j = julday(datetime_utc)
     angles = [swe.calc_ut(j, i)[0] for i in range(Ephemeris.N_PLANETS)]
     return angles
Example #53
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
Example #54
0
def solar_longitude(jd):
  """Solar longitude at given instant (julian day) jd"""
  data = swe.calc_ut(jd, swe.SUN, flag = swe.FLG_SWIEPH)
  return data[0]   # in degrees
Example #55
0
def lunar_latitude(jd):
  """Lunar latitude at given instant (julian day) jd"""
  data = swe.calc_ut(jd, swe.MOON, flag = swe.FLG_SWIEPH)
  return data[1]   # in degrees
Example #56
0
 def calc(self, lat=0.0, lon=0.0, i_date=DEFAULT_DATE, hsys='P'):
     year = i_date.year
     month = i_date.month
     day = i_date.day
     time = dechourjoin(i_date.hour, i_date.minute, i_date.second)
     
     julday = swe.julday(year, month, day, time)
     geo = swe.set_topo(lat, lon, 0)
     houses, ascmc = swe.houses(julday, lat, lon,  hsys)
     #print houses
     
     for i, body in enumerate(bnames): #日月水金火木土天海冥北交
         result = swe.calc_ut(julday, bnames_se[body])
         degree_ut = result[0]; #和春分点的夹角
         retrograde = bool(result[3] < 0) #是否逆行
         
         for sign in range(12): #行星在12星座的什么位置
             deg_low =  float(sign * 30)
             deg_high = float((sign + 1) * 30)
             if (degree_ut >= deg_low and degree_ut <= deg_high):
                 cibody = { "id"         : bnames_se[body],
                            "name"       : body,
                            "sign"       : sign,
                            "sign_name"  : snames[sign],
                            "degree"     : degree_ut - deg_low, #相对星座头部的夹角
                            "degree_ut"  : degree_ut, #和春分点的夹角
                            "retrograde" : retrograde } #是否逆行
                 self.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,
                             "name"       : "House",
                             "sign"       : sign,
                             "sign_name"  : snames[sign],
                             "degree"     : degree_ut - deg_low,
                             "degree_ut"  : degree_ut }
                 self.cihouses.append(cihouse)
                 
     for index in range(2): #上升点和天顶
         degree_ut = ascmc[index]
         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 }
                 self.ciascmcs.append(ciascmc)
                 cibody  = { "id"         : anames[index],
                             "name"       : anames[index],
                             "sign"       : sign,
                             "sign_name"  : snames[sign],
                             "degree"     : degree_ut - deg_low,
                             "degree_ut"  : degree_ut,
                             "retrograde" : None }
                 self.cibodies.append(cibody)
     
     swe.close()
     
     ciresults = {
         "bodies"  : self.cibodies,
         "houses"  : self.cihouses,
         "ascmcs"  : self.ciascmcs
         }
 
     return ciresults
)

sn = 9*[0]
old=''
date1 = '1979-01-01'
date2 = '2030-01-01'
startdate = datetime.datetime.strptime(date1, '%Y-%m-%d')
enddate = datetime.datetime.strptime(date2, '%Y-%m-%d')
step = datetime.timedelta(days=1)

while startdate <= enddate:
	out = ''
	y,m,d = startdate.year, startdate.month, startdate.day
	j = s.julday(y, m, d, 12)
	for n, b in enumerate(planets):
		ra = (s.calc_ut(j, b))[0]
		sn[n] = int(ra//30.)
	p = sn[3]*1728+sn[8]*144+sn[6]*12+sn[5]
	q = sn[4]*1728+sn[7]*144+sn[2]*12+sn[0]
	p = "{0:x}".format(p)
	q = "{0:x}".format(q)
	if len(p) < 4:
		p = (4-len(p)) * '0' + p
	if len(q) < 4:
		q = (4-len(q)) * '0' + q
	for xx,yy in r:
		p = p.replace(yy,xx)
		q = q.replace(yy,xx)
	dmer = sn[1] - sn[0]
	if dmer == 1 or dmer == -11:
		mer = '+'
Example #58
0
def sidereal_longitude(jd, planet):
  """Computes nirayana (sidereal) longitude of given planet on jd"""
  set_ayanamsa_mode()
  longi = swe.calc_ut(jd, planet, flag = swe.FLG_SWIEPH | swe.FLG_SIDEREAL)
  reset_ayanamsa_mode()
  return norm360(longi[0]) # degrees