Package com.kosherjava.zmanim.util
Class NOAACalculator
java.lang.Object
com.kosherjava.zmanim.util.AstronomicalCalculator
com.kosherjava.zmanim.util.NOAACalculator
- All Implemented Interfaces:
Cloneable
Implementation of sunrise and sunset methods to calculate astronomical times based on the NOAA algorithm. This calculator uses the Java algorithm based on the implementation by NOAA - National Oceanic and Atmospheric Administration's Surface Radiation Research Branch. NOAA's implementation is based on equations from Astronomical Algorithms by Jean Meeus. Added to the algorithm is an adjustment of the zenith
to account for elevation. The algorithm can be found in the Wikipedia Sunrise Equation article.
- Author:
- © Eliyahu Hershfeld 2011 - 2023
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final double
The Julian day of January 1, 2000, known as J2000.0.private static final double
Julian days per century. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the name of the algorithm.private static double
getEarthOrbitEccentricity
(double julianCenturies) Return the eccentricity of earth's orbit.private static double
getEquationOfTime
(double julianCenturies) Return the Equation of Time - the difference between true solar time and mean solar timeprivate static double
getJulianCenturiesFromJulianDay
(double julianDay) Convert Julian day to centuries since J2000.0.private static double
getJulianDay
(Calendar calendar) Return the Julian day from a Java Calendarprivate static double
getJulianDayFromJulianCenturies
(double julianCenturies) Convert centuries since J2000.0 to Julian day.private static double
getMeanObliquityOfEcliptic
(double julianCenturies) Returns the mean obliquity of the ecliptic (Axial tilt).private static double
getObliquityCorrection
(double julianCenturies) Returns the corrected obliquity of the ecliptic (Axial tilt).static double
getSolarAzimuth
(Calendar cal, double lat, double lon) Return the Solar Azimuth for the horizontal coordinate system at the given location at the given time.static double
getSolarElevation
(Calendar cal, double lat, double lon) Return the Solar Elevation for the horizontal coordinate system at the given location at the given time.private static double
getSolarNoonUTC
(double julianCenturies, double longitude) Return the Universal Coordinated Time (UTC) of of solar noon for the given day at the given location on earth.private static double
getSunApparentLongitude
(double julianCenturies) Return the apparent longitude of the sun.private static double
getSunDeclination
(double julianCenturies) Return the declination of the sun.private static double
getSunEquationOfCenter
(double julianCenturies) Returns the equation of center for the sun.private static double
getSunGeometricMeanAnomaly
(double julianCenturies) Returns the Geometric Mean Anomaly of the Sun.private static double
getSunGeometricMeanLongitude
(double julianCenturies) Returns the Geometric Mean Longitude of the Sun.private static double
getSunHourAngleAtSunrise
(double lat, double solarDec, double zenith) Return the hour angle of the sun in radians at sunrise for the latitude.private static double
getSunHourAngleAtSunset
(double lat, double solarDec, double zenith) Returns the hour angle of the sun in radiansat sunset for the latitude.private static double
getSunriseUTC
(double julianDay, double latitude, double longitude, double zenith) Return the Universal Coordinated Time (UTC) of sunrise for the given day at the given location on earth.private static double
getSunsetUTC
(double julianDay, double latitude, double longitude, double zenith) Return the Universal Coordinated Time (UTC) of sunset for the given day at the given location on earth.private static double
getSunTrueLongitude
(double julianCenturies) Return the true longitude of the sun.double
getUTCNoon
(Calendar calendar, GeoLocation geoLocation) Return the Universal Coordinated Time (UTC) of solar noon for the given day at the given location on earth.double
getUTCSunrise
(Calendar calendar, GeoLocation geoLocation, double zenith, boolean adjustForElevation) A method that calculates UTC sunrise as well as any time based on an angle above or below sunrise.double
getUTCSunset
(Calendar calendar, GeoLocation geoLocation, double zenith, boolean adjustForElevation) A method that calculates UTC sunset as well as any time based on an angle above or below sunset.Methods inherited from class com.kosherjava.zmanim.util.AstronomicalCalculator
adjustZenith, clone, getDefault, getEarthRadius, getElevationAdjustment, getRefraction, getSolarRadius, setEarthRadius, setRefraction, setSolarRadius
-
Field Details
-
JULIAN_DAY_JAN_1_2000
The Julian day of January 1, 2000, known as J2000.0.- See Also:
-
JULIAN_DAYS_PER_CENTURY
Julian days per century.- See Also:
-
-
Constructor Details
-
NOAACalculator
public NOAACalculator()
-
-
Method Details
-
getCalculatorName
Description copied from class:AstronomicalCalculator
Returns the name of the algorithm.- Specified by:
getCalculatorName
in classAstronomicalCalculator
- Returns:
- the descriptive name of the algorithm.
- See Also:
-
getUTCSunrise
public double getUTCSunrise(Calendar calendar, GeoLocation geoLocation, double zenith, boolean adjustForElevation) Description copied from class:AstronomicalCalculator
A method that calculates UTC sunrise as well as any time based on an angle above or below sunrise. This abstract method is implemented by the classes that extend this class.- Specified by:
getUTCSunrise
in classAstronomicalCalculator
- Parameters:
calendar
- Used to calculate day of year.geoLocation
- The location information used for astronomical calculating sun times.zenith
- the azimuth below the vertical zenith of 90 degrees. for sunrise typically thezenith
used for the calculation uses geometric zenith of 90° andadjusts
this slightly to account for solar refraction and the sun's radius. Another example would beAstronomicalCalendar.getBeginNauticalTwilight()
that passesAstronomicalCalendar.NAUTICAL_ZENITH
to this method.adjustForElevation
- Should the time be adjusted for elevation- Returns:
- The UTC time of sunrise in 24 hour format. 5:45:00 AM will return 5.75.0. If an error was encountered in
the calculation (expected behavior for some locations such as near the poles,
Double.NaN
will be returned. - See Also:
-
getUTCSunset
public double getUTCSunset(Calendar calendar, GeoLocation geoLocation, double zenith, boolean adjustForElevation) Description copied from class:AstronomicalCalculator
A method that calculates UTC sunset as well as any time based on an angle above or below sunset. This abstract method is implemented by the classes that extend this class.- Specified by:
getUTCSunset
in classAstronomicalCalculator
- Parameters:
calendar
- Used to calculate day of year.geoLocation
- The location information used for astronomical calculating sun times.zenith
- the azimuth below the vertical zenith of 90°. For sunset typically thezenith
used for the calculation uses geometric zenith of 90° andadjusts
this slightly to account for solar refraction and the sun's radius. Another example would beAstronomicalCalendar.getEndNauticalTwilight()
that passesAstronomicalCalendar.NAUTICAL_ZENITH
to this method.adjustForElevation
- Should the time be adjusted for elevation- Returns:
- The UTC time of sunset in 24 hour format. 5:45:00 AM will return 5.75.0. If an error was encountered in
the calculation (expected behavior for some locations such as near the poles,
Double.NaN
will be returned. - See Also:
-
getJulianDay
Return the Julian day from a Java Calendar- Parameters:
calendar
- The Java Calendar- Returns:
- the Julian day corresponding to the date Note: Number is returned for start of day. Fractional days should be added later.
-
getJulianCenturiesFromJulianDay
Convert Julian day to centuries since J2000.0.- Parameters:
julianDay
- the Julian Day to convert- Returns:
- the centuries since 2000 Julian corresponding to the Julian Day
-
getJulianDayFromJulianCenturies
Convert centuries since J2000.0 to Julian day.- Parameters:
julianCenturies
- the number of Julian centuries since J2000.0.- Returns:
- the Julian Day corresponding to the Julian centuries passed in
-
getSunGeometricMeanLongitude
Returns the Geometric Mean Longitude of the Sun.- Parameters:
julianCenturies
- the number of Julian centuries since J2000.0.- Returns:
- the Geometric Mean Longitude of the Sun in degrees
-
getSunGeometricMeanAnomaly
Returns the Geometric Mean Anomaly of the Sun.- Parameters:
julianCenturies
- the number of Julian centuries since J2000.0.- Returns:
- the Geometric Mean Anomaly of the Sun in degrees
-
getEarthOrbitEccentricity
Return the eccentricity of earth's orbit.- Parameters:
julianCenturies
- the number of Julian centuries since J2000.0.- Returns:
- the unitless eccentricity
-
getSunEquationOfCenter
Returns the equation of center for the sun.- Parameters:
julianCenturies
- the number of Julian centuries since J2000.0.- Returns:
- the equation of center for the sun in degrees
-
getSunTrueLongitude
Return the true longitude of the sun.- Parameters:
julianCenturies
- the number of Julian centuries since J2000.0.- Returns:
- the sun's true longitude in degrees
-
getSunApparentLongitude
Return the apparent longitude of the sun.- Parameters:
julianCenturies
- the number of Julian centuries since J2000.0.- Returns:
- sun's apparent longitude in degrees
-
getMeanObliquityOfEcliptic
Returns the mean obliquity of the ecliptic (Axial tilt).- Parameters:
julianCenturies
- the number of Julian centuries since J2000.0.- Returns:
- the mean obliquity in degrees
-
getObliquityCorrection
Returns the corrected obliquity of the ecliptic (Axial tilt).- Parameters:
julianCenturies
- the number of Julian centuries since J2000.0.- Returns:
- the corrected obliquity in degrees
-
getSunDeclination
Return the declination of the sun.- Parameters:
julianCenturies
- the number of Julian centuries since J2000.0.- Returns:
- the sun's declination in degrees
-
getEquationOfTime
Return the Equation of Time - the difference between true solar time and mean solar time- Parameters:
julianCenturies
- the number of Julian centuries since J2000.0.- Returns:
- equation of time in minutes of time
-
getSunHourAngleAtSunrise
Return the hour angle of the sun in radians at sunrise for the latitude.- Parameters:
lat
- the latitude of observer in degreessolarDec
- the declination angle of sun in degreeszenith
- the zenith- Returns:
- hour angle of sunrise in radians
-
getSunHourAngleAtSunset
Returns the hour angle of the sun in radiansat sunset for the latitude.- Parameters:
lat
- the latitude of observer in degreessolarDec
- the declination angle of sun in degreeszenith
- the zenith- Returns:
- the hour angle of sunset in radians
- TODO:
- use -
getSunHourAngleAtSunrise(double, double, double)
implementation to avoid duplication of code.
-
getSolarElevation
Return the Solar Elevation for the horizontal coordinate system at the given location at the given time. Can be negative if the sun is below the horizon. Not corrected for altitude.- Parameters:
cal
- time of calculationlat
- latitude of location for calculationlon
- longitude of location for calculation- Returns:
- solar elevation in degrees - horizon is 0 degrees, civil twilight is -6 degrees
-
getSolarAzimuth
Return the Solar Azimuth for the horizontal coordinate system at the given location at the given time. Not corrected for altitude. True south is 0 degrees.- Parameters:
cal
- time of calculationlat
- latitude of location for calculationlon
- longitude of location for calculation- Returns:
- the solar azimuth
-
getSunriseUTC
private static double getSunriseUTC(double julianDay, double latitude, double longitude, double zenith) Return the Universal Coordinated Time (UTC) of sunrise for the given day at the given location on earth.- Parameters:
julianDay
- the Julian daylatitude
- the latitude of observer in degreeslongitude
- the longitude of observer in degreeszenith
- the zenith- Returns:
- the time in minutes from zero UTC
-
getUTCNoon
Return the Universal Coordinated Time (UTC) of solar noon for the given day at the given location on earth. This implementation returns true solar noon as opposed to the time halfway between sunrise and sunset. Other calculators may return a more simplified calculation of halfway between sunrise and sunset. See The Definition of Chatzos for details on solar noon calculations.- Specified by:
getUTCNoon
in classAstronomicalCalculator
- Parameters:
calendar
- The Calendar representing the date to calculate solar noon forgeoLocation
- The location information used for astronomical calculating sun times. This class uses only requires the longitude for calculating noon since it is the same time anywhere along the longitude line.- Returns:
- the time in minutes from zero UTC
- See Also:
-
getSolarNoonUTC
Return the Universal Coordinated Time (UTC) of of solar noon for the given day at the given location on earth.- Parameters:
julianCenturies
- the number of Julian centuries since J2000.0.longitude
- the longitude of observer in degrees- Returns:
- the time in minutes from zero UTC
- See Also:
-
getSunsetUTC
private static double getSunsetUTC(double julianDay, double latitude, double longitude, double zenith) Return the Universal Coordinated Time (UTC) of sunset for the given day at the given location on earth.- Parameters:
julianDay
- the Julian daylatitude
- the latitude of observer in degreeslongitude
- longitude of observer in degreeszenith
- zenith- Returns:
- the time in minutes from zero Universal Coordinated Time (UTC)
-