Skip to content

interpolate_vertical

Import path: earth2studio.utils.interp.interpolate_vertical

View source on GitHub

Documentation

Interpolate x linearly along a vertical coordinate onto target levels.

The coordinate can be anything monotonic within a column: pressure (with log=True, for interpolation linear in log pressure), height or depth.

Parameters:

  • x (Tensor) –

    Field with a level dimension dim.

  • coordinate (Tensor) –

    Coordinate of each of x's levels: either one value per level, shape (level,) in any order without repeats, or one column per point, shaped like x (or broadcastable to it) and monotonic along dim in the same direction in every column. Columns that are not strictly monotonic, such as hybrid levels under an implausible surface pressure, are filled with fill_value, or NaN without one, rather than interpolated.

  • target (Tensor) –

    Coordinate of each output level, shape (target,), in the same units.

  • dim (int, default: -1 ) –

    Level dimension of x and coordinate, by default -1

  • log (bool, default: False ) –

    Interpolate linearly in the logarithm of the coordinate, as for pressure, by default False

  • fill_value (float | None, default: None ) –

    Value for targets outside a column's range, by default None, which takes the nearest level's value instead.

Returns:

  • Tensor –

    x with dimension dim replaced by the target levels, in x's dtype. Coordinates and weights are computed in at least single precision, as pressures in Pa overflow half precision.