public static double MeanGreenwichSiderealTime(double JD)
        {
            //Get the Julian day for the same day at midnight
            long   Year   = 0;
            long   Month  = 0;
            long   Day    = 0;
            long   Hour   = 0;
            long   Minute = 0;
            double Second = 0;

            AASDate date = new AASDate();

            date.Set(JD, AASDate.AfterPapalReform(JD));
            date.Get(ref Year, ref Month, ref Day, ref Hour, ref Minute, ref Second);
            date.Set(Year, Month, Day, 0, 0, 0, date.InGregorianCalendar);
            double JDMidnight = date.Julian;

            //Calculate the sidereal time at midnight
            double T        = (JDMidnight - 2451545) / 36525;
            double TSquared = T * T;
            double TCubed   = TSquared * T;
            double Value    = 100.46061837 + (36000.770053608 * T) + (0.000387933 * TSquared) - (TCubed / 38710000);

            //Adjust by the time of day
            Value += (((Hour * 15) + (Minute * 0.25) + (Second * 0.0041666666666666666666666666666667)) * 1.00273790935);

            Value = AASCoordinateTransformation.DegreesToHours(Value);

            return(AASCoordinateTransformation.MapTo0To24Range(Value));
        }
        public static long DaysInYear(long Year)
        {
            //Find the previous civil year corresponding to the specified jewish year
            long CivilYear = Year - 3761;

            //Find the date of the next Jewish Year in that civil year
            AASCalendarDate CurrentPesach = DateOfPesach(CivilYear);
            bool            bGregorian    = AASDate.AfterPapalReform(CivilYear, CurrentPesach.Month, CurrentPesach.Day);
            AASDate         CurrentYear   = new AASDate(CivilYear, CurrentPesach.Month, CurrentPesach.Day, bGregorian);

            AASCalendarDate NextPesach = DateOfPesach(CivilYear + 1);
            AASDate         NextYear   = new AASDate(CivilYear + 1, NextPesach.Month, NextPesach.Day, bGregorian);

            return((long)(NextYear.Julian - CurrentYear.Julian));
        }
Beispiel #3
0
        public static double DeltaT(double JD)
        {
            //Construct a CAADate from the julian day
            AASDate date = new AASDate(JD, AASDate.AfterPapalReform(JD));
            double  y    = date.FractionalYear;
            double  T    = (y - 2000) / 100;
            double  Delta;

            if (y < 948)
            {
                Delta = 2177 + (497 * T) + (44.1 * T * T);
            }
            else
            if (y < 1620)
            {
                Delta = 102 + (102 * T) + (25.3 * T * T);
            }
            else
            if (y < 1998)
            {
                uint Index = (uint)((y - 1620) / 2);

                y     = y / 2 - Index - 810;
                Delta = (DeltaTTable[Index] + (DeltaTTable[Index + 1] - DeltaTTable[Index]) * y);
            }
            else
            if (y <= 2000)
            {
                // This may be completely wrong.
                // I was trying to port from this:
                // int nLookupSize = sizeof(DeltaTTable)/sizeof(double);
                // Delta = DeltaTTable[nLookupSize - 1];

                Delta = DeltaTTable[DeltaTTable.Length - 1];
            }
            else
            if (y < 2100)
            {
                Delta = 102 + (102 * T) + (25.3 * T * T) + 0.37 * (y - 2100);
            }
            else
            {
                Delta = 102 + (102 * T) + (25.3 * T * T);
            }

            return(Delta);
        }
Beispiel #4
0
        public static double DeltaT(double JD)
        {
            //What will be the return value from the method
            double Delta = 0;

            //Determine if we can use the lookup table
            var nLookupElements = g_DeltaTValues.Length;

            if ((JD >= g_DeltaTValues[0].JD) && (JD < g_DeltaTValues[nLookupElements - 1].JD))
            {
                //Find the index in the lookup table which contains the JD value closest to the JD input parameter
                bool bFound      = false;
                var  nFoundIndex = 0;
                while (!bFound)
                {
                    if (!(nFoundIndex < nLookupElements))
                    {
                        throw new Exception("nFoundIndex must be lower than nLookupElements");
                    }
                    bFound = (g_DeltaTValues[nFoundIndex].JD > JD);

                    //Prepare for the next loop
                    if (!bFound)
                    {
                        ++nFoundIndex;
                    }
                    else
                    {
                        //Now do a simple linear interpolation of the DeltaT values from the lookup table
                        Delta = (JD - g_DeltaTValues[nFoundIndex - 1].JD) /
                                (g_DeltaTValues[nFoundIndex].JD - g_DeltaTValues[nFoundIndex - 1].JD) *
                                (g_DeltaTValues[nFoundIndex].DeltaT - g_DeltaTValues[nFoundIndex - 1].DeltaT) +
                                g_DeltaTValues[nFoundIndex - 1].DeltaT;
                    }
                }
            }
            else
            {
                AASDate date = new AASDate(JD, AASDate.AfterPapalReform(JD));
                double  y    = date.FractionalYear;

                //Use the polynomial expressions from Espenak & Meeus 2006. References: http://eclipse.gsfc.nasa.gov/SEcat5/deltatpoly.html and
                //http://www.staff.science.uu.nl/~gent0113/deltat/deltat_old.htm (Espenak & Meeus 2006 section)
                if (y < -500)
                {
                    double u  = (y - 1820) / 100.0;
                    double u2 = u * u;
                    Delta = -20 + (32 * u2);
                }
                else if (y < 500)
                {
                    double u  = y / 100.0;
                    double u2 = u * u;
                    double u3 = u2 * u;
                    double u4 = u3 * u;
                    double u5 = u4 * u;
                    double u6 = u5 * u;
                    Delta = 10583.6 + (-1014.41 * u) + (33.78311 * u2) + (-5.952053 * u3) + (-0.1798452 * u4) +
                            (0.022174192 * u5) + (0.0090316521 * u6);
                }
                else if (y < 1600)
                {
                    double u  = (y - 1000) / 100.0;
                    double u2 = u * u;
                    double u3 = u2 * u;
                    double u4 = u3 * u;
                    double u5 = u4 * u;
                    double u6 = u5 * u;
                    Delta = 1574.2 + (-556.01 * u) + (71.23472 * u2) + (0.319781 * u3) + (-0.8503463 * u4) + (-0.005050998 * u5) +
                            (0.0083572073 * u6);
                }
                else if (y < 1700)
                {
                    double u  = (y - 1600) / 100.0;
                    double u2 = u * u;
                    double u3 = u2 * u;
                    Delta = 120 + (-98.08 * u) + (-153.2 * u2) + (u3 / 0.007129);
                }
                else if (y < 1800)
                {
                    double u  = (y - 1700) / 100.0;
                    double u2 = u * u;
                    double u3 = u2 * u;
                    double u4 = u3 * u;
                    Delta = 8.83 + (16.03 * u) + (-59.285 * u2) + (133.36 * u3) + (-u4 / 0.01174);
                }
                else if (y < 1860)
                {
                    double u  = (y - 1800) / 100.0;
                    double u2 = u * u;
                    double u3 = u2 * u;
                    double u4 = u3 * u;
                    double u5 = u4 * u;
                    double u6 = u5 * u;
                    double u7 = u6 * u;
                    Delta = 13.72 + (-33.2447 * u) + (68.612 * u2) + (4111.6 * u3) + (-37436 * u4) + (121272 * u5) +
                            (-169900 * u6) + (87500 * u7);
                }
                else if (y < 1900)
                {
                    double u  = (y - 1860) / 100.0;
                    double u2 = u * u;
                    double u3 = u2 * u;
                    double u4 = u3 * u;
                    double u5 = u4 * u;
                    Delta = 7.62 + (57.37 * u) + (-2517.54 * u2) + (16806.68 * u3) + (-44736.24 * u4) + (u5 / 0.0000233174);
                }
                else if (y < 1920)
                {
                    double u  = (y - 1900) / 100.0;
                    double u2 = u * u;
                    double u3 = u2 * u;
                    double u4 = u3 * u;
                    Delta = -2.79 + (149.4119 * u) + (-598.939 * u2) + (6196.6 * u3) + (-19700 * u4);
                }
                else if (y < 1941)
                {
                    double u  = (y - 1920) / 100.0;
                    double u2 = u * u;
                    double u3 = u2 * u;
                    Delta = 21.20 + (84.493 * u) + (-761.00 * u2) + (2093.6 * u3);
                }
                else if (y < 1961)
                {
                    double u  = (y - 1950) / 100.0;
                    double u2 = u * u;
                    double u3 = u2 * u;
                    Delta = 29.07 + (40.7 * u) + (-u2 / 0.0233) + (u3 / 0.002547);
                }
                else if (y < 1986)
                {
                    double u  = (y - 1975) / 100.0;
                    double u2 = u * u;
                    double u3 = u2 * u;
                    Delta = 45.45 + 106.7 * u - u2 / 0.026 - u3 / 0.000718;
                }
                //TODO To check. Seems to be unreachable code.
                else if (y < 2005)
                {
                    double u  = (y - 2000) / 100.0;
                    double u2 = u * u;
                    double u3 = u2 * u;
                    double u4 = u3 * u;
                    double u5 = u4 * u;
                    Delta = 63.86 + (33.45 * u) + (-603.74 * u2) + (1727.5 * u3) + (65181.4 * u4) + (237359.9 * u5);
                }
                else if (y < 2050)
                {
                    double u  = (y - 2000) / 100.0;
                    double u2 = u * u;
                    Delta = 62.92 + (32.217 * u) + (55.89 * u2);
                }
                else if (y < 2150)
                {
                    double u  = (y - 1820) / 100.0;
                    double u2 = u * u;
                    Delta = -205.72 + (56.28 * u) + (32 * u2);
                }
                else
                {
                    double u  = (y - 1820) / 100.0;
                    double u2 = u * u;
                    Delta = -20 + (32 * u2);
                }
            }

            return(Delta);
        }