R: Local solar time

solar_time {photobiology} | R Documentation

## 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 = data.frame(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.

### Note

The algorithm is approximate, it calculates the difference between local solar noon and noon in the time zone of `time` and uses this value for the whole day when converting times into solar time. Days are not exactly 24 h long. Between successive days the shift is only a few seconds, and this leads to a small jump at midnight.

### See Also

Other astronomy related functions: `day_night`, `format.solar_time`, `is.solar_time`, `print.solar_time`, `sun_angles`

### Examples

    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)

[Package photobiology version 0.9.21 Index]