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 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 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 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
def IsConjunction(m1, s1, s2, m2): if m2 < m1: m2 += 360.0 if s2 < s1: s2 += 360.0 if (m1 <= s1) and (s1 < s2) and (s2 <= m2): return True m1 = GCMath.putIn180(m1) m2 = GCMath.putIn180(m2) s1 = GCMath.putIn180(s1) s2 = GCMath.putIn180(s2) return (m1 <= s1) and (s1 < s2) and (s2 <= m2)
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 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
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
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 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
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))
def SetFromJulian(self, jd): z = math.floor(jd + 0.5) f = (jd + 0.5) - z if z < 2299161.0: A = z else: alpha = math.floor((z - 1867216.25) / 36524.25) A = z + 1.0 + alpha - math.floor(alpha / 4.0) B = A + 1524 C = math.floor((B - 122.1) / 365.25) D = math.floor(365.25 * C) E = math.floor((B - D) / 30.6001) self.day = int(math.floor(B - D - floor(30.6001 * E) + f)) if E < 14: self.month = int(E - 1) else: self.month = int(E - 13) if self.month > 2: self.year = int(C - 4716) else: self.year = int(C - 4715) self.tzone = 0.0 self.shour = GCMath.getFraction(jd + 0.5)
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)))
def GetSecond(self): return int(math.floor(GCMath.getFraction(self.shour * 1440) * 60))
def GetMinuteRound(self): return int(math.floor(GCMath.getFraction(self.shour * 24) * 60 + 0.5))
def GetMinute(self): return int(math.floor(GCMath.getFraction(self.shour * 24) * 60))
def MoonDistance(jdate): arg_lr = [[0, 0, 1, 0], [2, 0, -1, 0], [2, 0, 0, 0], [0, 0, 2, 0], [0, 1, 0, 0], [0, 0, 0, 2], [2, 0, -2, 0], [2, -1, -1, 0], [2, 0, 1, 0], [2, -1, 0, 0], [0, 1, -1, 0], [1, 0, 0, 0], [0, 1, 1, 0], [2, 0, 0, -2], [0, 0, 1, 2], [0, 0, 1, -2], [4, 0, -1, 0], [0, 0, 3, 0], [4, 0, -2, 0], [2, 1, -1, 0], [2, 1, 0, 0], [1, 0, -1, 0], [1, 1, 0, 0], [2, -1, 1, 0], [2, 0, 2, 0], [4, 0, 0, 0], [2, 0, -3, 0], [0, 1, -2, 0], [2, 0, -1, 2], [2, -1, -2, 0], [1, 0, 1, 0], [2, -2, 0, 0], [0, 1, 2, 0], [0, 2, 0, 0], [2, -2, -1, 0], [2, 0, 1, -2], [2, 0, 0, 2], [4, -1, -1, 0], [0, 0, 2, 2], [3, 0, -1, 0], [2, 1, 1, 0], [4, -1, -2, 0], [0, 2, -1, 0], [2, 2, -1, 0], [2, 1, -2, 0], [2, -1, 0, -2], [4, 0, 1, 0], [0, 0, 4, 0], [4, -1, 0, 0], [1, 0, -2, 0], [2, 1, 0, -2], [0, 0, 2, -2], [1, 1, 1, 0], [3, 0, -2, 0], [4, 0, -3, 0], [2, -1, 2, 0], [0, 2, 1, 0], [1, 1, -1, 0], [2, 0, 3, 0], [2, 0, -1, -2]] sigma_r = [ -20905355, -3699111, -2955968, -569925, 48888, -3149, 246158, -152138, -170733, -204586, -129620, 108743, 104755, 10321, 0, 79661, -34782, -23210, -21636, 24208, 30824, -8379, -16675, -12831, -10445, -11650, 14403, -7003, 0, 10056, 6322, -9884, 5751, 0, -4950, 4130, 0, -3958, 0, 3258, 2616, -1897, -2117, 2354, 0, 0, -1423, -1117, -1571, -1739, 0, -4421, 0, 0, 0, 0, 1165, 0, 0, 8752 ] t = (jdate - 2451545.0) / 36525.0 # (* mean elongation of the moon d = 297.8502042 + (445267.1115168 + (-0.0016300 + (1.0 / 545868 - 1.0 / 113065000 * t) * t) * t) * t # (* mean anomaly of the sun m = 357.5291092 + (35999.0502909 + (-0.0001536 + 1.0 / 24490000 * t) * t) * t # (* mean anomaly of the moon ms = 134.9634114 + (477198.8676313 + (0.0089970 + (1.0 / 69699 - 1.0 / 1471200 * t) * t) * t) * t # (* argument of the longitude of the moon f = 93.2720993 + (483202.0175273 + (-0.0034029 + (-1.0 / 3526000 + 1.0 / 863310000 * t) * t) * t) * t # (* correction term due to excentricity of the earth orbit e = 1.0 + (-0.002516 - 0.0000074 * t) * t # (* mean longitude of the moon ls = 218.3164591 + (481267.88134236 + (-0.0013268 + (1.0 / 538841 - 1.0 / 65194000 * t) * t) * t) * t sr = 0 for i in range(60): temp = sigma_r[i] * GCMath.cosDeg(arg_lr[i][0] * d + arg_lr[i][1] * m + arg_lr[i][2] * ms + arg_lr[i][3] * f) if math.fabs(arg_lr[i][1]) == 1: temp = temp * e if math.fabs(arg_lr[i][1]) == 2: temp = temp * e * e sr = sr + temp return 385000.56 + sr / 1000
def CalculateEcliptical(self, jdate): arg_lr = [[0, 0, 1, 0], [2, 0, -1, 0], [2, 0, 0, 0], [0, 0, 2, 0], [0, 1, 0, 0], [0, 0, 0, 2], [2, 0, -2, 0], [2, -1, -1, 0], [2, 0, 1, 0], [2, -1, 0, 0], [0, 1, -1, 0], [1, 0, 0, 0], [0, 1, 1, 0], [2, 0, 0, -2], [0, 0, 1, 2], [0, 0, 1, -2], [4, 0, -1, 0], [0, 0, 3, 0], [4, 0, -2, 0], [2, 1, -1, 0], [2, 1, 0, 0], [1, 0, -1, 0], [1, 1, 0, 0], [2, -1, 1, 0], [2, 0, 2, 0], [4, 0, 0, 0], [2, 0, -3, 0], [0, 1, -2, 0], [2, 0, -1, 2], [2, -1, -2, 0], [1, 0, 1, 0], [2, -2, 0, 0], [0, 1, 2, 0], [0, 2, 0, 0], [2, -2, -1, 0], [2, 0, 1, -2], [2, 0, 0, 2], [4, -1, -1, 0], [0, 0, 2, 2], [3, 0, -1, 0], [2, 1, 1, 0], [4, -1, -2, 0], [0, 2, -1, 0], [2, 2, -1, 0], [2, 1, -2, 0], [2, -1, 0, -2], [4, 0, 1, 0], [0, 0, 4, 0], [4, -1, 0, 0], [1, 0, -2, 0], [2, 1, 0, -2], [0, 0, 2, -2], [1, 1, 1, 0], [3, 0, -2, 0], [4, 0, -3, 0], [2, -1, 2, 0], [0, 2, 1, 0], [1, 1, -1, 0], [2, 0, 3, 0], [2, 0, -1, -2]] arg_b = [[0, 0, 0, 1], [0, 0, 1, 1], [0, 0, 1, -1], [2, 0, 0, -1], [2, 0, -1, 1], [2, 0, -1, -1], [2, 0, 0, 1], [0, 0, 2, 1], [2, 0, 1, -1], [0, 0, 2, -1], [2, -1, 0, -1], [2, 0, -2, -1], [2, 0, 1, 1], [2, 1, 0, -1], [2, -1, -1, 1], [2, -1, 0, 1], [2, -1, -1, -1], [0, 1, -1, -1], [4, 0, -1, -1], [0, 1, 0, 1], [0, 0, 0, 3], [0, 1, -1, 1], [1, 0, 0, 1], [0, 1, 1, 1], [0, 1, 1, -1], [0, 1, 0, -1], [1, 0, 0, -1], [0, 0, 3, 1], [4, 0, 0, -1], [4, 0, -1, 1], [0, 0, 1, -3], [4, 0, -2, 1], [2, 0, 0, -3], [2, 0, 2, -1], [2, -1, 1, -1], [2, 0, -2, 1], [0, 0, 3, -1], [2, 0, 2, 1], [2, 0, -3, -1], [2, 1, -1, 1], [2, 1, 0, 1], [4, 0, 0, 1], [2, -1, 1, 1], [2, -2, 0, -1], [0, 0, 1, 3], [2, 1, 1, -1], [1, 1, 0, -1], [1, 1, 0, 1], [0, 1, -2, -1], [2, 1, -1, -1], [1, 0, 1, 1], [2, -1, -2, -1], [0, 1, 2, 1], [4, 0, -2, -1], [4, -1, -1, -1], [1, 0, 1, -1], [4, 0, 1, -1], [1, 0, -1, -1], [4, -1, 0, -1], [2, -2, 0, 1]] sigma_r = [ -20905355, -3699111, -2955968, -569925, 48888, -3149, 246158, -152138, -170733, -204586, -129620, 108743, 104755, 10321, 0, 79661, -34782, -23210, -21636, 24208, 30824, -8379, -16675, -12831, -10445, -11650, 14403, -7003, 0, 10056, 6322, -9884, 5751, 0, -4950, 4130, 0, -3958, 0, 3258, 2616, -1897, -2117, 2354, 0, 0, -1423, -1117, -1571, -1739, 0, -4421, 0, 0, 0, 0, 1165, 0, 0, 8752 ] sigma_l = [ 6288774, 1274027, 658314, 213618, -185116, -114332, 58793, 57066, 53322, 45758, -40923, -34720, -30383, 15327, -12528, 10980, 10675, 10034, 8548, -7888, -6766, -5163, 4987, 4036, 3994, 3861, 3665, -2689, -2602, 2390, -2348, 2236, -2120, -2069, 2048, -1773, -1595, 1215, -1110, -892, -810, 759, -713, -700, 691, 596, 549, 537, 520, -487, -399, -381, 351, -340, 330, 327, -323, 299, 294, 0 ] sigma_b = [ 5128122, 280602, 277693, 173237, 55413, 46271, 32573, 17198, 9266, 8822, 8216, 4324, 4200, -3359, 2463, 2211, 2065, -1870, 1828, -1794, -1749, -1565, -1491, -1475, -1410, -1344, -1335, 1107, 1021, 833, 777, 671, 607, 596, 491, -451, 439, 422, 421, -366, -351, 331, 315, 302, -283, -229, 223, 223, -220, -220, -185, 181, -177, 176, 166, -164, 132, -119, 115, 107 ] t = (jdate - 2451545.0) / 36525.0 # (* mean elongation of the moon d = 297.8502042 + (445267.1115168 + (-0.0016300 + (1.0 / 545868 - 1.0 / 113065000 * t) * t) * t) * t # (* mean anomaly of the sun m = 357.5291092 + (35999.0502909 + (-0.0001536 + 1.0 / 24490000 * t) * t) * t # (* mean anomaly of the moon ms = 134.9634114 + (477198.8676313 + (0.0089970 + (1.0 / 69699 - 1.0 / 1471200 * t) * t) * t) * t # (* argument of the longitude of the moon f = 93.2720993 + (483202.0175273 + (-0.0034029 + (-1.0 / 3526000 + 1.0 / 863310000 * t) * t) * t) * t # (* correction term due to excentricity of the earth orbit e = 1.0 + (-0.002516 - 0.0000074 * t) * t # (* mean longitude of the moon ls = 218.3164591 + (481267.88134236 + (-0.0013268 + (1.0 / 538841 - 1.0 / 65194000 * t) * t) * t) * t # (* arguments of correction terms a1 = 119.75 + 131.849 * t a2 = 53.09 + 479264.290 * t a3 = 313.45 + 481266.484 * t sr = 0 for i in range(60): temp = sigma_r[i] * GCMath.cosDeg(arg_lr[i][0] * d + arg_lr[i][1] * m + arg_lr[i][2] * ms + arg_lr[i][3] * f) if math.fabs(arg_lr[i][1]) == 1: temp = temp * e if math.fabs(arg_lr[i][1]) == 2: temp = temp * e * e sr = sr + temp sl = 0 for i in range(60): temp = sigma_l[i] * GCMath.sinDeg(arg_lr[i][0] * d + arg_lr[i][1] * m + arg_lr[i][2] * ms + arg_lr[i][3] * f) if math.fabs(arg_lr[i][1]) == 1: temp = temp * e if math.fabs(arg_lr[i][1]) == 2: temp = temp * e * e sl = sl + temp # (* correction terms sl =sl +3958*GCMath.sinDeg(a1) \ +1962*GCMath.sinDeg(ls-f) \ +318*GCMath.sinDeg(a2) sb = 0 for i in range(60): temp = sigma_b[i] * GCMath.sinDeg(arg_b[i][0] * d + arg_b[i][1] * m + arg_b[i][2] * ms + arg_b[i][3] * f) if math.fabs(arg_b[i][1]) == 1: temp = temp * e if math.fabs(arg_b[i][1]) == 2: temp = temp * e * e sb = sb + temp # (* correction terms sb = sb - 2235 * GCMath.sinDeg(ls) + 382 * GCMath.sinDeg( a3) + 175 * GCMath.sinDeg(a1 - f) + 175 * GCMath.sinDeg( a1 + f) + 127 * GCMath.sinDeg(ls - ms) - 115 * GCMath.sinDeg( ls + ms) coords = GCCoords.GCEclipticalCoords() coords.longitude = ls + sl / 1000000 coords.latitude = sb / 1000000 coords.distance = 385000.56 + sr / 1000 return coords
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
def getTopocentricEquatorial(self, obs, jdate): b_a = 0.99664719 tec = GCCoords.GCEquatorialCoords() altitude = 0 # geocentric position of observer on the earth surface # 10.1 - 10.3 u = GCMath.arcTanDeg(b_a * b_a * GCMath.tanDeg(obs.latitude_deg)) rho_sin = b_a * GCMath.sinDeg( u) + altitude / 6378140.0 * GCMath.sinDeg(obs.latitude_deg) rho_cos = GCMath.cosDeg(u) + altitude / 6378140.0 * GCMath.cosDeg( obs.latitude_deg) # equatorial horizontal paralax # 39.1 parallax = GCMath.arcSinDeg( GCMath.sinDeg(8.794 / 3600) / (self.radius / GCMath.AU)) # geocentric hour angle of the body h = GCEarthData.star_time( jdate) + obs.longitude_deg - self.rektaszension # 39.2 delta_alpha = GCMath.arcTanDeg( (-rho_cos * GCMath.sinDeg(self.parallax) * GCMath.sinDeg(h)) / (GCMath.cosDeg(self.declination) - rho_cos * GCMath.sinDeg(self.parallax) * GCMath.cosDeg(h))) tec.rightAscension = self.rektaszension + delta_alpha tec.declination = GCMath.arcTanDeg( ((GCMath.sinDeg(self.declination) - rho_sin * GCMath.sinDeg(self.parallax)) * GCMath.cosDeg(delta_alpha)) / (GCMath.cosDeg(self.declination) - rho_cos * GCMath.sinDeg(self.parallax) * GCMath.cosDeg(h))) return tec
def correct_position(self, jdate, latitude, longitude, height): b_a = 0.99664719 u = GCMath.arcTanDeg(b_a * b_a * GCMath.tanDeg(latitude)) rho_sin = b_a * GCMath.sinDeg(u) + height / 6378140.0 * GCMath.sinDeg( latitude) rho_cos = GCMath.cosDeg( u) + height / 6378140.0 * GCMath.cosDeg(latitude) self.parallax = GCMath.arcSinDeg( GCMath.sinDeg(8.794 / 3600) / (MoonDistance(jdate) / GCMath.AU)) h = GCEarthData.star_time(jdate) - longitude - self.rektaszension delta_alpha = GCMath.arcTanDeg( (-rho_cos * GCMath.sinDeg(self.parallax) * GCMath.sinDeg(h)) / (GCMath.cosDeg(self.declination) - rho_cos * GCMath.sinDeg(self.parallax) * GCMath.cosDeg(h))) self.rektaszension = self.rektaszension + delta_alpha self.declination = GCMath.arcTanDeg( ((GCMath.sinDeg(self.declination) - rho_sin * GCMath.sinDeg(self.parallax)) * GCMath.cosDeg(delta_alpha)) / (GCMath.cosDeg(self.declination) - rho_cos * GCMath.sinDeg(self.parallax) * GCMath.cosDeg(h)))
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
def GetHorizontDegrees(self, jday): return GCMath.putIn360( star_time(jday) - self.longitude_deg - GCAyanamsha.GetAyanamsa(jday) + 155)
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
def GetRasi(SunLongitude, Ayanamsa): return int(GCMath.Floor(GCMath.putIn360(SunLongitude - Ayanamsa) / 30.0))
import gaurabda.GCDayData as GCDayData import gaurabda.GCTithi as GCTithi import gaurabda.GCYoga as GCYoga import gaurabda.GCLocationList as GCLocationList import gaurabda.GCEventList as GCEventList import gaurabda.GCCalendar as GCCalendar import TMasaList import TCalendar import TAppDay import TCoreEvents 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()