Compute solar zenith angles from time and location using the formulation implemented in the NOAA Solar Calculator, itself based on the astronomical algorithms of Meeus.
Details
The computation is split internally into three steps:
geolight_solar_constants(): Time-only solar quantities (solar time and declination)geolight_solar_zenith(): Geometric solar zenith anglegeolight_solar_refracted(): Approximate atmospheric refraction correction
Conventions
lonis expressed in degrees east (positive eastward).latis expressed in degrees north.All angles are in degrees unless stated otherwise.
dateis provided as POSIXct and internally converted to Julian day.
When lat and lon are vectors, the result is a 3-D array with dimensions:
c(length(lat), length(lon), length(date))
When lat and lon are scalars, the result reduces to a vector of length
length(date).
Solar time and hour angle
Internally, the solar time is computed as NOAA's true solar time expressed as an angle (degrees) at Greenwich, without longitude adjustment. Longitude enters later through the hour angle:
hour_angle = solar_time + lon - 180
Values are intentionally not wrapped to [0, 360) because all downstream
trigonometric functions are periodic.
References
NOAA Global Monitoring Laboratory. Solar Calculation Details. https://gml.noaa.gov/grad/solcalc/calcdetails.html
Meeus, J. (1998). Astronomical Algorithms. Willmann-Bell.
Examples
date <- as.POSIXct(
c("2020-06-21 12:00:00", "2020-12-21 12:00:00"),
tz = "UTC"
)
z <- geolight_solar(date, lat = 46, lon = 6)
z
#> , , 1
#>
#> [,1]
#> [1,] 22.99545
#>
#> , , 2
#>
#> [,1]
#> [1,] 69.63826
#>
