Function returns sky illuminance parameters for both the sun and the moon, in addition to some ancillary parameters such as sun and moon azimuth and altitude.

skylight(.data, longitude, latitude, date, sky_condition = 1)

Arguments

.data

A data frame or data frame extension (e.g. a tibble) with named columns: longitude, latitude, date and optionally sky_condition

longitude

decimal longitude (single value or vector of values)

latitude

decimal latitude (single value or vector of values)

date

date and time in POSIXct format with GMT/UTC as time zone (single value or vector of values)

sky_condition

a positive value (>=1) with which to scale illuminance values (1 = cloud cover < 30 3 = average clouds, 10 = dark stratus clouds). By and large this can be considered a scaling factor, substituting it with the (inverse) slope parameter of an empirical fit should render more accurate results. (this can be a single value or vector of values)

Value

Sun and moon illuminance values (in lux), as well as their respective location in the sky (altitude, azimuth).

Details

The code is almost verbatim transcription of the work "Computer Programs for Sun and Moon Illuminance With Contingent Tables and Diagrams by Janiczek and DeYoung" and published in the US Naval observatory circular nr. 171, 1987.

Required parameters are a location (in longitude, latitude), and a date in POSIXct format set to the GMT/UTC time zone. Conversions to GMT/UTC should be done externally, errors are not trapped.

The original code has been vectorized, as such vectors of location, time and/or sky conditions can be provided.

Examples

 df <- skylight(
  longitude = -135.8,
  latitude = -23.4,
  date = as.POSIXct("1986-12-18 21:00:00", tz = "GMT"),
  sky_condition = 1
)

print(df)
#>   sun_azimuth sun_altitude sun_illuminance moon_azimuth moon_altitude
#> 1         346      89.9565        123786.3          282     -61.99004
#>   moon_illuminance moon_fraction total_illuminance
#> 1     1.066142e-27      93.94848          123786.3