tilt_diagonals

mdtools.numpy_helper_functions.tilt_diagonals(a, clockwise=True, diagpos=None, debug=False)[source]

Tilt a 2-dimensional array by 45 degrees so that the diagonals will either be converted to columns (if tilted clockwise) or to rows (if tilted counterclockwise).

Parameters:
  • a (array_like) – 2-dimensional array of shape (m, n)

  • clockwise (bool, optional) – If True, tilt the diagonals clockwise, if False tilt counterclockwise.

  • diagpos (int, optional) – Index of the column (if tilted clockwise) or row (if tilted counterclockwise) where the main diagonal will be located after tilting. The default is to put the diagonal in the middle column/row of the tilted array.

  • debug (bool, optional) – If True, check the input arguments.

Returns:

a_tilted (numpy.ndarray) – 2-dimensional array of shape (m, n) (if tilted clockwise) or (n, m) (if tilted counterclockwise).