Research SharingModel Introduction

Light and time

Updated on 2024-05-07 22:40:57

Using the ecotopia_data_devices_env function in the EcotopiaR package, you can get environment (ENV) data and create scatter plots with ggplot2 to visualize the variations in light intensity at different times of the day. This is crucial for studying the circadian rhythms, behavioral patterns, and migration behaviors of animals. By combining this with other animal data such as migration paths and ODBA (Overall Dynamic Body Acceleration), you can explore the correlations between changes in light intensity and animal behaviors, elucidating the mechanisms of environment influences on animal behaviors.

In the example below, EcotopiaR gets ENV data from a device over 100 days and generates a scatter plot of light intensity and time. It can be observed that the light intensity data from a normal device fluctuates throughout the day, corresponding to the changes between day and night.

Example

# Bar chart of ambient light
# Import EcotopiaR
library(EcotopiaR)
library(ggplot2)
now <- Sys.time()
attr(now, "tzone") <- "UTC"
start_time <- now - as.difftime(100, unit = "days")
data_list <- ecotopia_data_devices_env(
  # The device uuid can be viewed in the list of devices
  # obtained through ecotopia_data_devices.
  device_uuids = c("5d395935879cb58613e59e76"),
  show_progress = "FULL",
  start_time = start_time
)
data <- data_list[["5d395935879cb58613e59e76"]]
data$ambient_light <- as.numeric(data$ambient_light)
data$timestamp <- as.numeric(
  format(
    as.POSIXct(gsub("Z", "", gsub("T", " ", data$timestamp))), "%H%M%S"
  )
)
# Bar chart of ambient light
plot <- ggplot(data, aes(x = timestamp, y = ambient_light)) +
  geom_point(color = "green") +
  labs(title = "Ambient Light Intensity by Time",
       x = "Time", y = "Ambient Light Intensity")
ggsave("examples/env_light_timestamp_point.png", plot)

Copied!

Copy