Learn R Programming

photobiology (version 0.9.6)

day_night: Times for sun positions

Description

Functions for calculating the timing of solar positions by means of function sun_angles, given geographical coordinates and dates. They can be also used to find the time for an arbitrary solar elevation between 90 and -90 degrees by supplying "twilight" angle(s) as argument.

Usage

day_night(date = lubridate::today(), tz = "UTC", geocode = NULL,
  lon = 0, lat = 0, twilight = "none", unit.out = "date")

noon_time(date = lubridate::today(), tz = "UTC", geocode = NULL,
  lon = 0, lat = 0, twilight = NA, unit.out = "date")

sunrise_time(date = lubridate::today(), tz = "UTC", geocode = NULL,
  lon = 0, lat = 0, twilight = "none", unit.out = "date")

sunset_time(date = lubridate::today(), tz = "UTC", geocode = NULL,
  lon = 0, lat = 0, twilight = "none", unit.out = "date")

day_length(date = lubridate::today(), tz = "UTC", geocode = NULL,
  lon = 0, lat = 0, twilight = "none", unit.out = "hour")

night_length(date = lubridate::today(), tz = "UTC", geocode = NULL,
  lon = 0, lat = 0, twilight = "none", unit.out = "hour")

Arguments

date
array of POSIXct times or Date objects, any valid TZ is allowed, default is current date
tz
character string incading time zone to be used in output, default is system time zone
geocode
data frame with variables lon and lat as numeric values (degrees).
lon
numeric array of longitudes (degrees)
lat
numeric array of latitudes (degrees)
twilight
character string, one of "none", "civil", "nautical", "astronomical", or a numeric vector of length one, or two, giving solar elevation angle(s) in degrees (negative if below the horizon).
unit.out
charater string, One of "date", "hour", "minute", or "second".

Value

  • day_night returns a list with fields sunrise time, sunset time, day length, night length. Each element of the list is a vector of the same length as the argument supplied for date. noon_time, sunrise_time and sunset_time return a vector of POSIXct times day_length and night_length return numeric a vector giving the length in hours

See Also

Other astronomy related functions: sun_angles

Examples

Run this code
library(lubridate)
day_length()
day_length(ymd("2015-05-30"), lat = 60, lon = 25)
day_length(ymd("2014-12-30"), lat = 60, lon = 25)
day_length(ymd("2015-05-30"), lat = 60, lon = 25, twilight = "civil")
sunrise_time(ymd("2015-05-30"), lat = 60, lon = 25, tz = "EET")
day_night(ymd("2015-05-30"), lat = 60, lon = 25, twilight = "civil")

Run the code above in your browser using DataLab