Class RiseSet
- java.lang.Object
-
- com.mhuss.AstroLib.RiseSet
-
public class RiseSet extends java.lang.ObjectCalculates 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 doubleA_TWI_ALTAstronomical twilight altitude (when sun is 18 degrees below horizon).static intASTRONOMICAL_TWICalulation type (pseudo-enum)static doubleC_TWI_ALTCivil twilight altitude (when sun is 6 degrees below horizon).static intCIVIL_TWICalulation type (pseudo-enum)static intCULMINATINGState enumstatic intMOONCalulation type (pseudo-enum)static doubleMOON_ALTLunar altitude adjustmentstatic doubleN_TWI_ALTNautical twilight altitude (when sun is 12 degrees below horizon).static intNAUTICAL_TWICalulation type (pseudo-enum)static doublePLANET_ALTStellar altitude adjustmentstatic intRISINGState enumstatic intSETTINGState enumstatic intSUNCalulation type (pseudo-enum)static doubleSUN_ALTSolar altitude adjustmentstatic doubleSUN_TOPO_ALTSolar an lunar topocentric altitude adjustmentstatic intUNKNOWNState enum
-
Constructor Summary
Constructors Constructor and Description RiseSet()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static TimePairgetTimes(int rsType, double jd, ObsInfo oi)Calculate the rise/set (or start/end) times.static TimePairgetTimes(int rsType, double jd, ObsInfo oi, PlanetData pd)Calculate the rise/set (or start/end) times.
-
-
-
Field Detail
-
SUN
public static final int SUN
Calulation type (pseudo-enum)- See Also:
- Constant Field Values
-
MOON
public static final int MOON
Calulation type (pseudo-enum)- See Also:
- Constant Field Values
-
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).
-
UNKNOWN
public static final int UNKNOWN
State enum- See Also:
- Constant Field Values
-
RISING
public static final int RISING
State enum- See Also:
- Constant Field Values
-
SETTING
public static final int SETTING
State enum- See Also:
- Constant Field Values
-
CULMINATING
public static final int CULMINATING
State enum- See Also:
- Constant Field Values
-
-
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 timeoi- The observer's locationpd- 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 informationoi- The observer's location
-
-
DMelt 3.0 © DataMelt by jWork.ORG