I want to calculate the sunrise, sunset and daylength for 365 days. Therefore I use the insol package. The package includes the daylength()
function to achieve this. The function takes latitude, longitude, day and timezone as inputs. The JD()
function is used for transforming a POSIXct object into a Julian Day as required by the daylength()
function.
Reproduceable example:
date <- as.POSIXct("2021-01-15")
date_sunevents <- daylength(48.457778, 9.00, insol::JD(date), 1)
This codes returns the following values for the given day:
- sunrise: 8.28
- sunset: 16.83
- daylength: 8.55
This values seem to be close to the real values but something is wrong with the format. I expected the values to be in a format between 0-24.0-59
.
I feel like I am missing the point of the function..
CodePudding user response:
Answer from ChatGPT
The values that the
daylength()
function returns are not in a time format, but in decimal hours. Thesunrise
value of 8.28 indicates that the sun rises at 8:16:48 (8 hours 16 minutes 48 seconds) on that day. Similarly, thesunset
value of 16.83 indicates that the sun sets at 16:49:48 (16 hours 49 minutes 48 seconds) on that day. Thedaylength
value of 8.55 indicates that the day is 8 hours and 33 minutes long.