Example #1
2
def get_sunrise_and_sunset(date, observer):
    day = datetime_to_julian(date.replace(hour=12))

    sunrise = revjul_to_datetime(
        swisseph.revjul(
            swisseph.rise_trans(
                day - 1, swisseph.SUN, observer.lng, observer.lat, alt=observer.elevation, rsmi=swisseph.CALC_RISE
            )[1][0]
        )
    )

    sunset = revjul_to_datetime(
        swisseph.revjul(
            swisseph.rise_trans(
                day, swisseph.SUN, observer.lng, observer.lat, observer.elevation, rsmi=swisseph.CALC_SET
            )[1][0]
        )
    )

    next_sunrise = revjul_to_datetime(
        swisseph.revjul(
            swisseph.rise_trans(
                day, swisseph.SUN, observer.lng, observer.lat, observer.elevation, rsmi=swisseph.CALC_RISE
            )[1][0]
        )
    )
    swisseph.close()
    return sunrise, sunset, next_sunrise
Example #2
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 #3
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 #4
0
def get_sunrise_and_sunset(date, observer):
	day = datetime_to_julian(date.replace(hour=12))

	sunrise = revjul_to_datetime(swisseph.revjul(swisseph.rise_trans(day-1, swisseph.SUN, 
	                                                                 observer.lng, 
	                                                                 observer.lat, 
	                                                                 alt=observer.elevation, 
	                                                                 rsmi=swisseph.CALC_RISE)[1][0]
	                                            )
	                            )

	sunset = revjul_to_datetime(swisseph.revjul(swisseph.rise_trans(day, swisseph.SUN, 
	                                                                observer.lng, observer.lat, 
	                                                                observer.elevation, 
	                                                                rsmi=swisseph.CALC_SET)[1][0]
	                                           )
	                           )

	next_sunrise = revjul_to_datetime(swisseph.revjul(swisseph.rise_trans(day, swisseph.SUN, 
	                                                                      observer.lng, observer.lat, 
	                                                                      observer.elevation, 
	                                                                      rsmi=swisseph.CALC_RISE)[1][0]
	                                                 )
	                                 )
	swisseph.close()
	return sunrise, sunset, next_sunrise
Example #5
0
def get_transit(planet, observer, date):
	day = datetime_to_julian(date)
	if observer.lat < 0:
		transit=revjul_to_datetime(swisseph.revjul(swisseph.rise_trans(day-1, \
				planet, observer.lng, observer.lat, alt=observer.elevation, \
				rsmi=swisseph.CALC_MTRANSIT)[1][0]))
	else:
		transit=revjul_to_datetime(swisseph.revjul(swisseph.rise_trans(day-1, \
				planet, observer.lng, observer.lat, alt=observer.elevation, \
				rsmi=swisseph.CALC_ITRANSIT)[1][0]))
	swisseph.close()
	return transit
Example #6
0
def state_to_string(state_line, planet):
    name = swisseph.get_planet_name(planet)
    if state_line[1] == "New" or state_line[1] == "Full":
        state = "%s %s" % (state_line[1], name)
    elif state_line[1] == "Quarter":
        if state_line[0] == "Waning":
            state = "Last %s %s" % (state_line[1], name)
        else:
            state = "First %s %s" % (state_line[1], name)
    else:
        state = "%s %s %s" % (state_line[0], state_line[1], name)
    swisseph.close()
    return state
Example #7
0
def state_to_string(state_line, planet):
	name = swisseph.get_planet_name(planet)
	if state_line[1] == "New" or state_line[1] == "Full":
		state = "%s %s" %(state_line[1], name)
	elif state_line[1] == "Quarter":
		if state_line[0] == "Waning":
			state = "Last %s %s" %(state_line[1], name)
		else:
			state = "First %s %s" %(state_line[1], name)
	else:
		state = "%s %s %s" %(state_line[0], state_line[1], name)
	swisseph.close()
	return state
Example #8
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 #9
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 #10
0
def fill_houses(date, observer, houses=None, data=None):
	day = datetime_to_julian(date)
	if not data:
		data = swisseph.houses(day, observer.lat, observer.lng)[0]
	if houses == None:
		houses = []
		for i in range(12):
			houses.append(HouseMeasurement(data[i], data[(i+1)%12], num=i+1))
		swisseph.close()
		return houses
	else:
		for i in range(12):
			houses[i].cusp.longitude = data[i]
			houses[i].end.longitude = data[(i+1)%12]
		swisseph.close()
Example #11
0
def fill_houses(date, observer, houses=None, data=None):
    day = datetime_to_julian(date)
    if not data:
        data = swisseph.houses(day, observer.lat, observer.lng)[0]
    if houses == None:
        houses = []
        for i in range(12):
            houses.append(HouseMeasurement(data[i], data[(i + 1) % 12], num=i + 1))
        swisseph.close()
        return houses
    else:
        for i in range(12):
            houses[i].cusp.longitude = data[i]
            houses[i].end.longitude = data[(i + 1) % 12]
        swisseph.close()
Example #12
0
def get_transit(planet, observer, date):
	day = datetime_to_julian(date)
	if observer.lat < 0:
		transit = revjul_to_datetime(swisseph.revjul(swisseph.rise_trans(day-1, planet,
		                                                               observer.lng, 
		                                                               observer.lat, 
		                                                               alt=observer.elevation, 
		                                                               rsmi=swisseph.CALC_MTRANSIT)[1][0]
		                                          )
		                          )
	else:
		transit = revjul_to_datetime(swisseph.revjul(swisseph.rise_trans(day-1, planet, 
		                                                               observer.lng, 
		                                                               observer.lat, 
		                                                               alt=observer.elevation, 
		                                                               rsmi=swisseph.CALC_ITRANSIT)[1][0]
		                                          )
		                          )
	swisseph.close()
	return transit
Example #13
0
def grab_phase(date, refinements=2):
    day = datetime_to_julian(date)
    full_m = previous_full_moon(date, refinements=refinements)
    # next_new = next_new_moon(date)
    phase = swisseph.pheno_ut(day, swisseph.MOON)[1] * 100

    if 97.0 <= phase <= 100.0:
        illumination = "Full"
    elif 0 <= phase <= 2.0:
        illumination = "New"
    elif 2.0 <= phase <= 47.0:
        illumination = "Crescent"
    elif 47.0 <= phase <= 52.0:
        illumination = "Quarter"
    else:
        illumination = "Gibbous"
    status = "Waning"
    if LMONTH_HALF_TD < date - full_m < LMONTH_FULL_TD:
        status = "Waxing"
    swisseph.close()
    return status, illumination, "%.3f%%" % (phase)
Example #14
0
def grab_phase(date, refinements=2):
	day = datetime_to_julian(date)
	full_m = previous_full_moon(date, refinements=refinements)
	#next_new = next_new_moon(date)
	phase = swisseph.pheno_ut(day, swisseph.MOON)[1]*100

	if 97.0 <= phase <= 100.0:
		illumination = "Full"
	elif 0 <= phase <= 2.0:
		illumination = "New"
	elif 2.0 <= phase <= 47.0:
		illumination = "Crescent"
	elif 47.0 <= phase <= 52.0:
		illumination = "Quarter"
	else:
		illumination = "Gibbous"
	status = "Waning"
	if LMONTH_HALF_TD < date - full_m < LMONTH_FULL_TD:
		status = "Waxing"
	swisseph.close()
	return status, illumination, "%.3f%%" %(phase)
Example #15
0
def get_signs(date, observer, nodes, axes, prefix=None):
	entries = []
	houses = fill_houses(date, observer)
	day = datetime_to_julian(date)
	obliquity = swisseph.calc_ut(day, swisseph.ECL_NUT)[0]

	cusps, asmc = swisseph.houses(day, observer.lat, observer.lng)

	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])
		zm = ActiveZodiacalMeasurement(calcs[0], calcs[1], houses[int(hom-1)], progress=hom % 1.0)
		if i == swisseph.SUN or i == swisseph.MOON:
			retrograde = 'Not Applicable'
		else:
			retrograde = str(calcs[3] < 0)
		planet = Planet(swisseph.get_planet_name(i), prefix=prefix, m=zm, retrograde=retrograde)
		entries.append(planet)
	if nodes: #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])
		zm = ActiveZodiacalMeasurement(calcs[0], calcs[1], houses[int(hom-1)], progress=hom % 1.0)
		retrograde = "Always"
		planet = Planet("North Node", prefix=prefix, m=zm, retrograde=retrograde)
		entries.append(planet)

		#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
		zm = ActiveZodiacalMeasurement(reverse, calcs[1], houses[revhouse-1], progress=revprogress)
		planet = Planet("South Node", prefix=prefix ,m=zm, retrograde=retrograde)
		entries.append(planet)
	if axes:
		ascendant = asmc[0]
		descendant = cusps[6]
		mc = asmc[1]
		ic = cusps[3]
		retrograde = 'Not a Planet'

		zm = ActiveZodiacalMeasurement(ascendant, 0.0, houses[0], progress=0.0)
		planet = Planet("Ascendant", prefix=prefix, m=zm, retrograde=retrograde)
		entries.append(planet)

		zm = ActiveZodiacalMeasurement(descendant, 0.0, houses[6], progress=0.0)
		planet = Planet("Descendant", prefix=prefix, m=zm, retrograde=retrograde)
		entries.append(planet)

		zm = ActiveZodiacalMeasurement(mc, 0.0, houses[9], progress=0.0)
		planet = Planet("MC", prefix=prefix, m=zm, retrograde=retrograde)
		entries.append(planet)

		zm = ActiveZodiacalMeasurement(ic, 0.0, houses[3], progress=0.0)
		planet = Planet("IC", prefix=prefix, m=zm, retrograde=retrograde)
		entries.append(planet)

	#if stars:
		#print "Todo"
	swisseph.close()
	return houses, entries
Example #16
0
def datetime_to_julian(date):
    utc = date.utctimetuple()
    total_hour = utc.tm_hour * 1.0 + utc.tm_min / 60.0 + utc.tm_sec / 3600.0
    day = swisseph.julday(utc.tm_year, utc.tm_mon, utc.tm_mday, hour=total_hour)
    swisseph.close()
    return day
Example #17
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 #18
0
def get_sun_sign(date, observer):
	sign = get_house(swisseph.SUN, observer, date)[2][1]
	swisseph.close()
	return sign
Example #19
0
def datetime_to_julian(date):
	utc = date.utctimetuple()
	total_hour = utc.tm_hour*1.0+utc.tm_min/60.0+utc.tm_sec/3600.0
	day = swisseph.julday(utc.tm_year, utc.tm_mon, utc.tm_mday, hour=total_hour)
	swisseph.close()
	return day
Example #20
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 #21
0
    def create(self):
        hflag = 0
        fsflag = 0
        pflag = astrology.SEFLG_SWIEPH+astrology.SEFLG_SPEED
        astflag = astrology.SEFLG_SWIEPH
        self.ayanamsha = 0.0
        if self.options.ayanamsha != 0:
            swisseph.set_sid_mode(self.options.ayanamsha-1, 0, 0)
            self.ayanamsha = swisseph.get_ayanamsa_ut(self.time.jd)

        if self.options.topocentric:
            pflag += astrology.SEFLG_TOPOCTR

        self.houses = houses.Houses(
            self.time.jd,
            hflag,
            self.place.lat,
            self.place.lon,
            self.options.hsys,
            self.obl[0],
            self.options.ayanamsha,
            self.ayanamsha)

        self.raequasc, declequasc, dist = swisseph.cotrans(
            self.houses.ascmc[houses.Houses.EQUASC], 0.0, 1.0, -self.obl[0])
        self.planets = planets.Planets(
            self.time.jd,
            self.options.meannode,
            pflag,
            self.place.lat,
            self.houses.ascmc2,
            self.raequasc,
            self.nolat,
            self.obl[0])

        self.abovehorizonwithorb = self.isAboveHorizonWithOrb()

        abovehor = self.planets.planets[astrology.SE_SUN].abovehorizon
        if self.options.usedaynightorb:
            abovehor = self.abovehorizonwithorb

        self.fortune = fortune.Fortune(
            self.options.lotoffortune,
            self.houses.ascmc2,
            self.raequasc,
            self.planets,
            self.obl[0],
            self.place.lat,
            abovehor)

# ###########################################
# Roberto change  V 7.3.0
        self.firdaria = None
# ###########################################
        self.munfortune = None
        self.parts = None
        self.fixstars = None
        self.midpoints = None
        self.riseset = None
        self.zodpars = None
        self.antiscia = None
        self.antzodpars = None
        self.cpd = None
        self.cpd2 = None
        self.syzygy = None
        self.almutens = None
        mdsun = self.planets.planets[astrology.SE_SUN].speculums[0][planets.Planet.MD]
        sasun = self.planets.planets[astrology.SE_SUN].speculums[0][planets.Planet.SA]
        if self.full:
            # ###########################################
            # Roberto change  V 7.3.0
            self.firdaria = firdaria.Firdaria(
                self.time.origyear,
                self.time.origmonth,
                self.time.origday,
                self.options,
                self.abovehorizonwithorb)
# ###########################################
            self.munfortune = munfortune.MundaneFortune(
                self.houses.ascmc2, self.planets, self.obl[0], self.place.lat)
            self.syzygy = syzygy.Syzygy(self)
            self.parts = arabicparts.ArabicParts(
                self.options.arabicparts,
                self.houses.ascmc,
                self.planets,
                self.houses,
                self.houses.cusps,
                self.fortune,
                self.syzygy,
                self.options)
            self.fixstars = fixstars.FixStars(
                self.time.jd, fsflag, self.options.fixstars, self.obl[0])
            self.midpoints = midpoints.MidPoints(self.planets)
            self.riseset = riseset.RiseSet(
                self.time.jd,
                self.time.cal,
                self.place.lon,
                self.place.lat,
                self.place.altitude,
                self.planets)
            self.zodpars = zodpars.ZodPars(self.planets, self.obl[0])
            self.antiscia = antiscia.Antiscia(
                self.planets.planets,
                self.houses.ascmc,
                self.fortune.fortune,
                self.obl[0],
                self.options.ayanamsha,
                self.ayanamsha)
            self.antzodpars = antzodpars.AntZodPars(
                self.antiscia.plantiscia, self.antiscia.plcontraant, self.obl[0])
            self.almutens = almutens.Almutens(self)
            if self.options.pdcustomer:
                self.cpd = customerpd.CustomerPD(
                    self.options.pdcustomerlon[0],
                    self.options.pdcustomerlon[1],
                    self.options.pdcustomerlon[2],
                    self.options.pdcustomerlat[0],
                    self.options.pdcustomerlat[1],
                    self.options.pdcustomerlat[2],
                    self.options.pdcustomersouthern,
                    self.place.lat,
                    self.houses.ascmc2,
                    self.obl[0],
                    self.raequasc)
            if self.options.pdcustomer2:
                self.cpd2 = customerpd.CustomerPD(
                    self.options.pdcustomer2lon[0],
                    self.options.pdcustomer2lon[1],
                    self.options.pdcustomer2lon[2],
                    self.options.pdcustomer2lat[0],
                    self.options.pdcustomer2lat[1],
                    self.options.pdcustomer2lat[2],
                    self.options.pdcustomer2southern,
                    self.place.lat,
                    self.houses.ascmc2,
                    self.obl[0],
                    self.raequasc)

        swisseph.close()

        self.calcAspMatrix()

        if self.fixstars is not None:
            self.calcFixStarAspMatrix()
Example #22
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()
Example #23
0
def get_sun_sign(date, observer):
    sign = get_house(swisseph.SUN, observer, date)[2][1]
    swisseph.close()
    return sign
Example #24
0
def get_signs(date, observer, nodes, axes, prefix=None):
    entries = []
    houses = fill_houses(date, observer)
    day = datetime_to_julian(date)
    obliquity = swisseph.calc_ut(day, swisseph.ECL_NUT)[0]

    cusps, asmc = swisseph.houses(day, observer.lat, observer.lng)

    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])
        zm = ActiveZodiacalMeasurement(calcs[0], calcs[1], houses[int(hom - 1)], progress=hom % 1.0)
        if i == swisseph.SUN or i == swisseph.MOON:
            retrograde = "Not Applicable"
        else:
            retrograde = str(calcs[3] < 0)
        planet = Planet(swisseph.get_planet_name(i), prefix=prefix, m=zm, retrograde=retrograde)
        entries.append(planet)
    if nodes:  # 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])
        zm = ActiveZodiacalMeasurement(calcs[0], calcs[1], houses[int(hom - 1)], progress=hom % 1.0)
        retrograde = "Always"
        planet = Planet("North Node", prefix=prefix, m=zm, retrograde=retrograde)
        entries.append(planet)

        # 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
        zm = ActiveZodiacalMeasurement(reverse, calcs[1], houses[revhouse - 1], progress=revprogress)
        planet = Planet("South Node", prefix=prefix, m=zm, retrograde=retrograde)
        entries.append(planet)
    if axes:
        ascendant = asmc[0]
        descendant = cusps[6]
        mc = asmc[1]
        ic = cusps[3]
        retrograde = "Not a Planet"

        zm = ActiveZodiacalMeasurement(ascendant, 0.0, houses[0], progress=0.0)
        planet = Planet("Ascendant", prefix=prefix, m=zm, retrograde=retrograde)
        entries.append(planet)

        zm = ActiveZodiacalMeasurement(descendant, 0.0, houses[6], progress=0.0)
        planet = Planet("Descendant", prefix=prefix, m=zm, retrograde=retrograde)
        entries.append(planet)

        zm = ActiveZodiacalMeasurement(mc, 0.0, houses[9], progress=0.0)
        planet = Planet("MC", prefix=prefix, m=zm, retrograde=retrograde)
        entries.append(planet)

        zm = ActiveZodiacalMeasurement(ic, 0.0, houses[3], progress=0.0)
        planet = Planet("IC", prefix=prefix, m=zm, retrograde=retrograde)
        entries.append(planet)

        # if stars:
        # print "Todo"
    swisseph.close()
    return houses, entries
Example #25
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.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 = 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

        #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()
numHouse = 1
#print('ARMC:' + str(h[0][9]))

for i in h[0]:
    td = decdeg2dms(i)
    gdeg = int(td[0])
    mdeg = int(td[1])
    sdeg = int(td[2])
    index = getIndexSign(float(i))
    rsgdeg = gdeg - (index * 30)
    jsonHouses += '"h' + str(numHouse) + '": {'
    jsonHouses += '"is":' + str(index) + ', '
    jsonHouses += '"gdec":' + str(i) + ','
    jsonHouses += '"rsgdeg":' + str(rsgdeg) + ', '
    jsonHouses += '"gdeg":' + str(gdeg) + ','
    jsonHouses += '"mdeg":' + str(mdeg) + ','
    jsonHouses += '"sdeg":' + str(sdeg) + ''
    break

jsonHouses += '}'
jsonString += '' + jsonHouses + ','
jsonString += '' + jsonParams
jsonString += '}}'

#print(jsonBodies)
#print(jsonHouses)
#print(jsonAspets)
print(jsonString)
swe.close()
#help(swe)
Example #27
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
Example #28
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.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 = 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
		



		#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()