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
def sweHouses(jd, lat, lon, hsys): """ Returns lists of houses and angles. """ hsys = SWE_HOUSESYS[hsys] hlist, ascmc = swisseph.houses(jd, lat, lon, hsys) # Add first house to the end of 'hlist' so that we # can compute house sizes with an iterator hlist += (hlist[0], ) houses = [{ 'id': const.LIST_HOUSES[i], 'lon': hlist[i], 'size': angle.distance(hlist[i], hlist[i + 1]) } for i in range(12)] angles = [{ 'id': const.ASC, 'lon': ascmc[0] }, { 'id': const.MC, 'lon': ascmc[1] }, { 'id': const.DESC, 'lon': angle.norm(ascmc[0] + 180) }, { 'id': const.IC, 'lon': angle.norm(ascmc[1] + 180) }, { 'id': const.VERTEX, 'lon': ascmc[3] }] return (houses, angles)
def calc_houses(self): houses = swe.houses(self.datetime_julday, self.latitude, self.longitude)[0] planets_in_houses = [] for planet_code, planet in self.planets.items(): planet['house'] = self.calc_house(houses, planet['x']) self.asc = houses[0] self.asc_sign = SIGN_NAMES[int(houses[0] / 30)] return houses #, planets_in_houses
def sweHousesLon(jd, lat, lon, hsys): """ Returns lists with house and angle longitudes. """ hsys = SWE_HOUSESYS[hsys] hlist, ascmc = swisseph.houses(jd, lat, lon, hsys) angles = [ ascmc[0], ascmc[1], angle.norm(ascmc[0] + 180), angle.norm(ascmc[1] + 180), ascmc[3] ] return (hlist, angles)
def sweHousesLon(jd, lat, lon, hsys): """ Returns lists with house and angle longitudes. """ hsys = SWE_HOUSESYS[hsys] hlist, ascmc = swisseph.houses(jd, lat, lon, hsys) angles = [ ascmc[0], ascmc[1], angle.norm(ascmc[0] + 180), angle.norm(ascmc[1] + 180) ] return (hlist, angles)
def olivier_endpoint(): import math import swisseph as sweph latlong = None jd = cerridwen.jd_now() try: date = flask.request.args.get('date') if date: jd = cerridwen.parse_jd_or_iso_date(date) lat = flask.request.args.get('latitude') if lat: lat = float(lat) long = flask.request.args.get('longitude') if long: long = float(long) if (long is None and lat is not None) or (lat is None and long is not None): raise ValueError("Specify both longitude and latitude or none") if lat and long: latlong = cerridwen.LatLong(lat, long) except ValueError as e: return make_response(e, 400) result = collections.OrderedDict() result['jd'] = jd result['iso_date'] = cerridwen.jd2iso(jd) from cerridwen import Sun, Moon, Mercury, Venus, Mars, Jupiter, Saturn, Uranus, Neptune, Pluto for planet in [ Sun(), Moon(), Mercury(), Venus(), Mars(), Jupiter(), Saturn(), Uranus(), Neptune(), Pluto() ]: result[planet.name().lower()] = math.radians(planet.longitude(jd)) if latlong: result['houses'] = [ math.radians(cusp) for cusp in sweph.houses(jd, latlong.lat, latlong.long)[0] ] import json return make_response(json.dumps(result, indent=8), 200)
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()
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()
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()
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()
def calculate_main_chart(input_data, intermediate, output): output['houses'] = {} output['houses']['sh'] = {} output['houses']['sh'] = swe.houses( intermediate['jul_day_UT'], float(input_data['chart']['latitude']), float(input_data['chart']['longitude']), input_data['config']['house_system'].encode('ascii')) output['houses']['houses_degree_ut'] = output['houses']['sh'][0] output['houses']['ps'] = swe.nod_aps_ut(intermediate['jul_day_UT'], 0, swe.NODBIT_MEAN, intermediate['iflag']) output['houses']['pl'] = swe.nod_aps_ut(intermediate['jul_day_UT'], 1, swe.NODBIT_MEAN, intermediate['iflag']) return output
def houses(self): """Calculatetype positions and store them in dictionaries""" #creates the list of the house in 360° self.houses_degree_ut = swe.houses(self.j_day, self.city_lat, self.city_long)[0] #stores the house in signulare dictionaries. self.first_house = self.pos_calc(self.houses_degree_ut[0], "1", "name") self.second_house = self.pos_calc(self.houses_degree_ut[1], "2", "name") self.third_house = self.pos_calc(self.houses_degree_ut[2], "3", "name") self.fourth_house = self.pos_calc(self.houses_degree_ut[3], "4", "name") self.fifth_house = self.pos_calc(self.houses_degree_ut[4], "5", "name") self.sixth_house = self.pos_calc(self.houses_degree_ut[5], "6", "name") self.seventh_house = self.pos_calc(self.houses_degree_ut[6], "7", "name") self.eighth_house = self.pos_calc(self.houses_degree_ut[7], "8", "name") self.ninth_house = self.pos_calc(self.houses_degree_ut[8], "9", "name") self.tenth_house = self.pos_calc(self.houses_degree_ut[9], "10", "name") self.eleventh_house = self.pos_calc(self.houses_degree_ut[10], "11", "name") self.twelfth_house = self.pos_calc(self.houses_degree_ut[11], "12", "name") #creates a list of all the dictionaries of thetype. self.house_list = [ self.first_house, self.second_house, self.third_house, self.fourth_house, self.fifth_house, self.sixth_house, self.seventh_house, self.eighth_house, self.ninth_house, self.tenth_house, self.eleventh_house, self.twelfth_house ] self.houses_degree = [ self.house_list[0]["pos"], self.house_list[1]["pos"], self.house_list[2]["pos"], self.house_list[3]["pos"], self.house_list[4]["pos"], self.house_list[5]["pos"], self.house_list[6]["pos"], self.house_list[7]["pos"], self.house_list[8]["pos"], self.house_list[9]["pos"], self.house_list[10]["pos"], self.house_list[11]["pos"] ] return self.house_list
def house_cusps(self): houses = [] asc = 0 angle = [] for i, j in enumerate( swe.houses(self.julday(), self.latitude, self.longitude)[0]): if i == 0: asc += j angle.append(j) if i + 1 == 1: self.append_house(houses, i, j, name="Asc") elif i + 1 == 4: self.append_house(houses, i, j, name="IC") elif i + 1 == 7: self.append_house(houses, i, j, name="Dsc") elif i + 1 == 10: self.append_house(houses, i, j, name="MC") else: self.append_house(houses, i, j) return houses, asc, angle
def getHour(uHora, grado): for hora in range(24): #print('Hora: '+str(hora)) encontrado = False for minuto in range(60): #print('Minuto: '+str(minuto)) uHora += datetime.timedelta(minutes=1) #print(str(d)) jd1 = jdutil.datetime_to_jd(uHora) h = swe.houses(jd1, float(lat), float(lon), bytes("P", encoding="utf-8")) gasc = float(h[0][0]) if gasc >= grado - 1.00 and gasc <= grado + 1.00: #print(str(gasc)) uHora = uHora + datetime.timedelta(hours=int(gmt)) encontrado = True break if encontrado: break return uHora
def sweHouses(jd, lat, lon, hsys): """ Returns lists of houses and angles. """ hsys = SWE_HOUSESYS[hsys] hlist, ascmc = swisseph.houses(jd, lat, lon, hsys) # Add first house to the end of 'hlist' so that we # can compute house sizes with an iterator hlist += (hlist[0],) houses = [ { 'id': const.LIST_HOUSES[i], 'lon': hlist[i], 'size': angle.distance(hlist[i], hlist[i+1]) } for i in range(12) ] angles = [ {'id': const.ASC, 'lon': ascmc[0]}, {'id': const.MC, 'lon': ascmc[1]}, {'id': const.DESC, 'lon': angle.norm(ascmc[0] + 180)}, {'id': const.IC, 'lon': angle.norm(ascmc[1] + 180)} ] return (houses, angles)
def olivier_endpoint(): import math import swisseph as sweph latlong = None jd = cerridwen.jd_now() try: date = flask.request.args.get('date') if date: jd = cerridwen.parse_jd_or_iso_date(date) lat = flask.request.args.get('latitude') if lat: lat = float(lat) long = flask.request.args.get('longitude') if long: long = float(long) if (long is None and lat is not None) or (lat is None and long is not None): raise ValueError("Specify both longitude and latitude or none") if lat and long: latlong = cerridwen.LatLong(lat, long) except ValueError as e: return make_response(e, 400) result = collections.OrderedDict() result['jd'] = jd result['iso_date'] = cerridwen.jd2iso(jd) from cerridwen import Sun, Moon, Mercury, Venus, Mars, Jupiter, Saturn, Uranus, Neptune, Pluto for planet in [Sun(), Moon(), Mercury(), Venus(), Mars(), Jupiter(), Saturn(), Uranus(), Neptune(), Pluto()]: result[planet.name().lower()] = math.radians(planet.longitude(jd)); if latlong: result['houses'] = [math.radians(cusp) for cusp in sweph.houses(jd, latlong.lat, latlong.long)[0]] import json return make_response(json.dumps(result, indent=8), 200)
def local_asc_mc(sun_rise1, sun_set1, sun_rise_n1, b_latitude, b_longitude, h_type, t_zone, b_offset): date_year_birth = sun_rise1.year date_month_birth = sun_rise1.month date_day_birth = sun_rise1.day date_hour_birth = sun_rise1.hour date_min_birth = sun_rise1.minute day_diff = (sun_set1 - sun_rise1) / 12 day_diff1 = (sun_rise_n1 - sun_set1) / 12 day_divided = 24 + 1 # 60 * 24 /20 extra for storing start of next day, 24 planetary hours in a day l_asc_mc = np.zeros(day_divided * 2) j = -1 # print sun_rise1,sun_set1, sun_rise_n1 for i in range(day_divided): # print i, date_year_birth, date_month_birth, date_day_birth, date_hour_birth, date_min_birth, day_diff now_julian = swe.julday( date_year_birth, date_month_birth, date_day_birth, (date_hour_birth + date_min_birth / 60.) - (t_zone - b_offset)) house_array = (swe.houses(now_julian, b_latitude, b_longitude, h_type)) j += 1 l_asc_mc[j] = house_array[1][0] j += 1 l_asc_mc[j] = house_array[1][1] if i < 12: sun_rise1 += day_diff date_year_birth = sun_rise1.year date_month_birth = sun_rise1.month date_day_birth = sun_rise1.day date_hour_birth = sun_rise1.hour date_min_birth = sun_rise1.minute else: sun_set1 += day_diff1 date_year_birth = sun_set1.year date_month_birth = sun_set1.month date_day_birth = sun_set1.day date_hour_birth = sun_set1.hour date_min_birth = sun_set1.minute day_diff = day_diff1 return l_asc_mc
def local_asc_mc(sun_rise1, sun_set1, sun_rise_n1, b_latitude, b_longitude, h_type, t_zone, b_offset): date_year_birth = sun_rise1.year date_month_birth = sun_rise1.month date_day_birth = sun_rise1.day date_hour_birth = sun_rise1.hour date_min_birth = sun_rise1.minute day_diff = (sun_set1 - sun_rise1) / 12 day_diff1 = (sun_rise_n1 - sun_set1) / 12 day_divided = 24 + 1 # 60 * 24 /20 extra for storing start of next day, 24 planetary hours in a day l_asc_mc = np.zeros(day_divided * 2) j = -1 # print sun_rise1,sun_set1, sun_rise_n1 for i in range(day_divided): # print i, date_year_birth, date_month_birth, date_day_birth, date_hour_birth, date_min_birth, day_diff now_julian = swe.julday(date_year_birth, date_month_birth, date_day_birth, (date_hour_birth + date_min_birth / 60.) - (t_zone - b_offset)) house_array = (swe.houses(now_julian, b_latitude, b_longitude, h_type)) j += 1 l_asc_mc[j] = house_array[1][0] j += 1 l_asc_mc[j] = house_array[1][1] if i < 12: sun_rise1 += day_diff date_year_birth = sun_rise1.year date_month_birth = sun_rise1.month date_day_birth = sun_rise1.day date_hour_birth = sun_rise1.hour date_min_birth = sun_rise1.minute else: sun_set1 += day_diff1 date_year_birth = sun_set1.year date_month_birth = sun_set1.month date_day_birth = sun_set1.day date_hour_birth = sun_set1.hour date_min_birth = sun_set1.minute day_diff = day_diff1 return l_asc_mc
def longitude(self, jd=None): if jd is None: jd = self.jd return sweph.houses(jd, self.lat, self.long)[1][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
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()
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
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"]: e["4"] += (re["houses"],) else: del e["4"] else: del e["3"] del e["4"] # Zero hash for extra data -- useful with post-processing. # Preserves the input request if asked for it (with "re"). # Possibly also debug data, time metrics, etc. if "extra" in re and re["extra"]: for (add, conf) in re["extra"].iteritems():
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
def calc_houses(self): houses, ascmc = swe.houses(self.datetime_julday, self.latitude, self.longitude) houses = OrderedDict([(i+1, angle) for i, angle in enumerate(houses)]) ascmc = Ascmc(*ascmc) return houses, ascmc
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
def _swe_calc(self, datetime_utc, lat, lon): j = julday(datetime_utc) angles = swe.houses(j, lat, lon)[0] return angles
anio) + ' ' + str(hora) + ':' + str(min) + '",' jsonParams += '"sdgmt": "' + stringDateSinGmt jsonParams += '}' np = [('Sol', 0), ('Luna', 1), ('Mercurio', 2), ('Venus', 3), ('Marte', 4), ('Júpiter', 5), ('Saturno', 6), ('Urano', 7), ('Neptuno', 8), ('Plutón', 9), ('Nodo Norte', 11), ('Nodo Sur', 10), ('Quirón', 15), ('Selena', 57), ('Lilith', 12)] #La oblicuidad de calcula con ipl = SE_ECL_NUT = -1 en SWE pero en swisseph ECL_NUT = -1 posObli = swe.calc(jd1, -1, flag=swe.FLG_SWIEPH + swe.FLG_SPEED) oblicuidad = posObli[0][0] #print('Oblicuidad: ' + str(posObli[0][0])) #Se calculan casas previamente para calcular en cada cuerpo con swe.house_pos(...) h = swe.houses(jd1, float(lat), float(lon), bytes(houseType, encoding="utf-8")) jsonString = '{' index = 0 #print(jsonAspets) #print('Cantidad de Aspectos: '+str(indexAsp)) #Comienza JSON Houses jsonHouses = '"ph":{' numHouse = 1 #print('ARMC:' + str(h[0][9])) for i in h[0]: td = decdeg2dms(i) gdeg = int(td[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()
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()
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"]: e["4"] += (re["houses"],) else: del e["4"] else: del e["3"] del e["4"] # Zero hash for extra data -- useful with post-processing. # Preserves the input request if asked for it (with "re"). # Possibly also debug data, time metrics, etc. if "extra" in re and re["extra"]:
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
for i in range(1, 12): case_aoch_gm.append(decdeg2dm(case_aoch[i], "dm")) print("\nAOCH case dalla 10°") print(case_aoch) #print(case_ar_gm) # Ascensioni oblique delle case (ZZ, AOHOR) = divmod((ARMC + 90), 360) print("\nAOHOR") print(AOHOR) # Poli delle case case_poli = [] # Cuspidi delle case sullo zodiaco case_cuspidi = swe.houses(jut, top_lat, top_long, b'P')[0] HOR = hor(AOHOR, top_lat) #HOR = case_cuspidi[0] print("\nHOR") print(HOR) print(decdeg2dm(HOR)) print("\ncuspidi case dalla 10° sullo zodiaco") print(case_cuspidi) swe_houses = swe.houses(jut, top_lat, top_long, b'P') ### CARTA Z ################################# #print( "\nCuspidi dei segni") grado_z = 180 - AOHOR cx = 350 cy = 350 z1 = 200
for i in range(1,12): case_aoch_gm.append(decdeg2dm(case_aoch[i],"dm")) print( "\nAOCH case dalla 10°") print(case_aoch) #print(case_ar_gm) # Ascensioni oblique delle case (ZZ, AOHOR) = divmod((ARMC + 90) , 360) print( "\nAOHOR") print( AOHOR) # Poli delle case case_poli = [] # Cuspidi delle case sullo zodiaco case_cuspidi = swe.houses(jut, top_lat, top_long, b'P')[0] HOR = hor( AOHOR, top_lat) #HOR = case_cuspidi[0] print( "\nHOR") print( HOR ) print(decdeg2dm(HOR)) print( "\ncuspidi case dalla 10° sullo zodiaco") print(case_cuspidi) swe_houses = swe.houses(jut, top_lat, top_long, b'P') ### CARTA Z ################################# #print( "\nCuspidi dei segni") grado_z = 180 - AOHOR cx = 350
#print "uthour",uthour current_jul_day_UT = swe.julday(year, month, day, uthour, gregflag) ret_flag_sun = swe.calc_ut(current_jul_day_UT, 0, gregflag) longitude_sun = ret_flag_sun[0] print "Sun", longitude_sun zodiaque = int(longitude_sun // 30) + 1 print "zodiaque", zodiaque ret_flag_moon = swe.calc_ut(current_jul_day_UT, 1, gregflag) longitude_moon = ret_flag_moon[0] print "moon", longitude_moon cusp = range(13) cusp = swe.houses(current_jul_day_UT, geolat, geolon, "P") #print cusp[0] longitude_asc = cusp[0][0] print "ascendant", longitude_asc enjournee = daylight(longitude_sun, longitude_asc) print "daylight", enjournee print "-------------------------------------------------------------" charcodelist = [] charcodelistone = [] #choose the letters of the word------------------------------------------------------- #12 simples: zodiaque vowel_codes = [ "05B0", "05B1", "05B2", "05B3", "05B4", "05B5", "05B6", "05B7", "05B8", "05B9", "05BB", "05BC", "05BD", "05BF", "05C1", "05C2", "05C4"