Skip to contents

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

  • Time: linear interpolation using the resolution requested with rounding_interval

  • Space: nearet neighbor interpolation by default or bi-linear with pracma::interp2 if interp_spatial_linear=TRUE

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

Usage

edge_add_wind(
  tag_graph,
  edge_s,
  edge_t,
  pressure = NULL,
  variable = c("u", "v"),
  rounding_interval = 60,
  interp_spatial_linear = FALSE,
  return_averaged_variable = FALSE,
  file = function(stap_id) {
    
    glue::glue("./data/wind/{tag_graph$param$id}/{tag_graph$param$id}_{stap_id}.nc")
 },
  quiet = FALSE
)

Arguments

tag_graph

either a tag or a graph GeoPressureR object.

edge_s

a 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

a 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.

variable

list of variables to download from the ERA5 pressure level: "u_component_of_wind", "v_component_of_wind", "temperature", "fraction_of_cloud_cover", "relative_humidity", , "vertical_velocity", "specific_cloud_ice_water_content", "specific_cloud_liquid_water_content", "specific_humidity", "specific_rain_water_content", "specific_snow_water_content", "divergence", "geopotential", "ozone_mass_mixing_ratio", "potential_vorticity", 'vorticity".

rounding_interval

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

interp_spatial_linear

logical to interpolate the variable linearly over space, if FALSE takes the nearest neighbour. ERA5 native resolution is 0.25°

return_averaged_variable

logical to return the variable for each timestep or average for the entire flight.

file

absolute or relative path of the ERA5 wind data file to be downloaded. Function taking as single argument the stationary period identifier.

quiet

logical to hide messages about the progress

Value

A data.frame with columns:

  • stap_s id of the source/origin stationary period

  • stap_t id of the target/destination stationary period

  • s node id of the source (same as/similar to edge_s)

  • t node id of the target (same as/similar to edge_t)

  • lat_s latitude of the source

  • lat_t latitude of the target

  • lon_s longitude of the source

  • lon_t longitude of the target

  • start start datetime of the flight

  • end end datetime of the flight

  • duration flight duration

  • n number of flight

  • distance distance of the flight

  • bearing bearing of the flight

  • gs groundspeed

  • ws windspeed (if graph provided)