Ejemplo n.º 1
0
	def calcTimes(self):
		#the date we get from julianday is the same as year, month day in Time-class but we didn't pass it to the init function.
		oyear, omonth, oday, otim = astrology.swe_revjul(self.jd, self.calflag)

		numangles = len(RiseSet.Angles)
		for i in range(planets.Planets.PLANETS_NUM):#Nodes are excluded
			ar = []

			#Rise
			ret, JDRise, serr = astrology.swe_rise_trans(self.jd, i, "", astrology.SEFLG_SWIEPH, RiseSet.Angles[RiseSet.RISE], self.lon, self.lat, self.alt, 0.0, 10.0)
			tyear, tmonth, tday, ttim = astrology.swe_revjul(JDRise, self.calflag)
			if oyear != tyear or omonth != tmonth or oday != tday:
				ret, JDRise, serr = astrology.swe_rise_trans(self.jd-1.0, i, "", astrology.SEFLG_SWIEPH, RiseSet.Angles[RiseSet.RISE], self.lon, self.lat, self.alt, 0.0, 10.0)

			#MC
			ret, JDMC, serr = astrology.swe_rise_trans(self.jd, i, "", astrology.SEFLG_SWIEPH, RiseSet.Angles[RiseSet.MC], self.lon, self.lat, self.alt, 0.0, 10.0)
			tyear, tmonth, tday, ttim = astrology.swe_revjul(JDMC, self.calflag)
			if oyear != tyear or omonth != tmonth or oday != tday:
				ret, JDMC, serr = astrology.swe_rise_trans(self.jd-1.0, i, "", astrology.SEFLG_SWIEPH, RiseSet.Angles[RiseSet.MC], self.lon, self.lat, self.alt, 0.0, 10.0)

			#Set
			ret, JDSet, serr = astrology.swe_rise_trans(self.jd, i, "", astrology.SEFLG_SWIEPH, RiseSet.Angles[RiseSet.SET], self.lon, self.lat, self.alt, 0.0, 10.0)
			tyear, tmonth, tday, ttim = astrology.swe_revjul(JDSet, self.calflag)
			if oyear != tyear or omonth != tmonth or oday != tday:
				ret, JDSet, serr = astrology.swe_rise_trans(self.jd-1.0, i, "", astrology.SEFLG_SWIEPH, RiseSet.Angles[RiseSet.SET], self.lon, self.lat, self.alt, 0.0, 10.0)

			#IC
			ret, JDIC, serr = astrology.swe_rise_trans(self.jd, i, "", astrology.SEFLG_SWIEPH, RiseSet.Angles[RiseSet.IC], self.lon, self.lat, self.alt, 0.0, 10.0)
			tyear, tmonth, tday, ttim = astrology.swe_revjul(JDIC, self.calflag)
			if oyear != tyear or omonth != tmonth or oday != tday:
				ret, JDIC, serr = astrology.swe_rise_trans(self.jd-1.0, i, "", astrology.SEFLG_SWIEPH, RiseSet.Angles[RiseSet.IC], self.lon, self.lat, self.alt, 0.0, 10.0)

			#From GMT to Local
#			JDRise += self.offs
			year, month, day, hr = astrology.swe_revjul(JDRise, self.calflag)
			ar.append(hr)

#			JDMC += self.offs
			year, month, day, hr = astrology.swe_revjul(JDMC, self.calflag)
			ar.append(hr)

#			JDSet += self.offs
			year, month, day, hr = astrology.swe_revjul(JDSet, self.calflag)
			ar.append(hr)

#			JDIC += self.offs
			year, month, day, hr = astrology.swe_revjul(JDIC, self.calflag)
			ar.append(hr)

			self.times.append(ar)
Ejemplo n.º 2
0
	def __init__(self, lon, lat, altitude, weekday, jd):
		self.risetime = None
		self.settime = None
		self.hrlen = None
		self.daytime = None

		self.weekday = weekday

		#lon, lat, height, atmpress, celsius
		#in GMT, searches after jd!
		ret, risetime, serr = astrology.swe_rise_trans(jd, astrology.SE_SUN, '', astrology.SEFLG_SWIEPH, astrology.SE_CALC_RISE, lon, lat, float(altitude), 0.0, 10.0)
#		self.logCalc(risetime)#
		ret, settime, serr = astrology.swe_rise_trans(jd, astrology.SE_SUN, '', astrology.SEFLG_SWIEPH, astrology.SE_CALC_SET, lon, lat, float(altitude), 0.0, 10.0)
#		self.logCalc(settime)#

		#swe_rise_trans calculates only forward!!
		offs = lon*4.0/1440.0
		hr = 0
		HOURSPERHALFDAY = 12.0
		if risetime > settime: # daytime
			self.daytime = True
#			print 'daytime'#
			ret, self.risetime, serr = astrology.swe_rise_trans(jd-1.0, astrology.SE_SUN, '', astrology.SEFLG_SWIEPH, astrology.SE_CALC_RISE, lon, lat, float(altitude), 0.0, 10.0)
#			self.logCalc(risetime)#
			ret, self.settime, serr = astrology.swe_rise_trans(jd, astrology.SE_SUN, '', astrology.SEFLG_SWIEPH, astrology.SE_CALC_SET, lon, lat, float(altitude), 0.0, 10.0)

			#From GMT to Local
			self.risetime += offs
			self.settime += offs

#			self.logCalc(settime)#
			self.hrlen = (self.settime-self.risetime)/HOURSPERHALFDAY #hrlen(hour-length) is in days
			for i in range(int(HOURSPERHALFDAY)):
				if jd+offs < self.risetime+self.hrlen*(i+1):
					hr = i
					break
		else:# nighttime
			self.daytime = False
#			print 'nightime'#
			ret, self.risetime, serr = astrology.swe_rise_trans(jd, astrology.SE_SUN, '', astrology.SEFLG_SWIEPH, astrology.SE_CALC_RISE, lon, lat, float(altitude), 0.0, 10.0)
#			self.logCalc(risetime)#
			ret, self.settime, serr = astrology.swe_rise_trans(jd-1.0, astrology.SE_SUN, '', astrology.SEFLG_SWIEPH, astrology.SE_CALC_SET, lon, lat, float(altitude), 0.0, 10.0)
#			self.logCalc(settime)#

			#From GMT to Local
			self.risetime += offs
			self.settime += offs

			#Is the local birthtime greater than midnight? If so => decrement day because a planetary day is from sunrise to sunrise
			if jd+offs > int(jd+offs)+0.5:
				self.weekday = util.getPrevDay(self.weekday)

			self.hrlen = (self.risetime-self.settime)/HOURSPERHALFDAY
			for i in range(int(HOURSPERHALFDAY)):
				if jd+offs < self.settime+self.hrlen*(i+1):
					hr = i+int(HOURSPERHALFDAY)
					break

		self.planetaryhour = PlanetaryHours.PHs[self.weekday][hr]#planetary day begins from sunrise(not from 0 hour and Planetary hours are not equal!!)
Ejemplo n.º 3
0
    def __init__(self, lon, lat, altitude, weekday, jd):
        self.risetime = None
        self.settime = None
        self.hrlen = None
        self.daytime = None

        self.weekday = weekday

        #lon, lat, height, atmpress, celsius
        #in GMT, searches after jd!
        ret, risetime, serr = astrology.swe_rise_trans(
            jd, astrology.SE_SUN, '', astrology.SEFLG_SWIEPH,
            astrology.SE_CALC_RISE, lon, lat, float(altitude), 0.0, 10.0)
        #		self.logCalc(risetime)#
        ret, settime, serr = astrology.swe_rise_trans(
            jd, astrology.SE_SUN, '', astrology.SEFLG_SWIEPH,
            astrology.SE_CALC_SET, lon, lat, float(altitude), 0.0, 10.0)
        #		self.logCalc(settime)#

        #swe_rise_trans calculates only forward!!
        offs = lon * 4.0 / 1440.0
        hr = 0
        HOURSPERHALFDAY = 12.0
        if risetime > settime:  # daytime
            self.daytime = True
            #			print 'daytime'#
            ret, self.risetime, serr = astrology.swe_rise_trans(
                jd - 1.0, astrology.SE_SUN, '', astrology.SEFLG_SWIEPH,
                astrology.SE_CALC_RISE, lon, lat, float(altitude), 0.0, 10.0)
            #			self.logCalc(risetime)#
            ret, self.settime, serr = astrology.swe_rise_trans(
                jd, astrology.SE_SUN, '', astrology.SEFLG_SWIEPH,
                astrology.SE_CALC_SET, lon, lat, float(altitude), 0.0, 10.0)

            #From GMT to Local
            self.risetime += offs
            self.settime += offs

            #			self.logCalc(settime)#
            self.hrlen = (self.settime - self.risetime
                          ) / HOURSPERHALFDAY  #hrlen(hour-length) is in days
            for i in range(int(HOURSPERHALFDAY)):
                if jd + offs < self.risetime + self.hrlen * (i + 1):
                    hr = i
                    break
        else:  # nighttime
            self.daytime = False
            #			print 'nightime'#
            ret, self.risetime, serr = astrology.swe_rise_trans(
                jd, astrology.SE_SUN, '', astrology.SEFLG_SWIEPH,
                astrology.SE_CALC_RISE, lon, lat, float(altitude), 0.0, 10.0)
            #			self.logCalc(risetime)#
            ret, self.settime, serr = astrology.swe_rise_trans(
                jd - 1.0, astrology.SE_SUN, '', astrology.SEFLG_SWIEPH,
                astrology.SE_CALC_SET, lon, lat, float(altitude), 0.0, 10.0)
            #			self.logCalc(settime)#

            #From GMT to Local
            self.risetime += offs
            self.settime += offs

            #Is the local birthtime greater than midnight? If so => decrement day because a planetary day is from sunrise to sunrise
            if jd + offs > int(jd + offs) + 0.5:
                self.weekday = util.getPrevDay(self.weekday)

            self.hrlen = (self.risetime - self.settime) / HOURSPERHALFDAY
            for i in range(int(HOURSPERHALFDAY)):
                if jd + offs < self.settime + self.hrlen * (i + 1):
                    hr = i + int(HOURSPERHALFDAY)
                    break

        self.planetaryhour = PlanetaryHours.PHs[self.weekday][
            hr]  #planetary day begins from sunrise(not from 0 hour and Planetary hours are not equal!!)