earthkit.meteo.vertical.array.interpolate_monotonic¶
- earthkit.meteo.vertical.array.interpolate_monotonic(data, coord, target_coord, interpolation='linear', aux_min_level_data=None, aux_min_level_coord=None, aux_max_level_data=None, aux_max_level_coord=None, vertical_dim=0)¶
Interpolate data between the same type of monotonic coordinate levels.
- Parameters:
data (
ArrayLike) – Data to be interpolated. The axis corresponding to the vertical coordinate is defined by thevertical_dimparameter. Must have at least two levels.coord (
ArrayLike) – Vertical coordinates related todata. Either must have the same shape asdataor be a 1D array with length equal to the size of the number of levels indata. Must be monotonic (either sorted ascending or descending) along the vertical axis.target_coord (
ArrayLike) – Target coordinate levels to whichdatawill be interpolated. It can be either a scalar or a 1D array of coordinate levels. Alternatively, it can be a multidimensional array with a vertical axis defined by vertical_dim. In this case the other axes/dimensions must match those ofdata. Must be the same type of coordinate ascoord.interpolation (
{"linear", "log", "nearest"}, default"linear") –Interpolation mode. Possible values are:
”linear”: linear interpolation in coordinate between the two nearest levels
”log”: linear interpolation in logarithm of coordinate between the two nearest levels
”nearest”: nearest level interpolation
aux_min_level_data (
ArrayLike|None, optional) – Auxiliary data for interpolation to target levels below the minimum level ofcoordand above aux_min_level_coord. Can be a scalar or must have the same shape as a single level ofdata.aux_min_level_coord (
ArrayLike|None, optional) – Coordinates ofaux_min_level_data. Can be a scalar or must have the same shape as a single level ofdataorcoord. Must be the same type of coordinate ascoord.aux_max_level_data (
ArrayLike|None, optional) – Auxiliary data for interpolation to target levels above the maximum level ofcoordand below aux_max_level_coord. Can be a scalar or must have the same shape as a single level ofdata.aux_max_level_coord (
ArrayLike|None, optional) – Coordinates ofaux_max_level_data. Can be a scalar or must have the same shape as a single level ofdataorcoord. Must be the same type of coordinate ascoord.vertical_dim (
int) – Axis corresponding to the vertical coordinate in the input arrays and also in the output array. Default is 0 (first axis).
- Returns:
Data interpolated to the target levels. The shape depends on the shape of
target_coord. The axis corresponding to the vertical coordinate is defined by thevertical_dimparameter. When interpolation is not possible for a given target level (e.g., when the target level is outside the available level range), the corresponding output values are set to nan.- Return type:
ArrayLike- Raises:
ValueError – If
datahas less than two levels.ValueError – If the shape of
dataand that ofcoordare not compatible.
Notes
The ordering of the input coordinate levels is not checked.
The units of
coordandtarget_coordare assumed to be the same; no checks or conversions are performed.
Examples
/how-tos/interpolate_hybrid_to_pl.ipynb
/how-tos/interpolate_hybrid_to_hl.ipynb
/how-tos/interpolate_pl_to_hl.ipynb
/how-tos/interpolate_pl_to_pl.ipynb