Exemplo n.º 1
0
    def calculateAppDay(self, location, eventDate):
        d = self.details
        vc = GCGregorianDate(date=eventDate)
        vcsun = GCGregorianDate(date=eventDate)
        dprev = GCGregorianDate()
        dnext = GCGregorianDate()
        m_earth = location.GetEarthData()

        self.b_adhika = False
        self.eventTime.Set(eventDate)
        self.m_location.Set(location)

        vcsun.shour -= vcsun.tzone / 24.0
        vcsun.NormalizeValues()
        vcsun.tzone = 0.0
        d.sun.SunPosition(vcsun, m_earth, vcsun.shour - 0.5)
        d.moon.Calculate(vcsun.GetJulianComplete(), m_earth)
        d.msDistance = GCMath.putIn360(d.moon.longitude_deg -
                                       d.sun.longitude_deg - 180.0)
        d.msAyanamsa = GCAyanamsha.GetAyanamsa(vc.GetJulianComplete())

        # tithi
        dd = d.msDistance / 12.0
        d.nTithi = int(floor(dd))
        d.nTithiElapse = (dd - floor(dd)) * 100.0

        # naksatra
        dd = GCMath.putIn360(d.moon.longitude_deg - d.msAyanamsa)
        dd = (dd * 3.0) / 40.0
        d.nNaksatra = int(floor(dd))
        d.nNaksatraElapse = (dd - floor(dd)) * 100.0
        d.nMasa = d.MasaCalc(vc, m_earth)
        d.nMoonRasi = GCRasi.GetRasi(d.moon.longitude_deg, d.msAyanamsa)
        d.nSunRasi = GCRasi.GetRasi(d.sun.longitude_deg, d.msAyanamsa)

        if (d.nMasa == ADHIKA_MASA):
            d.nMasa = GCRasi.GetRasi(d.sun.longitude_deg, d.msAyanamsa)
            self.b_adhika = True

        vc.Today()
        vc.tzone = m_earth.tzone
        m = 0
        va = GCGaurabdaDate()
        vctemp = GCGregorianDate()

        va.tithi = d.nTithi
        va.masa = d.nMasa
        va.gyear = GCCalendar.GetGaurabdaYear(vc, m_earth)
        if (va.gyear < d.nGaurabdaYear):
            va.gyear = d.nGaurabdaYear

        for i in range(6):
            GCCalendar.Gaurabda2Gregorian(va, vctemp, m_earth)
            if (va.gyear > d.nGaurabdaYear):
                if (m < TRESULT_APP_CELEBS):
                    self.celeb_date[m].Set(vctemp)
                    self.celeb_gy[m] = va.gyear
                    m += 1
            va.gyear += 1
Exemplo n.º 2
0
    def CalculateEvents(self, loc, vcStart, vcEnd):
        sun = SUNDATA()
        ndst = 0

        self.m_location.Set(loc)
        self.m_vcStart.Set(vcStart)
        self.m_vcEnd.Set(vcEnd)

        vcNext = GCGregorianDate()
        earth = loc.GetEarthData()

        vc = GCGregorianDate(date=vcStart)
        vcAdd = GCGregorianDate(date=vcStart)
        vcAdd.InitWeekDay()

        previousLongitude = -100
        todayLongitude = 0
        fromTimeLimit = 0

        while vcAdd.IsBeforeThis(vcEnd):
            if (GCDisplaySettings.getValue(COREEVENTS_SUN)):
                ndst = GCTimeZone.determineDaylightChange(
                    vcAdd, loc.m_nTimezoneId)
                sun.SunCalc(vcAdd, earth)

                vcAdd.shour = sun.arunodaya.GetDayTime()
                self.AddEvent(vcAdd, CCTYPE_S_ARUN, 0, ndst)

                vcAdd.shour = sunRise = sun.rise.GetDayTime()
                self.AddEvent(vcAdd, CCTYPE_S_RISE, 0, ndst)

                vcAdd.shour = sun.noon.GetDayTime()
                self.AddEvent(vcAdd, CCTYPE_S_NOON, 0, ndst)

                vcAdd.shour = sunSet = sun.set.GetDayTime()
                self.AddEvent(vcAdd, CCTYPE_S_SET, 0, ndst)
            else:
                ndst = GCTimeZone.determineDaylightChange(
                    vcAdd, loc.m_nTimezoneId)
                sun.SunCalc(vcAdd, earth)
                sunRise = sun.rise.GetDayTime()
                sunSet = sun.set.GetDayTime()

            if (GCDisplaySettings.getValue(COREEVENTS_ASCENDENT)):
                todayLongitude = sun.longitude_deg
                vcAdd.shour = sunRise
                todaySunriseHour = sunRise
                if (previousLongitude < -10):
                    prevSunrise = GCGregorianDate(date=vcAdd)
                    prevSunrise.PreviousDay()
                    sun.SunCalc(prevSunrise, earth)
                    previousSunriseHour = sun.rise.GetDayTime() - 1
                    previousLongitude = sun.longitude_deg
                    fromTimeLimit = 0

                jd = vcAdd.GetJulianComplete()
                ayan = GCAyanamsha.GetAyanamsa(jd)
                r1 = GCMath.putIn360(previousLongitude - ayan) / 30
                r2 = GCMath.putIn360(todayLongitude - ayan) / 30

                while (r2 > r1 + 13):
                    r2 -= 12.0
                while (r2 < r1 + 11):
                    r2 += 12.0

                a = (r2 - r1) / (todaySunriseHour - previousSunriseHour)
                b = r2 - a * todaySunriseHour

                tr = ceil(r1)
                for tr in range(ceil(r1), ceil(r2)):
                    tm = (tr - b) / a
                    if (tm > fromTimeLimit):
                        vcNext.Set(vcAdd)
                        vcNext.shour = tm
                        vcNext.NormalizeValues()
                        self.AddEvent(vcNext, CCTYPE_ASCENDENT, tr, ndst)

                previousLongitude = todayLongitude
                previousSunriseHour = todaySunriseHour - 1
                fromTimeLimit = previousSunriseHour

            if (GCDisplaySettings.getValue(COREEVENTS_RAHUKALAM)):
                r1, r2 = CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek,
                                       KT_RAHU_KALAM)
                vcAdd.shour = r1
                self.AddEvent(vcAdd, CCTYPE_KALA_START, KT_RAHU_KALAM, ndst)
                vcAdd.shour = r2
                self.AddEvent(vcAdd, CCTYPE_KALA_END, KT_RAHU_KALAM, ndst)

            if (GCDisplaySettings.getValue(COREEVENTS_YAMAGHANTI)):
                r1, r2 = CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek,
                                       KT_YAMA_GHANTI)
                vcAdd.shour = r1
                self.AddEvent(vcAdd, CCTYPE_KALA_START, KT_YAMA_GHANTI, ndst)
                vcAdd.shour = r2
                self.AddEvent(vcAdd, CCTYPE_KALA_END, KT_YAMA_GHANTI, ndst)

            if (GCDisplaySettings.getValue(COREEVENTS_GULIKALAM)):
                r1, r2 = CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek,
                                       KT_GULI_KALAM)
                vcAdd.shour = r1
                self.AddEvent(vcAdd, CCTYPE_KALA_START, KT_GULI_KALAM, ndst)
                vcAdd.shour = r2
                self.AddEvent(vcAdd, CCTYPE_KALA_END, KT_GULI_KALAM, ndst)

            if (GCDisplaySettings.getValue(COREEVENTS_ABHIJIT_MUHURTA)):
                r1, r2 = CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek,
                                       KT_ABHIJIT)
                if (r1 > 0 and r2 > 0):
                    vcAdd.shour = r1
                    self.AddEvent(vcAdd, CCTYPE_KALA_START, KT_ABHIJIT, ndst)
                    vcAdd.shour = r2
                    self.AddEvent(vcAdd, CCTYPE_KALA_END, KT_ABHIJIT, ndst)

            vcAdd.NextDay()

        if (GCDisplaySettings.getValue(COREEVENTS_TITHI)):
            vcAdd.Set(vc)
            vcAdd.shour = 0.0
            while vcAdd.IsBeforeThis(vcEnd):
                nData = GCTithi.GetNextTithiStart(earth, vcAdd, vcNext)
                if (vcNext.GetDayInteger() < vcEnd.GetDayInteger()):
                    vcNext.InitWeekDay()
                    ndst = GCTimeZone.determineDaylightChange(
                        vcNext, loc.m_nTimezoneId)
                    self.AddEvent(vcNext, CCTYPE_TITHI, nData, ndst)
                else:
                    break
                vcAdd.Set(vcNext)
                vcAdd.shour += 0.2
                if (vcAdd.shour >= 1.0):
                    vcAdd.shour -= 1.0
                    vcAdd.NextDay()

        if (GCDisplaySettings.getValue(COREEVENTS_NAKSATRA)):
            vcAdd.Set(vc)
            vcAdd.shour = 0.0
            while vcAdd.IsBeforeThis(vcEnd):
                nData = GCNaksatra.GetNextNaksatra(earth, vcAdd, vcNext)
                if (vcNext.GetDayInteger() < vcEnd.GetDayInteger()):
                    vcNext.InitWeekDay()
                    ndst = GCTimeZone.determineDaylightChange(
                        vcNext, loc.m_nTimezoneId)
                    self.AddEvent(vcNext, CCTYPE_NAKS, nData, ndst)
                else:
                    break
                vcAdd.Set(vcNext)
                vcAdd.shour += 0.2
                if (vcAdd.shour >= 1.0):
                    vcAdd.shour -= 1.0
                    vcAdd.NextDay()

        if (GCDisplaySettings.getValue(COREEVENTS_YOGA)):
            vcAdd.Set(vc)
            vcAdd.shour = 0.0
            while vcAdd.IsBeforeThis(vcEnd):
                nData = GCYoga.GetNextYogaStart(earth, vcAdd, vcNext)
                if (vcNext.GetDayInteger() < vcEnd.GetDayInteger()):
                    vcNext.InitWeekDay()
                    ndst = GCTimeZone.determineDaylightChange(
                        vcNext, loc.m_nTimezoneId)
                    self.AddEvent(vcNext, CCTYPE_YOGA, nData, ndst)
                else:
                    break
                vcAdd.Set(vcNext)
                vcAdd.shour += 0.2
                if (vcAdd.shour >= 1.0):
                    vcAdd.shour -= 1.0
                    vcAdd.NextDay()

        if (GCDisplaySettings.getValue(COREEVENTS_SANKRANTI)):
            vcAdd.Set(vc)
            vcAdd.shour = 0.0
            while vcAdd.IsBeforeThis(vcEnd):
                date, nData = GCSankranti.GetNextSankranti(vcAdd)
                vcNext.Set(date)
                if (vcNext.GetDayInteger() < vcEnd.GetDayInteger()):
                    vcNext.InitWeekDay()
                    ndst = GCTimeZone.determineDaylightChange(
                        vcNext, loc.m_nTimezoneId)
                    self.AddEvent(vcNext, CCTYPE_SANK, nData, ndst)
                else:
                    break
                vcAdd.Set(vcNext)
                vcAdd.NextDay()

        if (GCDisplaySettings.getValue(COREEVENTS_MOONRASI)):
            vcAdd.Set(vc)
            vcAdd.shour = 0.0
            while vcAdd.IsBeforeThis(vcEnd):
                nData = GetNextMoonRasi(earth, vcAdd, vcNext)
                if (vcNext.GetDayInteger() < vcEnd.GetDayInteger()):
                    vcNext.InitWeekDay()
                    ndst = GCTimeZone.determineDaylightChange(
                        vcNext, loc.m_nTimezoneId)
                    self.AddEvent(vcNext, CCTYPE_M_RASI, nData, ndst)
                else:
                    break
                vcAdd.Set(vcNext)
                vcAdd.shour += 0.5
                vcAdd.NormalizeValues()

        if (GCDisplaySettings.getValue(COREEVENTS_CONJUNCTION)):
            vcAdd.Set(vc)
            vcAdd.shour = 0.0
            while vcAdd.IsBeforeThis(vcEnd):
                dlong = GCConjunction.GetNextConjunctionEx(
                    vcAdd, vcNext, True, earth)
                if (vcNext.GetDayInteger() < vcEnd.GetDayInteger()):
                    vcNext.InitWeekDay()
                    ndst = GCTimeZone.determineDaylightChange(
                        vcNext, loc.m_nTimezoneId)
                    self.AddEvent(
                        vcNext, CCTYPE_CONJ,
                        GCRasi.GetRasi(
                            dlong,
                            GCAyanamsha.GetAyanamsa(
                                vcNext.GetJulianComplete())), ndst)
                else:
                    break
                vcAdd.Set(vcNext)
                vcAdd.NextDay()

        if (GCDisplaySettings.getValue(COREEVENTS_MOON)):
            vcAdd.Set(vc)
            vcAdd.shour = 0.0
            while vcAdd.IsBeforeThis(vcEnd):
                vcNext.Set(MOONDATA.GetNextRise(earth, vcAdd, True))
                self.AddEvent(vcNext, CCTYPE_M_RISE, 0, ndst)

                vcNext.Set(MOONDATA.GetNextRise(earth, vcNext, False))
                self.AddEvent(vcNext, CCTYPE_M_SET, 0, ndst)

                vcNext.shour += 0.05
                vcNext.NormalizeValues()
                vcAdd.Set(vcNext)

        if self.b_sorted:
            self.Sort()