Ejemplo n.º 1
0
        public void Test_CalculateSolarPosition_TooHighDeltaT_ShouldThrowException()
        {
            var data = new SunData(
                observationTime: new DateTime(2003, 10, 17, 12, 30, 30),
                timezone: -7,
                deltaUT1: 0,
                deltaT: 67000,
                latitude: 39.742476,
                longitude: -105.1786,
                elevation: 1830.14,
                temperature: 11,
                pressure: 820,
                refraction: null);

            SunPositionCalculator.CalculateSunPosition(data);
        }
Ejemplo n.º 2
0
        public void Test_PartOfDayChecker_ForFullDay_ShouldReturnCorrectResults()
        {
            for (DateTime observationTime = new DateTime(2016, 6, 28); observationTime <= new DateTime(2016, 6, 29); observationTime = observationTime.AddMinutes(10))
            {
                var data = new SunData(
                    observationTime: observationTime,
                    timezone: 3,
                    deltaUT1: 0,
                    deltaT: 67,
                    latitude: 42.72275253,
                    longitude: 23.2992956,
                    elevation: 540,
                    temperature: 10,
                    pressure: 940,
                    refraction: null);

                SunPositionCalculator.CalculateSunPosition(data);
                var zenithAngle         = data.TopocentricZenithAngle;
                var azimuth             = data.AstronomicalTopocentricAzimuth;
                var twilightZenithAngle = 90 + PartOfDayChecker.TwilightElevation;

                var partOfDay = PartOfDayChecker.GetPartOfDay(observationTime, new TimeSpan(3, 0, 0), 42.72275253, 23.2992956);

                // Sanity checks
                Assert.IsTrue(zenithAngle >= 0 && zenithAngle <= 180);
                Assert.IsTrue(azimuth >= 0 && azimuth <= 360);

                if (partOfDay == PartOfDay.Night)
                {
                    Assert.IsTrue(zenithAngle >= twilightZenithAngle);
                }
                else if (partOfDay == PartOfDay.Dawn)
                {
                    Assert.IsTrue(zenithAngle > 90 && zenithAngle < twilightZenithAngle);
                    Assert.IsTrue(azimuth > 180);
                }
                else if (partOfDay == PartOfDay.Day)
                {
                    Assert.IsTrue(zenithAngle < 90);
                }
                else if (partOfDay == PartOfDay.Dusk)
                {
                    Assert.IsTrue(zenithAngle > 90 && zenithAngle < twilightZenithAngle);
                    Assert.IsTrue(azimuth <= 180);
                }
            }
        }
Ejemplo n.º 3
0
        public void Test_CalculateSolarPosition_ShouldCalculateIntermediateValuesCorrectly()
        {
            var data = new SunData(
                observationTime: new DateTime(2003, 10, 17, 12, 30, 30),
                timezone: -7,
                deltaUT1: 0,
                deltaT: 67,
                latitude: 39.742476,
                longitude: -105.1786,
                elevation: 1830.14,
                temperature: 11,
                pressure: 820,
                refraction: null);

            SunPositionCalculator.CalculateSunPosition(data);

            Assert.AreEqual(data.JulianDay, 2452930.312847, 5e-7);

            Assert.AreEqual(data.EarthHeliocentricLongitude, 24.0182616917, DefaultAccuracy);
            Assert.AreEqual(data.EarthHeliocentricLatitude, -0.0001011219, DefaultAccuracy);
            Assert.AreEqual(data.EarthRadiusVector, 0.9965422974, DefaultAccuracy);

            Assert.AreEqual(data.GeocentricLongitude, 204.0182616917, DefaultAccuracy);
            Assert.AreEqual(data.GeocentricLatitude, 0.0001011219, DefaultAccuracy);

            Assert.AreEqual(data.LongitudeNutation, -0.00399840, 5e-9);
            Assert.AreEqual(data.ObliquityNutation, 0.00166657, 5e-9);

            Assert.AreEqual(data.TrueEclipticObliquity, 23.440465, 5e-7);

            Assert.AreEqual(data.ApparentSunLongitude, 204.0085519281, DefaultAccuracy);

            Assert.AreEqual(data.SunRightAscension, 202.22741, 5e-6);
            Assert.AreEqual(data.SunDeclination, -9.31434, 5e-6);

            Assert.AreEqual(data.ObserverHourAngle, 11.105900, 5e-5);
            Assert.AreEqual(data.TopocentricLocalHourAngle, 11.10629, 5e-5);

            Assert.AreEqual(data.TopocentricSunRightAscension, 202.22704, 5e-6);
            Assert.AreEqual(data.TopocentricSunDeclination, -9.316179, 5e-7);

            Assert.AreEqual(data.TopocentricZenithAngle, 50.11162, 5e-6);
            Assert.AreEqual(data.TopocentricAzimuth, 194.34024, 5e-6);
        }
Ejemplo n.º 4
0
        public void Test_CalculateSolarPosition_NEQuadrantDawn()
        {
            // Moscow
            var data = new SunData(
                observationTime: new DateTime(2016, 6, 10, 3, 0, 0),
                timezone: 4,
                deltaUT1: 0,
                deltaT: 67,
                latitude: 55.7558,
                longitude: 37.6173,
                elevation: 151,
                temperature: 5.8,
                pressure: 1013.25,
                refraction: null);

            SunPositionCalculator.CalculateSunPosition(data);

            Assert.AreEqual(data.TopocentricZenithAngle, 98.879283, 5e-6);
            Assert.AreEqual(data.TopocentricAzimuth, 21.124674, 5e-5);
        }
Ejemplo n.º 5
0
        public void Test_CalculateSolarPosition_SouthernCircumpolarRegion()
        {
            // Antarctica
            var data = new SunData(
                observationTime: new DateTime(2016, 6, 10, 12, 30, 0),
                timezone: 8,
                deltaUT1: 0,
                deltaT: 67,
                latitude: -76.566667,
                longitude: 110.2,
                elevation: 2500,
                temperature: -45,
                pressure: 1013.25,
                refraction: null);

            SunPositionCalculator.CalculateSunPosition(data);

            Assert.AreEqual(data.TopocentricZenithAngle, 99.615244, 5e-6);
            Assert.AreEqual(data.TopocentricAzimuth, 2.023090, 5e-5);
        }
Ejemplo n.º 6
0
        public void Test_CalculateSolarPosition_NorthernCircumpolarRegion()
        {
            // Longyearbyen
            var data = new SunData(
                observationTime: new DateTime(2016, 6, 10, 12, 30, 0),
                timezone: 1,
                deltaUT1: 0,
                deltaT: 67,
                latitude: 78.2232,
                longitude: 15.6267,
                elevation: 100,
                temperature: -5.8,
                pressure: 1013.25,
                refraction: null);

            SunPositionCalculator.CalculateSunPosition(data);

            Assert.AreEqual(data.TopocentricZenithAngle, 55.276166, 5e-6);
            Assert.AreEqual(data.TopocentricAzimuth, 189.234844, 5e-5);
        }
Ejemplo n.º 7
0
        public void Test_CalculateSolarPosition_SWQuadrant()
        {
            // Sao Paulo
            var data = new SunData(
                observationTime: new DateTime(2016, 6, 10, 12, 30, 0),
                timezone: -3,
                deltaUT1: 0,
                deltaT: 67,
                latitude: -23.5505,
                longitude: -46.6333,
                elevation: 760,
                temperature: 22.5,
                pressure: 1013.25,
                refraction: null);

            SunPositionCalculator.CalculateSunPosition(data);

            Assert.AreEqual(data.TopocentricZenithAngle, 46.965500, 5e-6);
            Assert.AreEqual(data.TopocentricAzimuth, 352.472097, 5e-5);
        }
Ejemplo n.º 8
0
        public void Test_CalculateSolarPosition_SEQuadrant()
        {
            // Perth
            var data = new SunData(
                observationTime: new DateTime(2016, 6, 10, 12, 30, 0),
                timezone: 8,
                deltaUT1: 0,
                deltaT: 67,
                latitude: -31.9505,
                longitude: 115.8605,
                elevation: 31.5,
                temperature: 17.8,
                pressure: 1013.25,
                refraction: null);

            SunPositionCalculator.CalculateSunPosition(data);

            Assert.AreEqual(data.TopocentricZenithAngle, 55.067639, 5e-6);
            Assert.AreEqual(data.TopocentricAzimuth, 356.079664, 5e-5);
        }
Ejemplo n.º 9
0
        public void Test_CalculateSolarPosition_NWQuadrant()
        {
            // Chicago
            var data = new SunData(
                observationTime: new DateTime(2016, 6, 10, 12, 30, 0),
                timezone: -5,
                deltaUT1: 0,
                deltaT: 67,
                latitude: 41.8781,
                longitude: -87.6298,
                elevation: 181,
                temperature: 9.8,
                pressure: 1013.25,
                refraction: null);

            SunPositionCalculator.CalculateSunPosition(data);

            Assert.AreEqual(data.TopocentricZenithAngle, 19.259226, 5e-6);
            Assert.AreEqual(data.TopocentricAzimuth, 165.863616, 5e-5);
        }