def unittests(): GCUT.info('gc tithi') e = GCEarthData.EARTHDATA() e.longitude_deg = 27.0 e.latitude_deg = 45.0 e.tzone = 1.0 vc = Today() vc2 = GCGregorianDate() vc3 = GCGregorianDate(date=vc) vc3.NextDay() if False: import io s = io.StringIO() clr = GCLocation.GCLocation() writeXml(s, clr, vc) GCUT.msg(s.getvalue()) s.seek(0) writeGaurabdaTithiXml(s, clr, GCGaurabdaDate(2, 1, 512), GCGaurabdaDate(20, 1, 514)) GCUT.msg('writeGaurabdaTithiXml') GCUT.msg(s.getvalue()) s = io.StringIO() writeGaurabdaNextTithiXml(s, clr, vc, GCGaurabdaDate(2, 1, 512)) GCUT.msg('writeGaurabdaNextTithiXml') GCUT.msg(s.getvalue()) print(GetTithiTimes(e, vc, 0.25))
def GetEarthData(self): e = GCEarthData.EARTHDATA() e.dst = self.m_nTimezoneId e.latitude_deg = self.m_fLatitude e.longitude_deg = self.m_fLongitude e.tzone = self.m_fTimezone return e
def unittests(): GCUT.info('daydata') e = GCEarthData.EARTHDATA() e.longitude_deg = 27.0 e.latitude_deg = 45.0 e.tzone = 1.0 GCUT.msg('First day in year: ' + str(GetFirstDayOfYear(e, 2020)))
def unittests(): GCUT.info('yoga') e = GCEarthData.EARTHDATA() e.longitude_deg = 27.0 e.latitude_deg = 45.0 e.tzone = 1.0 vc = Today() vc2 = GCGregorianDate() GetNextYogaStart(e, vc, vc2) print('Next yoga:', repr(vc2))
def Calculate(self, jdate, earth): crd = self.CalculateEcliptical(jdate) eqc, crd = GCEarthData.eclipticalToEquatorialCoords(crd, jdate) self.radius = crd.distance self.longitude_deg = crd.longitude self.latitude_deg = crd.latitude self.rektaszension = eqc.rightAscension self.declination = eqc.declination
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 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 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 unittests(): GCUT.info('conjunctions') b = IsConjunction(10, 11, 12, 20) GCUT.val(b, True, 'is conjunction') e = GCEarthData.EARTHDATA() e.longitude_deg = 27.0 e.latitude_deg = 45.0 e.tzone = 1.0 vc = Today() vc2 = GCGregorianDate(date=vc) vc3 = GCGregorianDate(date=vc) l = GetPrevConjunction(vc2, e) GCUT.msg('Conjunction on: {}'.format(repr(vc2))) vc2.Set(vc) l = GetNextConjunctionEx(vc2, vc3, True, e) GCUT.msg('Conjunction on: {}'.format(repr(vc3)))
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 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 formatPlain(self, stream): p = self.GetCurrentDay() loc = self.calendar.m_Location vc = p.date sb = GCStringBuilder(stream) sb.Format = SBTF_TEXT if (p == None): return stream.write("{} ({}, {}, Timezone: {})\r\n\r\n[{} - {}]\r\n {}, {} {}\r\n {} {}, {} Gaurabda\r\n\r\n".format(loc.m_strName, GCEarthData.GetTextLatitude(loc.m_fLatitude), GCEarthData.GetTextLongitude(loc.m_fLongitude), GCTimeZone.GetTimeZoneName(loc.m_nTimezoneId), vc, GCStrings.getString(vc.dayOfWeek), GCStrings.GetTithiName(p.astrodata.nTithi), GCStrings.GetPaksaName(p.astrodata.nPaksa), GCStrings.getString(20), GCStrings.GetMasaName(p.astrodata.nMasa), GCStrings.getString(22), p.astrodata.nGaurabdaYear)) self.WriteTodayInfo(sb,p)
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 if True: TMasaList.unittests() if True: TCalendar.unittests()
def writeHtml(self, stream): d = self.details vc = GCGregorianDate(date=self.eventTime) m_earth = self.m_location.GetEarthData() stream.write("<html><head><title>Appearance day</title>") stream.write( "<style>\n<!--\nbody {\n font-family:Verdana;\n font-size:11pt;\n}\n\ntd.hed {\n font-size:11pt;\n font-weight:bold;\n" ) stream.write( " background:#aaaaaa;\n color:white;\n text-align:center;\n vertical-align:center;\n padding-left:15pt;\n padding-right:15pt;\n" ) stream.write( " padding-top:5pt;\n padding-bottom:5pt;\n}\n-->\n</style>\n") stream.write("</head>\n\n<body>\n") stream.write("<h2 align=center>Appearance day Calculation</h2>") stream.write("<table align=center><tr><td valign=top>\n\n") stream.write("<table align=center>") stream.write("<tr><td colspan=3 class=hed>Details</td></tr>\n") stream.write("<tr><td colspan=2>{}</td><td> {}</td></tr>\n".format( GCStrings.getString(7), vc)) stream.write( "<tr><td colspan=2>{}</td><td> {}:{:02d}</td></tr>\n\n".format( GCStrings.getString(8), vc.GetHour(), vc.GetMinuteRound())) stream.write("<tr><td colspan=2>{}</td><td> {}</td></tr>\n".format( GCStrings.getString(9), self.m_location.m_strName)) stream.write("<tr><td colspan=2>{}</td><td> {}</td></tr>\n".format( GCStrings.getString(10), GCEarthData.GetTextLatitude(self.m_location.m_fLatitude))) stream.write("<tr><td colspan=2>{}</td><td> {}</td></tr>\n".format( GCStrings.getString(11), GCEarthData.GetTextLongitude(self.m_location.m_fLongitude))) stream.write("<tr><td colspan=2>{}</td><td> ".format( GCStrings.getString(12))) stream.write( GCTimeZone.GetTimeZoneOffsetText(self.m_location.m_fTimezone)) stream.write("</td></tr>\n") stream.write("<tr><td colspan=2>DST</td><td>N/A</td></tr>\n") stream.write("<tr><td colspan=2>{}</td><td> {}</td></tr>\n".format( GCStrings.getString(13), GCStrings.GetTithiName(d.nTithi))) stream.write( "<tr><td colspan=2>{}</td><td> {:.2f} %</td></tr>\n".format( GCStrings.getString(14), d.nTithiElapse)) stream.write("<tr><td colspan=2>{}</td><td> {}</td></tr>\n".format( GCStrings.getString(15), GCStrings.GetNaksatraName(d.nNaksatra))) stream.write( "<tr><td colspan=2>{}</td><td> {:.2f} %</td></tr>\n".format( GCStrings.getString(16), d.nNaksatraElapse)) stream.write("<tr><td colspan=2>{}</td><td> {}</td></tr>\n".format( GCStrings.getString(20), GCStrings.GetPaksaName(d.nPaksa))) if (self.b_adhika == True): stream.write( "<tr><td colspan=2>{}</td><td> {} {}</td></tr>\n".format( GCStrings.getString(22), GCStrings.GetMasaName(d.nMasa), GCStrings.getString(21))) else: stream.write("<tr><td colspan=2>{}</td><td> {}</td></tr>\n".format( GCStrings.getString(22), GCStrings.GetMasaName(d.nMasa))) stream.write("<tr><td colspan=2>{}</td><td> {}</td></tr>\n\n".format( GCStrings.getString(23), d.nGaurabdaYear)) stream.write("</table></td><td valign=top><table>") stream.write("<tr><td colspan=3 class=hed>{}</td></tr>\n".format( GCStrings.getString(24))) for o in range(TRESULT_APP_CELEBS): stream.write( "<tr><td>Gaurabda {}</td><td> : </td><td><b>{}</b></td></tr>" .format(self.celeb_gy[o], self.celeb_date[o])) stream.write("</table>") stream.write("</td></tr></table>\n\n") stream.write( "<hr align=center width=\"50%\">\n<p style=\'text-align:center;font-size:8pt\'>Generated by {}</p>" .format(GCStrings.getString(130))) stream.write("</body></html>")
def m_strLongitude(self): return GCEarthData.GetTextLongitude(self.m_fLongitude)
def m_strLatitude(self): return GCEarthData.GetTextLatitude(self.m_fLatitude)
def formatRtf(self, stream): p = self.GetCurrentDay() loc = self.calendar.m_Location vc = p.date sb = GCStringBuilder(stream) sb.Format = SBTF_RTF sb.fontSizeH1 = GCLayoutData.textSizeH1 sb.fontSizeH2 = GCLayoutData.textSizeH2 sb.fontSizeText = GCLayoutData.textSizeText sb.fontSizeNote = GCLayoutData.textSizeNote sb.AppendDocumentHeader() stream.write("\\f2\\fs{} {} ".format(GCLayoutData.textSizeH1, vc.GetDateTextWithTodayExt())) stream.write("\\par\\f2\\fs{} {{\\fs{} {} }}\\line {} ({}, {}, Timezone: {})\\par\r\n\\par\r\n {}, {} {}\\par\r\n {} {}, {} Gaurabda\\par\r\n\\par\r\n".format( GCLayoutData.textSizeText, GCLayoutData.textSizeText+4, GCStrings.getString(p.date.dayOfWeek), loc.m_strName, GCEarthData.GetTextLatitude(loc.m_fLatitude), GCEarthData.GetTextLongitude(loc.m_fLongitude), GCTimeZone.GetTimeZoneName(loc.m_nTimezoneId), GCStrings.GetTithiName(p.astrodata.nTithi), GCStrings.GetPaksaName(p.astrodata.nPaksa), GCStrings.getString(20), GCStrings.GetMasaName(p.astrodata.nMasa), GCStrings.getString(22), p.astrodata.nGaurabdaYear)) self.WriteTodayInfo(sb,p)