Пример #1
0
        /// <summary>
        /// Gets equatorial coordinates of a star for current epoch
        /// </summary>
        public CrdsEquatorial Equatorial(SkyContext c, ushort hrNumber)
        {
            Star star = Stars.ElementAt(hrNumber - 1);

            PrecessionalElements p = c.Get(GetPrecessionalElements);
            double years           = c.Get(YearsSince2000);

            // Initial coodinates for J2000 epoch
            CrdsEquatorial eq0 = new CrdsEquatorial(star.Equatorial0);

            // Take into account effect of proper motion:
            // now coordinates are for the mean equinox of J2000.0,
            // but for epoch of the target date
            eq0.Alpha += star.PmAlpha * years / 3600.0;
            eq0.Delta += star.PmDelta * years / 3600.0;

            // Equatorial coordinates for the mean equinox and epoch of the target date
            CrdsEquatorial eq = Precession.GetEquatorialCoordinates(eq0, p);

            // Nutation effect
            var eq1 = Nutation.NutationEffect(eq, c.NutationElements, c.Epsilon);

            // Aberration effect
            var eq2 = Aberration.AberrationEffect(eq, c.AberrationElements, c.Epsilon);

            // Apparent coordinates of the star
            eq += eq1 + eq2;

            return(eq);
        }
Пример #2
0
        public override void Calculate(SkyContext context)
        {
            // precessional elements
            var p = Precession.ElementsFK5(Date.EPOCH_J2000, context.JulianDay);

            foreach (var ds in DeepSkies)
            {
                ds.Equatorial = context.Get(Equatorial, ds);
                ds.Horizontal = context.Get(Horizontal, ds);

                if (ds.Outline != null)
                {
                    foreach (var op in ds.Outline)
                    {
                        CrdsEquatorial eq0 = new CrdsEquatorial(op.Equatorial0);

                        // Equatorial coordinates for the mean equinox and epoch of the target date
                        var eq = Precession.GetEquatorialCoordinates(eq0, p);

                        // Nutation effect
                        var eq1 = Nutation.NutationEffect(eq, context.NutationElements, context.Epsilon);

                        // Aberration effect
                        var eq2 = Aberration.AberrationEffect(eq, context.AberrationElements, context.Epsilon);

                        // Apparent coordinates of the object
                        eq += eq1 + eq2;

                        // Apparent horizontal coordinates
                        op.Horizontal = eq.ToHorizontal(context.GeoLocation, context.SiderealTime);
                    }
                }
            }
        }
Пример #3
0
        public void CalculatePlanetApparentPlaceLP()
        {
            double jde = 2448976.5;

            double         tau = 0;
            CrdsEcliptical ecl = null;

            for (int i = 0; i < 2; i++)
            {
                CrdsHeliocentrical hEarth = PlanetPositions.GetPlanetCoordinates(3, jde - tau, highPrecision: false);

                CrdsHeliocentrical hVenus = PlanetPositions.GetPlanetCoordinates(2, jde - tau, highPrecision: false);

                var rect = hVenus.ToRectangular(hEarth);

                ecl = rect.ToEcliptical();

                tau = PlanetPositions.LightTimeEffect(ecl.Distance);
            }

            // Correction for FK5 system
            CrdsEcliptical corr = PlanetPositions.CorrectionForFK5(jde, ecl);

            ecl += corr;
            ecl += Nutation.NutationEffect(16.749 / 3600.0);

            CrdsEquatorial eq = ecl.ToEquatorial(23.439669);

            Assert.AreEqual(new HMS("21h 04m 41.459s"), new HMS(eq.Alpha));
            Assert.AreEqual(new DMS("-18* 53' 16.66''"), new DMS(eq.Delta));
        }
Пример #4
0
        public void HorizontalToEquatorial()
        {
            // Apparent local horizontal coordinates of Venus
            var hor = new CrdsHorizontal(68.0337, 15.1249);

            // Geographical coordinates of US Naval Observatory at Washington, DC
            var geo = new CrdsGeographical(new DMS("+38* 55' 17''"), new DMS("+77* 03' 56''"));

            // Date of observation
            var jd = new Date(new DateTime(1987, 4, 10, 19, 21, 0, DateTimeKind.Utc)).ToJulianDay();

            // Nutation elements
            var nutation = Nutation.NutationElements(jd);

            // True obliquity
            var epsilon = Date.TrueObliquity(jd, nutation.deltaEpsilon);

            // Apparent sidereal time at Greenwich
            var theta0 = Date.ApparentSiderealTime(jd, nutation.deltaPsi, epsilon);

            Assert.AreEqual(new HMS("8h 34m 56.853s"), new HMS(theta0));

            // Expected apparent equatorial coordinates of Venus
            var eqExpected = new CrdsEquatorial(new HMS("23h 09m 16.641s"), new DMS("-6* 43' 11.61''"));

            // Tested value
            var eqActual = hor.ToEquatorial(geo, theta0);

            Assert.AreEqual(eqExpected.Alpha, eqActual.Alpha, errorInHMS);
            Assert.AreEqual(eqExpected.Delta, eqActual.Delta, errorInDMS);
        }
Пример #5
0
        public void GetSolarCoordinatesLP()
        {
            double jde = 2448908.5;

            // get Earth coordinates
            CrdsHeliocentrical crds = PlanetPositions.GetPlanetCoordinates(Planet.Earth, jde, highPrecision: false);

            Assert.AreEqual(19.907372, crds.L, 1e-6);
            Assert.AreEqual(-0.644, crds.B * 3600, 1e-3);
            Assert.AreEqual(0.99760775, crds.R, 1e-8);

            // transform to ecliptical coordinates of the Sun
            CrdsEcliptical ecl = new CrdsEcliptical(Angle.To360(crds.L + 180), -crds.B, crds.R);

            // get FK5 system correction
            CrdsEcliptical corr = PlanetPositions.CorrectionForFK5(jde, ecl);

            Assert.AreEqual(-0.09033, corr.Lambda * 3600, 1e-5);
            Assert.AreEqual(-0.023, corr.Beta * 3600, 1e-3);

            // correct solar coordinates to FK5 system
            ecl += corr;

            Assert.AreEqual(199.907347, ecl.Lambda, 1e-6);
            Assert.AreEqual(0.62, ecl.Beta * 3600, 1e-2);
            Assert.AreEqual(0.99760775, ecl.Distance, 1e-8);

            var nutation = Nutation.NutationElements(jde);

            // True obliquity
            double epsilon = Date.TrueObliquity(jde, nutation.deltaEpsilon);

            // accuracy is 0.5"
            Assert.AreEqual(15.908, nutation.deltaPsi * 3600, 0.5);

            // accuracyis 0.1"
            Assert.AreEqual(-0.308, nutation.deltaEpsilon * 3600, 0.1);

            // accuracy is 0.1"
            Assert.AreEqual(23.4401443, epsilon, 0.1 / 3600.0);

            // add nutation effect
            ecl += Nutation.NutationEffect(nutation.deltaPsi);

            // calculate aberration effect
            CrdsEcliptical aberration = Aberration.AberrationEffect(ecl.Distance);

            Assert.AreEqual(-20.539, aberration.Lambda * 3600.0, 1e-3);

            // add aberration effect
            ecl += aberration;

            // convert ecliptical to equatorial coordinates
            CrdsEquatorial eq = ecl.ToEquatorial(epsilon);

            // check apparent equatorial coordinates
            // assume an accuracy of 0.5'' is sufficient
            Assert.AreEqual(198.378178, eq.Alpha, 1.0 / 3600 * 0.5);
            Assert.AreEqual(-7.783871, eq.Delta, 1.0 / 3600 * 0.5);
        }
Пример #6
0
        public void GetCoordinates()
        {
            double jd = 2448724.5;

            // geocentrical coordinates
            CrdsEcliptical ecl = LunarMotion.GetCoordinates(jd);

            Assert.AreEqual(133.162655, ecl.Lambda, 1e-6);
            Assert.AreEqual(-3.229126, ecl.Beta, 1e-6);
            Assert.AreEqual(368409.7, ecl.Distance, 1e-1);

            // get nutation elements
            var nutation = Nutation.NutationElements(jd);

            // apparent geocentrical ecliptical coordinates
            ecl += Nutation.NutationEffect(nutation.deltaPsi);

            // true obliquity of the Earth orbit
            double epsilon = Date.TrueObliquity(jd, nutation.deltaEpsilon);

            // equatorial geocentrical coordinates
            CrdsEquatorial eq = ecl.ToEquatorial(epsilon);

            // Max error in Right Ascention is 0.1" of time
            double errAlpha = new HMS("0h 0m 00.1s").ToDecimalAngle();

            // Max error in Declination is 1" of arc
            double errDelta = new DMS("0* 0' 01''").ToDecimalAngle();

            Assert.AreEqual(new HMS("8h 58m 45.2s").ToDecimalAngle(), eq.Alpha, errAlpha);
            Assert.AreEqual(new DMS("+13* 46' 06''").ToDecimalAngle(), eq.Delta, errDelta);
        }
Пример #7
0
        public void EquatorialToHorizontal()
        {
            // Apparent equatorial coordinates of Venus
            var eq = new CrdsEquatorial(new HMS("23h 09m 16.641s"), new DMS("-6* 43' 11.61''"));

            // Geographical coordinates of US Naval Observatory at Washington, DC
            var geo = new CrdsGeographical(new DMS("+38* 55' 17''"), new DMS("+77* 03' 56''"));

            // Date of observation
            var jd = new Date(new DateTime(1987, 4, 10, 19, 21, 0, DateTimeKind.Utc)).ToJulianDay();

            // Mean sidereal time at Greenwich
            var theta0 = Date.MeanSiderealTime(jd);

            Assert.AreEqual(new HMS("8h 34m 57.0896s"), new HMS(theta0));

            // Nutation elements
            var nutation = Nutation.NutationElements(jd);

            // True obliquity
            var epsilon = Date.TrueObliquity(jd, nutation.deltaEpsilon);

            // Apparent sidereal time at Greenwich
            theta0 = Date.ApparentSiderealTime(jd, nutation.deltaPsi, epsilon);
            Assert.AreEqual(new HMS("8h 34m 56.853s"), new HMS(theta0));

            // Expected local horizontal coordinates of Venus
            var hor = eq.ToHorizontal(geo, theta0);

            Assert.AreEqual(15.1249, hor.Altitude, 1e-4);
            Assert.AreEqual(68.0336, hor.Azimuth, 1e-4);
        }
Пример #8
0
        public void NutationElements()
        {
            var nutation = Nutation.NutationElements(jd);

            var deltaPsi     = nutation.deltaPsi * 3600;
            var deltaEpsilon = nutation.deltaEpsilon * 3600;

            Assert.AreEqual(-3.788, deltaPsi, 0.5);
            Assert.AreEqual(9.443, deltaEpsilon, 0.1);
        }
Пример #9
0
        /// <summary>
        /// Gets apparent geocentrical ecliptical coordinates of the Moon
        /// </summary>
        private CrdsEcliptical Ecliptical0(SkyContext c)
        {
            // geocentrical coordinates of the Moon
            CrdsEcliptical ecliptical0 = LunarMotion.GetCoordinates(c.JulianDay);

            // apparent geocentrical ecliptical coordinates
            ecliptical0 += Nutation.NutationEffect(c.NutationElements.deltaPsi);

            return(ecliptical0);
        }
Пример #10
0
        public static double ApparentEclipticLongitude(double julianDate, bool highPrecision)
        {
            var longitude = ConvertLongitudeToFK5(julianDate, highPrecision)
                            + CoordinateTransformation.SetDMSToDegrees(0, 0, Nutation.NutationInLongitude(julianDate));

            var radius = Earth.GetSunRadiusVector(julianDate);

            return((highPrecision)
                ? longitude - (0.005775518 * radius * CoordinateTransformation.SetDMSToDegrees(0, 0, GetVariationEclipticLongitude(julianDate)))
                : longitude - CoordinateTransformation.SetDMSToDegrees(0, 0, 20.4898 / radius));
        }
Пример #11
0
        private CrdsEcliptical UranusMoon_Ecliptical(SkyContext c, int m)
        {
            var ecliptical = c.Get(UranusMoons_Positions)[m - 1].ToEcliptical();

            // Correction for FK5 system
            ecliptical += PlanetPositions.CorrectionForFK5(c.JulianDay, ecliptical);

            // Take nutation into account
            ecliptical += Nutation.NutationEffect(c.NutationElements.deltaPsi);

            return(ecliptical);
        }
Пример #12
0
        /// <summary>
        /// Gets ecliptical coordinates of Sun
        /// </summary>
        public CrdsEcliptical Sun_Ecliptical(SkyContext c)
        {
            CrdsHeliocentrical hEarth = c.Get(Earth_Heliocentrial);
            var sunEcliptical         = new CrdsEcliptical(Angle.To360(hEarth.L + 180), -hEarth.B, hEarth.R);

            // Corrected solar coordinates to FK5 system
            sunEcliptical += PlanetPositions.CorrectionForFK5(c.JulianDay, sunEcliptical);

            // Add nutation effect to ecliptical coordinates of the Sun
            sunEcliptical += Nutation.NutationEffect(c.NutationElements.deltaPsi);

            // Add aberration effect, so we have an final ecliptical coordinates of the Sun
            sunEcliptical += Aberration.AberrationEffect(sunEcliptical.Distance);

            return(sunEcliptical);
        }
Пример #13
0
        public void NutationEffect()
        {
            CrdsEquatorial eq = new CrdsEquatorial(41.5472, 49.3485);

            NutationElements ne = new NutationElements()
            {
                deltaPsi     = 14.861 / 3600,
                deltaEpsilon = 2.705 / 3600
            };

            double epsilon = 23.436;

            CrdsEquatorial correction = Nutation.NutationEffect(eq, ne, epsilon);

            Assert.AreEqual(15.843, correction.Alpha * 3600, 1e-3);
            Assert.AreEqual(6.218, correction.Delta * 3600, 1e-3);
        }
Пример #14
0
        public void TestEquinox()
        {
            JulianDate jd  = new JulianDate(new DateTime(2003, 1, 1));
            Nutation   nut = new Nutation(jd);

            Assert.That(nut.EquationOfEquinox, Is.EqualTo(-0.9381).Within(0.00005));
            Assert.That(nut.DeltaPsi, Is.EqualTo(-15.340).Within(0.0005));
            Assert.That(nut.DeltaEpsilon, Is.EqualTo(3.024).Within(0.0005));
            Assert.That(nut.Epsilon.Seconds, Is.EqualTo(23.068));

            jd  = new JulianDate(new DateTime(2003, 2, 1));
            nut = new Nutation(jd);

            Assert.That(nut.EquationOfEquinox, Is.EqualTo(-0.8444).Within(0.00005));
            Assert.That(nut.DeltaPsi, Is.EqualTo(-13.808).Within(0.0005));
            Assert.That(nut.DeltaEpsilon, Is.EqualTo(3.782).Within(0.0005));
            //Assert.That(nut.Epsilon, Is.EqualTo(Angle.FromDegrees(23, 26, 23.068)));
        }
Пример #15
0
        /// <summary>
        /// Gets equatorial coordinates of deep sky object for current epoch
        /// </summary>
        private CrdsEquatorial Equatorial(SkyContext c, DeepSky ds)
        {
            PrecessionalElements p = c.Get(GetPrecessionalElements);

            // Equatorial coordinates for the mean equinox and epoch of the target date
            CrdsEquatorial eq = Precession.GetEquatorialCoordinates(ds.Equatorial0, p);

            // Nutation effect
            var eq1 = Nutation.NutationEffect(eq, c.NutationElements, c.Epsilon);

            // Aberration effect
            var eq2 = Aberration.AberrationEffect(eq, c.AberrationElements, c.Epsilon);

            // Apparent coordinates of the object
            eq += eq1 + eq2;

            return(eq);
        }
Пример #16
0
        public void CalculatePlanetApparentPlaceHP()
        {
            double jde = 2448976.5;

            // time taken by the light to reach the Earth
            double tau = 0;

            // previous value of tau to calculate the difference
            double tau0 = 1;

            // final difference to stop iteration process, 1 second of time
            double deltaTau = TimeSpan.FromSeconds(1).TotalDays;

            // Ecliptical coordinates of Venus
            CrdsEcliptical ecl = null;

            // Iterative process to find ecliptical coordinates of Venus
            while (Math.Abs(tau - tau0) > deltaTau)
            {
                // Heliocentrical coordinates of Earth
                var hEarth = PlanetPositions.GetPlanetCoordinates(3, jde - tau, highPrecision: true);

                // Heliocentrical coordinates of Venus
                var hVenus = PlanetPositions.GetPlanetCoordinates(2, jde - tau, highPrecision: true);

                // Ecliptical coordinates of Venus
                ecl = hVenus.ToRectangular(hEarth).ToEcliptical();

                tau0 = tau;
                tau  = PlanetPositions.LightTimeEffect(ecl.Distance);
            }

            // Correction for FK5 system
            ecl += PlanetPositions.CorrectionForFK5(jde, ecl);

            // Take nutation into account
            ecl += Nutation.NutationEffect(16.749 / 3600.0);

            // Apparent equatorial coordinates of Venus
            CrdsEquatorial eq = ecl.ToEquatorial(23.439669);

            Assert.AreEqual(new HMS("21h 04m 41.454s"), new HMS(eq.Alpha));
            Assert.AreEqual(new DMS("-18* 53' 16.84''"), new DMS(eq.Delta));
        }
Пример #17
0
        /// <summary>
        /// Gets ecliptical coordinates of planet
        /// </summary>
        public CrdsEcliptical Planet_Ecliptical(SkyContext c, int p)
        {
            // Heliocentrical coordinates of planet
            CrdsHeliocentrical heliocentrical = c.Get(Planet_Heliocentrical, p);

            // Heliocentrical coordinates of Earth
            CrdsHeliocentrical hEarth = c.Get(Earth_Heliocentrial);

            // Ecliptical coordinates of planet
            var ecliptical = heliocentrical.ToRectangular(hEarth).ToEcliptical();

            // Correction for FK5 system
            ecliptical += PlanetPositions.CorrectionForFK5(c.JulianDay, ecliptical);

            // Take nutation into account
            ecliptical += Nutation.NutationEffect(c.NutationElements.deltaPsi);

            return(ecliptical);
        }
Пример #18
0
        /// <summary>
        /// Gets apparent geocentrical ecliptical coordinates of the Sun
        /// </summary>
        private CrdsEcliptical SunEcliptical(SkyContext c)
        {
            // get Earth coordinates
            CrdsHeliocentrical hEarth = c.Get(EarthHeliocentrical);

            // transform to ecliptical coordinates of the Sun
            CrdsEcliptical sunEcliptical = new CrdsEcliptical(Angle.To360(hEarth.L + 180), -hEarth.B, hEarth.R);

            // correct solar coordinates to FK5 system
            sunEcliptical += PlanetPositions.CorrectionForFK5(c.JulianDay, sunEcliptical);

            // add nutation effect to ecliptical coordinates of the Sun
            sunEcliptical += Nutation.NutationEffect(c.NutationElements.deltaPsi);

            // add aberration effect, so we have an final ecliptical coordinates of the Sun
            sunEcliptical += Aberration.AberrationEffect(sunEcliptical.Distance);

            return(sunEcliptical);
        }
Пример #19
0
        /// <summary>
        /// Gets equatorial geocentrical coordinates for current epoch
        /// </summary>
        protected CrdsEquatorial EquatorialG(SkyContext c, T body)
        {
            // Precessinal elements to convert between epochs
            var pe = c.Get(GetPrecessionalElements);

            // Equatorial geocentrical coordinates for J2000 epoch
            var eq0 = c.Get(EquatorialJ2000, body);

            // Equatorial coordinates for the mean equinox and epoch of the target date
            CrdsEquatorial eq = Precession.GetEquatorialCoordinates(eq0, pe);

            // Nutation effect
            var eq1 = Nutation.NutationEffect(eq, c.NutationElements, c.Epsilon);

            // Aberration effect
            var eq2 = Aberration.AberrationEffect(eq, c.AberrationElements, c.Epsilon);

            // Apparent coordinates of the object
            eq += eq1 + eq2;

            return(eq);
        }
Пример #20
0
        /// <summary>
        /// Gets equatorial coordinates of a star for current epoch
        /// </summary>
        public CrdsEquatorial Equatorial(SkyContext c, Nova n)
        {
            PrecessionalElements p = c.Get(GetPrecessionalElements);
            double years           = c.Get(YearsSince2000);

            // Initial coodinates for J2000 epoch
            CrdsEquatorial eq0 = new CrdsEquatorial(n.Equatorial0);

            // Equatorial coordinates for the mean equinox and epoch of the target date
            CrdsEquatorial eq = Precession.GetEquatorialCoordinates(eq0, p);

            // Nutation effect
            var eq1 = Nutation.NutationEffect(eq, c.NutationElements, c.Epsilon);

            // Aberration effect
            var eq2 = Aberration.AberrationEffect(eq, c.AberrationElements, c.Epsilon);

            // Apparent coordinates of the star
            eq += eq1 + eq2;

            return(eq);
        }
Пример #21
0
        public CrdsEcliptical Ecliptical(SkyContext c)
        {
            // get Earth coordinates
            CrdsHeliocentrical crds = PlanetPositions.GetPlanetCoordinates(Planet.EARTH, c.JulianDay, highPrecision: true);

            // transform to ecliptical coordinates of the Sun
            var ecl = new CrdsEcliptical(Angle.To360(crds.L + 180), -crds.B, crds.R);

            // get FK5 system correction
            CrdsEcliptical corr = PlanetPositions.CorrectionForFK5(c.JulianDay, ecl);

            // correct solar coordinates to FK5 system
            ecl += corr;

            // add nutation effect
            ecl += Nutation.NutationEffect(c.NutationElements.deltaPsi);

            // add aberration effect
            ecl += Aberration.AberrationEffect(ecl.Distance);

            return(ecl);
        }
Пример #22
0
        public void GetSolarCoordinatesLP()
        {
            double jde = 2448908.5;

            // get Earth coordinates
            CrdsHeliocentrical crds = PlanetPositions.GetPlanetCoordinates(3, jde, highPrecision: false);

            // transform to ecliptical coordinates of the Sun
            CrdsEcliptical ecl = new CrdsEcliptical(Angle.To360(crds.L + 180), -crds.B, crds.R);

            // get FK5 system correction
            CrdsEcliptical corr = PlanetPositions.CorrectionForFK5(jde, ecl);

            // correct solar coordinates to FK5 system
            ecl += corr;

            var nutation = Nutation.NutationElements(jde);

            // True obliquity
            double epsilon = Date.TrueObliquity(jde, nutation.deltaEpsilon);

            // add nutation effect
            ecl += Nutation.NutationEffect(nutation.deltaPsi);

            // calculate aberration effect
            CrdsEcliptical aberration = Aberration.AberrationEffect(ecl.Distance);

            // add aberration effect
            ecl += aberration;

            // convert ecliptical to equatorial coordinates
            CrdsEquatorial eq = ecl.ToEquatorial(epsilon);

            // check apparent equatorial coordinates
            // assume an accuracy of 0.5'' is sufficient
            Assert.AreEqual(198.378178, eq.Alpha, 1.0 / 3600 * 0.5);
            Assert.AreEqual(-7.783871, eq.Delta, 1.0 / 3600 * 0.5);
        }
Пример #23
0
        /// <summary>
        /// Gets equatorial coordinates of a star for current epoch
        /// </summary>
        private CrdsEquatorial Equatorial(SkyContext context, Tycho2Star star)
        {
            PrecessionalElements p = context.Get(PrecessionalElements);
            double years           = context.Get(YearsSince2000);

            // Take into account effect of proper motion:
            // now coordinates are for the mean equinox of J2000.0,
            // but for epoch of the target date
            var eq0 = star.Equatorial0 + new CrdsEquatorial(star.PmRA * years / 3600000, star.PmDec * years / 3600000);

            // Equatorial coordinates for the mean equinox and epoch of the target date
            CrdsEquatorial eq = Precession.GetEquatorialCoordinates(eq0, p);

            // Nutation effect
            var eqN = Nutation.NutationEffect(eq, context.NutationElements, context.Epsilon);

            // Aberration effect
            var eqA = Aberration.AberrationEffect(eq, context.AberrationElements, context.Epsilon);

            // Apparent coordinates of the star
            eq += eqN + eqA;

            return(eq);
        }
Пример #24
0
        public void Positions()
        {
            // Test data is obtained from NASA JPL Ephemeris tool
            // https://ssd.jpl.nasa.gov/horizons.cgi

            List <TestData> testDatas = new List <TestData>()
            {
                // Triton
                // 2020-Jan-07 13:00 2458856.041666667    -0.964   12.797
                new TestData()
                {
                    MoonNumber = 1,
                    Neptune    = new CrdsEcliptical(new DMS("346* 24' 16.12''"), new DMS("-1* 01' 26.26''"), 30.416),
                    JulianDay  = 2458856.041666667,
                    X          = -0.964,
                    Y          = 12.797
                },

                // Triton
                // 2025-Jan-22 19:00 2460698.291666667        1.086  -12.382
                new TestData()
                {
                    MoonNumber = 1,
                    Neptune    = new CrdsEcliptical(new DMS("357° 43' 31.73''"), new DMS("-1° 16' 24.69''"), 30.416),
                    JulianDay  = 2460698.291666667,
                    X          = 1.086,
                    Y          = -12.382
                },

                // Nereid
                // 2020-Feb-27 00:00 2458906.500000000        5.124   10.556
                new TestData()
                {
                    MoonNumber = 2,
                    Neptune    = new CrdsEcliptical(new DMS("348* 00' 11.97''"), new DMS("-1* 00' 54.27''"), 30.906),
                    JulianDay  = 2458906.5,
                    X          = 5.124,
                    Y          = 10.556
                },

                // Nereid
                // 2020-Jul-13 00:00 2459043.500000000      384.491  206.269
                new TestData()
                {
                    MoonNumber = 2,
                    Neptune    = new CrdsEcliptical(new DMS("350* 51' 10.8''"), new DMS("-1* 05' 15.56''"), 29.405),
                    JulianDay  = 2459043.5,
                    X          = 384.491,
                    Y          = 206.269
                },

                // Nereid
                // 1980-Jan-01 00:00 2444239.500000000      135.407   32.771
                new TestData()
                {
                    MoonNumber = 2,
                    Neptune    = new CrdsEcliptical(new DMS("260* 55' 41.93''"), new DMS("+1* 20' 26.28''"), 31.209),
                    JulianDay  = 2444239.5,
                    X          = 135.407,
                    Y          = 32.771
                }
            };

            // possible error in coordinates is 1 arcsecond
            const double error = 1;

            foreach (var testData in testDatas)
            {
                NutationElements ne           = Nutation.NutationElements(testData.JulianDay);
                double           epsilon      = Date.TrueObliquity(testData.JulianDay, ne.deltaEpsilon);
                CrdsEcliptical   eclSatellite = NeptunianMoons.Position(testData.JulianDay, testData.Neptune, testData.MoonNumber);

                CrdsEquatorial eqNeptune   = testData.Neptune.ToEquatorial(epsilon);
                CrdsEquatorial eqSatellite = eclSatellite.ToEquatorial(epsilon);

                double X = (eqSatellite.Alpha - eqNeptune.Alpha) * Math.Cos(Angle.ToRadians(eqNeptune.Delta)) * 3600;
                double Y = (eqSatellite.Delta - eqNeptune.Delta) * 3600;

                Assert.AreEqual(testData.X, X, error);
                Assert.AreEqual(testData.Y, Y, error);
            }
        }
Пример #25
0
        public void Noumenia()
        {
            // Example are taken from
            // http://www.makkahcalendar.org/en/islamicCalendarArticle4.php

            // IX.4 Example of Makkah
            {
                // 17 Nov 2009, "best time" is 14:48 UTC
                double jd = new Date(new DateTime(2009, 11, 17, 14, 48, 0, DateTimeKind.Utc)).ToJulianEphemerisDay();

                // Nutation elements
                var nutation = Nutation.NutationElements(jd);

                // True obliquity
                var epsilon = Date.TrueObliquity(jd, nutation.deltaEpsilon);

                // Sidereal time at Greenwich
                double siderealTime = Date.ApparentSiderealTime(jd, nutation.deltaPsi, epsilon);

                // Ecliptical coordinates of the Sun, taken from the example (see ref.)
                CrdsEcliptical eclSun = new CrdsEcliptical(235.39, 0);

                // Ecliptical coordinates of the Moon, taken from the example (see ref.)
                CrdsEcliptical eclMoon = new CrdsEcliptical(245.01, -3.76);

                // Geograhical coordinates of Makkah
                CrdsGeographical geo = new CrdsGeographical(-39.82563, 21.42664);

                double q = LunarEphem.CrescentQ(eclMoon, eclSun, 0.2539 * 3600, epsilon, siderealTime, geo);

                Assert.AreEqual(-0.465, q, 0.001);
            }

            // IX.5 Example of intermediate horizon 30°W, 30°S at 21:04
            {
                // 17 Nov 2009, 21:04 UTC
                double jd = new Date(new DateTime(2009, 11, 17, 21, 04, 0, DateTimeKind.Utc)).ToJulianEphemerisDay();

                // Nutation elements
                var nutation = Nutation.NutationElements(jd);

                // True obliquity
                var epsilon = Date.TrueObliquity(jd, nutation.deltaEpsilon);

                // Sidereal time at Greenwich
                double siderealTime = Date.ApparentSiderealTime(jd, nutation.deltaPsi, epsilon);

                // Ecliptical coordinates of the Sun, taken from the example (see ref.)
                CrdsEcliptical eclSun = new CrdsEcliptical(235.65, 0);

                // Ecliptical coordinates of the Moon, taken from the example (see ref.)
                CrdsEcliptical eclMoon = new CrdsEcliptical(248.32, -3.55);

                // Geograhical coordinates of Makkah
                CrdsGeographical geo = new CrdsGeographical(30, -30);

                double q = LunarEphem.CrescentQ(eclMoon, eclSun, 0.2536 * 3600, epsilon, siderealTime, geo);

                Assert.AreEqual(0.367, q, 0.001);
            }
        }
Пример #26
0
        private void DoTest(CrdsGeographical location, OrbitalElements oe, string testData, double errorR, double errorEq)
        {
            Regex regex = new Regex("^(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+ \\S+ \\S+) (\\S+ \\S+ \\S+)$");

            string[] lines = testData.Split('\n');
            foreach (string line in lines)
            {
                string dataLine = line.Trim();
                if (!string.IsNullOrEmpty(dataLine))
                {
                    var    match = regex.Match(dataLine);
                    double jd    = double.Parse(match.Groups[1].Value, CultureInfo.InvariantCulture);
                    double X     = double.Parse(match.Groups[2].Value, CultureInfo.InvariantCulture);
                    double Y     = double.Parse(match.Groups[3].Value, CultureInfo.InvariantCulture);
                    double Z     = double.Parse(match.Groups[4].Value, CultureInfo.InvariantCulture);
                    string ra    = match.Groups[5].Value;
                    string dec   = match.Groups[6].Value;

                    var eqTest = new CrdsEquatorial(new HMS(ra), new DMS(dec));

                    var nutation = Nutation.NutationElements(jd);

                    var aberration = Aberration.AberrationElements(jd);

                    // True obliquity
                    double epsilon = Date.TrueObliquity(jd, nutation.deltaEpsilon);

                    // final difference to stop iteration process, 1 second of time
                    double deltaTau = TimeSpan.FromSeconds(1).TotalDays;

                    // time taken by the light to reach the Earth
                    double tau = 0;

                    // previous value of tau to calculate the difference
                    double tau0 = 1;

                    // Rectangular coordinates of minor body
                    CrdsRectangular r = null;

                    // Rectangular coordinates of the Sun
                    var sun = SunRectangular(jd, epsilon);

                    // Distance to the Earth
                    double Delta = 0;

                    // Iterative process to find rectangular coordinates of minor body
                    while (Math.Abs(tau - tau0) > deltaTau)
                    {
                        // Rectangular coordinates of minor body
                        r = MinorBodyPositions.GetRectangularCoordinates(oe, jd - tau, epsilon);

                        double ksi  = sun.X + r.X;
                        double eta  = sun.Y + r.Y;
                        double zeta = sun.Z + r.Z;

                        // Distance to the Earth
                        Delta = Math.Sqrt(ksi * ksi + eta * eta + zeta * zeta);

                        tau0 = tau;
                        tau  = PlanetPositions.LightTimeEffect(Delta);
                    }

                    // Test heliocentric rectangular coordinates
                    Assert.AreEqual(X, r.X, errorR);
                    Assert.AreEqual(Y, r.Y, errorR);
                    Assert.AreEqual(Z, r.Z, errorR);

                    double x = sun.X + r.X;
                    double y = sun.Y + r.Y;
                    double z = sun.Z + r.Z;

                    double alpha = Angle.ToDegrees(Math.Atan2(y, x));
                    double delta = Angle.ToDegrees(Math.Asin(z / Delta));

                    var eq0 = new CrdsEquatorial(alpha, delta);

                    var theta0 = Date.ApparentSiderealTime(jd, nutation.deltaPsi, epsilon);

                    var parallax = PlanetEphem.Parallax(Delta);

                    var eq = eq0.ToTopocentric(location, theta0, parallax);

                    // Test equatorial coordinates
                    Assert.AreEqual(eqTest.Alpha, eq.Alpha, errorEq / 3600.0);
                    Assert.AreEqual(eqTest.Delta, eq.Delta, errorEq / 3600.0);
                }
            }
        }