|
13 | 13 | #' @return The moment of sunrise or sunset for the date set by \code{date}and time zone as specified
|
14 | 14 | #' (by \code{date} and \code{tz}) or in UTC if not specified.
|
15 | 15 | #'
|
16 |
| -#' @details The angular diameter of the sun is about 0.536 degrees, |
| 16 | +#' @details |
| 17 | +#' The day for which sunrise and sunset are calcuated is given by the input date. |
| 18 | +#' Sunrise and sunset are calculated relative to the moment of solar noon for that date, |
| 19 | +#' i.e. the first sunrise before the moment of solar noon, and the first sunset after the |
| 20 | +#' moment of solar noon. Therefore, depending on the timezone provided, it is possible that |
| 21 | +#' the nearest sunrise prior to solar noon occurs a day earlier than the input date. |
| 22 | +#' Similarly, sunset may occur a day later than the input date. See examples for details. |
| 23 | +#' |
| 24 | +#' The angular diameter of the sun is about 0.536 degrees, |
17 | 25 | #' therefore the moment of sunrise/sunset corresponds to half that elevation
|
18 | 26 | #' at -0.268 degrees.
|
19 | 27 | #'
|
|
22 | 30 | #' Approximate astronomical formula are used, therefore the moment of
|
23 | 31 | #' sunrise / sunset may be off by a few minutes
|
24 | 32 | #'
|
25 |
| -#' Sunrise and sunset is given for the day specified by \code{date}, with sunset always |
26 |
| -#' later than sunrise given the same \code{date}. |
27 |
| -#' |
28 | 33 | #' If \code{force_tz} is \code{TRUE}, the input date is converted to the timezone
|
29 | 34 | #' set by \code{tz} prior to calculating the sunrise/sunset time, resulting in a shift by +/-1 day
|
30 | 35 | #'
|
|
35 | 40 | #' # sunset in the Netherlands
|
36 | 41 | #' sunset("2016-01-01", 5, 53)
|
37 | 42 | #'
|
38 |
| -#' # civil twilight in Ithaca, NY, today |
39 |
| -#' sunrise(Sys.time(), -76.5, 42.4, elev = -6) |
| 43 | +#' # civil twilight in Ithaca, NY |
| 44 | +#' sunrise("2016-01-01", -76.5, 42.4, elev = -6) |
| 45 | +#' |
| 46 | +#' # next sunset in South Dakota, USA |
| 47 | +#' sunset("2016-11-15", -98, 45) |
| 48 | +#' |
| 49 | +#' # Beware that some days have two sunsets, or |
| 50 | +#' # two sunrises! E.g. on 5 Oct (local timezone) at |
| 51 | +#' # this location sunset is actually on the 6 Oct |
| 52 | +#' # in UTC time zone, i.e. the next day |
| 53 | +#' sunset("2016-10-5", -98, 45) |
| 54 | +#' # One day later, sunset is again on 6 Oct: |
| 55 | +#' sunset("2016-10-6", -98, 45) |
| 56 | +#' |
| 57 | +#' # working in local time zones typically avoids such ambiguities: |
| 58 | +#' sunset(as_datetime("2016-06-05",tz="America/Chicago"), -98, 45) |
| 59 | +#' sunset(as_datetime("2016-06-06",tz="America/Chicago"), -98, 45) |
| 60 | +#' |
| 61 | +#' # use force_tz to force output to a specific time zone, by default UTC: |
| 62 | +#' sunset(as_datetime("2016-06-05",tz="America/Chicago"), -98, 45, force_tz=T) |
| 63 | +#' sunset(as_datetime("2016-06-06",tz="America/Chicago"), -98, 45, force_tz=T) |
| 64 | +#' |
| 65 | +#' # Also beware of jumps in sunrise and sunset date with longitude: |
| 66 | +#' sunrise("2016-11-01", 100, 45) |
| 67 | +#' sunrise("2016-11-01", 102, 45) |
| 68 | +#' |
| 69 | +#' # sunrise date can even be two days earlier in specific cases: |
| 70 | +#' # e.g. "2016-10-31 00:00" in Asia/Ulaanbaatar time zone is converted to |
| 71 | +#' # 2016-10-30 16:00 UTC when force_tz=TRUE. Solar noon on 2016-10-30 at this |
| 72 | +#' location in Mongolia is at 04:55 UTC, and the first sunrise prior to this |
| 73 | +#' is on 2016-10-29: |
| 74 | +#' sunrise(as_datetime("2016-10-31",tz="Asia/Ulaanbaatar"), 120, 45, tz="UTC", force_tz=T) |
40 | 75 | #' @name sunrise_sunset
|
41 | 76 | NULL
|
42 | 77 |
|
|
0 commit comments