Detecting Cavity Use From Geolocator Data
cavityuse
is an R package for calculating patterns of cavity use from geolocator light data. Patterns of light and dark are used to identify daytime usage, while patterns of sunrise/sunset are used to identify nighttime usage.
While
cavityuse
is ready to be experimented with, it's still in early development and should be considered experimental. Please give me a hand by letting me know of any problems you have (missing functionality, difficult to use, bugs, etc.)
knitr::opts_chunk$set(fig.path = "man/figures/", out.width = "100%", fig.asp = 0.5, fig.width = 10)
cavityuse
You can install cavityuse
directly from my R-Universe:
install.packages("cavityuse", repos = c("https://steffilazerte.r-universe.dev", "https://cloud.r-project.org"))
Load the package
library(cavityuse)
We'll get started with the built in example file calib
which clearly shows
sunrise/sunset events
Let's take a look at the patterns in the raw data:
cavity_plot(calib)
Look for any sunrise/sunset events in your geolocator data
s <- sun_detect(calib) s
Let's see what these look like
cavity_plot(data = calib, sun = s, days = 1)
Now let's move on to the flicker
data set:
cavity_plot(flicker) s <- sun_detect(flicker) # Nothing detected e <- cavity_detect(flicker, sun = s) e
Let's see how these assignments match the patterns we see
cavity_plot(data = flicker, cavity = e)
You data must be in a data frame with the columns called time
and light
.
time
must be in a date/time
formatlight
must be a number, representing light levels in lux (low = dark, high = light)For example:
dplyr::select(flicker, time, light)
Consider using the lubridate
package to format your times
Most geolocator data is in the UTC timezone, and although previous versions of cavityuse recommended converting your data to your the timezone of your location (non-daylight savings), I now recommend keeping it in UTC. cavityuse will apply a timezone offset to your data according to the location.
This means that the time output by cavityuse will be in UTC according to R, however it will actually have had an offset applied (noted in the new column tz_offset
). This just makes things simpler.
cavityuse
functions require coordinates in order to more efficiently detect sunrise/sunset times, but also to estimate sunrise/sunset when they are not detected in the data.
You can supply coordinates in one of two ways.
lon
and lat
columns, indicating the decimal coordinates for your location either in your datadplyr::select(flicker, time, light, lon, lat)
lon
, lat
):sun_times(data, loc = c(-120.3408, 50.67611))
Right now, cavityuse
is limited to the follow scenarios:
cavityuse
assigns activity based on sunrise/sunset times which are inferred from lon/lat (this may change in the future). Minor migratory changes can be accommodated, and larger ones can be somewhat handled by splitting the data by location (different lat/lons) and applying cavity_detect()
to each set of locations. But this isn't perfect.cavityuse
detects sunrise and sunset, extremely latitudes may result in unpredicatable behaviour (this should hopefully be fixed in the future)Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.