Description Usage Arguments Details Value Author(s) References See Also Examples
View source: R/twilight_timeframe.R
A wrapper function for twilight(). In addition to the calculation of sunrise and sunset the function compares the specified timeframe with current data (optional).
1 | twilight_timeframe(data_POSIXct, latitude, longitude, twilight = "civil", min2sunrise = 0, minaftersunrise = 0, min2sunset = 0, minaftersunset = 0)
|
data_POSIXct |
An object of class POSIXct. It is important to specify the correct timezone. |
latitude |
specify latitude |
longitude |
specify longitude |
twilight |
A character value: Choose between "civil", "nautic" or "rise/set" to specify required twilight condition. Default: "civil" |
min2sunrise |
Positive numeric value indicating the minutes before sunrise. |
minaftersunrise |
Positive numeric value indicating the minutes after sunrise. |
min2sunset |
Positive numeric value indicating the minutes before sunset. |
minaftersunset |
Positive numeric value indicating the minutes after sunset. |
By using the function it is straightforward to subset the original data and get additional information about lighting conditions.
The output is a data.frame object (including sunrise and sunset in POSIXct-format). If desired you can use cbind() to add this information to the original dataframe.
Frederik Sachser, Thomas Ruf
The formula within the function twilight() was adapted from the following webpage: http://lexikon.astronomie.info/zeitgleichung/
1 2 3 4 5 6 | now <- as.POSIXct(x = "2015-01-30 20:58:00", tz = "CET", origin = "01/01/1970")
art_date <- seq(now, now + 90*60*99, 90*60)
attributes(art_date)$tz <- 'CET'
lat <- runif(n = 100, min = 46.1, max = 46.9)
lon <- runif(n = 100, min = 13.1, max = 13.9)
twilight_timeframe(data_POSIXct = art_date, latitude = lat, longitude = lon, twilight = "civil", min2sunrise = 90, minaftersunrise = 90, min2sunset = 90, minaftersunset = 90)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.