Skip to contents

This function interpolates meteorological variablesat a specified height above ground.

Usage

interpolate_at_height(
  var_s,
  zg_s,
  pa_s,
  var_pl,
  zg_pl,
  pa_pl,
  levels,
  log_interp = FALSE,
  nthreads = 1
)

Arguments

var_s

variable [lon, lat, time] near the surface (K).

zg_s

surface geopotential [lon, lat, time] (m^2/s^2).

pa_s

surface pressure [lon, lat, lev, time] (hPa).

var_pl

variable [lon, lat, lev, time] on pressure level (K).

zg_pl

geopotential [lon, lat, lev, time] on pressure levels (m^2/s^2)

pa_pl

pressure levels [lev] (hPa).

levels

a numeric vector specifying heights (m) for interpolation, e.g., `c(500,6000)`.

log_interp

Logical. If `TRUE`, performs interpolation in log-pressure space; otherwise, uses linear interpolation.

nthreads

an integer specifying the number of threads to use for computation (OpenMP). Default is 1.

Value

list of arrays [lon, lat, time] for the interpolated variables.

Examples

data("ERA5_pl")
data("ERA5_sfc")
ta_s <- ERA5_sfc$t2m
pa_s <- ERA5_sfc$sp / 100
zg_s <- ERA5_sfc$z[, , 1]


ta_pl <- ERA5_pl$ta
zg_pl <- ERA5_pl$z
pa_pl <- ERA5_pl$plev / 100

levels <- c(500, 6000)

res <- interpolate_at_height(ta_s, zg_s, pa_s,
  ta_pl, zg_pl, pa_pl,
  levels,
  log_interp = FALSE
)