Beispiel #1
0
 public void Set(GCHourTime d)
 {
     hour = d.hour;
     min  = d.min;
     sec  = d.sec;
     mili = d.mili;
 }
Beispiel #2
0
        public string ShortSandhyaString()
        {
            GCHourTime start, end;

            start = new GCHourTime(this, -96);
            end   = new GCHourTime(this, -48);

            return(string.Format("{0}-{1}", start.ToShortTimeString(), end.ToShortTimeString()));
        }
Beispiel #3
0
        public string ShortMuhurtaString(int nMuhurta)
        {
            GCHourTime start, end;

            start = new GCHourTime(this, nMuhurta * 48);
            end   = new GCHourTime(this, nMuhurta * 48 + 48);

            return(string.Format("{0}-{1}", start.ToShortTimeString(), end.ToShortTimeString()));
        }
Beispiel #4
0
 public GCHourTime(GCHourTime rise, int p)
 {
     // TODO: Complete member initialization
     hour          = rise.hour;
     min           = rise.min;
     sec           = rise.sec;
     mili          = rise.mili;
     longitude     = 0.0;
     longitudeMoon = 0.0;
     Ayanamsa      = 0.0;
     AddMinutes(p);
 }
Beispiel #5
0
        public static GCHourTime CalcSunrise(GregorianDateTime vct, GCEarthData earth)
        {
            double    tempSunrise = 180.0;
            GCSunData sun         = new GCSunData();

            for (int i = 0; i < 3; i++)
            {
                sun.SunPosition(vct, earth, tempSunrise - 180.0);

                double x;
                // definition of event
                double eventdef = 0.01454;

                /*	switch(ed.obs)
                 *  {
                 *  case 1:	// civil twilight
                 *      eventdef = 0.10453;
                 *      break;
                 *  case 2:	// nautical twilight
                 *      eventdef = 0.20791;
                 *      break;
                 *  case 3:	// astronomical twilight
                 *      eventdef = 0.30902;
                 *      break;
                 *  default:// center of the sun on the horizont
                 *      eventdef = 0.01454;
                 *      break;
                 *  }*/

                eventdef = (eventdef / GCMath.cosDeg(earth.latitudeDeg)) / GCMath.cosDeg(sun.declinationDeg);

                x = GCMath.tanDeg(earth.latitudeDeg) * GCMath.tanDeg(sun.declinationDeg) + eventdef;

                if ((x >= -1.0) && (x <= 1.0))
                {
                    // time of sunrise
                    tempSunrise = 90.0 - earth.longitudeDeg - GCMath.arcSinDeg(x) + sun.equationOfTime;
                }
                else
                {
                    // initial values for the case
                    // that no rise no set for that day
                    tempSunrise = -360.0;
                    break;
                }
            }

            GCHourTime result = new GCHourTime();

            result.longitude = sun.longitudeDeg;
            result.SetDegTime(tempSunrise + earth.OffsetUtcHours * 15.0);
            return(result);
        }
Beispiel #6
0
        /*********************************************************************/
        /*                                                                   */
        /* Calculation of tithi, paksa, naksatra, yoga for given             */
        /*    Gregorian date                                                 */
        /*                                                                   */
        /*                                                                   */
        /*********************************************************************/

        public int DayCalc(GregorianDateTime date, GCEarthData earth)
        {
            double d;

            // sun position on sunrise on that day
            sunRise = GCSunData.CalcSunrise(date, earth);
            sunSet  = GCSunData.CalcSunset(date, earth);

            // arunodaya is 96 min before sunrise
            //  sunrise_deg is from range 0-360 so 96min=24deg
            sunArunodaya.TotalDays = sunRise.TotalDays - 96 / 1440.0;
            sunArunodaya.longitude = sunRise.longitude - (24.0 / 365.25);
            // noon
            sunNoon.TotalDays = (sunSet.TotalDays + sunRise.TotalDays) / 2;
            sunNoon.longitude = (sunRise.longitude + sunSet.longitude) / 2;

            date.shour = sunRise.TotalDays;

            // date.shour is [0..1] time of sunrise in local timezone time
            this.JulianDay = date.GetJulianDetailed();

            // moon position at sunrise on that day
            sunRise.longitudeMoon = GCCoreAstronomy.GetMoonLongitude(date, earth);

            this.Ayanamsa         = GCAyanamsha.GetAyanamsa(this.JulianDay);
            sunArunodaya.Ayanamsa = this.Ayanamsa;
            sunRise.Ayanamsa      = this.Ayanamsa;
            sunNoon.Ayanamsa      = this.Ayanamsa;
            sunSet.Ayanamsa       = this.Ayanamsa;

            // masa
            this.Masa = -1;

            date.shour           = sunSet.TotalDays;
            sunSet.longitudeMoon = GCCoreAstronomy.GetMoonLongitude(date, earth);


            date.shour = sunArunodaya.TotalDays;
            sunArunodaya.longitudeMoon = GCCoreAstronomy.GetMoonLongitude(date, earth);


            return(1);
        }
Beispiel #7
0
        public static GCHourTime CalcSunset(GregorianDateTime vct, GCEarthData earth)
        {
            double    tempSunset = 180.0;
            GCSunData sun        = new GCSunData();

            for (int i = 0; i < 3; i++)
            {
                sun.SunPosition(vct, earth, tempSunset - 180.0);

                double x;
                // definition of event
                double eventdef = GCSunData.RiseAngleLevel;

                eventdef = (eventdef / GCMath.cosDeg(earth.latitudeDeg)) / GCMath.cosDeg(sun.declinationDeg);

                x = GCMath.tanDeg(earth.latitudeDeg) * GCMath.tanDeg(sun.declinationDeg) + eventdef;


                if ((x >= -1.0) && (x <= 1.0))
                {
                    // time of sunset
                    tempSunset = 270.0 - earth.longitudeDeg + GCMath.arcSinDeg(x) + sun.equationOfTime;
                }
                else
                {
                    // initial values for the case
                    // that no rise no set for that day
                    tempSunset = -360.0;
                    break;
                }
            }

            GCHourTime result = new GCHourTime();

            result.longitude = sun.longitudeDeg;
            result.SetDegTime(tempSunset + earth.OffsetUtcHours * 15.0);
            return(result);
        }
Beispiel #8
0
        public bool IsLessOrEqualThan(GCHourTime dt)
        {
            if (hour <= dt.hour)
            {
                return(true);
            }
            else if (hour > dt.hour)
            {
                return(false);
            }

            if (min <= dt.min)
            {
                return(true);
            }
            else if (min > dt.min)
            {
                return(false);
            }

            if (sec <= dt.sec)
            {
                return(true);
            }
            else if (sec > dt.sec)
            {
                return(false);
            }

            if (mili <= dt.mili)
            {
                return(true);
            }

            return(false);
        }
Beispiel #9
0
        public bool IsGreaterOrEqualThan(GCHourTime dt)
        {
            if (hour >= dt.hour)
            {
                return(true);
            }
            else if (hour < dt.hour)
            {
                return(false);
            }

            if (min >= dt.min)
            {
                return(true);
            }
            else if (min < dt.min)
            {
                return(false);
            }

            if (sec >= dt.sec)
            {
                return(true);
            }
            else if (sec < dt.sec)
            {
                return(false);
            }

            if (mili >= dt.mili)
            {
                return(true);
            }

            return(false);
        }
Beispiel #10
0
 public GCHourTimeObject(GCHourTime v)
 {
     Value = v;
 }
Beispiel #11
0
 public GCHourTimeObject()
 {
     Value = new GCHourTime();
 }
Beispiel #12
0
        //==================================================================================
        //
        //==================================================================================

        public static void CalcMoonTimes(GCEarthData e, GregorianDateTime vc, double biasHours, out GCHourTime rise, out GCHourTime set)
        {
            double UT;
            int    i;
            double prev_elev;
            int    nType, nFound = 0;
            double a, ae, b, be, c = 0, ce = 0, elev;

            rise = new GCHourTime();
            set  = new GCHourTime();

            rise.SetValue(-1);
            set.SetValue(-1);

            // inicializacia prvej hodnoty ELEVATION
            vc.shour  = (-biasHours - 1.0) / 24.0;
            prev_elev = GCCoreAstronomy.GetMoonElevation(e, vc);

            // prechod cez vsetky hodiny
            for (UT = (-0.1 - biasHours); UT <= (24.1 - biasHours); UT += 1.0)
            {
                vc.shour = UT / 24.0;
                elev     = GCCoreAstronomy.GetMoonElevation(e, vc);

                if (prev_elev * elev <= 0.0)
                {
                    if (prev_elev <= 0.0)
                    {
                        nType = 0x1;
                    }
                    else
                    {
                        nType = 0x2;
                    }

                    a  = UT - 1.0;
                    ae = prev_elev;
                    b  = UT;
                    be = elev;
                    for (i = 0; i < 20; i++)
                    {
                        c        = (a + b) / 2.0;
                        vc.shour = c / 24.0;
                        ce       = GCCoreAstronomy.GetMoonElevation(e, vc);
                        if (ae * ce <= 0.0)
                        {
                            be = ce;
                            b  = c;
                        }
                        else
                        {
                            ae = ce;
                            a  = c;
                        }
                    }

                    if (nType == 1)
                    {
                        rise.SetDayTime((c + biasHours) / 24.0);
                    }
                    else
                    {
                        set.SetDayTime((c + biasHours) / 24.0);
                    }

                    nFound |= nType;

                    if (nFound == 0x3)
                    {
                        break;
                    }
                }

                prev_elev = elev;
            }
        }
Beispiel #13
0
        public static int writeGaurabdaTithiXml(string fileName, GCLocation loc, GaurabdaDate vaStart, GaurabdaDate vaEnd)
        {
            int gyearA = vaStart.gyear;
            int gyearB = vaEnd.gyear;
            int gmasa  = vaStart.masa;
            int gpaksa = vaStart.tithi / 15;
            int gtithi = vaStart.tithi % 15;

            if (gyearB < gyearA)
            {
                gyearB = gyearA;
            }

            using (StreamWriter xml = new StreamWriter(fileName))
            {
                xml.Write("<xml>\n");
                xml.Write("\t<request name=\"Tithi\" version=\"");
                xml.Write(GCStrings.getString(130));
                xml.Write("\">\n");
                xml.Write("\t\t<arg name=\"longitude\" val=\"");
                xml.Write(loc.Longitude);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"latitude\" val=\"");
                xml.Write(loc.Latitude);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"timezone\" val=\"");
                xml.Write(loc.OffsetUtcHours);
                xml.Write("\" />\n");
                if (gyearA > 1500)
                {
                    xml.Write("\t\t<arg name=\"year-start\" val=\"");
                    xml.Write(gyearA);
                    xml.Write("\" />\n");
                    xml.Write("\t\t<arg name=\"year-end\" val=\"");
                    xml.Write(gyearB);
                    xml.Write("\" />\n");
                }
                else
                {
                    xml.Write("\t\t<arg name=\"gaurabdayear-start\" val=\"");
                    xml.Write(gyearA);
                    xml.Write("\" />\n");
                    xml.Write("\t\t<arg name=\"gaurabdayear-end\" val=\"");
                    xml.Write(gyearB);
                    xml.Write("\" />\n");
                }
                xml.Write("\t\t<arg name=\"masa\" val=\"");
                xml.Write(gmasa);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"paksa\" val=\"");
                xml.Write(gpaksa);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"tithi\" val=\"");
                xml.Write(gtithi);
                xml.Write("\" />\n");
                xml.Write("\t</request>\n");
                xml.Write("\t<result name=\"Tithi\">\n");


                GCEarthData       earth = loc.GetEarthData();
                GregorianDateTime vcs = new GregorianDateTime(), vce = new GregorianDateTime(), today = new GregorianDateTime();
                GCHourTime        sun = new GCHourTime();
                int         A, B;
                double      sunrise;
                GCAstroData day = new GCAstroData();
                int         oTithi, oPaksa, oMasa, oYear;

                if (gyearA > 1500)
                {
                    A = gyearA - 1487;
                    B = gyearB - 1485;
                }
                else
                {
                    A = gyearA;
                    B = gyearB;
                }

                for (; A <= B; A++)
                {
                    vcs.Set(GCTithi.CalcTithiEnd(A, gmasa, gpaksa, gtithi, earth, out vce));
                    if (gyearA > 1500)
                    {
                        if ((vcs.year < gyearA) || (vcs.year > gyearB))
                        {
                            continue;
                        }
                    }
                    oTithi = gpaksa * 15 + gtithi;
                    oMasa  = gmasa;
                    oPaksa = gpaksa;
                    oYear  = 0;
                    xml.Write("\t<celebration\n");
                    //		xml.Write("\t\t<tithi\n";
                    xml.Write("\t\trtithi=\"");
                    xml.Write(GCTithi.GetName(oTithi));
                    xml.Write("\"\n");
                    xml.Write("\t\trmasa=\"");
                    xml.Write(GCMasa.GetName(oMasa));
                    xml.Write("\"\n");
                    xml.Write("\t\trpaksa=\"");
                    xml.Write(oPaksa != 0 ? "Gaura" : "Krsna");
                    xml.Write("\"\n");
                    // test ci je ksaya
                    today.Set(vcs);
                    today.shour = 0.5;
                    sun         = GCSunData.CalcSunrise(today, earth);
                    sunrise     = sun.TotalDays;
                    if (sunrise < vcs.shour)
                    {
                        today.Set(vce);
                        sun     = GCSunData.CalcSunrise(today, earth);
                        sunrise = sun.TotalDays;
                        if (sunrise < vce.shour)
                        {
                            // normal type
                            vcs.NextDay();
                            xml.Write("\t\ttype=\"normal\"\n");
                        }
                        else
                        {
                            // ksaya
                            vcs.NextDay();
                            day.DayCalc(vcs, earth);
                            oTithi = day.sunRise.Tithi;
                            oPaksa = day.sunRise.Paksa;
                            oMasa  = day.MasaCalc(vcs, earth);
                            oYear  = day.GaurabdaYear;
                            xml.Write("\t\ttype=\"ksaya\"\n");
                        }
                    }
                    else
                    {
                        // normal, alebo prvy den vriddhi
                        today.Set(vce);
                        sun = GCSunData.CalcSunrise(today, earth);
                        if (sun.TotalDays < vce.shour)
                        {
                            // first day of vriddhi type
                            xml.Write("\t\ttype=\"vriddhi\"\n");
                        }
                        else
                        {
                            // normal
                            xml.Write("\t\ttype=\"normal\"\n");
                        }
                    }
                    xml.Write("\t\tdate=\"");
                    xml.Write(vcs);
                    xml.Write("\"\n");
                    xml.Write("\t\totithi=\"");
                    xml.Write(GCTithi.GetName(oTithi));
                    xml.Write("\"\n");
                    xml.Write("\t\tomasa=\"");
                    xml.Write(GCMasa.GetName(oMasa));
                    xml.Write("\"\n");
                    xml.Write("\t\topaksa=\"");
                    xml.Write(GCPaksa.GetName(oPaksa));
                    xml.Write("\"\n");
                    xml.Write("\t/>\n");
                }

                xml.Write("\t</result>\n");
                xml.Write("</xml>\n");
            }
            return(1);
        }
Beispiel #14
0
        public static int writeXml(string fileName, GCLocation loc, GregorianDateTime vc)
        {
            String            str;
            GregorianDateTime date;

            using (StreamWriter xml = new StreamWriter(fileName))
            {
                xml.Write("<xml>\n");
                xml.Write("\t<request name=\"Tithi\" version=\"");
                xml.Write(GCStrings.getString(130));
                xml.Write("\">\n");
                xml.Write("\t\t<arg name=\"longitude\" val=\"");
                xml.Write(loc.Longitude);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"latitude\" val=\"");
                xml.Write(loc.Latitude);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"timezone\" val=\"");
                xml.Write(loc.OffsetUtcHours);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"startdate\" val=\"");
                xml.Write(vc);
                xml.Write("\" />\n");
                xml.Write("\t</request>\n");
                xml.Write("\t<result name=\"Tithi\">\n");

                GregorianDateTime d = new GregorianDateTime();
                d.Set(vc);
                GregorianDateTime d1, d2;
                d.TimezoneHours = loc.OffsetUtcHours;
                GregorianDateTime dn;
                GCHourTime        dt    = new GCHourTime();
                GCEarthData       earth = loc.GetEarthData();


                GCAstroData day = new GCAstroData();

                day.DayCalc(vc, earth);

                d.shour = day.sunRise.TotalDays;

                GCTithi.GetPrevTithiStart(earth, d, out d1);
                GCTithi.GetNextTithiStart(earth, d, out d2);

                {
                    dt.SetDegTime(d1.shour * 360);
                    // start tithi at t[0]
                    xml.Write("\t\t<tithi\n\t\t\tid=\"");
                    xml.Write(day.sunRise.Tithi);
                    xml.Write("\"\n");
                    xml.Write("\t\t\tname=\"");
                    xml.Write(GCTithi.GetName(day.sunRise.Tithi));
                    xml.Write("\"\n");
                    xml.Write("\t\t\tstartdate=\"");
                    xml.Write(d1);
                    xml.Write("\"\n");
                    xml.Write("\t\t\tstarttime=\"");
                    xml.Write(dt);
                    xml.Write("\"\n");

                    dt.SetDegTime(d2.shour * 360);
                    xml.Write("\t\t\tenddate=\"");
                    xml.Write(d2);
                    xml.Write("\"\n");
                    xml.Write("\t\t\tendtime=\"");
                    xml.Write(dt);
                    xml.Write("\"\n />");
                }

                xml.Write("\t</result>\n");
                xml.Write("</xml>\n");
            }
            return(1);
        }
Beispiel #15
0
        public static int writeXml(string fileName, GCLocation loc, GregorianDateTime vc, int nDaysCount)
        {
            using (StreamWriter xml = new StreamWriter(fileName))
            {
                xml.Write("<xml>\n");
                xml.Write("\t<request name=\"Naksatra\" version=\"");
                xml.Write(GCStrings.getString(130));
                xml.Write("\">\n");
                xml.Write("\t\t<arg name=\"longitude\" val=\"");
                xml.Write(loc.Longitude);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"latitude\" val=\"");
                xml.Write(loc.Latitude);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"timezone\" val=\"");
                xml.Write(loc.OffsetUtcHours);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"startdate\" val=\"");
                xml.Write(vc);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"daycount\" val=\"");
                xml.Write(nDaysCount);
                xml.Write("\" />\n");
                xml.Write("\t</request>\n");
                xml.Write("\t<result name=\"Naksatra\">\n");

                GregorianDateTime d = new GregorianDateTime();
                d.Set(vc);
                d.TimezoneHours = loc.OffsetUtcHours;
                GregorianDateTime dn;
                GCHourTime        dt = new GCHourTime();
                int         nak;
                GCEarthData earth = loc.GetEarthData();

                for (int i = 0; i < 30; i++)
                {
                    nak = GCNaksatra.GetNextNaksatra(earth, d, out dn);
                    d.Set(dn);
                    xml.Write("\t\t<day date=\"");
                    xml.Write(d);
                    xml.Write("\">\n");
                    //str.Format("%d.%d.%d", d.day, d.month, d.year);
                    //n = m_list.InsertItem(50, GetNaksatraName(nak));
                    //m_list.SetItemText(n, 1, str);
                    xml.Write("\t\t\t<naksatra id=\"");
                    xml.Write(nak);
                    xml.Write("\" name=\"");
                    xml.Write(GCNaksatra.GetName(nak));
                    xml.Write("\"\n");
                    dt.SetDegTime(d.shour * 360);
                    //time_print(str, dt);
                    xml.Write("\t\t\t\tstarttime=\"");
                    xml.Write(dt);
                    xml.Write("\" />\n");
                    //m_list.SetItemText(n, 2, str);

                    //time_print(str, sun.rise);
                    //m_list.SetItemText(n, 3, str);
                    xml.Write("\t\t\t<sunrise time=\"");
                    xml.Write(GCSunData.CalcSunrise(d, earth));
                    xml.Write("\" />\n");

                    xml.Write("\t\t</day>\n");
                    // increment for non-duplication of naksatra
                    d.Set(dn);
                    d.shour += 1.0 / 8.0;
                }


                xml.Write("\t</result>\n");
                xml.Write("</xml>\n");
            }

            return(1);
        }