nctoolkit.DataSet.vertical_interp

DataSet.vertical_interp(self, levels=None, fixed=None, thickness=None)

Verticaly interpolate a dataset based on given vertical levels This 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 True.

  • thickness (str or Dataset) – This must be supplied if fixed is False, otherwise vertical thickness 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.

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.