Class SunMoonCalculator


  • public class SunMoonCalculator
    extends java.lang.Object
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  SunMoonCalculator.TWILIGHT
      The set of twilights to calculate (types of rise/set events).
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static double AU  
      static double DEG_TO_RAD  
      static double EARTH_RADIUS  
      static double FOUR_PI  
      static double J2000  
      static double JULIAN_DAYS_PER_CENTURY  
      double moonAge
      Values for azimuth, elevation, rise, set, and transit for the Moon.
      double moonAz
      Values for azimuth, elevation, rise, set, and transit for the Moon.
      double moonDist
      Values for azimuth, elevation, rise, set, and transit for the Moon.
      double moonEl
      Values for azimuth, elevation, rise, set, and transit for the Moon.
      double moonRise
      Values for azimuth, elevation, rise, set, and transit for the Moon.
      double moonSet
      Values for azimuth, elevation, rise, set, and transit for the Moon.
      double moonTransit
      Values for azimuth, elevation, rise, set, and transit for the Moon.
      double moonTransitElev
      Values for azimuth, elevation, rise, set, and transit for the Moon.
      static double PI_OVER_TWO  
      static double RAD_TO_DAY  
      static double RAD_TO_DEG  
      static double RAD_TO_HOUR  
      static double SECONDS_PER_DAY  
      static double SIDEREAL_DAY_LENGTH  
      double sunAz
      Values for azimuth, elevation, rise, set, and transit for the Sun.
      double sunDist
      Values for azimuth, elevation, rise, set, and transit for the Sun.
      double sunEl
      Values for azimuth, elevation, rise, set, and transit for the Sun.
      double sunrise
      Values for azimuth, elevation, rise, set, and transit for the Sun.
      double sunset
      Values for azimuth, elevation, rise, set, and transit for the Sun.
      double sunTransit
      Values for azimuth, elevation, rise, set, and transit for the Sun.
      double sunTransitElev
      Values for azimuth, elevation, rise, set, and transit for the Sun.
      static double TWO_PI  
      static double TWO_PI_INVERSE  
    • Constructor Summary

      Constructors 
      Constructor Description
      SunMoonCalculator​(int YEAR, int MONTH, int DAY, double LAT_DEG, double LNG_DEG)
      Main constructor for Sun/Moon calculations.
      SunMoonCalculator​(int year, int month, int day, int h, int m, int s, double latDeg, double lngDeg)
      Main constructor for Sun/Moon calculations.
    • Field Detail

      • JULIAN_DAYS_PER_CENTURY

        public static final double JULIAN_DAYS_PER_CENTURY
        See Also:
        Constant Field Values
      • sunAz

        public double sunAz
        Values for azimuth, elevation, rise, set, and transit for the Sun. Angles in radians, rise ... as Julian days in UT. Distance in AU.
      • sunEl

        public double sunEl
        Values for azimuth, elevation, rise, set, and transit for the Sun. Angles in radians, rise ... as Julian days in UT. Distance in AU.
      • sunrise

        public double sunrise
        Values for azimuth, elevation, rise, set, and transit for the Sun. Angles in radians, rise ... as Julian days in UT. Distance in AU.
      • sunset

        public double sunset
        Values for azimuth, elevation, rise, set, and transit for the Sun. Angles in radians, rise ... as Julian days in UT. Distance in AU.
      • sunTransit

        public double sunTransit
        Values for azimuth, elevation, rise, set, and transit for the Sun. Angles in radians, rise ... as Julian days in UT. Distance in AU.
      • sunTransitElev

        public double sunTransitElev
        Values for azimuth, elevation, rise, set, and transit for the Sun. Angles in radians, rise ... as Julian days in UT. Distance in AU.
      • sunDist

        public double sunDist
        Values for azimuth, elevation, rise, set, and transit for the Sun. Angles in radians, rise ... as Julian days in UT. Distance in AU.
      • moonAz

        public double moonAz
        Values for azimuth, elevation, rise, set, and transit for the Moon. Angles in radians, rise ... as Julian days in UT. Moon age is the number of days since last new Moon, in days, from 0 to 29.5. Distance in AU.
      • moonEl

        public double moonEl
        Values for azimuth, elevation, rise, set, and transit for the Moon. Angles in radians, rise ... as Julian days in UT. Moon age is the number of days since last new Moon, in days, from 0 to 29.5. Distance in AU.
      • moonRise

        public double moonRise
        Values for azimuth, elevation, rise, set, and transit for the Moon. Angles in radians, rise ... as Julian days in UT. Moon age is the number of days since last new Moon, in days, from 0 to 29.5. Distance in AU.
      • moonSet

        public double moonSet
        Values for azimuth, elevation, rise, set, and transit for the Moon. Angles in radians, rise ... as Julian days in UT. Moon age is the number of days since last new Moon, in days, from 0 to 29.5. Distance in AU.
      • moonTransit

        public double moonTransit
        Values for azimuth, elevation, rise, set, and transit for the Moon. Angles in radians, rise ... as Julian days in UT. Moon age is the number of days since last new Moon, in days, from 0 to 29.5. Distance in AU.
      • moonAge

        public double moonAge
        Values for azimuth, elevation, rise, set, and transit for the Moon. Angles in radians, rise ... as Julian days in UT. Moon age is the number of days since last new Moon, in days, from 0 to 29.5. Distance in AU.
      • moonTransitElev

        public double moonTransitElev
        Values for azimuth, elevation, rise, set, and transit for the Moon. Angles in radians, rise ... as Julian days in UT. Moon age is the number of days since last new Moon, in days, from 0 to 29.5. Distance in AU.
      • moonDist

        public double moonDist
        Values for azimuth, elevation, rise, set, and transit for the Moon. Angles in radians, rise ... as Julian days in UT. Moon age is the number of days since last new Moon, in days, from 0 to 29.5. Distance in AU.
    • Constructor Detail

      • SunMoonCalculator

        public SunMoonCalculator​(int YEAR,
                                 int MONTH,
                                 int DAY,
                                 double LAT_DEG,
                                 double LNG_DEG)
                          throws java.lang.Exception
        Main constructor for Sun/Moon calculations. Observer angles in degrees.
        Parameters:
        YEAR - The year.
        MONTH - The month.
        DAY - The day.
        LAT_DEG - Latitude for the observer.
        LNG_DEG - Longitude for the observer.
        Throws:
        java.lang.Exception - If the date does not exists.
      • SunMoonCalculator

        public SunMoonCalculator​(int year,
                                 int month,
                                 int day,
                                 int h,
                                 int m,
                                 int s,
                                 double latDeg,
                                 double lngDeg)
                          throws java.lang.Exception
        Main constructor for Sun/Moon calculations. Time should be given in Universal Time (UT), observer angles in degrees.
        Parameters:
        year - The year.
        month - The month.
        day - The day.
        h - The hour.
        m - Minute.
        s - Second.
        latDeg - Latitude for the observer.
        lngDeg - Longitude for the observer.
        Throws:
        java.lang.Exception - If the date does not exists.
    • Method Detail

      • getDate

        public static int[] getDate​(double JULIAN_DAY)
                             throws java.lang.Exception
        Transforms a Julian day (rise/set/transit fields) to a common date.
        Parameters:
        JULIAN_DAY - The Julian day.
        Returns:
        A set of integers: year, month, day, hour, minute, second.
        Throws:
        java.lang.Exception - If the input date does not exists.
      • getZonedDateTime

        public static java.time.ZonedDateTime getZonedDateTime​(double JULIAN_DAY,
                                                               java.time.ZoneOffset ZONE_OFFSET)
                                                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getDateAsString

        public static java.lang.String getDateAsString​(double JULIAN_DAY)
                                                throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getDateAsString

        public static java.lang.String getDateAsString​(double JULIAN_DAY,
                                                       int TIMEZONE_OFFSET)
                                                throws java.lang.Exception
        Returns a date as a string.
        Parameters:
        JULIAN_DAY - The Juliand day.
        Returns:
        The String.
        Throws:
        java.lang.Exception - If the date does not exists.
      • normalizeRadians

        public static double normalizeRadians​(double r)
        Reduce an angle in radians to the range (0 - 2 Pi).
        Parameters:
        r - Value in radians.
        Returns:
        The reduced radian value.
      • setTwilight

        public void setTwilight​(SunMoonCalculator.TWILIGHT T)
        Sets the rise/set times to return. Default is for the local horizon.
        Parameters:
        T - The Twilight.
      • setDate

        public void setDate​(java.time.LocalDate DATE)
                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • setDate

        public void setDate​(java.time.LocalDateTime DATE_TIME)
                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • setDate

        public void setDate​(int year,
                            int month,
                            int day)
                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • setDate

        public void setDate​(int year,
                            int month,
                            int day,
                            int h,
                            int m,
                            int s)
                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • calcSunAndMoon

        public void calcSunAndMoon()
        Calculates everything for the Sun and the Moon.
      • getMoonDiskOrientationAngles

        public double[] getMoonDiskOrientationAngles()
      • calcEphemeris

        public void calcEphemeris​(java.time.ZoneId ZONE_ID)
      • getSunrise

        public java.time.ZonedDateTime getSunrise()
      • getSunset

        public java.time.ZonedDateTime getSunset()
      • getSunriseGoldenHour

        public java.time.ZonedDateTime getSunriseGoldenHour()
      • getSunsetGoldenHour

        public java.time.ZonedDateTime getSunsetGoldenHour()
      • getSunriseCivil

        public java.time.ZonedDateTime getSunriseCivil()
      • getSunsetCivil

        public java.time.ZonedDateTime getSunsetCivil()
      • getSunriseBlueHour

        public java.time.ZonedDateTime getSunriseBlueHour()
      • getSunsetBlueHour

        public java.time.ZonedDateTime getSunsetBlueHour()