6  Pressurepath

In this chapter, we will see what a pressurepath object is and how to use it to compute the altitude of the bird throughout its trajectory.

Let’s load the tag from the Great Reed Warbler (18LX) created in the advanced tutorial.

load("./data/interim/18LX.Rdata")

6.1 Timeseries at a single position

Before creating a full pressurepath, we start with the basic building block of a pressurepath, which is to retrieve the pressure timeseries from ERA5 at a single location with geopressure_timeseries.

geopressure_timeseries relies on the pressure timeseries entry point of GeoPressureAPI which return the timeseries of pressure at a given latitude and longitude.

Let’s start by retrieving the pressure at the known site of equipment, querying the same date as the first stationary period.

ts <- geopressure_timeseries(
  lat = tag$stap$known_lat[1],
  lon = tag$stap$known_lon[1],
  start_time = tag$stap$start[1],
  end_time = tag$stap$end[1],
  quiet = TRUE
)

We can compare the retrieved ERA5 pressure to the pressure measured on the Great Reed Warbler:

Eureka!

This was the figure that made me realize the potential of pressure measurement to determine birds’ position! The accuracy of the reanalysis data and the precision of the sensor were such that a timeseries of pressure had only a few possible options on the map.

6.2 Pressurepath

What is a pressurepath?

You can think of a pressurepath as the timeseries of pressure that a tag would record on a bird traveling along a specified path. To do that, pressurepath_create() calls geopressure_timeseries() for each stationary period and combines the resulting timeseries of ERA5 pressure.

The pressurepath data.frame returned also contains the original pressure pressure_tag which can be very helpful for labelling and the altitude of the bird corrected for the natural variation of pressure.

pressurepath <- pressurepath_create(
  tag,
  path = path_most_likely,
  quiet = TRUE
)

Note that if a position on the path is over water, it is automatically moved to the closest point onshore as we use ERA5 Land.

plot_pressurepath(pressurepath)

6.3 Altitude

The main benefit of creating pressurepath is the ability to retrieve ERA5 variable along the the trajectory of the bird. One of them is altitude which can be directly plot with

plot_pressurepath(pressurepath, type = "altitude")
Why use GeoPressureAPI for altitude?

Computing the bird altitude \(z_{gl}\) from its pressure measurement \(P_{gl}\) is best performed with the barometric equation

\[ z_{gl}=z_0 + \frac{T_0}{L_b} \left( \frac{P_{gl}}{P_0} \right) ^{\frac{RL_b}{g M}-1},\]

where \(L_b\) is the standard temperature lapse rate, \(R\) is the universal gas constant, \(g\) is the gravity constant and \(M\) is the molar mass of air.

It is typical to assume a standard atmosphere with fixed \(T_0=15°C\), \(P_0=1013.25 hPa\) and \(z_0=0 m\),

Lb <- -0.0065
R <- 8.31432
g0 <- 9.80665
M <- 0.0289644
T0 <- 273.15 + 15
P0 <- 1013.25
pressurepath$altitude_uncorrected <- T0 / Lb * ((pressurepath$pressure_tag / P0)^(-R * Lb / g0 / M) - 1)

However, we know that pressure and temperature vary considerably over time and space, leading to approximation in the altitude estimated.

Using GeoPressureAPI, we can adjust the barometric equation with the actual ground-level pressure \(P_{ERA}\) and ground temperature \(T_{ERA}\) retrieved from ERA5 at the bird’s location \(x\), \[ z_{gl}(x)=z_{ERA5}(x) + \frac{T_{ERA5}(x)}{L_b} \left( \frac{P_{gl}}{P_{ERA5}(x)} \right) ^{\frac{RL_b}{g M}-1},\]

See more information on the GeoPressureAPI documentation.

We can compare these two altitudes for the first stationary period,

p <- ggplot(pressurepath[pressurepath$stap_id == 1, ]) +
  geom_line(aes(x = date, y = altitude, colour = "Corrected elevation with ERA5")) +
  geom_line(aes(x = date, y = altitude_uncorrected, colour = "Uncorrected elevation")) +
  theme_bw() +
  ylab("Pressure (hPa)") +
  scale_color_manual(values = c("Corrected elevation with ERA5" = "black", "Uncorrected elevation" = "red"))
plotly::layout(plotly::ggplotly(p), legend = list(orientation = "h"))

The uncorrected altitude estimate incorrectly produces a 200m amplitude error in the altitude due to the natural variation of pressure. In contrast, the corrected altitude shows that the Great Reed Warbler mostly stayed at the same location/altitude during the entire period.

You can also retrieve the ground elevation with path2elevation() which allows us to compare the altitude of flight compare the elevation.

elevation <- path2elevation(path_most_likely,
  scale = tag$param$scale,
  sampling_scale = tag$param$scale * 2,
  percentile = c(10, 50, 90)
)

Note that because of the imprecision of the position, particularly during flight, it’s important to analyse with caution the relationship between flight altitude and ground elevation. path2elevation() aggregate the elevation accross a larger area defined by scale and return different percentile.

# Compute distance along the path for pressurepath (to be able to plot it with elevation)
lonlat <- data.frame(
  lon = pressurepath$lon,
  lat = pressurepath$lat
)
distance <- geosphere::distHaversine(tail(lonlat, -1), head(lonlat, -1))
pressurepath$distance <- c(0, cumsum(distance))

# Get also a point per stap_id
# exclude flight
pp <- pressurepath[pressurepath$stap_id == round(pressurepath$stap_id), ]
# compute average flight and distance
pp_stap <- merge(
  tag$stap,
  data.frame(
    stap_id = sapply(split(pp$stap_id, pp$stap_id), median),
    altitude = sapply(split(pp$altitude, pp$stap_id), \(x) round(mean(x), 1)),
    distance = sapply(split(pp$distance, pp$stap_id), \(x) round(mean(x), 1))
  )
)
pp_stap$duration <- stap2duration(pp_stap)

# Plot
p <- ggplot() +
  geom_line(data = elevation, aes(x = distance, y = X50, color = "ground")) +
  geom_line(data = pressurepath, aes(x = distance / 1000, y = altitude, color = "flight")) +
  geom_point(data = pp_stap, aes(x = distance / 1000, y = altitude, name = stap_id, color = "stap", size = duration^(0.25) * 6)) +
  theme_bw() +
  ylab("altitude/elevation (m a.s.l.)") +
  xlab("Distance along trajectory (km)") +
  scale_color_manual(
    values = c(ground = "brown", flight = "black", stap = "blue"),
    labels = c(ground = "Ground elevation (median over 0.25°)", flight = "Bird flight altitude", stap = "Stationary period")
  ) +
  guides(size = FALSE)

# Interactive plot
plotly::layout(plotly::ggplotly(p), legend = list(orientation = "h"))

6.4 Save

The graph object can become extremely big for such models, and it might not be recommended to save it. Check its size with format(object.size(graph), units = "MB").

save(
  tag,
  graph,
  path_most_likely,
  path_simulation,
  marginal,
  edge_simulation,
  edge_most_likely,
  pressurepath,
  file = "./data/interim/18LX.RData"
)