Version: 0.5.1
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.
Imports: data.table, lubridate, magrittr
License: GPL-2 | file LICENSE
URL: https://github.com/datastorm-open/suncalc
NeedsCompilation: no
RoxygenNote: 7.1.2
Encoding: UTF-8
Packaged: 2022-09-29 05:56:11 UTC; BenoitThieurmel
Author: Benoit Thieurmel [aut, cre] (R interface), Achraf Elmarhraoui [aut] (R interface)
Maintainer: Benoit Thieurmel <bthieurmel@gmail.com>
Repository: CRAN
Date/Publication: 2022-09-29 16:20:14 UTC

Get Moon illumination

Description

Get Moon illumination

Usage

getMoonIllumination(date = Sys.Date(), keep = c("fraction", "phase", "angle"))

Arguments

date

: Single or multiple DateTime. Can be a Date (YYYY-MM-DD), a character in UTC (YYYY-MM-DD HH:mm:ss) or a POSIXct

keep

: character. Vector of variables to keep. See Details

Details

Returns an object with the following properties:

Moon phase value should be interpreted like this:

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).

Value

data.frame

See Also

getSunlightTimes, getMoonTimes, getMoonIllumination, getMoonPosition,getSunlightPosition

Examples


# 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

Description

Get Moon position

Usage

getMoonPosition(
  date = NULL,
  lat = NULL,
  lon = NULL,
  data = NULL,
  keep = c("altitude", "azimuth", "distance", "parallacticAngle")
)

Arguments

date

: Single or multiple DateTime. Can be a Date (YYYY-MM-DD), a character in UTC (YYYY-MM-DD HH:mm:ss) or a POSIXct

lat

: numeric. Single latitude

lon

: numeric. Single longitude

data

: data.frame. Alternative to use date, lat, lon for passing multiple coordinates

keep

: character. Vector of variables to keep. See Details

Details

Returns an object with the following properties:

Value

data.frame

See Also

getSunlightTimes, getMoonTimes, getMoonIllumination, getMoonPosition,getSunlightPosition

Examples


# 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

Description

Get Moon times

Usage

getMoonTimes(
  date = NULL,
  lat = NULL,
  lon = NULL,
  data = NULL,
  keep = c("rise", "set", "alwaysUp", "alwaysDown"),
  tz = "UTC",
  inUTC = FALSE
)

Arguments

date

: Date. Single or multiple Date. YYYY-MM-DD

lat

: numeric. Single latitude

lon

: numeric. Single longitude

data

: data.frame. Alternative to use date, lat, lon for passing multiple coordinates

keep

: character. Vector of variables to keep. See Details

tz

: character. Timezone of results

inUTC

: logical. By default, it will search for moon rise and set during local user's day (from 0 to 24 hours). If TRUE, it will instead search the specified date from 0 to 24 UTC hours.

Details

Available variables are :

Value

data.frame

See Also

getSunlightTimes, getMoonTimes, getMoonIllumination, getMoonPosition,getSunlightPosition

Examples


# 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

Description

Get Sunlight position

Usage

getSunlightPosition(
  date = NULL,
  lat = NULL,
  lon = NULL,
  data = NULL,
  keep = c("altitude", "azimuth")
)

Arguments

date

: Single or multiple DateTime. Can be a Date (YYYY-MM-DD), a character in UTC (YYYY-MM-DD HH:mm:ss) or a POSIXct

lat

: numeric. Single latitude

lon

: numeric. Single longitude

data

: data.frame. Alternative to use date, lat, lon for passing multiple coordinates

keep

: character. Vector of variables to keep. See Details

Details

Returns an object with the following properties:

Value

data.frame

See Also

getSunlightTimes, getMoonTimes, getMoonIllumination, getMoonPosition,getSunlightPosition

Examples


# 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

Description

Get Sunlight times

Usage

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"
)

Arguments

date

: Date. Single or multiple Date. YYYY-MM-DD

lat

: numeric. Single latitude

lon

: numeric. Single longitude

data

: data.frame. Alternative to use date, lat, lon for passing multiple coordinates

keep

: character. Vector of variables to keep. See Details

tz

: character. Timezone of results

Details

Available variables are :

Value

data.frame

See Also

getSunlightTimes, getMoonTimes, getMoonIllumination, getMoonPosition,getSunlightPosition

Examples


# 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")