Skip to contents

This function estimate twilight (i.e., datetime of sunrise and sunset) by searching for the first and last light of the day which is defined by the light exceeds or falls below the light threshold twl_thr.

Usage

twilight_create(tag, twl_thr = NULL, twl_offset = NULL, transform_light = TRUE)

Arguments

tag

a GeoPressureR tag object

twl_thr

Light threshold that defines twilight. By default (NULL), it uses the smallest value of light (i.e, first and last light of day).

twl_offset

Shift of the middle of the night compared to 00:00 UTC (in hours). If not provided, it uses the middle of all nights.

transform_light

logical to use a log transformation of light

Value

a tag list containing a new data.frame twilight with columns:

  • twilight (date-time of twilight)

  • rise (logical) indicating sunrise (TRUE) or sunset (FALSE).

  • stap_id if stap_id is present in light.

Examples

owd <- setwd(system.file("extdata", package = "GeoPressureR"))
tag <- tag_create("18LX", quiet = TRUE) |> tag_label(quiet = TRUE)
setwd(owd)

# Create twilight data.frame
tag <- twilight_create(tag)

str(tag$twilight)
#> 'data.frame':	28 obs. of  3 variables:
#>  $ twilight: POSIXct, format: "2017-07-27 03:05:00" "2017-07-27 18:30:00" ...
#>  $ rise    : logi  FALSE TRUE FALSE TRUE FALSE TRUE ...
#>  $ stap_id : num  1 1 1 1 1 1 1 1 1 1 ...

plot(tag, type = "twilight")