Documentation of 'com.mhuss.AstroLib.RiseSet' Java class
RiseSet
com.mhuss.AstroLib

Class RiseSet



  • public class RiseSet
    extends java.lang.Object
    Calculates rise & set times of the sun or moon, and also calculates twilight times (civil/nautical/astronomical).

    Based on code by Bill Gray (www.projectpluto.com)

    [Bill Gray's Comments:]
    This class computes the times at which the sun or moon will rise and set during a given day starting on the given Julian day. It does this by computing the altitude of the object during each of the 24 hours of that day (and 1 hour of the next). What we really want to know is the object's altitude relative to the "rise/set altitude." This is the altitude at which the top of the object becomes visible, after correcting for refraction and (in the case of the Moon) topocentric parallax.

    For the sun, this altitude is -.8333 degrees (its apparent radius is about .25 degrees, and refraction 'lifts it up' by .58333 degrees.) For the moon, this altitude is +.125 degrees.

    If we find that the object was below this altitude at one hour, and above it on the next hour, then it must have risen in that interval; Conversely, if we find that the object was above this altitude at one hour, and below it on the next hour, then it must have set in that interval.

    We then do an iterative search to find the instant during that hour that it rose or set. This starts with a guessed rise/set time in the middle of the particular hour in question. At each step, we look at the altitude of that object at that time, and use it to adjust the rise/set time based on the assumption that the motion was linear during the hour (this isn't a perfect assumption, but we still usually converge in a few iterations.)

    As a side benefit, this function will also calculate twilight times by using the sun and just changing the event altitude. The modified altitudes are -6 degrees (civil twilight), -12 degrees (nautical twilight) and -18 degrees (astronomical twilight).

    TimePair.a stores the rise (or twilight start) times.
    TimePair.b stores the set (or twilight end) times.

    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static double A_TWI_ALT
      Astronomical twilight altitude (when sun is 18 degrees below horizon).
      static int ASTRONOMICAL_TWI
      Calulation type (pseudo-enum)
      static double C_TWI_ALT
      Civil twilight altitude (when sun is 6 degrees below horizon).
      static int CIVIL_TWI
      Calulation type (pseudo-enum)
      static int CULMINATING
      State enum
      static int MOON
      Calulation type (pseudo-enum)
      static double MOON_ALT
      Lunar altitude adjustment
      static double N_TWI_ALT
      Nautical twilight altitude (when sun is 12 degrees below horizon).
      static int NAUTICAL_TWI
      Calulation type (pseudo-enum)
      static double PLANET_ALT
      Stellar altitude adjustment
      static int RISING
      State enum
      static int SETTING
      State enum
      static int SUN
      Calulation type (pseudo-enum)
      static double SUN_ALT
      Solar altitude adjustment
      static double SUN_TOPO_ALT
      Solar an lunar topocentric altitude adjustment
      static int UNKNOWN
      State enum
    • Constructor Summary

      Constructors 
      Constructor and Description
      RiseSet() 
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static TimePair getTimes(int rsType, double jd, ObsInfo oi)
      Calculate the rise/set (or start/end) times.
      static TimePair getTimes(int rsType, double jd, ObsInfo oi, PlanetData pd)
      Calculate the rise/set (or start/end) times.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • CIVIL_TWI

        public static final int CIVIL_TWI
        Calulation type (pseudo-enum)
        See Also:
        Constant Field Values
      • NAUTICAL_TWI

        public static final int NAUTICAL_TWI
        Calulation type (pseudo-enum)
        See Also:
        Constant Field Values
      • ASTRONOMICAL_TWI

        public static final int ASTRONOMICAL_TWI
        Calulation type (pseudo-enum)
        See Also:
        Constant Field Values
      • SUN_ALT

        public static final double SUN_ALT
        Solar altitude adjustment
      • SUN_TOPO_ALT

        public static final double SUN_TOPO_ALT
        Solar an lunar topocentric altitude adjustment
      • MOON_ALT

        public static final double MOON_ALT
        Lunar altitude adjustment
      • PLANET_ALT

        public static final double PLANET_ALT
        Stellar altitude adjustment
      • C_TWI_ALT

        public static final double C_TWI_ALT
        Civil twilight altitude (when sun is 6 degrees below horizon).
      • N_TWI_ALT

        public static final double N_TWI_ALT
        Nautical twilight altitude (when sun is 12 degrees below horizon).
      • A_TWI_ALT

        public static final double A_TWI_ALT
        Astronomical twilight altitude (when sun is 18 degrees below horizon).
    • Constructor Detail

      • RiseSet

        public RiseSet()
    • Method Detail

      • getTimes

        public static TimePair getTimes(int rsType,
                                        double jd,
                                        ObsInfo oi,
                                        PlanetData pd)
        Calculate the rise/set (or start/end) times.
        Parameters:
        rsType - Rise/Set type (SUN, MOON, CIVIL_TWI, NAUTICAL_TWI, or ASTRONOMICAL_TWI).
        jd - The Julian day for which to calculate the desired information (set to 0h local time
        oi - The observer's location
        pd - A PlanetData instance to use for our calculations.
        Returns:
        the TimePair result, local time
      • getTimes

        public static TimePair getTimes(int rsType,
                                        double jd,
                                        ObsInfo oi)
        Calculate the rise/set (or start/end) times.
        Parameters:
        rsType - Rise/Set type (SUN, MOON, CIVIL_TWI, NAUTICAL_TWI, or ASTRONOMICAL_TWI).
        jd - The Julian day for which to calculate the desired information
        oi - The observer's location

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.