# Choose the id
id <- "18LX"
# Set the directory to the project root
# see Working directory bullet point in https://bookdown.org/yihui/rmarkdown/notebook.html#executing-code
knitr::opts_knit$set(root.dir = here::here())
# Alternatively, you can change the global RStudio settings in menu "Tools/Global Options...", on the "R Markdown" panel, choose "Project" for "Evaluate chunks in directory:"
library(GeoPressureR)
library(ggplot2)
library(plotly)11 Tag label
This script will guide you through the tag labeling of pressure and/or acceleration data and creation of the pressure map.
Delete this block when you have read!
- 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 labeling instructions, before running this script
- Nothing is saved at the end of the script and it is meant to be like that. The goal of this script is to (1) create the tag labels (
./data/tag-label/) and (2) adaptconfig.yml.
11.1 Edit config.yml
Delete this block when you have read!
Edit the default config according to your study: Use default for all parameters which are the same for all your tracks and add any parameter that is tag specific.
config.yml is structured in the following level as defined by the indentation and :
tag_id:
function_name:
arguments: valueNote that the values are written in JSON format (and not R), so for a vector/array you need to use [, ] and for an array of objects (named lists), you need to use - and indentation. Here is an example:
18LX:
tag_set_map:
extent: [-16, 23, 0, 50]
known:
- stap_id: 1
known_lon: 7.05
known_lat: 48.9
bird:
species_name: "Acrocephalus arundinaceus" # only if you have different species, otherwise add to defaultCheck that the config is correct.
── GeoPressureR `param` object for id: 18LX ────────────────────────────────────
Note: All green texts are fields of `param` (i.e., `param$field`).
• GeoPressureR_version: 3.6.0.9000
── Sensors data `tag_create()`
• manufacturer:
• crop_start: "2017-06-20"
• crop_end: "2018-05-02"
• directory: `glue::glue("./data/raw-tag/{id}")`
• pressure_file:
• light_file:
• acceleration_file:
• temperature_external_file:
• temperature_internal_file:
• magnetic_file:
• time_shift: 0
── Tag label `tag_label()`
• file: `glue::glue("./data/tag-label/{tag$param$id}-labeled.csv")`
── Stationary period definition `tag_set_map()`
• extent: [W:-16, E:23, S:0, N:50]
• scale: 5
• known:
stap_id: "1" and "-1"
known_lon: "17.05"
known_lat: "48.9"
• include_stap_id:
• include_min_duration: 0
── Geopressure `geopressure_map()`
• max_sample: 250
• margin: 20
• sd: 1
• thr_mask: 0.9
• log_linear_pooling_weight: `function (n) log(n)/n`
── Twilight & Geolight `twilight_create()` `geolight_map()`
• twl_thr:
• twl_offset:
• twilight_file:
• twl_calib_adjust: 1.4
• fitted_location_duration: "Inf"
• zenith_prior_mean: 93
• zenith_prior_sd: 1.3
• zenith_prior_penalty_weight: 1e-04
• refine_fitted_location_scale_km: 20
• refine_fitted_location_max_iter: 0
• twl_llp: `function (n) log(n)/n`
── Graph `graph_create()`
• thr_likelihood: 0.99
• thr_gs: 150
── Movement model & wind `graph_add_wind()` `graph_movement()`
• thr_as: 90
• file: `function(stap_id, tag_id) {
glue::glue("./data/wind/{tag_id}/{tag_id}_{stap_id}.nc")}`
• type: "as"
• method: `ifelse("ws" %in% names(graph), "power", "gamma")`
• shape: 7
• scale: 7
• location: 40
• bird_create:
mass:
wing_span:
wing_aspect:
wing_area:
body_frontal_area:
scientific_name: "Acrocephalus arundinaceus"
• power2prob: `function(power) (1/power)^3`
• low_speed_fix: 15
• zero_speed_ratio: 1
── Outputs `graph_simulation()` `pressurepath_create()`
• nj: 10
• variable: "altitude" and "surface_pressure"
• solar_dep: 0
• era5_dataset: "both"
── GeoPressureTemplate `geopressuretemplate()`
• likelihood: "map_pressure" and "map_light"
• outputs: "marginal", "most_likely", and "simulation"
• pressurepath: "most_likely"
11.2 Sensor data and crop date
Check if the crop dates (in red) are correct.
ggplotly(
tag_create(id, quiet = TRUE) |>
plot(type = "pressure", plot_plotly = FALSE) +
geom_vline(
xintercept = c(
as.POSIXct(config::get("tag_create", id)$crop_start),
as.POSIXct(config::get("tag_create", id)$crop_end)
),
color = "red",
lwd = 1
)
)You might want to change type to check the values of the other sensors (e.g., acceleration or light).
Create tag with cropped date:
tag <- tag_create(
id,
crop_start = config::get("tag_create", id)$crop_start,
crop_end = config::get("tag_create", id)$crop_end
)✔ 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.3 Labeling
Use the trainset shiny app for labeling
trainset(tag)Once you’re done click Save to write the labeling file to ./data/tag-label/{id}-labeled.csv.
11.3.1 Run Trainset checks
Use the Check button in the trainset app header to run the built-in checks while you label. See Trainset checks for more details.
11.3.2 Run GeoPressureViz checks
Improve the label file until you can draw a coherent trajectory on GeoPressureViz. See GeoPressureViz checks for more details.
tag <- tag_create(
id,
crop_start = config::get("tag_create", id)$crop_start,
crop_end = config::get("tag_create", id)$crop_end
) |>
tag_label() |>
tag_set_map(
extent = config::get("tag_set_map", id)$extent,
scale = 1, # Use a coarse scale at first 1° is usually enough
known = config::get("tag_set_map", id)$known
) |>
geopressure_map()Run GeoPressureViz:
geopressureviz(tag, path = tag2path(tag, interp = 1))