twilight | R Documentation |
Estimate time of sunrise or sunset for a given day and location
twilight(tm, lon, lat, rise, zenith = 96, iters = 3, closest = FALSE) sunrise(tm, lon, lat, zenith = 96, iters = 3, closest = FALSE) sunset(tm, lon, lat, zenith = 96, iters = 3, closest = FALSE)
tm |
vector of approximate times of twilight. |
lon |
vector of longitudes. |
lat |
vector of latitudes. |
rise |
logical vector indicating whether to compute rise or set. |
zenith |
the solar zenith angle that defines twilight. |
iters |
number of iteratve refinements made to the initial approximation. |
closest |
if |
twilight
uses an iterative algorithm to estimate times of
sunrise and sunset.
Note that these functions return the twilight that occurs on the
same date GMT as tm
, and so sunset may occur before
sunrise, depending upon latitude.
Solar declination and equation of time vary slowly over the day, and so the values of the Solar declination and equation of time at sunrise/sunset are well approximated by their values at 6AM/6PM local time. The sun's hour angle and hence sunrise/sunset for the required zenith can then be caclulates from these approximations. The calculation is then repeated using the approximate sunrise/sunset times to derive more accurate values of the Solar declination and equation of time and hence better approximations of sunrise/sunset. The process is repreated and is accurate to less than 2 seconds within 2 or 3 iterations.
It is possible that sunrise or sunset does occur for a given date
and location. When closest
is FALSE
, the twilight
returned on or before the (UTC) date of tm
. When
closest
is TRUE
, twilight
attempts to return
the twilight closest to the input time tm
.
sunrise
and sunset
are simple wrappers for
twilight
.
a vector of twilight times.
## Approx location of Santa Barbara lon <- -119.7022 lat <- 34.4191 ## Sunrise and sunset for 8th April 2013 at Santa Barbara day <- as.POSIXct("2013-04-08","GMT") sunrise(day,lon,lat) sunset(day,lon,lat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.