Skip to contents

Reads the NetCDF files and extracts the variable requested along each flight defined by the edges.

  • Time: linear interpolation using the resolution requested with rounding_interval

  • Space: nearest ERA5 grid cell

  • Pressure/altitude: linear interpolation using the exact pressure values

Positions follow the straight edge flown at constant groundspeed, or with constant_speed = "airspeed" the track drifted by the wind when flying at constant airspeed, as in graph_add_wind().

Usage

edge_add_wind(
  graph,
  edge_s,
  edge_t,
  pressure = NULL,
  variable = c("u_component_of_wind", "v_component_of_wind"),
  rounding_interval = 60,
  interp_spatial_linear = lifecycle::deprecated(),
  return_averaged_variable = lifecycle::deprecated(),
  file = wind_file_default,
  quiet = FALSE,
  constant_speed = NULL
)

Arguments

graph

either a tag or a graph GeoPressureR object.

edge_s

an index of the source node of the edge. Either a vector with 3D index or a matrix of 3 columns, one for each dimension.

edge_t

an index of the target node of the edge. Either a vector with 3D index or a matrix of 3 columns, one for each dimension.

pressure

pressure measurement of the associated tag data used to estimate the pressure level (i.e., altitude) of the bird during the flights. This data.frame needs to contain date as POSIXt and value in hPa. If not provided, uses graph$pressure, assuming that argument graph is a GeoPressureR tag object.

variable

variables to extract, named exactly as in tag_download_wind() — the files must of course contain them. The NetCDF stores its arrays under GRIB short names ("u" for "u_component_of_wind") and this function translates; passing those short names still works but is deprecated.

rounding_interval

temporal resolution on which to query the variable (min). Default is to match ERA5 native resolution (1hr).

interp_spatial_linear

[Deprecated] No longer used. The nearest ERA5 grid cell is always used.

return_averaged_variable

[Deprecated] No longer used.

file

function returning the path of the wind file of a flight from (1) the stationary period identifier and (2) the tag_id. The default, wind_file_default, gives ./data/wind/{tag_id}/{tag_id}_{stap_id}.nc.

quiet

logical to hide messages about the progress

constant_speed

speed held constant during each flight: "groundspeed" (straight edge flown at constant groundspeed) or "airspeed" (track drifted by the wind when flying at constant airspeed). Defaults to the value used by graph_add_wind() for this graph, otherwise "groundspeed".

Value

A data.frame with one row per time step, edge, and variable:

  • edge_id edge index

  • val value of the variable at each time step

  • pressure pressure at each time step

  • date datetime of each time step

  • w weight for averaging over the edge (weights of an edge sum to 1, flights spanned by the edge weighted by their duration)

  • var variable name, as passed to variable

  • lat latitude at each time step

  • lon longitude at each time step

Examples

if (FALSE) { # \dontrun{
withr::with_dir(system.file("extdata", package = "GeoPressureR"), {
  tag <- tag_create("18LX", quiet = TRUE) |>
    tag_label(quiet = TRUE) |>
    tag_set_map(extent = c(-16, 23, 0, 50), scale = 1) |>
    geopressure_map(quiet = TRUE)
})
graph <- graph_create(tag, quiet = TRUE)
wind <- edge_add_wind(graph, edge_s = graph$s, edge_t = graph$t, quiet = TRUE)
} # }