nctoolkit.DataSet.vertical_interp

DataSet.vertical_interp(levels=None, fixed=None, thickness=None, depths=None, surface=None)

vertical_interp: Verticaly interpolate a dataset based on given vertical levels

Vertical interpolation is calculated for each time step and grid cell

Note

This requires consistent vertical levels in space. For the likes of sigma-coordinates, please use to_zlevels.

Parameters:
  • levels (list, int or str) – list of vertical levels, for example depths for an ocean model, to vertically interpolate to. These must be floats or ints.

  • fixed (bool) – Define whether the vertical levels are the same in all spatial locations. Set to True if they are, e.g. you have z-levels. If you have the likes of sigma-coordinates, set this to False.

  • thickness (str or Dataset) – This or depths must be supplied if fixed is False, otherwise vertical thickness/depth cannot be known. Option argument when vertical levels vary in space. One of: a variable, in the dataset, which contains the variable thicknesses; a .nc file which contains the thicknesses; or a Dataset that contains the thicknesses. Note: the .nc file or Dataset must only contain one variable. Thickness should be in metres. Vertical interpolation will take the value from the mid-point of the level.

  • depths (str or Dataset) – This or thickness must be supplied if fixed is False, otherwise vertical thickness/depth cannot be known. Option argument when vertical levels vary in space. One of: a variable, in the dataset, which contains the variable depths; a .nc file which contains the depths; or a Dataset that contains the depths. Note: the .nc file or Dataset must only contain one variable. Depths should be in metres, and be the mid-point of the level.

  • surface (str) – If thickness is supplied you must also supply this to identify whether the top or bottom of the level is the surface, i.e. the lowest level. This must be one of ‘top’ or ‘bottom’.

Examples

If you wanted to vertically interpolate a dataset with spatially consistent vertical levels to 5 and 10 metres, you would do the following:

>>> ds.vertical_interp(levels = [5,10], fixed = True)

This method is most useful for things like oceanic data, where you need to interpolate to certain depth levels. It will require that vertical levels are the same in every grid cell.