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.
day_night(date = lubridate::today(), tz = Sys.timezone(),
geocode = data.frame(lon = 0, lat = 51.5, address = "Greenwich"),
twilight = "none", unit.out = "hours")noon_time(date = lubridate::today(), tz = Sys.timezone(),
geocode = data.frame(lon = 0, lat = 51.5, address = "Greenwich"),
twilight = "none", unit.out = "datetime")
sunrise_time(date = lubridate::today(), tz = Sys.timezone(),
geocode = data.frame(lon = 0, lat = 51.5, address = "Greenwich"),
twilight = "sunlight", unit.out = "datetime")
sunset_time(date = lubridate::today(), tz = Sys.timezone(),
geocode = data.frame(lon = 0, lat = 51.5, address = "Greenwich"),
twilight = "sunlight", unit.out = "datetime")
day_length(date = lubridate::today(), tz = "UTC", geocode = data.frame(lon
= 0, lat = 51.5, address = "Greenwich"), twilight = "sunlight",
unit.out = "hours")
night_length(date = lubridate::today(), tz = "UTC",
geocode = data.frame(lon = 0, lat = 51.5, address = "Greenwich"),
twilight = "sunlight", unit.out = "hours")
vector of POSIXct times or Date objects, any valid TZ is allowed, default is current date
vector of character string indicating time zone to be used in output.
data frame with one or more rows and variables lon and lat as numeric values (degrees).
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).
charater string, One of "datetime", "hour", "minute", or "second".
A data.fraame with variables day, tz, twilight.rise, twilight.set, longitude, latitude, address, sunrise, noon, sunset, daylength, nightlength.
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
Twilight names are interpreted as follows. "none": solar elevation = 0 degrees. "refraction": solar elevation = 0 degrees + refraction correction. "sunlight": upper rim of solar disk corrected for refraction. "civil": -6 degrees, "naval": -12 degrees, and "astronomical": -18 degrees. Unit names for output are as follows: "hours" times for sunrise and sunset are returned as times-of-day in hours since middnight. "date" or "datetime" return the same times as datetime objects with TZ set (this is much slower the "hours"). Day length and night length are always returned as numeric values expressed in hours.
Other astronomy related functions: format.solar_time
,
is.solar_time
,
print.solar_time
, solar_time
,
sun_angles
library(lubridate)
my.geocode <- data.frame(lat = 60, lon = 25)
day_night(ymd("2015-05-30"), geocode = my.geocode, twilight = "civil")
Run the code above in your browser using DataLab