Beispiel #1
0
        /// <summary>
        /// Calculate prayer time for isha.
        /// </summary>
        private static double ComputeIshaTime(double jd, double ishaParameterValue, double latitude)
        {
            var dayFraction = AstronomyMath.GetDayFraction(IshaDefaultTime);
            var ishaTime    = AstronomyMath.ComputeSolarTime(jd, dayFraction, ishaParameterValue, latitude, Direction.Clockwise);

            return(ishaTime);
        }
Beispiel #2
0
        /// <summary>
        /// Calculate prayer time for maghrib.
        /// </summary>
        private static double ComputeMaghribTime(double jd, double maghribParameterValue, double latitude)
        {
            var dayFraction = AstronomyMath.GetDayFraction(MaghribDefaultTime);
            var maghribTime = AstronomyMath.ComputeSolarTime(jd, dayFraction, maghribParameterValue, latitude, Direction.Clockwise);

            return(maghribTime);
        }
Beispiel #3
0
        // /// <summary>
        // /// Calculate prayer time for imsak.
        // /// </summary>
        // // NOTE: Do imsak time can be calculated using angle parameter?
        // private static double ComputeImsakTime(double jd, double imsakParameterValue, double latitude)
        // {
        //     var dayFraction = AstronomyMath.GetDayFraction(ImsakDefaultTime);
        //     var imsakTime = AstronomyMath.ComputeSolarTime(jd, dayFraction, imsakParameterValue, latitude, Direction.CounterClockwise);
        //
        //     return imsakTime;
        // }

        /// <summary>
        /// Calculate prayer time for fajr.
        /// </summary>
        private static double ComputeFajrTime(double jd, double fajrParameterValue, double latitude)
        {
            var dayFraction = AstronomyMath.GetDayFraction(FajrDefaultTime);
            var fajrTime    = AstronomyMath.ComputeSolarTime(jd, dayFraction, fajrParameterValue, latitude, Direction.CounterClockwise);

            return(fajrTime);
        }
Beispiel #4
0
        /// <summary>
        /// Calculate prayer time for sunset.
        /// </summary>
        private static double ComputeSunsetTime(double jd, double latitude, double altitude)
        {
            var dayFraction  = AstronomyMath.GetDayFraction(SunsetDefaultTime);
            var sunriseAngle = AstronomyMath.ComputeSunriseAngle(altitude);
            var sunsetTime   = AstronomyMath.ComputeSolarTime(jd, dayFraction, sunriseAngle, latitude, Direction.Clockwise);

            return(sunsetTime);
        }
Beispiel #5
0
        /// <summary>
        /// Calculate prayer time for asr.
        /// </summary>
        private static double ComputeAsrTime(double jd, int juristicTimeOfShadow, double latitude)
        {
            var dayFraction    = AstronomyMath.GetDayFraction(AsrDefaultTime);
            var sunDeclination = AstronomyMath.ComputeSunDeclination(jd + dayFraction);
            var angle          = -AngleMath.InverseCotangentInDegree(juristicTimeOfShadow + AngleMath.TangentOfDegree(Math.Abs(latitude - sunDeclination)));
            var asrTime        = AstronomyMath.ComputeSolarTime(jd, dayFraction, angle, latitude, Direction.Clockwise);

            return(asrTime);
        }
Beispiel #6
0
        /// <summary>
        /// Calculate prayer time for zuhr.
        /// </summary>
        private static double ComputeZuhrTime(double jd)
        {
            var dayFraction = AstronomyMath.GetDayFraction(ZuhrDefaultTime);
            var midDay      = AstronomyMath.ComputeMidDay(jd, dayFraction);

            // The fiqh method which states that zuhr is when the sun's disk comes out
            // of its zenith line, which is a line between the observer and the center
            // of the sun when it is at the highest point is used here. Thus,
            // additional 65 seconds is added to the mid day time, which corresponds
            // to the formula t = arctan(r/d) / 2π × 24 × 60 × 60, where r is the
            // radius of the sun (r = 695,000km), d is the sun-earth distance
            // (d = 147,098,074km at minimum and d = 152,097,701km at maximum).
            // When, d is at maximum, t evaluates to ~62 seconds and ~65 seconds when
            // d is at minimum. Converting 65 seconds to hour yields a value of
            // 0.018055555555555554.
            var zuhrTime = midDay + 0.018055555555555554;

            return(zuhrTime);
        }
Beispiel #7
0
        /// <summary>
        /// Adjust calculated prayer time to high latitude adjustment.
        /// </summary>
        private static double AdjustForHighLatitude(HighLatitudeAdjustment method, double time, double baseTime, double angle, double diff, Direction direction)
        {
            // Compute night fraction and duration.
            var nightFraction = AstronomyMath.GetNightFraction(method, angle, diff);
            var duration      = direction == Direction.Clockwise
                               ? DateTimeMath.ComputeDuration(time, baseTime)
                               : DateTimeMath.ComputeDuration(baseTime, time);

            // Copy reference;
            var newTime = time;

            if (duration > nightFraction)
            {
                var adjustment = direction == Direction.Clockwise ? nightFraction : -nightFraction;
                newTime = baseTime + adjustment;
            }

            return(newTime);
        }
Beispiel #8
0
 public void TestGetDayFractionForAsrDefaultTime()
 {
     Assert.Equal(0.5416666666666666, AstronomyMath.GetDayFraction(13.0));
 }
Beispiel #9
0
 public void TestGetDayFractionForZuhrDefaultTime()
 {
     Assert.Equal(0.5, AstronomyMath.GetDayFraction(12.0));
 }
Beispiel #10
0
 public void TestGetDayFractionForSunriseDefaultTime()
 {
     Assert.Equal(0.25, AstronomyMath.GetDayFraction(6.0));
 }
Beispiel #11
0
 public void TestGetDayFractionForFajrDefaultTime()
 {
     Assert.Equal(0.20833333333333334, AstronomyMath.GetDayFraction(5.0));
 }
Beispiel #12
0
 public void TestGetNightFractionForHighLatitudeAdjustmentOfAngleBased()
 {
     Assert.Equal(3.9474849041733533, AstronomyMath.GetNightFraction(HighLatitudeAdjustment.AngleBased, FajrAngle, Diff));
 }
Beispiel #13
0
 public void TestGetNightFractionForHighLatitudeAdjustmentOfMiddleOfNight()
 {
     Assert.Equal(5.92122735626003, AstronomyMath.GetNightFraction(HighLatitudeAdjustment.MiddleOfNight, FajrAngle, Diff));
 }
Beispiel #14
0
        // ReSharper disable once InconsistentNaming
        public void TestComputeSolarTimeForIshaPrayerOnApril12th2018()
        {
            var st = AstronomyMath.ComputeSolarTime(Jd, 0.75, IshaAngle, Latitude, Direction.Clockwise);

            Assert.Equal(19.250576300230424, st);
        }
Beispiel #15
0
 public void TestGetDayFractionForIshaDefaultTime()
 {
     Assert.Equal(0.75, AstronomyMath.GetDayFraction(18.0));
 }
Beispiel #16
0
 public void TestGetNightFractionForHighLatitudeAdjustmentOfNoneShouldThrow()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => AstronomyMath.GetNightFraction(HighLatitudeAdjustment.None, FajrAngle, Diff));
 }
Beispiel #17
0
        // ReSharper disable once InconsistentNaming
        public void TestComputeSunDeclinationOnApril12th2018()
        {
            var sd = AstronomyMath.ComputeSunDeclination(Jd + 0.5416666666666666);

            Assert.Equal(8.680557660849296, sd);
        }
Beispiel #18
0
 public void TestGetNightFractionForHighLatitudeAdjustmentOfOneSeventhOfNight()
 {
     Assert.Equal(1.691779244645723, AstronomyMath.GetNightFraction(HighLatitudeAdjustment.OneSeventhOfNight, FajrAngle, Diff));
 }
Beispiel #19
0
        // ReSharper disable once InconsistentNaming
        public void TestComputeMidDayOnApril12th2018()
        {
            var mid = AstronomyMath.ComputeMidDay(Jd, 0.5);

            Assert.Equal(12.014588571149947, mid);
        }
Beispiel #20
0
        // ReSharper disable once InconsistentNaming
        public void TestComputeSolarTimeForFajrPrayerOnApril12th2018()
        {
            var st = AstronomyMath.ComputeSolarTime(Jd, 0.20833333333333334, FajrAngle, Latitude, Direction.CounterClockwise);

            Assert.Equal(4.644572520441736, st);
        }
Beispiel #21
0
        public void TestComputeSunriseAngleAt2MetresAltitude()
        {
            var sa = AstronomyMath.ComputeSunriseAngle(2.0);

            Assert.Equal(0.8820732106143464, sa);
        }