Ejemplo n.º 1
0
        public void Seasons()
        {
            // 2 min error
            const double error = 2.0 / (24 * 60);

            // example 26.a
            {
                double jd = SolarEphem.Season(new Date(1962, 1, 1).ToJulianDay(), Season.Summer);
                Assert.AreEqual(2437837.39245, jd, error);
            }

            {
                double jd = SolarEphem.Season(new Date(1991, 1, 1).ToJulianDay(), Season.Spring);
                Assert.AreEqual(new Date(new DateTime(1991, 3, 21, 3, 2, 54, DateTimeKind.Utc)).ToJulianEphemerisDay(), jd, error);
            }

            {
                double jd = SolarEphem.Season(new Date(1991, 1, 1).ToJulianDay(), Season.Summer);
                Assert.AreEqual(new Date(new DateTime(1991, 6, 21, 21, 19, 46, DateTimeKind.Utc)).ToJulianEphemerisDay(), jd, error);
            }

            {
                double jd = SolarEphem.Season(new Date(1991, 1, 1).ToJulianDay(), Season.Autumn);
                Assert.AreEqual(new Date(new DateTime(1991, 9, 23, 12, 49, 04, DateTimeKind.Utc)).ToJulianEphemerisDay(), jd, error);
            }

            {
                double jd = SolarEphem.Season(new Date(1991, 1, 1).ToJulianDay(), Season.Winter);
                Assert.AreEqual(new Date(new DateTime(1991, 12, 22, 8, 54, 38, DateTimeKind.Utc)).ToJulianEphemerisDay(), jd, error);
            }
        }
Ejemplo n.º 2
0
        public void Ecliptical()
        {
            var ecl = SolarEphem.Ecliptical(2448908.5);

            Assert.AreEqual(new DMS("199* 54' 32.19''"), new DMS(ecl.Lambda));
            Assert.AreEqual(0.99766, ecl.Distance, 1e-5);
        }
Ejemplo n.º 3
0
        public ICollection <AstroEvent> EventsSeasons(AstroEventsContext context)
        {
            List <AstroEvent> events = new List <AstroEvent>();

            for (double jd = context.From; jd < context.To; jd += 365)
            {
                events.Add(new AstroEvent(SolarEphem.Season(jd, Season.Spring), Text.Get("SunEvents.Seasons.Spring")));
                events.Add(new AstroEvent(SolarEphem.Season(jd, Season.Summer), Text.Get("SunEvents.Seasons.Summer")));
                events.Add(new AstroEvent(SolarEphem.Season(jd, Season.Autumn), Text.Get("SunEvents.Seasons.Autumn")));
                events.Add(new AstroEvent(SolarEphem.Season(jd, Season.Winter), Text.Get("SunEvents.Seasons.Winter")));
            }

            return(events);
        }
Ejemplo n.º 4
0
        private static void TestSeasons()
        {
            var sb = new StringBuilder();

            sb.AppendLine("<table border=1 cellspacing=3 cellpadding=3><tr><th>Year</th><th>Season</th><th>Local</th><th>UTC</th></tr>");
            foreach (int year in new[] { 2019, 2020, 2021 })
            {
                foreach (Season season in Enum.GetValues(typeof(Season)))
                {
                    var adate = SolarEphem.SeasonDate(year, season);
                    var date  = adate.ToDateTimeUTC();
                    Console.WriteLine($"{year} {season}: {date} UTC {date.ToLocalTime()} Local");
                    sb.AppendLine($"<tr><td>{year}</td><td>{season}</td><td>{date.ToLocalTime()}</td><td>{date}</td></tr>");
                }
            }
            sb.AppendLine("</table>");
            File.WriteAllText("/Users/mmuegel/Mike/Projects/Sundial App/Tests/ADK-Equinox.html",
                              sb.ToString());
        }
Ejemplo n.º 5
0
        public ICollection <AstroEvent> EventsSeasons(AstroEventsContext context)
        {
            List <AstroEvent> events = new List <AstroEvent>();

            for (double jd = context.From; jd < context.To; jd += 365)
            {
                // check for cancel
                if (context.CancelToken?.IsCancellationRequested == true)
                {
                    return(new AstroEvent[0]);
                }

                events.Add(new AstroEvent(SolarEphem.Season(jd, Season.Spring), Text.Get("SunEvents.Seasons.Spring")));
                events.Add(new AstroEvent(SolarEphem.Season(jd, Season.Summer), Text.Get("SunEvents.Seasons.Summer")));
                events.Add(new AstroEvent(SolarEphem.Season(jd, Season.Autumn), Text.Get("SunEvents.Seasons.Autumn")));
                events.Add(new AstroEvent(SolarEphem.Season(jd, Season.Winter), Text.Get("SunEvents.Seasons.Winter")));
            }

            return(events);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates new instance of <see cref="LocationVM"/>
        /// </summary>
        public LocationVM(ISky sky, ISettings settings)
        {
            CrdsEquatorial eqSun = SolarEphem.Ecliptical(sky.Context.JulianDay).ToEquatorial(sky.Context.Epsilon);

            ObserverLocation = new CrdsGeographical(sky.Context.GeoLocation);
            SunHourAngle     = Coordinates.HourAngle(sky.Context.SiderealTime, 0, eqSun.Alpha);
            SunDeclination   = eqSun.Delta;
            IsNightMode      = settings.Get <ColorSchema>("Schema") == ColorSchema.Red;

            OkCommand             = new Command(Ok);
            CancelCommand         = new Command(Close);
            EndSearchModeCommand  = new Command(EndSearchMode);
            SelectLocationCommand = new Command(SelectLocation);

            string line;
            string filePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Data", "TimeZones.dat");

            using (StreamReader file = new StreamReader(filePath))
            {
                while ((line = file.ReadLine()) != null)
                {
                    // skip first and empty lines
                    if (line.StartsWith("CountryCode") ||
                        string.IsNullOrWhiteSpace(line))
                    {
                        continue;
                    }

                    string[] chunks = line.Split('\t');
                    TimeZones.Add(new TimeZoneItem()
                    {
                        TimeZoneId = chunks[1], UtcOffset = double.Parse(chunks[4], CultureInfo.InvariantCulture)
                    });
                }
                file.Close();
            }
        }
Ejemplo n.º 7
0
 public void CarringtonNumber()
 {
     Assert.AreEqual(1624, SolarEphem.CarringtonNumber(2442439.50));
 }
Ejemplo n.º 8
0
 public void Parallax()
 {
     Assert.AreEqual(8.794, SolarEphem.Parallax(1) * 3600, 1e-3);
     Assert.AreEqual(8.650, SolarEphem.Parallax(1.0167) * 3600, 1e-3);
     Assert.AreEqual(8.943, SolarEphem.Parallax(0.98329) * 3600, 1e-3);
 }
Ejemplo n.º 9
0
 public void Semidiameter()
 {
     Assert.AreEqual(959.63, SolarEphem.Semidiameter(1), 1e-2);
     Assert.AreEqual(943.87, SolarEphem.Semidiameter(1.0167), 1e-2);
     Assert.AreEqual(975.94, SolarEphem.Semidiameter(0.98329), 1e-2);
 }
Ejemplo n.º 10
0
 private Date Seasons(SkyContext c, Season s)
 {
     return(c.GetDate(SolarEphem.Season(c.JulianDay, s)));
 }
Ejemplo n.º 11
0
 private double CarringtonNumber(SkyContext c)
 {
     return(SolarEphem.CarringtonNumber(c.JulianDay));
 }
Ejemplo n.º 12
0
 public double Semidiameter(SkyContext c)
 {
     return(SolarEphem.Semidiameter(c.Get(Ecliptical).Distance));
 }
Ejemplo n.º 13
0
 private double Parallax(SkyContext c)
 {
     return(SolarEphem.Parallax(c.Get(Ecliptical).Distance));
 }