Interpolating from pressure to pressure levels

This notebook demonstrates how to interpolate pressure level data to pressure levels.

[1]:
import earthkit.meteo.vertical.array as vertical

Getting the data

We get some sample pressure level data for two points. The data is sorted in descending order according to pressure.

[2]:
from earthkit.meteo.utils.sample import get_sample

DATA = get_sample("vertical_pl_data")
p = DATA.p  # pressure [Pa]
t = DATA.t  # temperature [K]

p, t.shape
[2]:
(array([100000.,  85000.,  70000.,  50000.,  40000.,  30000.,  20000.,
         15000.,  10000.]),
 (9, 2))

Using interpolate_monotonic

We can use :py:meth:`~earthkit.meteo.vertical.array.interpolate_monotonic` to carry out the interpolation.
[3]:
target_p = [87000.0, 60000.0]  # Pa

t_res = vertical.interpolate_monotonic(
    t,  # data to interpolate
    p,
    target_p,
    interpolation="linear",
)

for hp, rv in zip(target_p, t_res):
    print(hp, rv)
87000.0 [295.7878306 296.2361379]
60000.0 [276.56495667 275.68653869]
[ ]: