Example #1
0
        /// <summary>
        /// Converts Celestial values to local times.
        /// </summary>
        /// <param name="c">Coordinate</param>
        /// <param name="offset">UTC offset</param>
        /// <returns></returns>
        public static Celestial Celestial_LocalTime(Coordinate c, double offset)
        {
            if (offset < -12 || offset > 12)
            {
                throw new ArgumentOutOfRangeException("Time offsets cannot be greater 12 or less than -12.");
            }
            //Probably need to offset initial UTC date so user can op in local
            //Determine best way to do this.
            DateTime d = c.GeoDate.AddHours(offset);

            //Get 3 objects for comparison
            Celestial cel     = new Celestial(c.Latitude.ToDouble(), c.Longitude.ToDouble(), c.GeoDate);
            Celestial celPre  = new Celestial(c.Latitude.ToDouble(), c.Longitude.ToDouble(), c.GeoDate.AddDays(-1));
            Celestial celPost = new Celestial(c.Latitude.ToDouble(), c.Longitude.ToDouble(), c.GeoDate.AddDays(1));

            //Slip objects for comparison. Compare with slipped date.
            celPre.Local_Convert(c, offset);
            cel.Local_Convert(c, offset);
            celPost.Local_Convert(c, offset);

            //Get SunSet
            int i = Determine_Slipped_Event_Index(cel.SunSet, celPre.SunSet, celPost.SunSet, d);

            cel.SunSet = Get_Correct_Slipped_Date(cel.SunSet, celPre.SunSet, celPost.SunSet, i);
            cel.AdditionalSolarTimes.CivilDusk = Get_Correct_Slipped_Date(cel.AdditionalSolarTimes.CivilDusk,
                                                                          celPre.AdditionalSolarTimes.CivilDusk, celPost.AdditionalSolarTimes.CivilDusk, i);
            cel.AdditionalSolarTimes.NauticalDusk = Get_Correct_Slipped_Date(cel.AdditionalSolarTimes.NauticalDusk,
                                                                             celPre.AdditionalSolarTimes.NauticalDusk, celPost.AdditionalSolarTimes.NauticalDusk, i);
            //Get SunRise
            i           = Determine_Slipped_Event_Index(cel.SunRise, celPre.SunRise, celPost.SunRise, d);
            cel.SunRise = Get_Correct_Slipped_Date(cel.SunRise, celPre.SunRise, celPost.SunRise, i);
            cel.AdditionalSolarTimes.CivilDawn = Get_Correct_Slipped_Date(cel.AdditionalSolarTimes.CivilDawn,
                                                                          celPre.AdditionalSolarTimes.CivilDawn, celPost.AdditionalSolarTimes.CivilDawn, i);
            cel.AdditionalSolarTimes.NauticalDawn = Get_Correct_Slipped_Date(cel.AdditionalSolarTimes.NauticalDawn,
                                                                             celPre.AdditionalSolarTimes.NauticalDawn, celPost.AdditionalSolarTimes.NauticalDawn, i);

            //MoonRise
            i            = Determine_Slipped_Event_Index(cel.MoonRise, celPre.MoonRise, celPost.MoonRise, d);
            cel.MoonRise = Get_Correct_Slipped_Date(cel.MoonRise, celPre.MoonRise, celPost.MoonRise, i);

            //MoonSet
            i           = Determine_Slipped_Event_Index(cel.MoonSet, celPre.MoonSet, celPost.MoonSet, d);
            cel.MoonSet = Get_Correct_Slipped_Date(cel.MoonSet, celPre.MoonSet, celPost.MoonSet, i);

            //Local Conditions
            CelestialStatus[] cels = new CelestialStatus[]
            {
                celPre.MoonCondition, cel.MoonCondition, celPost.MoonCondition
            };
            cel.MoonCondition = Celestial.GetStatus(cel.MoonRise, cel.MoonSet, cels);
            cels = new CelestialStatus[]
            {
                celPre.SunCondition, cel.SunCondition, celPost.SunCondition
            };
            cel.SunCondition = Celestial.GetStatus(cel.SunRise, cel.SunSet, cels);
            return(cel);
        }
Example #2
0
        /// <summary>
        /// Converts lunar time values to local time.
        /// </summary>
        /// <param name="coord">Coordinate</param>
        /// <param name="offset">UTC offset</param>
        /// <returns>Celestial</returns>
        /// <example>
        /// The following example demonstrates how to get Celestial, lunar time only values in Local time.
        /// DateTime offsets are done manually for readability purposes of this example.
        /// <code>
        /// //Local time
        ///  DateTime d = new DateTime(2018, 3, 19, 6, 56, 0, 0, DateTimeKind.Local);
        ///
        /// //EST Time is -4 hours from UTC
        /// double offset = -4;
        ///
        /// //Convert the date to UTC time
        /// d = d.AddHours(offset*-1);
        ///
        /// //Create a Coordinate with the UTC time
        /// Coordinate c = new Coordinate(39.0000, -72.0000, d);
        /// //Create a new Celestial object by converting the existing one to Local
        /// Celestial celestial = Celestial.Lunar_LocalTime(c, offset);
        ///
        /// Console.WriteLine(celestial.IsMoonUp); //False
        /// Console.WriteLine(celestial.SunRise); //3/19/2018 08:17 AM
        /// </code>
        /// </example>
        public static Celestial Lunar_LocalTime(Coordinate coord, double offset)
        {
            if (offset < -12 || offset > 12)
            {
                throw new ArgumentOutOfRangeException("Time offsets cannot be greater 12 or less than -12.");
            }
            //Probably need to offset initial UTC date so user can op in local
            //Determine best way to do this.
            DateTime d = coord.GeoDate.AddHours(offset);

            //Get 3 objects for comparison
            Celestial cel     = CalculateMoonData(coord.Latitude.ToDouble(), coord.Longitude.ToDouble(), coord.GeoDate);
            Celestial celPre  = CalculateMoonData(coord.Latitude.ToDouble(), coord.Longitude.ToDouble(), coord.GeoDate.AddDays(-1));
            Celestial celPost = CalculateMoonData(coord.Latitude.ToDouble(), coord.Longitude.ToDouble(), coord.GeoDate.AddDays(1));

            //Slip objects for comparison. Compare with slipped date.
            celPre.Local_Convert(coord, offset, Celestial_EagerLoad.Lunar);
            cel.Local_Convert(coord, offset, Celestial_EagerLoad.Lunar);
            celPost.Local_Convert(coord, offset, Celestial_EagerLoad.Lunar);


            //MoonRise
            int i = Determine_Slipped_Event_Index(cel.MoonRise, celPre.MoonRise, celPost.MoonRise, d);

            cel.moonRise = Get_Correct_Slipped_Date(cel.MoonRise, celPre.MoonRise, celPost.MoonRise, i);

            //MoonSet
            i           = Determine_Slipped_Event_Index(cel.MoonSet, celPre.MoonSet, celPost.MoonSet, d);
            cel.moonSet = Get_Correct_Slipped_Date(cel.MoonSet, celPre.MoonSet, celPost.MoonSet, i);

            //Local Conditions
            CelestialStatus[] cels = new CelestialStatus[]
            {
                celPre.MoonCondition, cel.MoonCondition, celPost.MoonCondition
            };
            cel.moonCondition = Celestial.GetStatus(cel.MoonRise, cel.MoonSet, cels);

            //Load IsUp values based on local time with populated Celestial
            Celestial.Calculate_Celestial_IsUp_Booleans(d, cel);

            return(cel);
        }
Example #3
0
        /// <summary>
        /// Converts all Celestial values to local time.
        /// </summary>
        /// <param name="coord">Coordinate</param>
        /// <param name="offset">UTC offset</param>
        /// <returns>Celestial</returns>
        /// <example>
        /// The following example demonstrates how to get Celestial values in Local time.
        /// DateTime offsets are done manually for readability purposes of this example.
        /// <code>
        /// //Local time
        ///  DateTime d = new DateTime(2018, 3, 19, 6, 56, 0, 0, DateTimeKind.Local);
        ///
        /// //EST Time is -4 hours from UTC
        /// double offset = -4;
        ///
        /// //Convert the date to UTC time
        /// d = d.AddHours(offset*-1);
        ///
        /// //Create a Coordinate with the UTC time
        /// Coordinate c = new Coordinate(39.0000, -72.0000, d);
        /// //Create a new Celestial object by converting the existing one to Local
        /// Celestial celestial = Celestial.Celestial_LocalTime(c, offset);
        ///
        /// Console.WriteLine(celestial.IsSunUp); //True
        /// Console.WriteLine(celestial.SunRise); //3/19/2018 6:54:25 AM
        /// </code>
        /// </example>
        public static Celestial Celestial_LocalTime(Coordinate coord, double offset)
        {
            if (offset < -12 || offset > 12)
            {
                throw new ArgumentOutOfRangeException("Time offsets cannot be greater 12 or less than -12.");
            }
            //Probably need to offset initial UTC date so user can op in local
            //Determine best way to do this.
            DateTime d = coord.GeoDate.AddHours(offset);

            //Get 3 objects for comparison
            Celestial cel     = new Celestial(coord.Latitude.ToDouble(), coord.Longitude.ToDouble(), coord.GeoDate);
            Celestial celPre  = new Celestial(coord.Latitude.ToDouble(), coord.Longitude.ToDouble(), coord.GeoDate.AddDays(-1));
            Celestial celPost = new Celestial(coord.Latitude.ToDouble(), coord.Longitude.ToDouble(), coord.GeoDate.AddDays(1));

            //Slip objects for comparison. Compare with slipped date.
            celPre.Local_Convert(coord, offset, Celestial_EagerLoad.All);
            cel.Local_Convert(coord, offset, Celestial_EagerLoad.All);
            celPost.Local_Convert(coord, offset, Celestial_EagerLoad.All);

            //Get SunSet
            int i = Determine_Slipped_Event_Index(cel.SunSet, celPre.SunSet, celPost.SunSet, d);

            cel.sunSet = Get_Correct_Slipped_Date(cel.SunSet, celPre.SunSet, celPost.SunSet, i);
            cel.AdditionalSolarTimes.civilDusk = Get_Correct_Slipped_Date(cel.AdditionalSolarTimes.CivilDusk,
                                                                          celPre.AdditionalSolarTimes.CivilDusk, celPost.AdditionalSolarTimes.CivilDusk, i);
            cel.AdditionalSolarTimes.nauticalDusk = Get_Correct_Slipped_Date(cel.AdditionalSolarTimes.NauticalDusk,
                                                                             celPre.AdditionalSolarTimes.NauticalDusk, celPost.AdditionalSolarTimes.NauticalDusk, i);
            //Get SunRise
            i           = Determine_Slipped_Event_Index(cel.SunRise, celPre.SunRise, celPost.SunRise, d);
            cel.sunRise = Get_Correct_Slipped_Date(cel.SunRise, celPre.SunRise, celPost.SunRise, i);
            cel.AdditionalSolarTimes.civilDawn = Get_Correct_Slipped_Date(cel.AdditionalSolarTimes.CivilDawn,
                                                                          celPre.AdditionalSolarTimes.CivilDawn, celPost.AdditionalSolarTimes.CivilDawn, i);
            cel.AdditionalSolarTimes.nauticalDawn = Get_Correct_Slipped_Date(cel.AdditionalSolarTimes.NauticalDawn,
                                                                             celPre.AdditionalSolarTimes.NauticalDawn, celPost.AdditionalSolarTimes.NauticalDawn, i);

            //MoonRise
            i            = Determine_Slipped_Event_Index(cel.MoonRise, celPre.MoonRise, celPost.MoonRise, d);
            cel.moonRise = Get_Correct_Slipped_Date(cel.MoonRise, celPre.MoonRise, celPost.MoonRise, i);

            //MoonSet
            i           = Determine_Slipped_Event_Index(cel.MoonSet, celPre.MoonSet, celPost.MoonSet, d);
            cel.moonSet = Get_Correct_Slipped_Date(cel.MoonSet, celPre.MoonSet, celPost.MoonSet, i);

            //Local Conditions
            CelestialStatus[] cels = new CelestialStatus[]
            {
                celPre.MoonCondition, cel.MoonCondition, celPost.MoonCondition
            };
            cel.moonCondition = GetStatus(cel.MoonRise, cel.MoonSet, cels);
            cels = new CelestialStatus[]
            {
                celPre.SunCondition, cel.SunCondition, celPost.SunCondition
            };
            cel.sunCondition = GetStatus(cel.SunRise, cel.SunSet, cels);

            //Load IsUp values based on local time with populated Celestial
            //If EagerLoading Extensions used, this function will handle null values
            Calculate_Celestial_IsUp_Booleans(d, cel);

            return(cel);
        }