Learn R Programming

photobiology (version 0.10.6)

solar_time: Local solar time

Description

solar_time computes from a time and geocode, the time of day expressed in seconds since midnight. solar_date returns the same instant in time as a date-time object. Solar time is useful when we want to plot data according to the local solar time of day, irrespective of the date. Solar date is useful when we want to plot a time series stretching for several days using the local solar time but distinguishing between days.

Usage

solar_time(
  time = lubridate::now(),
  geocode = tibble::tibble(lon = 0, lat = 51.5, address = "Greenwich"),
  unit.out = "time"
)

Arguments

time

POSIXct Time, any valid time zone (TZ) is allowed, default is current time

geocode

data frame with variables lon and lat as numeric values (degrees).

unit.out

character string, One of "datetime", "hour", "minute", or "second".

Value

For solar_time() numeric value in seconds from midnight but with an additional class attribute "solar.time".

Warning!

Returned values are computed based on the time zone of the argument for parameter time. In the case of solar time, this timezone does not affect the result. However, in the case of solar dates the date part may be off by one day, if the time zone does not match the coordinates of the geocode value provided as argument.

See Also

Other astronomy related functions: day_night(), format.solar_time(), format.tod_time(), is.solar_time(), print.solar_time(), print.tod_time(), sun_angles()

Examples

Run this code
# NOT RUN {
BA.geocode <-
  data.frame(lon = -58.38156, lat = -34.60368, address = "Buenos Aires, Argentina")
sol_t <- solar_time(lubridate::dmy_hms("21/06/2016 10:00:00", tz = "UTC"),
                    BA.geocode)
sol_t
class(sol_t)

sol_d <- solar_time(lubridate::dmy_hms("21/06/2016 10:00:00", tz = "UTC"),
                    BA.geocode,
                    unit.out = "datetime")
sol_d
class(sol_d)

# }

Run the code above in your browser using DataLab