direction

sisl.utils.direction(d: int | str, abc=None, xyz=None) int | Any[source]

Index coordinate transformation from int/str to an integer

Parameters:
  • d ({0, "x", "a", 1, "y", "b", 2, "z", "c"}) – returns the integer that corresponds to the coordinate index (strings are lower-cased).

  • abc ((3, 3), optional) – for "abc" inputs the returned value will be the vector abc[direction(d)]

Returns:

  • index (int) – index of the Cartesian coordinate system, only if both abc and xyz are none or if the requested direction is not present, only returned if the corresponding direction is none

  • vector ((3,)) – the vector corresponding to the value gotten from abc or xyz, only returned if the corresponding direction is not none

Examples

>>> direction(0)
0
>>> direction("Y")
1
>>> direction("z")
2
>>> direction("2")
2
>>> direction(" 2")
2
>>> direction("b")
1
>>> direction("b", abc=np.diag([1, 2, 3])
[0, 2, 0]
>>> direction("x", abc=np.diag([1, 2, 3])
0
>>> direction(1, abc=np.diag([1, 2, 3])
[0, 2, 0]
>>> direction(1, abc=np.diag([1, 2, 3], xyz=np.diag([4, 5, 6])
[0, 2, 0]