def GetNextSankranti(startDate):
    zodiac = 0
    step = 1.0
    count = 0
    prevday = GCGregorianDate()

    d = GCGregorianDate(date=startDate)

    prev = GCMath.putIn360(
        GCSunData.GetSunLongitude(d) - GCAyanamsha.GetAyanamsa(d.GetJulian()))
    prev_rasi = int(floor(prev / 30.0))

    while count < 20:
        prevday.Set(d)
        d.shour += step
        d.NormalizeHours()

        ld = GCMath.putIn360(
            GCSunData.GetSunLongitude(d) -
            GCAyanamsha.GetAyanamsa(d.GetJulian()))
        new_rasi = int(floor(ld / 30.0))

        if prev_rasi != new_rasi:
            zodiac = new_rasi
            step *= 0.5
            d.Set(prevday)
            count += 1
            continue

    return d, zodiac
예제 #2
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
def GetPrevConjunction(date, earth, forward=False):
    prevSun = 0.0
    prevMoon = 0.0
    prevDiff = 0.0
    nowSun = 0.0
    nowMoon = 0.0
    nowDiff = 0.0
    dir = 1.0 if forward else -1.0
    moon = GCMoonData.MOONDATA()

    d = GCGregorianDate(date=date)
    d.shour = 0.5
    d.tzone = 0.0
    jd = d.GetJulian()

    # set initial data for input day
    # NOTE: for grenwich
    moon.Calculate(jd, earth)
    prevSun = GCSunData.GetSunLongitude(d)
    prevMoon = moon.longitude_deg
    prevDiff = GCMath.putIn180(prevSun - prevMoon)

    for bCont in range(32):
        if forward:
            d.NextDay()
        else:
            d.PreviousDay()
        jd += dir
        moon.Calculate(jd, earth)
        nowSun = GCSunData.GetSunLongitude(d)
        nowMoon = moon.longitude_deg
        nowDiff = GCMath.putIn180(nowSun - nowMoon)

        if IsConjunction(nowMoon, nowSun, prevSun, prevMoon):
            # now it calculates actual time and zodiac of conjunction
            if prevDiff == nowDiff: return 0
            x = math.fabs(nowDiff) / math.fabs(prevDiff - nowDiff)
            if x < 0.5:
                if forward: d.PreviousDay()
                d.shour = x + 0.5
            else:
                if not forward: d.NextDay()
                d.shour = x - 0.5
            date.Set(d)
            prevSun = GCMath.putIn360(prevSun)
            nowSun = GCMath.putIn360(nowSun)
            if math.fabs(prevSun - nowSun) > 10.0:
                return GCMath.putIn180(nowSun) + (GCMath.putIn180(prevSun) -
                                                  GCMath.putIn180(nowSun)) * x
            else:
                return nowSun + (prevSun - nowSun) * x
        prevSun = nowSun
        prevMoon = nowMoon
        prevDiff = nowDiff

    return 1000.0
예제 #4
0
    def DayCalc(self, date, earth):
        # sun position on sunrise on that day
        self.sun.SunCalc(date, earth)
        date.shour = self.sun.sunrise_deg / 360.0

        # date.shour is [0..1] time of sunrise in local timezone time
        self.jdate = jdate = date.GetJulianDetailed()

        # moon position at sunrise on that day
        self.moon.Calculate(date.GetJulianDetailed(), earth)

        self.msDistance = GCMath.putIn360(self.moon.longitude_deg -
                                          self.sun.longitude_deg - 180.0)
        self.msAyanamsa = GCAyanamsha.GetAyanamsa(jdate)

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

        # naksatra
        d = GCMath.putIn360(self.moon.longitude_deg - self.msAyanamsa)
        d = (d * 3.0) / 40.0
        self.nNaksatra = int(floor(d))
        self.nNaksatraElapse = (d - floor(d)) * 100.0

        # yoga
        d = GCMath.putIn360(self.moon.longitude_deg + self.sun.longitude_deg -
                            2 * self.msAyanamsa)
        d = (d * 3.0) / 40.0
        self.nYoga = int(floor(d))
        self.nYogaElapse = (d - floor(d)) * 100.0

        # masa
        self.nMasa = -1

        # rasi
        self.nSunRasi = GCRasi.GetRasi(self.sun.longitude_deg, self.msAyanamsa)
        self.nMoonRasi = GCRasi.GetRasi(self.moon.longitude_deg,
                                        self.msAyanamsa)

        moon = MOONDATA()
        date.shour = self.sun.sunset_deg / 360.0
        moon.Calculate(date.GetJulianDetailed(), earth)
        d = GCMath.putIn360(moon.longitude_deg - self.sun.longitude_set_deg -
                            180) / 12.0
        self.nTithiSunset = int(floor(d))

        date.shour = self.sun.arunodaya_deg / 360.0
        moon.Calculate(date.GetJulianDetailed(), earth)
        d = GCMath.putIn360(moon.longitude_deg - self.sun.longitude_arun_deg -
                            180) / 12.0
        self.nTithiArunodaya = int(floor(d))

        return 1
예제 #5
0
def star_time(date):
    jd = date
    t = (jd - 2451545.0) / 36525.0
    delta_phi, epsilon = calc_epsilon_phi(date)
    return GCMath.putIn360(280.46061837 + 360.98564736629 * (jd - 2451545.0) +
                           t * t * (0.000387933 - t / 38710000) +
                           delta_phi * GCMath.cosDeg(epsilon))
def GetNextMoonRasi(ed, startDate):
    nextDate = GCGregorianDate.GCGregorianDate(date=startDate)
    phi = 30.0
    jday = startDate.GetJulianComplete()
    moon = MOONDATA()
    d = GCGregorianDate.GCGregorianDate(date=startDate)
    ayanamsa = GCAyanamsha.GetAyanamsa(jday)
    scan_step = 0.5
    prev_naks = 0
    new_naks = -1

    xj = 0.0
    xd = GCGregorianDate.GCGregorianDate()

    moon.Calculate(jday, ed)
    l1 = GCMath.putIn360(moon.longitude_deg - ayanamsa)
    prev_naks = int(GCMath.Floor(l1 / phi))

    counter = 0
    while counter < 20:
        xj = jday
        xd.Set(d)

        jday += scan_step
        d.shour += scan_step
        if d.shour > 1.0:
            d.shour -= 1.0
            d.NextDay()

        moon.Calculate(jday, ed)
        l2 = GCMath.putIn360(moon.longitude_deg - ayanamsa)
        new_naks = int(GCMath.Floor(l2 / phi))
        if prev_naks != new_naks:
            jday = xj
            d.Set(xd)
            scan_step *= 0.5
            counter += 1
            continue
        else:
            l1 = l2
    nextDate.Set(d)
    return new_naks, nextDate
예제 #7
0
def GetNextYogaStart(ed, startDate, nextDate):
    phi = 40.0 / 3.0
    jday = startDate.GetJulianComplete()
    moon = MOONDATA()
    d = GCGregorianDate(date=startDate)
    xd = GCGregorianDate()
    scan_step = 0.5
    prev_tit = 0
    new_tit = -1
    ayanamsha = GCAyanamsha.GetAyanamsa(jday)
    moon.Calculate(jday, ed)
    sunl = GetSunLongitude(d)
    l1 = GCMath.putIn360(moon.longitude_deg + sunl - 2 * ayanamsha)
    prev_tit = int(floor(l1 / phi))

    counter = 0
    while counter < 20:
        xj = jday
        xd.Set(d)

        jday += scan_step
        d.shour += scan_step
        d.NormalizeHours()

        moon.Calculate(jday, ed)
        sunl = GetSunLongitude(d)
        l2 = GCMath.putIn360(moon.longitude_deg + sunl - 2 * ayanamsha)
        new_tit = int(floor(l2 / phi))

        if prev_tit != new_tit:
            jday = xj
            d.Set(xd)
            scan_step *= 0.5
            counter += 1
            continue
        else:
            l1 = l2
    nextDate.Set(d)

    return new_tit
예제 #8
0
def GetNextTithiStart(ed, startDate, nextDate, forward=True):
    phi = 12.0
    jday = startDate.GetJulianComplete()
    moon = MOONDATA()
    d = GCGregorianDate(date=startDate)
    xd = GCGregorianDate()
    dir = 1.0 if forward else -1.0
    scan_step = 0.5 * dir
    prev_tit = 0
    new_tit = -1

    moon.Calculate(jday, ed)
    sunl = GetSunLongitude(d)
    l1 = GCMath.putIn360(moon.longitude_deg - sunl - 180.0)
    prev_tit = int(floor(l1 / phi))

    counter = 0
    while counter < 20:
        xj = jday
        xd.Set(d)

        jday += scan_step
        d.shour += scan_step
        d.NormalizeHours()

        moon.Calculate(jday, ed)
        sunl = GetSunLongitude(d)
        l2 = GCMath.putIn360(moon.longitude_deg - sunl - 180.0)
        new_tit = int(floor(l2 / phi))

        if prev_tit != new_tit:
            jday = xj
            d.Set(xd)
            scan_step *= 0.5
            counter += 1
            continue
        else:
            l1 = l2
    nextDate.Set(d)
    return new_tit
    def calc_horizontal(self, date, longitude, latitude):
        h = GCMath.putIn360(
            GCEarthData.star_time(date) - self.rektaszension + longitude)

        self.azimuth = GCMath.rad2deg(
            math.atan2(
                GCMath.sinDeg(h),
                GCMath.cosDeg(h) * GCMath.sinDeg(latitude) -
                GCMath.tanDeg(self.declination) * GCMath.cosDeg(latitude)))

        self.elevation = GCMath.rad2deg(
            math.asin(
                GCMath.sinDeg(latitude) * GCMath.sinDeg(self.declination) +
                GCMath.cosDeg(latitude) * GCMath.cosDeg(self.declination) *
                GCMath.cosDeg(h)))
예제 #10
0
def equatorialToHorizontalCoords(eqc, obs, date):
    hc = GCCoords.GCHorizontalCoords()

    h = GCMath.putIn360(
        star_time(date) - eqc.rightAscension + obs.longitude_deg)

    hc.azimut = GCMath.rad2deg(
        math.atan2(
            GCMath.sinDeg(h),
            GCMath.cosDeg(h) * GCMath.sinDeg(obs.latitude_deg) -
            GCMath.tanDeg(eqc.declination) * GCMath.cosDeg(obs.latitude_deg)))

    hc.elevation = GCMath.rad2deg(
        math.asin(
            GCMath.sinDeg(obs.latitude_deg) * GCMath.sinDeg(eqc.declination) +
            GCMath.cosDeg(obs.latitude_deg) * GCMath.cosDeg(eqc.declination) *
            GCMath.cosDeg(h)))

    return hc
예제 #11
0
def eclipticalToEquatorialCoords(ecc, date):
    eqc = GCCoords.GCEquatorialCoords()
    epsilon = 0.0
    delta_phi = 0.0
    alpha = delta = 0.0

    delta_phi, epsilon = calc_epsilon_phi(date)

    ecc.longitude = GCMath.putIn360(ecc.longitude + delta_phi)

    eqc.rightAscension = GCMath.arcTan2Deg(
        GCMath.sinDeg(ecc.longitude) * GCMath.cosDeg(epsilon) -
        GCMath.tanDeg(ecc.latitude) * GCMath.sinDeg(epsilon),
        GCMath.cosDeg(ecc.longitude))

    eqc.declination = GCMath.arcSinDeg(
        GCMath.sinDeg(ecc.latitude) * GCMath.cosDeg(epsilon) +
        GCMath.cosDeg(ecc.latitude) * GCMath.sinDeg(epsilon) *
        GCMath.sinDeg(ecc.longitude))

    return eqc, ecc
예제 #12
0
    def SetDegTime(self, time_deg):
        time_hr = 0.0

        time_deg = GCMath.putIn360(time_deg)

        # hour
        time_hr = time_deg / 360 * 24
        self.hour = int(math.floor(time_hr))

        # minute
        time_hr -= self.hour
        time_hr *= 60
        self.min = int(math.floor(time_hr))

        # second
        time_hr -= self.min
        time_hr *= 60
        self.sec = int(math.floor(time_hr))

        # miliseconds
        time_hr -= self.sec
        time_hr *= 1000
        self.mili = int(math.floor(time_hr))
예제 #13
0
def GetRasi(SunLongitude, Ayanamsa):
    return int(GCMath.Floor(GCMath.putIn360(SunLongitude - Ayanamsa) / 30.0))
예제 #14
0
 def GetHorizontDegrees(self, jday):
     return GCMath.putIn360(
         star_time(jday) - self.longitude_deg -
         GCAyanamsha.GetAyanamsa(jday) + 155)
예제 #15
0
def calc_epsilon_phi(date):
    arg_mul = [[0, 0, 0, 0, 1], [-2, 0, 0, 2, 2], [0, 0, 0, 2, 2],
               [0, 0, 0, 0, 2], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0],
               [-2, 1, 0, 2, 2], [0, 0, 0, 2, 1], [0, 0, 1, 2, 2],
               [-2, -1, 0, 2, 2], [-2, 0, 1, 0, 0], [-2, 0, 0, 2, 1],
               [0, 0, -1, 2, 2], [2, 0, 0, 0, 0], [0, 0, 1, 0, 1],
               [2, 0, -1, 2, 2], [0, 0, -1, 0, 1], [0, 0, 1, 2, 1],
               [-2, 0, 2, 0, 0], [0, 0, -2, 2, 1], [2, 0, 0, 2, 2],
               [0, 0, 2, 2, 2], [0, 0, 2, 0, 0], [-2, 0, 1, 2, 2],
               [0, 0, 0, 2, 0], [-2, 0, 0, 2, 0], [0, 0, -1, 2, 1],
               [0, 2, 0, 0, 0], [2, 0, -1, 0, 1], [-2, 2, 0, 2, 2],
               [0, 1, 0, 0, 1]]
    arg_phi = [[-171996, -1742], [-13187, -16], [-2274, -2], [2062, 2],
               [1426, -34], [712, 1], [-517, 12], [-386, -4], [-301, 0],
               [217, -5], [-158, 0], [129, 1], [123, 0], [63, 0], [63, 1],
               [-59, 0], [-58, -1], [-51, 0], [48, 0], [46, 0], [-38, 0],
               [-31, 0], [29, 0], [29, 0], [26, 0], [-22, 0], [21, 0],
               [17, -1], [16, 0], [-16, 1], [-15, 0]]
    arg_eps = [[92025, 89], [5736, -31], [977, -5], [-895, 5], [54, -1],
               [-7, 0], [224, -6], [200, 0], [129, -1], [-95, 3], [0, 0],
               [-70, 0], [-53, 0], [0, 0], [-33, 0], [26, 0], [32, 0], [27, 0],
               [0, 0], [-24, 0], [16, 0], [13, 0], [0, 0], [-12, 0], [0, 0],
               [0, 0], [-10, 0], [0, 0], [-8, 0], [7, 0], [9, 0]]

    t = (date - 2451545.0) / 36525
    delta_phi = 0.0

    # longitude of rising knot
    omega = GCMath.putIn360(125.04452 +
                            (-1934.136261 +
                             (0.0020708 + 1.0 / 450000 * t) * t) * t)

    if True:
        l = 280.4665 + 36000.7698 * t
        ls = 218.3165 + 481267.8813 * t

        delta_epsilon = 9.20 * GCMath.cosDeg(omega) + 0.57 * GCMath.cosDeg(
            2 * l) + 0.10 * GCMath.cosDeg(2 * ls) - 0.09 * GCMath.cosDeg(
                2 * omega)

        delta_phi = (-17.20 * GCMath.sinDeg(omega) -
                     1.32 * GCMath.sinDeg(2 * l) - 0.23 * GCMath.sinDeg(2 * ls)
                     + 0.21 * GCMath.sinDeg(2 * omega)) / 3600
    else:
        # mean elongation of moon to sun
        d = GCMath.putIn360(297.85036 + (445267.111480 +
                                         (-0.0019142 + t / 189474) * t) * t)

        # mean anomaly of the sun
        m = GCMath.putIn360(357.52772 + (35999.050340 +
                                         (-0.0001603 - t / 300000) * t) * t)

        # mean anomaly of the moon
        ms = GCMath.putIn360(134.96298 + (477198.867398 +
                                          (0.0086972 + t / 56250) * t) * t)

        # argument of the latitude of the moon
        f = GCMath.putIn360(93.27191 + (483202.017538 +
                                        (-0.0036825 + t / 327270) * t) * t)

        delta_phi = 0
        delta_epsilon = 0

        for i in range(31):
            s = arg_mul[i][0] * d + arg_mul[i][1] * m + arg_mul[i][
                2] * ms + arg_mul[i][3] * f + arg_mul[i][4] * omega
            delta_phi = delta_phi + (
                arg_phi[i][0] + arg_phi[i][1] * t * 0.1) * GCMath.sinDeg(s)
            delta_epsilon = delta_epsilon + (
                arg_eps[i][0] + arg_eps[i][1] * t * 0.1) * GCMath.cosDeg(s)

        delta_phi = delta_phi * 0.0001 / 3600
        delta_epsilon = delta_epsilon * 0.0001 / 3600

    # angle of ecliptic
    epsilon_0 = 84381.448 + (-46.8150 + (-0.00059 + 0.001813 * t) * t) * t

    epsilon = (epsilon_0 + delta_epsilon) / 3600

    return delta_phi, epsilon