def determineDaylightChange(vc2, nIndex):
    t2 = determineDaylightStatus(vc2, nIndex)
    vc3 = GCGregorianDate()
    vc3.Set(vc2)
    vc3.PreviousDay()
    t1 = determineDaylightStatus(vc3, nIndex)
    if t1:
        if t2:
            return 2
        else:
            return 3
    elif t2:
        return 1
    else:
        return 0
def GetNextRise(e, vc, bRise):
    nFound = 0
    h = [0, 0, 0]
    hour = 1 / 24.0
    startHour = vc.shour

    track = GCGregorianDate.GCGregorianDate(date=vc)
    track.NormalizeValues()

    #   inicializacia prvej hodnoty ELEVATION
    h[0] = MoonCalcElevation(e, track)
    track.shour += hour
    h[1] = MoonCalcElevation(e, track)
    track.shour += hour
    h[2] = MoonCalcElevation(e, track)

    for c in range(24):
        has_change = False
        if bRise:
            has_change = h[1] < 0.0 and h[2] > 0.0
        else:
            has_change = h[1] > 0.0 and h[2] < 0.0
        if has_change:
            a = (h[2] - h[1]) / hour
            b = h[2] - a * track.shour
            track.shour = -b / a
            track.NormalizeValues()
            return track

        h[0] = h[1]
        h[1] = h[2]
        track.shour += hour
        h[2] = MoonCalcElevation(e, track)

    return track
def unittests():
    GCUT.info('timezones')
    LoadFile('timezones.json')
    GCUT.msg('Timezones:' + str(len(gzone)))
    tz = GetTimeZone(id=321)
    vc = GCGregorianDate(year=2020, month=4, day=4)
    GCUT.val(GetDaylightBias(vc, tz), 1, 'daylight bias')
    GCUT.val(GetTimeZoneOffsetText(1.0), '+1:00', 'offset text')
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
예제 #5
0
def unittests():
    GCUT.info('sundata')
    r1, r2 = CalculateKala(0.25, 0.75, 0, KalaType.KT_ABHIJIT)
    GCUT.msg('abhijit on sunday {} {}'.format(r1, r2))
    s = SUNDATA()
    e = GCEarthData.EARTHDATA()
    e.longitude_deg = 27.0
    e.latitude_deg = 45.0
    e.tzone = 1.0
    vc = GCGregorianDate.Today()
    s.SunCalc(vc, e)
    GCUT.msg(str(repr(s)))
def GetNormalTimeStartDate(nDst, nYear):
    vcStart = GCGregorianDate()
    vcStart.day = 1
    vcStart.month = 10
    vcStart.year = nYear
    vcStart.shour = 3 / 24.0
    return vcStart
def unittests():
    GCUT.info('moon data')
    ed = GCEarthData.EARTHDATA()
    ed.longitude_deg = 20.0
    ed.latitude_deg = 45.0
    ed.tzone = 1.0
    vc = GCGregorianDate.GCGregorianDate(2000, 1, 1, 0.5)
    GCUT.msg('Moon distance: ' + str(MoonDistance(vc.GetJulianComplete())))
    nd = GetNextRise(ed, vc, True)
    GCUT.msg('Next rise: ' + repr(nd))
    nd = GetNextRise(ed, vc, False)
    GCUT.msg('Next set: ' + repr(nd))
    a, b = GetNextMoonRasi(ed, vc)
    GCUT.msg('next moon rasi: {} {}'.format(a, b))
    a, b = CalcMoonTimes(ed, vc, 1.0)
    GCUT.msg('moon times: {} {}'.format(repr(a), repr(b)))
def GetDaylightTimeStartDate(nDst, nYear):
    nDst = ID2INDEX(nDst)
    a = gzone[nDst]

    vcStart = GCGregorianDate()
    vcStart.day = 1
    vcStart.month = a['startMonth']
    vcStart.year = nYear
    if a['startType'] == 1:
        vcStart.day = a['startWeek']
    else:
        if a['startWeek'] == 5:
            vcStart.day = GCGregorianDate.GetMonthMaxDays(
                nYear, a['startMonth'])
            vcStart.InitWeekDay()
            while vcStart.dayOfWeek != a['startDay']:
                vcStart.PreviousDay()
        else:
            vcStart.day = 1
            vcStart.InitWeekDay()
            while vcStart.dayOfWeek != a['startDay']:
                vcStart.NextDay()
            vcStart.day += a['startWeek'] * 7
    vcStart.shour = 1 / 24.0
    return vcStart
예제 #9
0
import TToday
import os

os.mkdir('test')

GCMath.unittests()
GCTime.unittests()
GCUT.info('enums')
GCUT.val(FastType.FAST_NULL, 0, 'FastType')
GCUT.val(MahadvadasiType.EV_VIJAYA, 0x110, 'MahadvadasiType')
GCAyanamsha.unittests()
GCPancangaDate.unittests()
GCDisplaySettings.unittests()
GCStrings.unittests()
GCCountry.unittests()
GCGregorianDate.unittests()
GCTimeZone.unittests()
GCEarthData.unittests()
GCStringBuilder.unittests()
GCMoonData.unittests()
GCSunData.unittests()
GCConjunction.unittests()
GCNaksatra.unittests()
GCSankranti.unittests()
GCTithi.unittests()
GCDayData.unittests()
GCYoga.unittests()
GCLocationList.unittests()
GCEventList.unittests()
GCCalendar.unittests()
# retype to if True: ... in case you need unittests for specific engine