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
def GetPrevConjunctionEx(test_date, found, this_conj, earth, forward=False):
    phi = 12.0
    dir = 1.0 if forward else -1.0
    if this_conj:
        test_date.shour += 0.2 * dir
        test_date.NormalizeHours()

    jday = test_date.GetJulianComplete()
    moon = GCMoonData.MOONDATA()
    d = GCGregorianDate(date=test_date)
    xd = GCGregorianDate()
    scan_step = 1.0
    prev_tit = 0
    new_tit = -1

    moon.Calculate(jday, earth)
    sunl = GCSunData.GetSunLongitude(d)
    l1 = GCMath.putIn180(moon.longitude_deg - sunl)
    prev_tit = int(math.floor(l1 / phi))

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

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

        moon.Calculate(jday, earth)
        sunl = GCSunData.GetSunLongitude(d)
        l2 = GCMath.putIn180(moon.longitude_deg - sunl)
        new_tit = int(math.floor(l2 / phi))

        if forward:
            is_change = prev_tit < 0 and new_tit >= 0
        else:
            is_change = prev_tit >= 0 and new_tit < 0

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

    found.Set(d)
    return sunl
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
Beispiel #4
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