Detects patterns of sunrise and sunset in geolocator data.
sun_detect(data, n = 10, range = 10, cutoff = 0.95, loc = NULL, local = TRUE, filter_problems = TRUE)
data | Data frame. Raw light data. Requires two columns: "time" and "light" |
---|---|
n | Numeric. Number of light observations to use when assessing a sunrise/sunset event |
range | Numeric. Minimum lux difference between minimum and maximum light levels in sunrise and sunset event |
cutoff | Numeric. R-Squared cutoff value to assess the model fit to sunrise and sunset. Higher values are more stringent, lower values are less. |
loc | Numeric vector. Longitude and Latitude of the observations (if not in the data, this must be provided). |
local | Logical. Restrict data to expect windows of sunrise/sunset based on coordinates (will speed up the function, but may result in problems if sunrise/sunset occur close to midnight) |
filter_problems | Logical. Remove problematic sunrise/sunset events? Problematic events are defined as those which are preceded/proceeded by unexpectedly variable light levels (True sunrise/sunset events should only be preceded/proceeded by darkness) |
Data frame containing sunrise and sunset events
This function looks for sunrise/sunset events by matching n
points to a cubic polynomial regression. Events with a high degree of model
fit (determined by an R-squared cutoff of cutoff
are returned.
Because this essentially fits models to every point in the data, it can be
very time consuming. local = TRUE
attempts to reduce this time by
first filtering the data to blocks of time which should contain
sunrise/sunset, based on the coordinates of the data.
Only one sunrise and one sunset event are allowed per day. If
filter_problems = TRUE
, then sunrise events that are preceded by
variable light levels and sunset events proceeded by variable light levels
are omitted (before sunrise and after sunset, it should be dark).
# Calibration data should have perfect sunrise/sunset event detection s <- sun_detect(calib) cavity_plot(calib, sun =s)# Sunrise/sunset events missed with extra stringent cutoff values s <- sun_detect(calib, cutoff = 0.9995) cavity_plot(calib, sun = s)