Beispiel #1
0
        /*************************************/
        /*    sun functions                  */
        /*                                   */
        /*    sun longitude                  */
        /*    sunrise, sunset time           */
        /*                                   */
        /*************************************/

        //////////////////////////////////////////////////////////////////////////
        //
        // VCTIME vct [in] - valid must be each member of this structure
        //

        // from vct uses members: year, month, day
        // double is in range 0.0 - 1.0

        private void SunPosition(GregorianDateTime vct, GCEarthData ed, double dayHours)
        {
            double DG  = GCMath.PI / 180;
            double RAD = 180 / GCMath.PI;

            double dLatitude  = ed.latitudeDeg;
            double dLongitude = ed.longitudeDeg;

            // mean ecliptic longitude of the sun
            meanLongitudeOfSun = GCSunData.SunGetMeanLong(vct.year, vct.month, vct.day) + (360 / 365.25) * dayHours / 360.0;

            // ecliptic longitude of perigee
            double elp = GCSunData.SunGetPerigee(vct.year, vct.month, vct.day);

            // mean anomaly of the sun
            double mas = meanLongitudeOfSun - elp;

            // ecliptic longitude of the sun
            double els = 0.0;

            this.longitudeDeg = els = meanLongitudeOfSun + 1.915 * Math.Sin(mas * DG) + 0.02 * Math.Sin(2 * DG * mas);

            // declination of the sun
            this.declinationDeg = RAD * Math.Asin(0.39777 * Math.Sin(els * DG));

            // right ascension of the sun
            this.rightAscensionDeg = els - RAD * Math.Atan2(Math.Sin(2 * els * DG), 23.2377 + Math.Cos(2 * DG * els));

            // equation of time
            equationOfTime = this.rightAscensionDeg - meanLongitudeOfSun;
        }
Beispiel #2
0
        public static double GetSunLongitude(GregorianDateTime vct, GCEarthData earth)
        {
            switch (System)
            {
            case AstronomySystem.Meeus:
                return(GCSunData.GetSunLongitude(vct));
            }

            return(0);
        }
Beispiel #3
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 #4
0
        private void CalculateKalam(GregorianDateTime vcAdd, double sunRise, double sunSet, int kalaType, GCConfigRatedEvents rec)
        {
            double r1, r2;

            GCSunData.CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek, out r1, out r2, kalaType);

            if (r1 > 0 && r2 > 0)
            {
                vcAdd.shour = r1;
                //AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_START, kalaType, ndst);
                AddRating(vcAdd, rec.rateKalas[kalaType], rec.rateKalas[KalaType.KT_NONE]);

                vcAdd.shour = r2;
                //AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_END, kalaType, ndst);
                AddRating(vcAdd, rec.rateKalas[KalaType.KT_NONE], rec.rateKalas[kalaType]);
            }
        }
Beispiel #5
0
        //
        // takes values year, month, day, shour, TimeZone
        //
        public static double GetSunLongitude(GregorianDateTime vct)
        {
            //	double mel = 0.0;
            double DG  = GCMath.PI / 180;
            double RAD = 180 / GCMath.PI;

            // mean ecliptic longitude of the sun
            double mel = GCSunData.SunGetMeanLong(vct.year, vct.month, vct.day) + (360 / 365.25) * (vct.shour - 0.5 - vct.TimezoneHours / 24.0);

            // ecliptic longitude of perigee
            double elp = GCSunData.SunGetPerigee(vct.year, vct.month, vct.day);

            // mean anomaly of the sun
            double mas = mel - elp;

            // ecliptic longitude of the sun
            //double els = 0.0;
            return(mel + 1.915 * Math.Sin(mas * DG) + 0.02 * Math.Sin(2 * DG * mas));
        }
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 static int writeGaurabdaNextTithiXml(string fileName, GCLocation loc, GregorianDateTime vcStart, GaurabdaDate vaStart)
        {
            int        gmasa, gpaksa, gtithi;
            GCHourTime sunRise;

            using (StreamWriter xml = new StreamWriter(fileName))
            {
                gmasa  = vaStart.masa;
                gpaksa = vaStart.tithi / 15;
                gtithi = vaStart.tithi % 15;

                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=\"start date\" val=\"");
                xml.Write(vcStart);
                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();
                //GCSunData sun = new GCSunData();
                int         A;
                double      sunrise;
                GCAstroData day = new GCAstroData();
                int         oTithi, oPaksa, oMasa, oYear;

                today.Set(vcStart);
                today.PreviousDay();
                vcStart.SubtractDays(15);
                for (A = 0; A <= 3; A++)
                {
                    vcs.Set(GCTithi.CalcTithiEndEx(vcStart, 0, gmasa, gpaksa, gtithi, earth, out vce));
                    if (!vcs.IsBeforeThis(today))
                    {
                        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;
                        sunRise     = GCSunData.CalcSunrise(today, earth);
                        sunrise     = sunRise.TotalDays;
                        if (sunrise < vcs.shour)
                        {
                            today.Set(vce);
                            sunRise = GCSunData.CalcSunrise(today, earth);
                            sunrise = sunRise.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);
                            sunRise = GCSunData.CalcSunrise(today, earth);
                            if (sunRise.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");
                        break;
                    }
                    else
                    {
                        vcStart.Set(vcs);
                        vcs.NextDay();
                    }
                }

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

            return(1);
        }
Beispiel #9
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 #10
0
        private void CalculateEvents(GCLocation loc, GregorianDateTime vcStart, GregorianDateTime vcEnd, GCConfigRatedEvents rec)
        {
            GregorianDateTime vc        = new GregorianDateTime(vcStart);
            double            biasHours = 0;

            ShowAboveOnly     = rec.useAcceptLimit;
            ShowLongerThan    = rec.useMinPeriodLength;
            RatingsAboveOnly  = rec.acceptLimit;
            MinIntervalLength = rec.minPeriodLength;

            //bool hasAscendent = rec.RequiredGrahaRasi(9);
            bool hasRahuKalam  = rec.rateKalas[KalaType.KT_RAHU_KALAM].Usable;
            bool hasYamaghanti = rec.rateKalas[KalaType.KT_YAMA_GHANTI].Usable;
            bool hasGulikalam  = rec.rateKalas[KalaType.KT_GULI_KALAM].Usable;
            bool hasAbhijit    = rec.rateKalas[KalaType.KT_ABHIJIT].Usable;
            bool hasMuhurta    = rec.RequiredMuhurta();

            p_events.Clear();
            EarthLocation = new GCLocation(loc);
            DateStart     = new GregorianDateTime(vcStart);
            DateEnd       = new GregorianDateTime(vcEnd);

            bool hasPreviousSunset           = false;
            GregorianDateTime previousSunset = new GregorianDateTime();
            GregorianDateTime vcAdd          = new GregorianDateTime(vcStart);
            GregorianDateTime vcNext         = new GregorianDateTime();
            GCEarthData       earth          = loc.GetEarthData();

            vcAdd.InitWeekDay();

            GCHourTime sunRise, sunSet;
            double     muhurtaLength = 48.0 / 1440.0;

            GregorianDateTime muhurtaDate = new GregorianDateTime();

            while (vcAdd.IsBeforeThis(vcEnd))
            {
                biasHours = loc.TimeZone.GetBiasMinutesForDay(vcAdd) / 60.0;
                sunRise   = GCSunData.CalcSunrise(vcAdd, earth);
                sunSet    = GCSunData.CalcSunset(vcAdd, earth);

                sunRise.AddMinutes(biasHours * 60);
                sunSet.AddMinutes(biasHours * 60);

                vcAdd.shour = sunRise.TotalDays;
                vcAdd.InitWeekDay();

                //AddEvent(vcAdd, CoreEventType.CCTYPE_S_RISE, 0, ndst);
                AddRating(vcAdd, rec.rateDayHours[0], rec.rateDayHours[3]);
                AddRating(vcAdd, rec.rateDay[0], rec.rateDayHours[1]);
                //AddEvent(vcAdd, CoreEventType.CCTYPE_DAY_OF_WEEK, vcAdd.dayOfWeek, ndst);
                AddRating(vcAdd, rec.weekday[vcAdd.dayOfWeek], rec.weekday[Prev(vcAdd.dayOfWeek, 7)]);

                if (hasPreviousSunset)
                {
                    previousSunset.shour += (vcAdd.shour + 1.0 - previousSunset.shour) / 2;
                    previousSunset.NormalizeValues();
                    //AddEvent(previousSunset, CoreEventType.CCTYPE_S_MIDNIGHT, 0, ndst);
                    AddRating(previousSunset, rec.rateDayHours[3], rec.rateDayHours[2]);
                }

                if (hasMuhurta)
                {
                    muhurtaDate.Set(vcAdd);
                    muhurtaDate.shour -= 2 * muhurtaLength;
                    muhurtaDate.NormalizeValues();
                    for (int j = 0; j < 30; j++)
                    {
                        //AddEvent(muhurtaDate, CoreEventType.CCTYPE_DAY_MUHURTA, (j + 28) % 30, ndst);
                        int mi = (j + 28) % 30;
                        AddRating(muhurtaDate, rec.rateMuhurta[mi], rec.rateMuhurta[Prev(mi, 30)]);
                    }
                }

                vcAdd.shour = (sunRise.TotalDays + sunSet.TotalDays) / 2;
                //AddEvent(vcAdd, CoreEventType.CCTYPE_S_NOON, 0, ndst);
                AddRating(vcAdd, rec.rateDayHours[1], rec.rateDayHours[0]);

                vcAdd.shour = sunSet.TotalDays;
                //AddEvent(vcAdd, CoreEventType.CCTYPE_S_SET, 0, ndst);
                AddRating(vcAdd, rec.rateDayHours[2], rec.rateDayHours[1]);
                AddRating(vcAdd, rec.rateDay[1], rec.rateDayHours[0]);
                previousSunset.Set(vcAdd);
                hasPreviousSunset = true;

                if (hasRahuKalam)
                {
                    CalculateKalam(vcAdd, sunRise.TotalDays, sunSet.TotalDays, KalaType.KT_RAHU_KALAM, rec);
                }

                if (hasYamaghanti)
                {
                    CalculateKalam(vcAdd, sunRise.TotalDays, sunSet.TotalDays, KalaType.KT_YAMA_GHANTI, rec);
                }

                if (hasGulikalam)
                {
                    CalculateKalam(vcAdd, sunRise.TotalDays, sunSet.TotalDays, KalaType.KT_GULI_KALAM, rec);
                }

                if (hasAbhijit)
                {
                    CalculateKalam(vcAdd, sunRise.TotalDays, sunSet.TotalDays, KalaType.KT_ABHIJIT, rec);
                }

                vcAdd.NextDay();
            }

            if (rec.RequiredGrahaRasi(9))
            {
                GCAscendant asc = new GCAscendant();
                asc.Earth           = EarthLocation.GetEarthData();
                asc.CurrentDateTime = new GregorianDateTime(vc);
                while (asc.GetNextAscendantBefore(vcEnd))
                {
                    AddRating(asc.CurrentDateTime.TimeWithOffset(biasHours), rec.rateGrahaRasi[9, asc.CurrentSign], rec.rateGrahaRasi[9, Prev(asc.CurrentSign, 12)]);
                    asc.CurrentDateTime.AddHours(0.5);
                }
            }

            if (rec.RequiredTithi())
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                CalculateTithis(loc, vcEnd, vcAdd, earth, rec);
            }


            if (rec.RequiredNaksatra())
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                CalculateNaksatras(loc, vcEnd, vcAdd, earth, rec);
            }

            if (rec.RequiredYoga())
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                CalculateYoga(loc, vcEnd, vcAdd, earth, rec);
            }

            for (int i = 0; i < 9; i++)
            {
                if (rec.RequiredGrahaRasi(i))
                {
                    vcAdd.Set(vc);
                    vcAdd.shour = 0.0;
                    CalculatePlanetRasi(i, loc, vcEnd, vcAdd, rec);
                    //CalculateSunRasi(loc, vcEnd, vcAdd, rec);
                }

                if (rec.RequiredGrahaHouse(i))
                {
                    vcAdd.Set(vc);
                    vcAdd.shour = 0.0;
                    CalculatePlanetHouse(i, loc, vcEnd, vcAdd, rec);
                    //CalculateSunRasi(loc, vcEnd, vcAdd, rec);
                }
            }

            /*if (rec.RequiredGrahaRasi(1))
             * {
             *  vcAdd.Set(vc);
             *  vcAdd.shour = 0.0;
             *  CalculateMoonRasi(loc, vcEnd, vcAdd, earth, rec);
             *
             * }*/

            if (rec.RequiredMoonTimes())
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                CalculateMoonTimes(vcEnd, vcAdd, earth, rec);
            }

            IComparer <GCRatedMoment> C = new GCRatedMoment.ComparerClass();

            p_ratings.Sort(C);
        }
Beispiel #11
0
 public static GCHourTime CalcSunset(GregorianDateTime vct, GCEarthData earth)
 {
     return(GCSunData.CalcSunset(vct, earth));
 }
Beispiel #12
0
        public void CalculateEvents(GCLocation loc, GregorianDateTime vcStart, GregorianDateTime vcEnd)
        {
            //GCSunData sun = new GCSunData();
            DstTypeChange ndst = 0;
            int           nData;

            TResultEvents inEvents = this;

            this.Clear();
            this.EarthLocation = loc;
            this.StartDateTime = new GregorianDateTime(vcStart);
            this.EndDateTime   = new GregorianDateTime(vcEnd);

            GregorianDateTime vc = new GregorianDateTime();
            GregorianDateTime vcAdd = new GregorianDateTime(), vcNext = new GregorianDateTime();
            GCEarthData       earth = loc.GetEarthData();

            vc.Set(vcStart);
            vc.TimezoneHours = loc.OffsetUtcHours;
            vcAdd.Set(vc);
            vcAdd.InitWeekDay();

            GCHourTime sunriseData, sunsetData;
            double     sunRise, sunSet;
            double     r1, r2;

            while (vcAdd.IsBeforeThis(vcEnd))
            {
                sunriseData = GCSunData.CalcSunrise(vcAdd, earth);
                sunsetData  = GCSunData.CalcSunset(vcAdd, earth);
                sunRise     = sunriseData.TotalDays;
                sunSet      = sunsetData.TotalDays;
                ndst        = loc.TimeZone.DetermineDaylightChange(vcAdd);

                if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_SUN) != 0)
                {
                    ndst = loc.TimeZone.DetermineDaylightChange(vcAdd);

                    vcAdd.shour = sunriseData.TotalDays - 96.0 / 1440.0;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_S_ARUN, 0, ndst);

                    vcAdd.shour = sunRise;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_S_RISE, 0, ndst);

                    vcAdd.shour = (sunRise + sunSet) / 2;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_S_NOON, 0, ndst);

                    vcAdd.shour = sunSet;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_S_SET, 0, ndst);
                }

                /*if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_ASCENDENT) != 0)
                 * {
                 *  todayLongitude = sun.longitude_deg;
                 *  vcAdd.shour = sunRise;
                 *  todaySunriseHour = sunRise;
                 *  if (previousLongitude < -10)
                 *  {
                 *      GregorianDateTime prevSunrise = new GregorianDateTime();
                 *      prevSunrise.Set(vcAdd);
                 *      prevSunrise.PreviousDay();
                 *      sun.SunCalc(prevSunrise, earth);
                 *      previousSunriseHour = sun.rise.GetDayTime() - 1;
                 *      previousLongitude = sun.longitude_deg;
                 *      fromTimeLimit = 0;
                 *  }
                 *
                 *  double a, b;
                 *  double jd = vcAdd.GetJulianComplete();
                 *  double ayan = GCAyanamsha.GetAyanamsa(jd);
                 *  r1 = GCMath.putIn360(previousLongitude - ayan) / 30;
                 *  r2 = GCMath.putIn360(todayLongitude - ayan) / 30;
                 *
                 *  while (r2 > r1 + 13)
                 *  {
                 *      r2 -= 12.0;
                 *  }
                 *  while (r2 < r1 + 11)
                 *  {
                 *      r2 += 12.0;
                 *  }
                 *
                 *  a = (r2 - r1) / (todaySunriseHour - previousSunriseHour);
                 *  b = r2 - a * todaySunriseHour;
                 *
                 *  for (double tr = Math.Floor(r1) + 1.0; tr < r2; tr += 1.0)
                 *  {
                 *      double tm = (tr - b) / a;
                 *      if (tm > fromTimeLimit)
                 *      {
                 *          vcNext.Set(vcAdd);
                 *          vcNext.shour = tm;
                 *          vcNext.NormalizeValues();
                 *          inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_ASCENDENT, (int)tr, ndst);
                 *      }
                 *  }
                 *
                 *  previousLongitude = todayLongitude;
                 *  previousSunriseHour = todaySunriseHour - 1;
                 *  fromTimeLimit = previousSunriseHour;
                 * }*/

                if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_RAHUKALAM) != 0)
                {
                    GCSunData.CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek, out r1, out r2, KalaType.KT_RAHU_KALAM);

                    vcAdd.shour = r1;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_START, KalaType.KT_RAHU_KALAM, ndst);

                    vcAdd.shour = r2;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_END, KalaType.KT_RAHU_KALAM, ndst);
                }

                if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_YAMAGHANTI) != 0)
                {
                    GCSunData.CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek, out r1, out r2, KalaType.KT_YAMA_GHANTI);

                    vcAdd.shour = r1;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_START, KalaType.KT_YAMA_GHANTI, ndst);

                    vcAdd.shour = r2;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_END, KalaType.KT_YAMA_GHANTI, ndst);
                }

                if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_GULIKALAM) != 0)
                {
                    GCSunData.CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek, out r1, out r2, KalaType.KT_GULI_KALAM);

                    vcAdd.shour = r1;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_START, KalaType.KT_GULI_KALAM, ndst);

                    vcAdd.shour = r2;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_END, KalaType.KT_GULI_KALAM, ndst);
                }

                if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_ABHIJIT_MUHURTA) != 0)
                {
                    GCSunData.CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek, out r1, out r2, KalaType.KT_ABHIJIT);

                    if (r1 > 0 && r2 > 0)
                    {
                        vcAdd.shour = r1;
                        inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_START, KalaType.KT_ABHIJIT, ndst);

                        vcAdd.shour = r2;
                        inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_END, KalaType.KT_ABHIJIT, ndst);
                    }
                }

                vcAdd.NextDay();
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_ASCENDENT) != 0)
            {
                GCAscendant asc = new GCAscendant();
                asc.Earth           = EarthLocation.GetEarthData();
                asc.CurrentDateTime = new GregorianDateTime(vc);
                while (asc.GetNextAscendantBefore(vcEnd))
                {
                    ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                    inEvents.AddEvent(asc.CurrentDateTime, CoreEventType.CCTYPE_ASCENDENT, asc.CurrentSign, ndst);
                    asc.CurrentDateTime.AddHours(0.5);
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_TITHI) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = GCTithi.GetNextTithiStart(earth, vcAdd, out vcNext);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        vcNext.InitWeekDay();
                        ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_TITHI, nData, ndst);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.shour += 0.2;
                    if (vcAdd.shour >= 1.0)
                    {
                        vcAdd.shour -= 1.0;
                        vcAdd.NextDay();
                    }
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_NAKSATRA) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = GCNaksatra.GetNextNaksatra(earth, vcAdd, out vcNext);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        vcNext.InitWeekDay();
                        ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_NAKS, nData, ndst);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.shour += 0.2;
                    if (vcAdd.shour >= 1.0)
                    {
                        vcAdd.shour -= 1.0;
                        vcAdd.NextDay();
                    }
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_YOGA) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = GCYoga.GetNextYogaStart(earth, vcAdd, out vcNext);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        vcNext.InitWeekDay();
                        ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_YOGA, nData, ndst);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.shour += 0.2;
                    if (vcAdd.shour >= 1.0)
                    {
                        vcAdd.shour -= 1.0;
                        vcAdd.NextDay();
                    }
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_SANKRANTI) != 0)
            {
                vcNext = new GregorianDateTime();
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    vcNext.Set(GCSankranti.GetNextSankranti(vcAdd, earth, out nData));
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        vcNext.InitWeekDay();
                        ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_SANK, nData, ndst);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.NextDay();
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_MOONRASI) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = GCMoonData.GetNextMoonRasi(earth, vcAdd, out vcNext);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        vcNext.InitWeekDay();
                        ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_M_RASI, nData, ndst);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.shour += 0.5;
                    vcAdd.NormalizeValues();
                }
            }
            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_CONJUNCTION) != 0)
            {
                double dlong;
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    dlong = GCConjunction.GetNextConjunction(vcAdd, out vcNext, true, earth);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        vcNext.InitWeekDay();
                        ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_CONJ, GCRasi.GetRasi(dlong, GCAyanamsha.GetAyanamsa(vcNext.GetJulianComplete())), ndst);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.NextDay();
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_MOON) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    vcNext.Set(GCMoonData.GetNextRise(earth, vcAdd, true));
                    inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_M_RISE, 0, ndst);

                    vcNext.Set(GCMoonData.GetNextRise(earth, vcNext, false));
                    inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_M_SET, 0, ndst);

                    vcNext.shour += 0.05;
                    vcNext.NormalizeValues();
                    vcAdd.Set(vcNext);
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_ASCENDENT) != 0)
            {/*
              *         vcAdd = vc;
              *         vcAdd.shour = 0.0;
              *         while(vcAdd.IsBeforeThis(vcEnd))
              *         {
              *                 nData = earth.GetNextAscendentStart(vcAdd, vcNext);
              *                 if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
              *                 {
              *                         vcNext.InitWeekDay();
              *                         ndst = TTimeZone.determineDaylightChange(vcNext, loc.m_nDST);
              *                         inEvents.AddEvent(vcNext, CCTYPE_ASCENDENT, nData, ndst);
              *                 }
              *                 else
              *                 {
              *                         break;
              *                 }
              *                 vcAdd = vcNext;
              *                 vcAdd.shour += 1/24.0;
              *                 if (vcAdd.shour >= 1.0)
              *                 {
              *                         vcAdd.shour -= 1.0;
              *                         vcAdd.NextDay();
              *                 }
              *         }
              *
              */
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_SORT) != 0)
            {
                inEvents.Sort(SORTING_BY_DATE);
            }
            else
            {
                inEvents.Sort(SORTING_BY_TYPE);
            }
        }
Beispiel #13
0
        ///////////////////////////////////////////////////////////////////////
        // GET PREVIOUS CONJUNCTION OF THE SUN AND MOON
        //
        // THIS IS HELP FUNCTION FOR GetPrevConjunction(VCTIME test_date,
        //                                         VCTIME &found, bool this_day, EARTHDATA earth)
        //
        // looking for previous sun-moon conjunction
        // it starts from input day from 12:00 AM (noon) UTC
        // so output can be the same day
        // if output is the same day, then conjunction occurs between 00:00 AM and noon of this day
        //
        // date - input / output
        // earth - input
        // return value - sun longitude in degs
        //
        // error is when return value is greater than 999.0 deg

        public static double GetPrevConjunction(ref GregorianDateTime date, GCEarthData earth)
        {
            int    bCont = 32;
            double prevSun = 0.0, prevMoon = 0.0, prevDiff = 0.0;
            double nowSun = 0.0, nowMoon = 0.0, nowDiff = 0.0;
            //	SUNDATA sun;
            double            jd, longitudeMoon;
            GregorianDateTime d = new GregorianDateTime();

            d.Set(date);
            d.shour         = 0.5;
            d.TimezoneHours = 0.0;
            jd = d.GetJulian();//GetJulianDay(d.year, d.month, d.day);

            // set initial data for input day
            // NOTE: for grenwich
            //SunPosition(d, earth, sun);
            longitudeMoon = GCCoreAstronomy.GetMoonLongitude(d, earth);
            prevSun       = GCSunData.GetSunLongitude(d);
            prevMoon      = longitudeMoon;
            prevDiff      = GCMath.putIn180(prevSun - prevMoon);

            do
            {
                // shift to day before
                d.PreviousDay();
                jd -= 1.0;
                // calculation
                //SunPosition(d, earth, sun);
                longitudeMoon = GCCoreAstronomy.GetMoonLongitude(d, earth);
                nowSun        = GCSunData.GetSunLongitude(d);
                nowMoon       = longitudeMoon;
                nowDiff       = GCMath.putIn180(nowSun - nowMoon);
                // if difference of previous has another sign than now calculated
                // then it is the case that moon was faster than sun and he
                //printf("        prevsun=%f\nprevmoon=%f\nnowsun=%f\nnowmoon=%f\n", prevSun, prevMoon, nowSun, nowMoon);


                if (IsConjunction(nowMoon, nowSun, prevSun, prevMoon))
                {
                    // now it calculates actual time and zodiac of conjunction
                    double x;
                    if (prevDiff == nowDiff)
                    {
                        return(0);
                    }
                    x = Math.Abs(nowDiff) / Math.Abs(prevDiff - nowDiff);
                    if (x < 0.5)
                    {
                        d.shour = x + 0.5;
                    }
                    else
                    {
                        d.NextDay();
                        d.shour = x - 0.5;
                    }
                    date.Set(d);
                    double other = GCSunData.GetSunLongitude(d);
                    //			double other2 = nowSun + (prevSun - nowSun)*x;
                    GCMath.putIn360(prevSun);
                    GCMath.putIn360(nowSun);
                    if (Math.Abs(prevSun - nowSun) > 10.0)
                    {
                        return(GCMath.putIn180(nowSun) + (GCMath.putIn180(prevSun) - GCMath.putIn180(nowSun)) * x);
                    }
                    else
                    {
                        return(nowSun + (prevSun - nowSun) * x);
                    }
                    //			return other2;
                }
                prevSun  = nowSun;
                prevMoon = nowMoon;
                prevDiff = nowDiff;
                bCont--;
            }while (bCont >= 0);

            return(1000.0);
        }
Beispiel #14
0
        /*********************************************************************/
        /*                                                                   */
        /*                                                                   */
        /*                                                                   */
        /*                                                                   */
        /*                                                                   */
        /*********************************************************************/

        public static double GetNextConjunction(GregorianDateTime test_date, out GregorianDateTime found, bool this_conj, GCEarthData earth)
        {
            double phi = 12.0;
            double l1, l2, longitudeSun, longitudeMoon;

            if (this_conj)
            {
                test_date.shour += 0.2;
                test_date.NormalizeValues();
            }


            double            jday = test_date.GetJulianComplete();
            double            xj;
            GregorianDateTime d = new GregorianDateTime();

            d.Set(test_date);
            GregorianDateTime xd        = new GregorianDateTime();
            double            scan_step = 1.0;
            int prev_tit = 0;
            int new_tit  = -1;

            longitudeMoon = GCCoreAstronomy.GetMoonLongitude(d, earth);
            longitudeSun  = GCSunData.GetSunLongitude(d);
            l1            = GCMath.putIn180(longitudeMoon - longitudeSun);
            prev_tit      = GCMath.IntFloor(l1 / phi);

            int 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();
                }

                longitudeMoon = GCCoreAstronomy.GetMoonLongitude(d, earth);
                longitudeSun  = GCSunData.GetSunLongitude(d);
                l2            = GCMath.putIn180(longitudeMoon - longitudeSun);
                new_tit       = GCMath.IntFloor(l2 / phi);

                if (prev_tit < 0 && new_tit >= 0)
                {
                    jday = xj;
                    d.Set(xd);
                    scan_step *= 0.5;
                    counter++;
                    continue;
                }
                else
                {
                    l1 = l2;
                }

                prev_tit = new_tit;
            }
            found = new GregorianDateTime();
            found.Set(d);
            return(longitudeSun);
        }
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);
        }