11  Twilight Label

Tip

Delete this block when you have read!

If you don’t have light data, delete this file!

  • These scripts should be adapted based on your project, but the same script should run for all your tags. You can always check the original version online.
  • Make sure you’ve read the GeoPressureManual, in particular the twilight labelling instructions, before running this script
  • Nothing is saved at the end of the script and it is meant to be like that. Only twilight label file and config.yml should be edited. Use geopressure.R for the final run.
id <- "18LX"

knitr::opts_knit$set(root.dir = here::here())
library(GeoPressureR)
library(ggplot2)

11.1 Create tag

Make sure you have already created the label file with the “1-label.qmd” script.

tag <- tag_create(
  id,
  crop_start = config::get("tag_create", id)$crop_start,
  crop_end = config::get("tag_create", id)$crop_end
) |>
  tag_label(quiet = TRUE) |>
  tag_set_map(
    extent = config::get("tag_set_map", id)$extent,
    scale = config::get("tag_set_map", id)$scale,
    known = config::get("tag_set_map", id)$known
  )
✔ Read './data/raw-tag/18LX/18LX_20180725.pressure'
✔ Read './data/raw-tag/18LX/18LX_20180725.glf'
✔ Read './data/raw-tag/18LX/18LX_20180725.acceleration'
✔ Read './data/raw-tag/18LX/18LX_20180725.temperature'

11.2 Create Twilight

Generate the twilight automatically. Check that twl_offset allows for night/day being centered on the figure, otherwise edit accordingly

tag <- twilight_create(
  tag,
  twl_offset = config::get("twilight_create", id)$twl_offset
)
plot(tag, type = "twilight")

11.3 Annotate twilight

✔ './data/twilight-label/18LX.csv' written successfully.

Open csv on https://trainset.raphaelnussbaumer.com/.

Read and check the twilight annotation

tag <- twilight_label_read(tag)
plot(tag, type = "twilight")

11.4 Compute likelihood map

tag <- geolight_map(tag)
Compute a map for each twilight ■■■■■■■■■■■■                      38% | ETA:  4s
Compute a map for each twilight ■■■■■■■■■■■■■■■■■■■■■■■■■■■■      89% | ETA:  1s

twl_calib_adjust and twl_llp can generally be left to default, but add to config.yml if needed.

11.5 Check

11.5.1 Check calibration

barW <- median(diff(tag$param$geolight_map$twl_calib$x)) / 2
plot(tag$param$geolight_map$twl_calib, xlim = c(85, 100))
rect(xleft = tag$param$geolight_map$twl_calib$x - barW, ybottom = 0, xright = tag$param$geolight_map$twl_calib$x + barW, ytop = tag$param$geolight_map$twl_calib$y, col = gray(0.5))
lines(tag$param$geolight_map$twl_calib, col = "red")

11.5.2 Check light map

plot(tag, type = "map_light")

11.5.3 Check with pressure and trajectory