Skip to contents

Estimate the temperature gradient between two heights or two pressure levels.

Usage

lapse_rate(
  ta_s,
  zg_s,
  pa_s,
  ta_pl,
  zg_pl,
  pa_pl,
  levels,
  use_height = TRUE,
  nthreads = 1
)

Arguments

ta_s

air temperature [lon, lat, time] at 2 meter above the surface (K).

zg_s

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

pa_s

Surface pressure [lon, lat, time] (hPa).

ta_pl

air temperature [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 matrix specifying height (km) or pressure (hPa) intervals. Each row represents a different lapse rate calculation range, e.g., `0-1 km`, `0-3 km`, or `900-850 hPa`. The function determines the lapse rate based on the rows of this matrix.

use_height

a logical value (`TRUE` for height in km, `FALSE` for pressure in hPa) indicating whether the `levels` matrix represents altitude (in km) or pressure (in hPa).

nthreads

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

Value

list of arrays of the lapse rate (°C/km) each as [lon, lat, time].

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 <- matrix(c(0, 6),
  byrow = TRUE,
  ncol = 2
)

res <- lapse_rate(ta_s, zg_s, pa_s,
  ta_pl, zg_pl, pa_pl,
  levels,
  use_height = TRUE
)