This follows the SPA algorithm described in Reda, I.; Andreas, A. (2003): Solar Position Algorithm for Solar Radiation Applications. NREL Report No. TP-560-34302, Revised January 2008.
This is not a port of the C code, but a re-implementation based on the published procedure.
- Author:
- Klaus Brunner
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumPredefined elevation angles to use in sunrise-sunset calculation. -
Method Summary
Modifier and TypeMethodDescriptionstatic SolarPositioncalculateSolarPosition(ZonedDateTime date, double latitude, double longitude, double elevation, double deltaT) Calculate topocentric solar position: the location of the sun on the sky for a certain point in time on a certain point of the Earth's surface.static SolarPositioncalculateSolarPosition(ZonedDateTime date, double latitude, double longitude, double elevation, double deltaT, double pressure, double temperature) Calculate topocentric solar position: the location of the sun on the sky for a certain point in time on a certain point of the Earth's surface.static SunriseResultcalculateSunriseTransitSet(ZonedDateTime day, double latitude, double longitude, double deltaT) Calculate the times of sunrise, sun transit (solar noon), and sunset for a given day.static SunriseResultcalculateSunriseTransitSet(ZonedDateTime day, double latitude, double longitude, double deltaT, SPA.Horizon horizon) Calculate the times of sunrise, sun transit (solar noon), and sunset for a given day.static Map<SPA.Horizon, SunriseResult> calculateSunriseTransitSet(ZonedDateTime day, double latitude, double longitude, double deltaT, SPA.Horizon... horizons) Calculate the times of sunrise, sun transit (solar noon), and sunset for a given day and horizon types.
-
Method Details
-
calculateSolarPosition
public static SolarPosition calculateSolarPosition(ZonedDateTime date, double latitude, double longitude, double elevation, double deltaT, double pressure, double temperature) Calculate topocentric solar position: the location of the sun on the sky for a certain point in time on a certain point of the Earth's surface.This follows the SPA algorithm described in Reda, I.; Andreas, A. (2003): Solar Position Algorithm for Solar Radiation Applications. NREL Report No. TP-560-34302, Revised January 2008. The algorithm is supposed to work for the years -2000 to 6000, with uncertainties of +/-0.0003 degrees.
- Parameters:
date- Observer's local date and time.latitude- Observer's latitude, in degrees (negative south of equator).longitude- Observer's longitude, in degrees (negative west of Greenwich).elevation- Observer's elevation, in meters.deltaT- Difference between earth rotation time and terrestrial time (or Universal Time and Terrestrial Time), in seconds. SeeJulianDate(ZonedDateTime, double)andDeltaT.pressure- Annual average local pressure, in millibars (or hectopascals). Used for refraction correction of zenith angle. If unsure, 1000 is a reasonable default.temperature- Annual average local temperature, in degrees Celsius. Used for refraction correction of zenith angle.- Returns:
- Topocentric solar position (azimuth measured eastward from north)
- Throws:
IllegalArgumentException- for nonsensical latitude/longitude- See Also:
-
calculateSolarPosition
public static SolarPosition calculateSolarPosition(ZonedDateTime date, double latitude, double longitude, double elevation, double deltaT) Calculate topocentric solar position: the location of the sun on the sky for a certain point in time on a certain point of the Earth's surface.This follows the SPA algorithm described in Reda, I.; Andreas, A. (2003): Solar Position Algorithm for Solar Radiation Applications. NREL Report No. TP-560-34302, Revised January 2008. The algorithm is supposed to work for the years -2000 to 6000, with uncertainties of +/-0.0003 degrees.
This method does not perform refraction correction.
- Parameters:
date- Observer's local date and time.latitude- Observer's latitude, in degrees (negative south of equator).longitude- Observer's longitude, in degrees (negative west of Greenwich).elevation- Observer's elevation, in meters.deltaT- Difference between earth rotation time and terrestrial time (or Universal Time and Terrestrial Time), in seconds. SeeJulianDate(ZonedDateTime, double)andDeltaT.- Returns:
- Topocentric solar position (azimuth measured eastward from north)
- Throws:
IllegalArgumentException- for nonsensical latitude/longitude- See Also:
-
calculateSunriseTransitSet
public static SunriseResult calculateSunriseTransitSet(ZonedDateTime day, double latitude, double longitude, double deltaT) Calculate the times of sunrise, sun transit (solar noon), and sunset for a given day. The calculation is based on the astronomical definition of sunrise and sunset, using a refraction correction of -0.8333°.- Parameters:
day- GregorianCalendar of day for which sunrise/transit/sunset are to be calculated. The time of day (hour, minute, second, millisecond) is ignored.latitude- Observer's latitude, in degrees (negative south of equator).longitude- Observer's longitude, in degrees (negative west of Greenwich).deltaT- Difference between earth rotation time and terrestrial time (or Universal Time and Terrestrial Time), in seconds. SeeJulianDate(ZonedDateTime, double)andDeltaT.- Returns:
- An implementation of
SunriseResultdepending on the type of day. - Throws:
IllegalArgumentException- for nonsensical latitude/longitude
-
calculateSunriseTransitSet
public static SunriseResult calculateSunriseTransitSet(ZonedDateTime day, double latitude, double longitude, double deltaT, SPA.Horizon horizon) Calculate the times of sunrise, sun transit (solar noon), and sunset for a given day. The definition of sunrise or sunset can be chosen based on a horizon type (defined via its elevation angle).- Parameters:
day- GregorianCalendar of day for which sunrise/transit/sunset are to be calculated. The time of day (hour, minute, second, millisecond) is ignored.latitude- Observer's latitude, in degrees (negative south of equator).longitude- Observer's longitude, in degrees (negative west of Greenwich).deltaT- Difference between earth rotation time and terrestrial time (or Universal Time and Terrestrial Time), in seconds. SeeJulianDate(ZonedDateTime, double)andDeltaT.horizon- Horizon (basically, elevation angle) to use as the sunrise/sunset definition. This can be used to calculate twilight times.- Returns:
- An implementation of
SunriseResultdepending on the type of day. - Throws:
IllegalArgumentException- for nonsensical latitude/longitude
-
calculateSunriseTransitSet
public static Map<SPA.Horizon,SunriseResult> calculateSunriseTransitSet(ZonedDateTime day, double latitude, double longitude, double deltaT, SPA.Horizon... horizons) Calculate the times of sunrise, sun transit (solar noon), and sunset for a given day and horizon types. This is useful to get sunrise/sunset and multiple twilight times in one call and is expected to be faster than separate calls.- Parameters:
day- GregorianCalendar of day for which sunrise/transit/sunset are to be calculated. The time of day (hour, minute, second, millisecond) is ignored.latitude- Observer's latitude, in degrees (negative south of equator).longitude- Observer's longitude, in degrees (negative west of Greenwich).deltaT- Difference between earth rotation time and terrestrial time (or Universal Time and Terrestrial Time), in seconds. SeeJulianDate(ZonedDateTime, double)andDeltaT.horizons- Horizons (basically, elevation angles) to use as the sunrise/sunset definition. This can be used to calculate twilight times.- Returns:
- A Map with one key-value pair for each unique horizon type and
SunriseResult. This map may or may not be mutable. - Throws:
IllegalArgumentException- for nonsensical latitude/longitude
-