Title: | Compute Sun Position, Sunlight Phases, Moon Position and Lunar Phase |
---|---|
Description: | Get sun position, sunlight phases (times for sunrise, sunset, dusk, etc.), moon position and lunar phase for the given location and time. Most calculations are based on the formulas given in Astronomy Answers articles about position of the sun and the planets : <https://www.aa.quae.nl/en/reken/zonpositie.html>. |
Authors: | Benoit Thieurmel [aut, cre] (R interface), Achraf Elmarhraoui [aut] (R interface) |
Maintainer: | Benoit Thieurmel <[email protected]> |
License: | GPL-2 | file LICENSE |
Version: | 0.5.2 |
Built: | 2024-11-11 05:14:59 UTC |
Source: | https://github.com/datastorm-open/suncalc |
Get Moon illumination
getMoonIllumination(date = Sys.Date(), keep = c("fraction", "phase", "angle"))
getMoonIllumination(date = Sys.Date(), keep = c("fraction", "phase", "angle"))
date |
: Single or multiple DateTime. Can be a |
keep |
: |
Returns an object with the following properties:
"fraction" : illuminated fraction of the moon; varies from 0.0 (new moon) to 1.0 (full moon)
"phase" : moon phase; varies from 0.0 to 1.0, described below
"angle" : midpoint angle in radians of the illuminated limb of the moon reckoned eastward from the north point of the disk; the moon is waxing if the angle is negative, and waning if positive
Moon phase value should be interpreted like this:
0 : New Moon
Waxing Crescent
0.25 : First Quarter
: Waxing Gibbous
0.5Full Moon
: Waning Gibbous
0.75Last Quarter
: Waning Crescent
By subtracting the parallacticAngle from the angle one can get the zenith angle of the moons bright limb (anticlockwise). The zenith angle can be used do draw the moon shape from the observers perspective (e.g. moon lying on its back).
data.frame
getSunlightTimes, getMoonTimes, getMoonIllumination, getMoonPosition,getSunlightPosition
# one date getMoonIllumination(date = Sys.Date()) # in character getMoonIllumination(date = c("2017-05-12", "2017-05-12 00:00:00"), keep = c("fraction", "phase")) # in POSIXct getMoonIllumination(date = as.POSIXct("2017-05-12 00:00:00", tz = "UTC")) getMoonIllumination(date = as.POSIXct("2017-05-12 02:00:00", tz = "CET")) date <- seq(ISOdate(2009,1,1), ISOdate(2010,1,1), "hours") date_cet <- date attr(date_cet, "tzone") <- "CET" res <- getMoonIllumination(date = date_cet)
# one date getMoonIllumination(date = Sys.Date()) # in character getMoonIllumination(date = c("2017-05-12", "2017-05-12 00:00:00"), keep = c("fraction", "phase")) # in POSIXct getMoonIllumination(date = as.POSIXct("2017-05-12 00:00:00", tz = "UTC")) getMoonIllumination(date = as.POSIXct("2017-05-12 02:00:00", tz = "CET")) date <- seq(ISOdate(2009,1,1), ISOdate(2010,1,1), "hours") date_cet <- date attr(date_cet, "tzone") <- "CET" res <- getMoonIllumination(date = date_cet)
Get Moon position
getMoonPosition( date = NULL, lat = NULL, lon = NULL, data = NULL, keep = c("altitude", "azimuth", "distance", "parallacticAngle") )
getMoonPosition( date = NULL, lat = NULL, lon = NULL, data = NULL, keep = c("altitude", "azimuth", "distance", "parallacticAngle") )
date |
: Single or multiple DateTime. Can be a |
lat |
: |
lon |
: |
data |
: |
keep |
: |
Returns an object with the following properties:
"altitude" : moon altitude above the horizon in radians
"azimuth" : moon azimuth in radians
"distance" : distance to moon in kilometers
"parallacticAngle" : parallactic angle of the moon in radians
data.frame
getSunlightTimes, getMoonTimes, getMoonIllumination, getMoonPosition,getSunlightPosition
# one date getMoonPosition(date = Sys.Date(), lat = 50.1, lon = 1.83) # in character getMoonPosition(date = c("2017-05-12", "2017-05-12 00:00:00"), lat = 50.1, lon = 1.83) # in POSIXct getMoonPosition(date = as.POSIXct("2017-05-12 00:00:00", tz = "UTC"), lat = 50.1, lon = 1.83) getMoonPosition(date = as.POSIXct("2017-05-12 02:00:00", tz = "CET"), lat = 50.1, lon = 1.83) # multiple date + subset getMoonPosition(date = seq.Date(Sys.Date()-9, Sys.Date(), by = 1), keep = c("altitude", "azimuth"), lat = 50.1, lon = 1.83) # multiple coordinates data <- data.frame(date = seq.Date(Sys.Date()-9, Sys.Date(), by = 1), lat = c(rep(50.1, 10), rep(49, 10)), lon = c(rep(1.83, 10), rep(2, 10))) getMoonPosition(data = data, keep = c("altitude", "azimuth"))
# one date getMoonPosition(date = Sys.Date(), lat = 50.1, lon = 1.83) # in character getMoonPosition(date = c("2017-05-12", "2017-05-12 00:00:00"), lat = 50.1, lon = 1.83) # in POSIXct getMoonPosition(date = as.POSIXct("2017-05-12 00:00:00", tz = "UTC"), lat = 50.1, lon = 1.83) getMoonPosition(date = as.POSIXct("2017-05-12 02:00:00", tz = "CET"), lat = 50.1, lon = 1.83) # multiple date + subset getMoonPosition(date = seq.Date(Sys.Date()-9, Sys.Date(), by = 1), keep = c("altitude", "azimuth"), lat = 50.1, lon = 1.83) # multiple coordinates data <- data.frame(date = seq.Date(Sys.Date()-9, Sys.Date(), by = 1), lat = c(rep(50.1, 10), rep(49, 10)), lon = c(rep(1.83, 10), rep(2, 10))) getMoonPosition(data = data, keep = c("altitude", "azimuth"))
Get Moon times
getMoonTimes( date = NULL, lat = NULL, lon = NULL, data = NULL, keep = c("rise", "set", "alwaysUp", "alwaysDown"), tz = "UTC", ... )
getMoonTimes( date = NULL, lat = NULL, lon = NULL, data = NULL, keep = c("rise", "set", "alwaysUp", "alwaysDown"), tz = "UTC", ... )
date |
: |
lat |
: |
lon |
: |
data |
: |
keep |
: |
tz |
: |
... |
:Not used. (Maintenance only) |
Available variables are :
"rise" : Date
. moonrise time
"set" : Date
. moonset time
"alwaysUp" : Logical
. TRUE if the moon never rises or sets and is always above the horizon during the day
"alwaysDown" : Logical
. TRUE if the moon is always below the horizon
data.frame
getSunlightTimes, getMoonTimes, getMoonIllumination, getMoonPosition,getSunlightPosition
# one date getMoonTimes(date = Sys.Date(), lat = 47.21, lon = -1.557, tz = "CET") # multiple date + subset getMoonTimes(date = seq.Date(Sys.Date()-9, Sys.Date(), by = 1), keep = c("rise", "set", "alwaysUp"), lat = 47.21, lon = -1.557, tz = "CET") # multiple coordinates data <- data.frame(date = seq.Date(Sys.Date()-9, Sys.Date(), by = 1), lat = c(rep(50.1, 10), rep(49, 10)), lon = c(rep(1.83, 10), rep(2, 10))) getMoonTimes(data = data, tz = "CET")
# one date getMoonTimes(date = Sys.Date(), lat = 47.21, lon = -1.557, tz = "CET") # multiple date + subset getMoonTimes(date = seq.Date(Sys.Date()-9, Sys.Date(), by = 1), keep = c("rise", "set", "alwaysUp"), lat = 47.21, lon = -1.557, tz = "CET") # multiple coordinates data <- data.frame(date = seq.Date(Sys.Date()-9, Sys.Date(), by = 1), lat = c(rep(50.1, 10), rep(49, 10)), lon = c(rep(1.83, 10), rep(2, 10))) getMoonTimes(data = data, tz = "CET")
Get Sunlight position
getSunlightPosition( date = NULL, lat = NULL, lon = NULL, data = NULL, keep = c("altitude", "azimuth") )
getSunlightPosition( date = NULL, lat = NULL, lon = NULL, data = NULL, keep = c("altitude", "azimuth") )
date |
: Single or multiple DateTime. Can be a |
lat |
: |
lon |
: |
data |
: |
keep |
: |
Returns an object with the following properties:
"altitude" : sun altitude above the horizon in radians, e.g. 0 at the horizon and PI/2 at the zenith (straight over your head)
"azimuth" : sun azimuth in radians (direction along the horizon, measured from south to west), e.g. 0 is south and Math.PI * 3/4 is northwest
data.frame
getSunlightTimes, getMoonTimes, getMoonIllumination, getMoonPosition,getSunlightPosition
# one date getSunlightPosition(date = Sys.Date(), lat = 50.1, lon = 1.83) # in character getSunlightPosition(date = c("2017-05-12", "2017-05-12 00:00:00"), lat = 50.1, lon = 1.83) # in POSIXct getSunlightPosition(date = as.POSIXct("2017-05-12 00:00:00", tz = "UTC"), lat = 50.1, lon = 1.83) getSunlightPosition(date = as.POSIXct("2017-05-12 02:00:00", tz = "CET"), lat = 50.1, lon = 1.83) # multiple date + subset getSunlightPosition(date = seq.Date(Sys.Date()-9, Sys.Date(), by = 1), keep = c("altitude"), lat = 50.1, lon = 1.83) # multiple coordinates data <- data.frame(date = seq.Date(Sys.Date()-9, Sys.Date(), by = 1), lat = c(rep(50.1, 10), rep(49, 10)), lon = c(rep(1.83, 10), rep(2, 10))) getSunlightPosition(data = data, keep = c("altitude", "azimuth"))
# one date getSunlightPosition(date = Sys.Date(), lat = 50.1, lon = 1.83) # in character getSunlightPosition(date = c("2017-05-12", "2017-05-12 00:00:00"), lat = 50.1, lon = 1.83) # in POSIXct getSunlightPosition(date = as.POSIXct("2017-05-12 00:00:00", tz = "UTC"), lat = 50.1, lon = 1.83) getSunlightPosition(date = as.POSIXct("2017-05-12 02:00:00", tz = "CET"), lat = 50.1, lon = 1.83) # multiple date + subset getSunlightPosition(date = seq.Date(Sys.Date()-9, Sys.Date(), by = 1), keep = c("altitude"), lat = 50.1, lon = 1.83) # multiple coordinates data <- data.frame(date = seq.Date(Sys.Date()-9, Sys.Date(), by = 1), lat = c(rep(50.1, 10), rep(49, 10)), lon = c(rep(1.83, 10), rep(2, 10))) getSunlightPosition(data = data, keep = c("altitude", "azimuth"))
Get Sunlight times
getSunlightTimes( date = NULL, lat = NULL, lon = NULL, data = NULL, keep = c("solarNoon", "nadir", "sunrise", "sunset", "sunriseEnd", "sunsetStart", "dawn", "dusk", "nauticalDawn", "nauticalDusk", "nightEnd", "night", "goldenHourEnd", "goldenHour"), tz = "UTC" )
getSunlightTimes( date = NULL, lat = NULL, lon = NULL, data = NULL, keep = c("solarNoon", "nadir", "sunrise", "sunset", "sunriseEnd", "sunsetStart", "dawn", "dusk", "nauticalDawn", "nauticalDusk", "nightEnd", "night", "goldenHourEnd", "goldenHour"), tz = "UTC" )
date |
: |
lat |
: |
lon |
: |
data |
: |
keep |
: |
tz |
: |
Available variables are :
"sunrise" : sunrise (top edge of the sun appears on the horizon)
"sunriseEnd" : sunrise ends (bottom edge of the sun touches the horizon)
"goldenHourEnd" : morning golden hour (soft light, best time for photography) ends
"solarNoon" : solar noon (sun is in the highest position)
"goldenHour" : evening golden hour starts
"sunsetStart" : sunset starts (bottom edge of the sun touches the horizon)
"sunset" : sunset (sun disappears below the horizon, evening civil twilight starts)
"dusk" : dusk (evening nautical twilight starts)
"nauticalDusk" : nautical dusk (evening astronomical twilight starts)
"night" : night starts (dark enough for astronomical observations)
"nadir" : nadir (darkest moment of the night, sun is in the lowest position)
"nightEnd" : night ends (morning astronomical twilight starts)
"nauticalDawn" : nautical dawn (morning nautical twilight starts)
"dawn" : dawn (morning nautical twilight ends, morning civil twilight starts)
data.frame
getSunlightTimes, getMoonTimes, getMoonIllumination, getMoonPosition,getSunlightPosition
# one date getSunlightTimes(date = Sys.Date(), lat = 50.1, lon = 1.83, tz = "CET") # multiple date + subset getSunlightTimes(date = seq.Date(Sys.Date()-9, Sys.Date(), by = 1), keep = c("sunrise", "sunriseEnd", "sunset", "sunsetStart"), lat = 50.1, lon = 1.83, tz = "CET") # multiple coordinates data <- data.frame(date = seq.Date(Sys.Date()-9, Sys.Date(), by = 1), lat = c(rep(50.1, 10), rep(49, 10)), lon = c(rep(1.83, 10), rep(2, 10))) getSunlightTimes(data = data, keep = c("sunrise", "sunriseEnd", "sunset", "sunsetStart"), tz = "CET")
# one date getSunlightTimes(date = Sys.Date(), lat = 50.1, lon = 1.83, tz = "CET") # multiple date + subset getSunlightTimes(date = seq.Date(Sys.Date()-9, Sys.Date(), by = 1), keep = c("sunrise", "sunriseEnd", "sunset", "sunsetStart"), lat = 50.1, lon = 1.83, tz = "CET") # multiple coordinates data <- data.frame(date = seq.Date(Sys.Date()-9, Sys.Date(), by = 1), lat = c(rep(50.1, 10), rep(49, 10)), lon = c(rep(1.83, 10), rep(2, 10))) getSunlightTimes(data = data, keep = c("sunrise", "sunriseEnd", "sunset", "sunsetStart"), tz = "CET")