Beispiel #1
0
        /// <summary>
        /// In place time slip
        /// </summary>
        /// <param name="c">Coordinate</param>
        /// <param name="offset">hour offset</param>
        /// <param name="el">Celestial EagerLoad Option</param>
        private void Local_Convert(Coordinate c, double offset, Celestial_EagerLoad el)
        {
            //Find new lunar set rise times
            if (el == Celestial_EagerLoad.All || el == Celestial_EagerLoad.Lunar)
            {
                if (MoonSet.HasValue)
                {
                    moonSet = moonSet.Value.AddHours(offset);
                }
                if (MoonRise.HasValue)
                {
                    moonRise = moonRise.Value.AddHours(offset);
                }

                Perigee.ConvertTo_Local_Time(offset);
                Apogee.ConvertTo_Local_Time(offset);
                LunarEclipse.ConvertTo_LocalTime(offset);
                MoonCalc.GetMoonSign(c.GeoDate.AddHours(offset), this);
            }

            ////Solar
            if (el == Celestial_EagerLoad.All || el == Celestial_EagerLoad.Solar)
            {
                if (sunSet.HasValue)
                {
                    sunSet = sunSet.Value.AddHours(offset);
                }
                if (SunRise.HasValue)
                {
                    sunRise = SunRise.Value.AddHours(offset);
                }
                AdditionalSolarTimes.Convert_To_Local_Time(offset);

                //Eclipse
                SolarEclipse.ConvertTo_LocalTime(offset);
                SunCalc.CalculateZodiacSign(c.GeoDate.AddHours(offset), this);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Calculate celestial data based on latitude, longitude and UTC date at the location.
        /// </summary>
        /// <param name="lat">Decimal format latitude</param>
        /// <param name="longi">Decimal format longitude</param>
        /// <param name="date">Geographic DateTime</param>
        /// <returns>Celestial (Fully Populated)</returns>
        /// <example>
        /// The following example demonstrates how to create a fully populated Celestial object
        /// using static functions.
        /// <code>
        /// //Get Celestial data at N 39, W 72 on 19-Mar-2019 10:10:12 UTC
        /// Celestial cel = Celestial.CalculateCelestialTimes(39, -72, new DateTime(2019, 3, 19, 10, 10, 12));
        ///
        /// Console.WriteLine(cel.SunRise); //3/19/2019 10:54:50 AM
        /// Console.WriteLine(cel.MoonRise); //3/19/2019 9:27:27 PM
        /// </code>
        /// </example>
        public static Celestial CalculateCelestialTimes(double lat, double longi, DateTime date)
        {
            date = new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, DateTimeKind.Utc);

            Celestial c = new Celestial(false);

            SunCalc.CalculateSunTime(lat, longi, date, c, new EagerLoad());
            MoonCalc.GetMoonTimes(date, lat, longi, c);
            MoonCalc.GetMoonDistance(date, c);
            MoonCalc.GetMoonIllumination(date, c, lat, longi, new EagerLoad());

            SunCalc.CalculateZodiacSign(date, c);
            MoonCalc.GetMoonSign(date, c);



            c.perigee = MoonCalc.GetPerigeeEvents(date);
            c.apogee  = MoonCalc.GetApogeeEvents(date);

            Calculate_Celestial_IsUp_Booleans(date, c);

            return(c);
        }