cross_section
- mdtools.numpy_helper_functions.cross_section(z, x, y, line, num=None, order=1)[source]
Extract a cross section from a 2-dimensional array along a given line using
scipy.ndimage.map_coordinates(). See also https://stackoverflow.com/questions/18920614/plot-cross-section-through-heat-map- Parameters:
z (
array_like) – Input array of shape(m, n)from which to extract the cross section. The data representation follows the standard matrix convention, i.e. columns represent the x values and rows the y values.x, y (
array_like) – The sample points corresponding to the z values. x must be of shape(n,)and y must be of shape(m,).line (
array_like) – Start point and end point of the line along which to extract the cross section. line must be given in the following format:[(x0, y0), (x1, y1)]with(x0, y0)being the start point and(x1, y1)being the end point. Note that the start point and end point must lie within the data range given by x and y.num (
int, optional) – Number of points to use for sampling the cross section along the given line. IfNone(default), approximately as many sample points are used as real data points are on the line.order (
int, optional) – Interpolation order.
- Returns:
cs (
numpy.ndarray) – (Interpolated) values of z along the given line.r (
numpy.ndarray) – The sample points along the given line.